From 0d44571674ccbf27a6fb48cde8b9164cd297a254 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Tue, 13 Jan 2015 18:08:03 +0000 Subject: [PATCH 01/11] - update to latest red5 with local connection ishared object fix --- bbb-video/build.gradle | 79 +++++++++++++------------------ bbb-voice/build.gradle | 83 ++++++++++++++------------------- bigbluebutton-apps/build.gradle | 25 ++++------ deskshare/app/build.gradle | 15 +++--- deskshare/build.gradle | 16 +++++-- 5 files changed, 97 insertions(+), 121 deletions(-) diff --git a/bbb-video/build.gradle b/bbb-video/build.gradle index a1b0f2e0b0..5e7b79a723 100755 --- a/bbb-video/build.gradle +++ b/bbb-video/build.gradle @@ -13,49 +13,36 @@ task resolveDeps(type: Copy) { } repositories { - add(new org.apache.ivy.plugins.resolver.ChainResolver()) { - name = 'remote' - returnFirst = true - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "googlecode" - addArtifactPattern "http://red5.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" - addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "blindside-repos" - addArtifactPattern "http://blindside.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" - addArtifactPattern "http://blindside.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" - } + mavenCentral() + add(new org.apache.ivy.plugins.resolver.ChainResolver()) { + name = 'remote' + returnFirst = true add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "maven2-central" - m2compatible = true - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision]).[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" - } + name = "googlecode" + addArtifactPattern "http://red5.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" + addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" + } add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "testng_ibiblio_maven2" - m2compatible = true - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision])-jdk15.[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision])-jdk15.[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "netty-dependency" - m2compatible = true - addArtifactPattern "http://repository.jboss.org/nexus/content/groups/public-jboss/[organisation]/[module]/[revision]/[artifact](-[revision]).[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "spring-bundles" - m2compatible = true - addArtifactPattern "http://repository.springsource.com/maven/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - addArtifactPattern "http://repository.springsource.com/maven/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "Red5" - m2compatible = true - addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - } + name = "blindside-repos" + addArtifactPattern "http://blindside.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" + addArtifactPattern "http://blindside.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" + } + add(new org.apache.ivy.plugins.resolver.URLResolver()) { + name = "testng_ibiblio_maven2" + m2compatible = true + addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision])-jdk15.[ext]" + addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision])-jdk15.[ext]" + } + add(new org.apache.ivy.plugins.resolver.URLResolver()) { + name = "spring-bundles" + m2compatible = true + addArtifactPattern "http://repository.springsource.com/maven/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" + addArtifactPattern "http://repository.springsource.com/maven/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" + } + mavenRepo name: "jboss", urls: "http://repository.jboss.org/nexus/content/groups/public-jboss" + mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots" + mavenRepo name: "sonatype-releases", urls: "http://oss.sonatype.org/content/repositories/releases" + } } @@ -75,10 +62,10 @@ dependencies { providedCompile 'org.springframework:spring-core:4.0.7.RELEASE@jar' // Red5 - providedCompile 'org/red5:red5-server:1.0.4-RELEASE@jar' - providedCompile 'org.red5:red5-io:1.0.4-RELEASE@jar' - providedCompile 'org/red5:red5-server-common:1.0.4-RELEASE@jar' - + providedCompile 'org/red5:red5-server:1.0.5-jan122015-SNAPSHOT@jar' + providedCompile 'org.red5:red5-server-common:1.0.5-SNAPSHOT@jar' + providedCompile 'org.red5:red5-io:1.0.5-SNAPSHOT@jar' + // Logging providedCompile 'ch.qos.logback:logback-core:1.1.2@jar' providedCompile 'ch.qos.logback:logback-classic:1.1.2@jar' @@ -96,7 +83,7 @@ dependencies { providedCompile 'net.jcip:jcip-annotations:1.0@jar' // Testing - compile 'org.testng:testng:5.8@jar' +// compile 'org.testng:testng:5.8@jar' compile 'org.easymock:easymock:2.4@jar' //redis diff --git a/bbb-voice/build.gradle b/bbb-voice/build.gradle index 01a7103b4a..fc05450ed2 100755 --- a/bbb-voice/build.gradle +++ b/bbb-voice/build.gradle @@ -13,52 +13,40 @@ task resolveDeps(type: Copy) { } repositories { - add(new org.apache.ivy.plugins.resolver.ChainResolver()) { - name = 'remote' - returnFirst = true - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "googlecode" - addArtifactPattern "http://red5.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" - addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "blindside-repos" - addArtifactPattern "http://blindside.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" - addArtifactPattern "http://blindside.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" - } + mavenCentral() + add(new org.apache.ivy.plugins.resolver.ChainResolver()) { + name = 'remote' + returnFirst = true add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "maven2-central" - m2compatible = true - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision]).[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" - } + name = "googlecode" + addArtifactPattern "http://red5.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" + addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" + } add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "testng_ibiblio_maven2" - m2compatible = true - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision])-jdk15.[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision])-jdk15.[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "netty-dependency" - m2compatible = true - addArtifactPattern "http://repository.jboss.org/nexus/content/groups/public-jboss/[organisation]/[module]/[revision]/[artifact](-[revision]).[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "spring-bundles" - m2compatible = true - addArtifactPattern "http://repository.springsource.com/maven/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - addArtifactPattern "http://repository.springsource.com/maven/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "Red5" - m2compatible = true - addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" - } - } + name = "blindside-repos" + addArtifactPattern "http://blindside.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" + addArtifactPattern "http://blindside.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" + } + add(new org.apache.ivy.plugins.resolver.URLResolver()) { + name = "testng_ibiblio_maven2" + m2compatible = true + addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision])-jdk15.[ext]" + addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision])-jdk15.[ext]" + } + add(new org.apache.ivy.plugins.resolver.URLResolver()) { + name = "spring-bundles" + m2compatible = true + addArtifactPattern "http://repository.springsource.com/maven/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" + addArtifactPattern "http://repository.springsource.com/maven/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" + } + mavenRepo name: "jboss", urls: "http://repository.jboss.org/nexus/content/groups/public-jboss" + mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots" + mavenRepo name: "sonatype-releases", urls: "http://oss.sonatype.org/content/repositories/releases" + + } } + dependencies { // Servlet providedCompile 'javax.servlet:servlet-api:2.5@jar' @@ -74,10 +62,9 @@ dependencies { providedCompile 'org.springframework:spring-context:4.0.8.RELEASE@jar' providedCompile 'org.springframework:spring-core:4.0.8.RELEASE@jar' - // Red5 - providedCompile 'org/red5:red5-server:1.0.4-RELEASE@jar' - providedCompile 'org.red5:red5-io:1.0.4-RELEASE@jar' - providedCompile 'org/red5:red5-server-common:1.0.4-RELEASE@jar' + providedCompile 'org/red5:red5-server:1.0.5-jan122015-SNAPSHOT@jar' + providedCompile 'org.red5:red5-server-common:1.0.5-SNAPSHOT@jar' + providedCompile 'org.red5:red5-io:1.0.5-SNAPSHOT@jar' // Logging providedCompile 'ch.qos.logback:logback-core:1.1.2@jar' @@ -96,11 +83,11 @@ dependencies { //providedCompile 'net.jcip:jcip-annotations:1.0@jar' // Testing - compile 'org.testng:testng:5.8@jar' +// compile 'org.testng:testng:5.8@jar' compile 'org.easymock:easymock:2.4@jar' // Testing - testRuntime 'org/testng:testng:5.8@jar' +// testRuntime 'org/testng:testng:5.8@jar' testRuntime 'org.easymock:easymock:2.4@jar' compile 'javax/media:jmf:2.1.1e@jar' diff --git a/bigbluebutton-apps/build.gradle b/bigbluebutton-apps/build.gradle index 563b191d5f..6e8ce42803 100755 --- a/bigbluebutton-apps/build.gradle +++ b/bigbluebutton-apps/build.gradle @@ -17,6 +17,7 @@ task resolveDeps(type: Copy) { } repositories { + mavenCentral() add(new org.apache.ivy.plugins.resolver.ChainResolver()) { name = 'remote' returnFirst = true @@ -29,31 +30,23 @@ repositories { name = "blindside-repos" addArtifactPattern "http://blindside.googlecode.com/svn/repository/[artifact](-[revision]).[ext]" addArtifactPattern "http://blindside.googlecode.com/svn/repository/[organisation]/[artifact](-[revision]).[ext]" - } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "maven2-central" - m2compatible = true - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision]).[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" - } + } add(new org.apache.ivy.plugins.resolver.URLResolver()) { name = "testng_ibiblio_maven2" m2compatible = true addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[module]/[revision]/[artifact](-[revision])-jdk15.[ext]" addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision])-jdk15.[ext]" } - add(new org.apache.ivy.plugins.resolver.URLResolver()) { - name = "netty-dependency" - m2compatible = true - addArtifactPattern "http://repository.jboss.org/nexus/content/groups/public-jboss/[organisation]/[module]/[revision]/[artifact](-[revision]).[ext]" - addArtifactPattern "http://repo1.maven.org/maven2/[organisation]/[artifact]/[revision]/[artifact](-[revision]).[ext]" - } add(new org.apache.ivy.plugins.resolver.URLResolver()) { name = "spring-bundles" m2compatible = true addArtifactPattern "http://repository.springsource.com/maven/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" addArtifactPattern "http://repository.springsource.com/maven/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } + mavenRepo name: "jboss", urls: "http://repository.jboss.org/nexus/content/groups/public-jboss" + mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots" + mavenRepo name: "sonatype-releases", urls: "http://oss.sonatype.org/content/repositories/releases" + } } @@ -73,8 +66,8 @@ dependencies { providedCompile 'org.springframework:spring-core:4.0.8.RELEASE@jar' // Red5 - providedCompile 'org/red5:red5-server:1.0.4-RELEASE@jar' - providedCompile 'org/red5:red5-server-common:1.0.4-RELEASE@jar' + providedCompile 'org/red5:red5-server:1.0.5-jan122015-SNAPSHOT@jar' + providedCompile 'org.red5:red5-server-common:1.0.5-SNAPSHOT@jar' // Logging providedCompile 'ch.qos.logback:logback-core:1.1.2@jar' @@ -98,7 +91,7 @@ dependencies { compile 'aopalliance:aopalliance:1.0@jar' // Testing - compile 'org.testng:testng:5.8@jar' + //compile 'org.testng:testng:5.8-jdk15@jar' compile 'org.easymock:easymock:2.4@jar' //redis diff --git a/deskshare/app/build.gradle b/deskshare/app/build.gradle index 532eaba930..39674f552f 100755 --- a/deskshare/app/build.gradle +++ b/deskshare/app/build.gradle @@ -19,6 +19,7 @@ task resolveDeps(type: Copy) { * (ralam Oct 4, 2009) */ repositories { + mavenCentral() add(new org.apache.ivy.plugins.resolver.ChainResolver()) { name = 'remote' returnFirst = true @@ -62,6 +63,8 @@ repositories { addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } + mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots" + mavenRepo name: "sonatype-releases", urls: "http://oss.sonatype.org/content/repositories/releases" } } @@ -81,9 +84,9 @@ dependencies { providedCompile 'org.springframework:spring-core:4.0.8.RELEASE@jar' // Red5 - providedCompile 'org/red5:red5-server:1.0.4-RELEASE@jar' - providedCompile 'org.red5:red5-io:1.0.4-RELEASE@jar' - providedCompile 'org/red5:red5-server-common:1.0.4-RELEASE@jar' + providedCompile 'org/red5:red5-server:1.0.5-jan122015-SNAPSHOT@jar' + providedCompile 'org.red5:red5-server-common:1.0.5-SNAPSHOT@jar' + providedCompile 'org.red5:red5-io:1.0.5-SNAPSHOT@jar' // Logging providedCompile 'ch.qos.logback:logback-core:1.1.2@jar' @@ -100,11 +103,11 @@ dependencies { providedCompile 'aopalliance:aopalliance:1.0@jar' // Testing - compile 'org.testng:testng:5.8@jar' + //compile 'org.testng:testng:5.8@jar' compile 'org.easymock:easymock:2.4@jar' // Testing - testRuntime 'org/testng:testng:5.8@jar' + //testRuntime 'org/testng:testng:5.8@jar' testRuntime 'org.easymock:easymock:2.4@jar' // Tunnelling servlet @@ -129,7 +132,7 @@ dependencies { // Libraries needed for scala api compile 'org.scala-lang:scala-library:2.9.2' - compile 'net.lag:configgy:2.0.0' + compile 'net.lag:configgy:2.0.0@jar' //redis compile 'redis.clients:jedis:1.5.1' diff --git a/deskshare/build.gradle b/deskshare/build.gradle index c932e0b49c..22b1afdf9a 100755 --- a/deskshare/build.gradle +++ b/deskshare/build.gradle @@ -13,6 +13,7 @@ task resolveDeps(type: Copy) { * (ralam Oct 4, 2009) */ repositories { + mavenCentral() add(new org.apache.ivy.plugins.resolver.ChainResolver()) { name = 'remote' returnFirst = true @@ -56,6 +57,8 @@ repositories { addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" addArtifactPattern "http://red5.googlecode.com/svn/repository/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } + mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots" + mavenRepo name: "sonatype-releases", urls: "http://oss.sonatype.org/content/repositories/releases" } } @@ -79,9 +82,9 @@ dependencies { compile 'org.springframework:spring-core:4.0.8.RELEASE@jar' // Red5 - compile 'org/red5:red5-server:1.0.4-RELEASE@jar' - compile 'org.red5:red5-io:1.0.4-RELEASE@jar' - compile 'org/red5:red5-server-common:1.0.4-RELEASE@jar' + compile 'org/red5:red5-server:1.0.5-jan122015-SNAPSHOT@jar' + compile 'org.red5:red5-server-common:1.0.5-SNAPSHOT@jar' + compile 'org.red5:red5-io:1.0.5-SNAPSHOT@jar' // Logging compile 'ch.qos.logback:logback-core:1.1.2@jar' @@ -97,7 +100,7 @@ dependencies { compile 'aopalliance:aopalliance:1.0@jar' // Testing - compile 'org.testng:testng:5.8@jar' +// compile 'org.testng:testng:5.8@jar' compile 'org.easymock:easymock:2.4@jar' compile project(':common') @@ -111,7 +114,7 @@ dependencies { // Libraries needed for scala api compile 'org.scala-lang:scala-library:2.9.2' - compile 'net.lag:configgy:2.0.0' + compile 'net.lag:configgy:2.0.0@jar' //redis compile 'redis.clients:jedis:2.0.0' @@ -127,6 +130,7 @@ subprojects { apply plugin: 'eclipse' repositories { + mavenCentral() add(new org.apache.ivy.plugins.resolver.ChainResolver()) { name = 'remote' returnFirst = true @@ -165,6 +169,8 @@ subprojects { addArtifactPattern "http://repository.springsource.com/maven/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } } + mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots" + mavenRepo name: "sonatype-releases", urls: "http://oss.sonatype.org/content/repositories/releases" } group = 'org.bigbluebutton' From eca5c391bf3e28c5b858f8d0211a0686415884ec Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 14 Jan 2015 19:40:35 +0000 Subject: [PATCH 02/11] - display the correct number of modules when loading. --- .../src/org/bigbluebutton/main/views/LoadingBar.mxml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml index 35a3fdc925..da46c54d7e 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml @@ -41,13 +41,19 @@ with BigBlueButton; if not, see . private var modules:Dictionary = new Dictionary(); private var numModules:int = 0; private var portUpdateStr:String = 'Connecting to the server'; - private function moduleLoadingStarted(e:ModuleLoadEvent):void{ + + private function moduleLoadingStarted(e:ModuleLoadEvent):void{ var list:XMLList = e.modules; var item:XML; + + numModules = 0; + trace("LoadingBar.mxml numModules=[" + numModules + "]"); for each(item in list){ modules[item.@name] = 0; numModules++; + trace("LoadingBar.mxml numModules=[" + numModules + "] modulename=[" + item.@name + "]"); } + this.label = ResourceUtil.getInstance().getString('bbb.mainshell.statusProgress.loading', [numModules]); } From 083d85687c84e8ed30ac5c063195a1ebbefaf98f Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 14 Jan 2015 19:44:34 +0000 Subject: [PATCH 03/11] - fix formatting --- .../bigbluebutton/main/views/LoadingBar.mxml | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml index da46c54d7e..e67b6ca6ad 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/LoadingBar.mxml @@ -31,66 +31,66 @@ with BigBlueButton; if not, see . From 3579ad212294054acade576f71de8843610555aa Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Wed, 14 Jan 2015 21:04:43 +0000 Subject: [PATCH 04/11] - prevent dispatching of join event twice whihc triggers loading of modules twice --- .../main/model/users/NetConnectionDelegate.as | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) mode change 100644 => 100755 bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as old mode 100644 new mode 100755 index 0dc89aeb1b..8d4f42e496 --- a/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as +++ b/bigbluebutton-client/src/org/bigbluebutton/main/model/users/NetConnectionDelegate.as @@ -132,25 +132,7 @@ package org.bigbluebutton.main.model.users _conferenceParameters.internalUserID ); //_netConnection.call } - - private function joinMeeting():void { - sendMessage( - "joinMeeting",// Remote function name - // result - On successful result - function(result:Object):void { - trace(LOG + "joining meeting for [" + _conferenceParameters.internalUserID + "]"); - }, - // status - On error occurred - function(status:Object):void { - LogUtil.error(LOG + "Error occurred:"); - for (var x:Object in status) { - LogUtil.error(x + " : " + status[x]); - } - }, - _conferenceParameters.internalUserID - ); //_netConnection.call - } - + private function handleValidateAuthTokenReply(msg: Object):void { trace(LOG + "*** handleValidateAuthTokenReply " + msg.msg + " **** \n"); var map:Object = JSON.parse(msg.msg); @@ -160,7 +142,6 @@ package org.bigbluebutton.main.model.users if (tokenValid) { authenticated = true; trace(LOG + "*** handleValidateAuthTokenReply. valid=[ " + tokenValid + "] **** \n"); - joinMeeting(); } else { trace(LOG + "*** handleValidateAuthTokenReply. valid=[ " + tokenValid + "] **** \n"); dispatcher.dispatchEvent(new InvalidAuthTokenEvent()); From 644ad523c58c42153b610baa1aa46dfe44a9ac05 Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Thu, 15 Jan 2015 15:12:24 -0800 Subject: [PATCH 05/11] removed the old Settings module --- .../resources/prod/check/bbb-check.html | 89 --- .../resources/prod/check/lib/bbb_check.js | 215 ------- .../resources/prod/check/lib/deployJava.js | 567 ------------------ .../prod/check/lib/pre_flight_check.js | 55 -- bigbluebutton-client/src/SettingsModule.mxml | 99 --- .../modules/settings/SettingsPanel.mxml | 102 ---- .../settings/checkers/DeskShareChecker.mxml | 157 ----- .../modules/settings/checkers/MicChecker.mxml | 83 --- .../settings/checkers/SystemCheck.mxml | 169 ------ .../settings/checkers/WebcamChecker.mxml | 191 ------ .../settings/connectors/AppsConnector.as | 27 - .../settings/connectors/AudioConnector.as | 142 ----- .../settings/connectors/DeskShareConnector.as | 249 -------- .../settings/connectors/VideoConnector.as | 120 ---- .../modules/settings/uihelpers/JavaOKEvent.as | 32 - .../modules/settings/uihelpers/UserAlert.mxml | 56 -- .../settings/uihelpers/WarningEvent.as | 37 -- .../settings/uihelpers/WarningItem.mxml | 52 -- .../settings/uihelpers/WarningsList.mxml | 44 -- .../modules/settings/util/FlashCheck.as | 27 - .../modules/settings/util/JavaCheck.as | 115 ---- .../settings/util/PersistUserPreferences.as | 74 --- .../modules/settings/util/Requirements.as | 58 -- 23 files changed, 2760 deletions(-) delete mode 100755 bigbluebutton-client/resources/prod/check/bbb-check.html delete mode 100755 bigbluebutton-client/resources/prod/check/lib/bbb_check.js delete mode 100644 bigbluebutton-client/resources/prod/check/lib/deployJava.js delete mode 100755 bigbluebutton-client/resources/prod/check/lib/pre_flight_check.js delete mode 100755 bigbluebutton-client/src/SettingsModule.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/SettingsPanel.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/DeskShareChecker.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/MicChecker.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/SystemCheck.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/WebcamChecker.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AppsConnector.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AudioConnector.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/DeskShareConnector.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/VideoConnector.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/JavaOKEvent.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/UserAlert.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningEvent.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningItem.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningsList.mxml delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/FlashCheck.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/JavaCheck.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/PersistUserPreferences.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/Requirements.as diff --git a/bigbluebutton-client/resources/prod/check/bbb-check.html b/bigbluebutton-client/resources/prod/check/bbb-check.html deleted file mode 100755 index f11ac3ad29..0000000000 --- a/bigbluebutton-client/resources/prod/check/bbb-check.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - -
- - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - Get Adobe Flash player - - - - - -
-
- - - - - - - - - - - - - - - Get Adobe Flash player - - - - - -
- - diff --git a/bigbluebutton-client/resources/prod/check/lib/bbb_check.js b/bigbluebutton-client/resources/prod/check/lib/bbb_check.js deleted file mode 100755 index 1bcf946039..0000000000 --- a/bigbluebutton-client/resources/prod/check/lib/bbb_check.js +++ /dev/null @@ -1,215 +0,0 @@ -(function(window, undefined) { - - var BBBCheck = {}; - - /** - * Internal function to get the BBB embed object. Seems like we have to do this - * each time and can't create a var for it. - * - * To get the object, see https://code.google.com/p/swfobject/wiki/api - */ - function getSwfObj() { - return swfobject.getObjectById("MicrophoneCheck"); - } - - function getConnObj() { - return swfobject.getObjectById("RTMPConnCheck"); - } - - BBBCheck.getFlashPlayerVersion = function() { - return swfobject.getFlashPlayerVersion(); - } - - BBBCheck.hasMinFlashPlayerVersion = function(flashVersion) { - return swfobject.hasFlashPlayerVersion(flashVersion); - } - - BBBCheck.getBrowser = function() { - return deployJava.getBrowser(); - } - - BBBCheck.getJREs = function() { - return deployJava.getJREs(); - } - - BBBCheck.installJRE = function(version) { - deployJava.installJRE(version); - } - - BBBCheck.installLatestJRE = function() { - deployJava.installLatestJRE(); - } - - BBBCheck.runApplet = function(attributes, parameters, minimumVersion) { - deployJava.runApplet(attributes, parameters, minimumVersion); - } - - BBBCheck.runApplet = function(attributes, parameters, minimumVersion) { - deployJava.runApplet(attributes, parameters, minimumVersion); - } - - BBBCheck.showCamSettings = function() { - var swfObj = getSwfObj(); - if (swfObj) { - swfObj.showCamSettings(); - } - } - - BBBCheck.showMicSettings = function() { - var swfObj = getSwfObj(); - if (swfObj) { - swfObj.showMicSettings(); - } - } - - BBBCheck.startTestMicrophone = function() { - var swfObj = getSwfObj(); - if (swfObj) { - swfObj.startTestMicrophone(); - } - } - - BBBCheck.stopTestMicrophone = function() { - var swfObj = getSwfObj(); - if (swfObj) { - swfObj.stopTestMicrophone(); - } - } - - BBBCheck.testRTMPConnection = function(host, app) { - var swfObj = getConnObj(); - if (swfObj) { - swfObj.testRTMPConnection(host, app); - } - } - - BBBCheck.testSocketConnection = function(host, port) { - var swfObj = getConnObj(); - if (swfObj) { - swfObj.testSocketConnection(host, port); - } - } - - BBBCheck.setSocketPolicyFileURL = function(url) { - var swfObj = getConnObj(); - if (swfObj) { - swfObj.setPolicyFileURL(url); - } - } - - /*** Callbacks from Flash test apps **/ - BBBCheck.microphoneCheckAppReady = function() { - console.log("microphone check app ready."); - broadcast("MicCheckAppReadyEvent"); - } - - BBBCheck.noAvailableMicrophoneError = function() { - console.log("no available microphone"); - } - - BBBCheck.microphoneAccessDenied = function() { - console.log("Mic access has been denied."); - } - - BBBCheck.microphoneAccessAllowed = function() { - console.log("Mic access has been allowed."); - } - - BBBCheck.camAccessDenied = function() { - console.log("Cam access has been denied."); - } - - BBBCheck.camAccessAllowed = function() { - console.log("Cam access has been allowed."); - } - - BBBCheck.invalidParamsForRtmpConnectionTest = function() { - console.log("Invalid host or app for rtmp connection test."); - } - - BBBCheck.rtmpConnectionTestSuccess = function(rtmp, server, application) { - console.log("Connection succeeded using rtmp[" + rtmp + "]"); - } - - BBBCheck.rtmpConnectionTestFailed = function(host, app) { - console.log("Failed to connect to [" + host + "][" + app + "]"); - } - - BBBCheck.socketConnTestFailed = function(host, port) { - console.log("Failed to connect to [" + host + "][" + port + "]"); - } - - BBBCheck.socketConnTestClosed = function(host, port) { - console.log("Connection closed to [" + host + "][" + port + "]"); - } - - BBBCheck.socketConnTestSuccess = function(host, port) { - console.log("Connection success to [" + host + "][" + port + "]"); - } - - BBBCheck.socketConnTestIOError = function(host, port) { - console.log("Connection IO error to [" + host + "][" + port + "]"); - } - - BBBCheck.socketConnTestSecurityError = function(host, port) { - console.log("Connection security error to [" + host + "][" + port + "]"); - } - - - - /* *********************************************************************************** - * Broadcasting of events to 3rd-party apps. - *************************************************************************************/ - - /** Stores the 3rd-party app event listeners ***/ - var listeners = {}; - - /** - * 3rd-party apps should user this method to register to listen for events. - */ - BBBCheck.listen = function(eventName, handler) { - if (typeof listeners[eventName] === 'undefined') - listeners[eventName] = []; - - listeners[eventName].push(handler); - }; - - /** - * 3rd-party app should use this method to unregister listener for a given event. - */ - BBBCheck.unlisten = function(eventName, handler) { - if (!listeners[eventName]) - return; - - for (var i = 0; i < listeners[eventName].length; i++) { - if (listeners[eventName][i] === handler) { - listeners.splice(i, 1); - break; - } - } - }; - - /** - * Private function to broadcast received event from the BigBlueButton Flash client to - * 3rd-parties. - */ - function broadcast(eventName, params) { - if (!listeners[eventName]) { - console.log("No listeners for [" + eventName + "]"); - return; - } - - for (var i = 0; i < listeners[eventName].length; i++) { - console.log("Notifying listeners for [" + eventName + "]"); - if (params == null) { - listeners[eventName][i](); - } else { - listeners[eventName][i](params); - } - - } - }; - - window.BBBCheck = BBBCheck; -})(this); - \ No newline at end of file diff --git a/bigbluebutton-client/resources/prod/check/lib/deployJava.js b/bigbluebutton-client/resources/prod/check/lib/deployJava.js deleted file mode 100644 index 2552751747..0000000000 --- a/bigbluebutton-client/resources/prod/check/lib/deployJava.js +++ /dev/null @@ -1,567 +0,0 @@ -var deployJava = { - debug: null, - firefoxJavaVersion: null, - myInterval: null, - preInstallJREList: null, - returnPage: null, - brand: null, - locale: null, - installType: null, - EAInstallEnabled: false, - EarlyAccessURL: null, - getJavaURL: 'http://java.sun.com/webapps/getjava/BrowserRedirect?host=java.com', - appleRedirectPage: 'http://www.apple.com/support/downloads/', - oldMimeType: 'application/npruntime-scriptable-plugin;DeploymentToolkit', - mimeType: 'application/java-deployment-toolkit', - launchButtonPNG: 'http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png', - browserName: null, - browserName2: null, - getJREs: function() { - var list = new Array(); - if (deployJava.isPluginInstalled()) { - var plugin = deployJava.getPlugin(); - var VMs = plugin.jvms; - for (var i = 0; i < VMs.getLength(); i++) { - list[i] = VMs.get(i).version; - } - } else { - var browser = deployJava.getBrowser(); - if (browser == 'MSIE') { - if (deployJava.testUsingActiveX('1.7.0')) { - list[0] = '1.7.0'; - } else if (deployJava.testUsingActiveX('1.6.0')) { - list[0] = '1.6.0'; - } else if (deployJava.testUsingActiveX('1.5.0')) { - list[0] = '1.5.0'; - } else if (deployJava.testUsingActiveX('1.4.2')) { - list[0] = '1.4.2'; - } else if (deployJava.testForMSVM()) { - list[0] = '1.1'; - } - } else if (browser == 'Netscape Family') { - deployJava.getJPIVersionUsingMimeType(); - if (deployJava.firefoxJavaVersion != null) { - list[0] = deployJava.firefoxJavaVersion; - } else if (deployJava.testUsingMimeTypes('1.7')) { - list[0] = '1.7.0'; - } else if (deployJava.testUsingMimeTypes('1.6')) { - list[0] = '1.6.0'; - } else if (deployJava.testUsingMimeTypes('1.5')) { - list[0] = '1.5.0'; - } else if (deployJava.testUsingMimeTypes('1.4.2')) { - list[0] = '1.4.2'; - } else if (deployJava.browserName2 == 'Safari') { - if (deployJava.testUsingPluginsArray('1.7.0')) { - list[0] = '1.7.0'; - } else if (deployJava.testUsingPluginsArray('1.6')) { - list[0] = '1.6.0'; - } else if (deployJava.testUsingPluginsArray('1.5')) { - list[0] = '1.5.0'; - } else if (deployJava.testUsingPluginsArray('1.4.2')) { - list[0] = '1.4.2'; - } - } - } - } - if (deployJava.debug) { - for (var i = 0; i < list.length; ++i) { - alert('We claim to have detected Java SE ' + list[i]); - } - } - return list; - }, - installJRE: function(requestVersion) { - var ret = false; - if (deployJava.isPluginInstalled()) { - if (deployJava.getPlugin().installJRE(requestVersion)) { - deployJava.refresh(); - if (deployJava.returnPage != null) { - document.location = deployJava.returnPage; - } - return true; - } else { - return false; - } - } else { - return deployJava.installLatestJRE(); - } - }, - installLatestJRE: function() { - if (deployJava.isPluginInstalled()) { - if (deployJava.getPlugin().installLatestJRE()) { - deployJava.refresh(); - if (deployJava.returnPage != null) { - document.location = deployJava.returnPage; - } - return true; - } else { - return false; - } - } else { - var browser = deployJava.getBrowser(); - var platform = navigator.platform.toLowerCase(); - if ((deployJava.EAInstallEnabled == 'true') && (platform.indexOf('win') != -1) && (deployJava.EarlyAccessURL != null)) { - deployJava.preInstallJREList = deployJava.getJREs(); - if (deployJava.returnPage != null) { - deployJava.myInterval = setInterval("deployJava.poll()", 3000); - } - location.href = deployJava.EarlyAccessURL; - return false; - } else { - if (browser == 'MSIE') { - return deployJava.IEInstall(); - } else if ((browser == 'Netscape Family') && (platform.indexOf('win32') != -1)) { - return deployJava.FFInstall(); - } else { - location.href = deployJava.getJavaURL + ((deployJava.returnPage != null) ? ('&returnPage=' + deployJava.returnPage) : '') + ((deployJava.locale != null) ? ('&locale=' + deployJava.locale) : '') + ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : ''); - } - return false; - } - } - }, - runApplet: function(attributes, parameters, minimumVersion) { - if (minimumVersion == 'undefined' || minimumVersion == null) { - minimumVersion = '1.1'; - } - var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"; - var matchData = minimumVersion.match(regex); - if (deployJava.returnPage == null) { - deployJava.returnPage = document.location; - } - if (matchData != null) { - var browser = deployJava.getBrowser(); - if ((browser != '?') && ('Safari' != deployJava.browserName2)) { - if (deployJava.versionCheck(minimumVersion + '+')) { - deployJava.writeAppletTag(attributes, parameters); - } else if (deployJava.installJRE(minimumVersion + '+')) { - deployJava.refresh(); - location.href = document.location; - deployJava.writeAppletTag(attributes, parameters); - } - } else { - deployJava.writeAppletTag(attributes, parameters); - } - } else { - if (deployJava.debug) { - alert('Invalid minimumVersion argument to runApplet():' + minimumVersion); - } - } - }, - writeAppletTag: function(attributes, parameters) { - var s = '<' + 'applet '; - var codeAttribute = false; - for (var attribute in attributes) { - s += (' ' + attribute + '="' + attributes[attribute] + '"'); - if (attribute == 'code') { - codeAttribute = true; - } - } - if (!codeAttribute) { - s += (' code="dummy"'); - } - s += '>'; - document.write(s); - if (parameters != 'undefined' && parameters != null) { - var codebaseParam = false; - for (var parameter in parameters) { - if (parameter == 'codebase_lookup') { - codebaseParam = true; - } - s = ''; - document.write(s); - } - if (!codebaseParam) { - document.write(''); - } - } - document.write('<' + '/' + 'applet' + '>'); - }, - versionCheck: function(versionPattern) { - var index = 0; - var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?(\\*|\\+)?$"; - var matchData = versionPattern.match(regex); - if (matchData != null) { - var familyMatch = true; - var patternArray = new Array(); - for (var i = 1; i < matchData.length; ++i) { - if ((typeof matchData[i] == 'string') && (matchData[i] != '')) { - patternArray[index] = matchData[i]; - index++; - } - } - if (patternArray[patternArray.length - 1] == '+') { - familyMatch = false; - patternArray.length--; - } else { - if (patternArray[patternArray.length - 1] == '*') { - patternArray.length--; - } - } - var list = deployJava.getJREs(); - for (var i = 0; i < list.length; ++i) { - if (deployJava.compareVersionToPattern(list[i], patternArray, familyMatch)) { - return true; - } - } - return false; - } else { - alert('Invalid versionPattern passed to versionCheck: ' + versionPattern); - return false; - } - }, - isWebStartInstalled: function(minimumVersion) { - var browser = deployJava.getBrowser(); - if ((browser == '?') || ('Safari' == deployJava.browserName2)) { - return true; - } - if (minimumVersion == 'undefined' || minimumVersion == null) { - minimumVersion = '1.4.2'; - } - var retval = false; - var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"; - var matchData = minimumVersion.match(regex); - if (matchData != null) { - retval = deployJava.versionCheck(minimumVersion + '+'); - } else { - if (deployJava.debug) { - alert('Invalid minimumVersion argument to isWebStartInstalled(): ' + minimumVersion); - } - retval = deployJava.versionCheck('1.4.2+'); - } - return retval; - }, - getJPIVersionUsingMimeType: function() { - for (var i = 0; i < navigator.mimeTypes.length; ++i) { - var s = navigator.mimeTypes[i].type; - var m = s.match(/^application\/x-java-applet;jpi-version=(.*)$/); - if (m != null) { - deployJava.firefoxJavaVersion = m[1]; - if ('Opera' != deployJava.browserName2) { - break; - } - } - } - }, - launchWebStartApplication: function(jnlp) { - return false; - }, - createWebStartLaunchButtonEx: function(jnlp, minimumVersion) { - if (deployJava.returnPage == null) { - deployJava.returnPage = jnlp; - } - var url = 'javascript:deployJava.launchWebStartApplication(\'' + jnlp + '\');'; - document.write('<' + 'a href="' + url + '" onMouseOver="window.status=\'\'; ' + 'return true;"><' + 'img ' + 'src="' + deployJava.launchButtonPNG + '" ' + 'border="0" /><' + '/' + 'a' + '>'); - }, - createWebStartLaunchButton: function(jnlp, minimumVersion) { - if (deployJava.returnPage == null) { - deployJava.returnPage = jnlp; - } - var url = 'javascript:' + 'if (!deployJava.isWebStartInstalled("' + minimumVersion + '")) {' + 'if (deployJava.installLatestJRE()) {' + 'if (deployJava.launch("' + jnlp + '")) {}' + '}' + '} else {' + 'if (deployJava.launch("' + jnlp + '")) {}' + '}'; - document.write('<' + 'a href="' + url + '" onMouseOver="window.status=\'\'; ' + 'return true;"><' + 'img ' + 'src="' + deployJava.launchButtonPNG + '" ' + 'border="0" /><' + '/' + 'a' + '>'); - }, - launch: function(jnlp) { - document.location = jnlp; - return true; - }, - isPluginInstalled: function() { - var plugin = deployJava.getPlugin(); - if (plugin && plugin.jvms) { - return true; - } else { - return false; - } - }, - isAutoUpdateEnabled: function() { - if (deployJava.isPluginInstalled()) { - return deployJava.getPlugin().isAutoUpdateEnabled(); - } - return false; - }, - setAutoUpdateEnabled: function() { - if (deployJava.isPluginInstalled()) { - return deployJava.getPlugin().setAutoUpdateEnabled(); - } - return false; - }, - setInstallerType: function(type) { - deployJava.installType = type; - if (deployJava.isPluginInstalled()) { - return deployJava.getPlugin().setInstallerType(type); - } - return false; - }, - setAdditionalPackages: function(packageList) { - if (deployJava.isPluginInstalled()) { - return deployJava.getPlugin().setAdditionalPackages(packageList); - } - return false; - }, - setEarlyAccess: function(enabled) { - deployJava.EAInstallEnabled = enabled; - }, - isPlugin2: function() { - if (deployJava.isPluginInstalled()) { - if (deployJava.versionCheck('1.6.0_10+')) { - try { - return deployJava.getPlugin().isPlugin2(); - } catch (err) {} - } - } - return false; - }, - allowPlugin: function() { - deployJava.getBrowser(); - var ret = ('Safari' != deployJava.browserName2 && 'Opera' != deployJava.browserName2); - return ret; - }, - getPlugin: function() { - deployJava.refresh(); - var ret = null; - if (deployJava.allowPlugin()) { - ret = document.getElementById('deployJavaPlugin'); - } - return ret; - }, - compareVersionToPattern: function(version, patternArray, familyMatch) { - var regex = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:_(\\d+))?)?)?$"; - var matchData = version.match(regex); - if (matchData != null) { - var index = 0; - var result = new Array(); - for (var i = 1; i < matchData.length; ++i) { - if ((typeof matchData[i] == 'string') && (matchData[i] != '')) { - result[index] = matchData[i]; - index++; - } - } - var l = Math.min(result.length, patternArray.length); - if (familyMatch) { - for (var i = 0; i < l; ++i) { - if (result[i] != patternArray[i]) return false; - } - return true; - } else { - for (var i = 0; i < l; ++i) { - if (result[i] < patternArray[i]) { - return false; - } else if (result[i] > patternArray[i]) { - return true; - } - } - return true; - } - } else { - return false; - } - }, - getBrowser: function() { - if (deployJava.browserName == null) { - var browser = navigator.userAgent.toLowerCase(); - if (deployJava.debug) { - alert('userAgent -> ' + browser); - } - if (browser.indexOf('msie') != -1) { - deployJava.browserName = 'MSIE'; - deployJava.browserName2 = 'MSIE'; - } else if (browser.indexOf('firefox') != -1) { - deployJava.browserName = 'Netscape Family'; - deployJava.browserName2 = 'Firefox'; - } else if (browser.indexOf('chrome') != -1) { - deployJava.browserName = 'Netscape Family'; - deployJava.browserName2 = 'Chrome'; - } else if (browser.indexOf('safari') != -1) { - deployJava.browserName = 'Netscape Family'; - deployJava.browserName2 = 'Safari'; - } else if (browser.indexOf('mozilla') != -1) { - deployJava.browserName = 'Netscape Family'; - deployJava.browserName2 = 'Other'; - } else if (browser.indexOf('opera') != -1) { - deployJava.browserName = 'Netscape Family'; - deployJava.browserName2 = 'Opera'; - } else { - deployJava.browserName = '?'; - deployJava.browserName2 = 'unknown'; - } - if (deployJava.debug) { - alert('Detected browser name:' + deployJava.browserName + ', ' + deployJava.browserName2); - } - } - return deployJava.browserName; - }, - testUsingActiveX: function(version) { - var objectName = 'JavaWebStart.isInstalled.' + version + '.0'; - if (!ActiveXObject) { - if (deployJava.debug) { - alert('Browser claims to be IE, but no ActiveXObject object?'); - } - return false; - } - try { - return (new ActiveXObject(objectName) != null); - } catch (exception) { - return false; - } - }, - testForMSVM: function() { - var clsid = '{08B0E5C0-4FCB-11CF-AAA5-00401C608500}'; - if (typeof oClientCaps != 'undefined') { - var v = oClientCaps.getComponentVersion(clsid, "ComponentID"); - if ((v == '') || (v == '5,0,5000,0')) { - return false; - } else { - return true; - } - } else { - return false; - } - }, - testUsingMimeTypes: function(version) { - if (!navigator.mimeTypes) { - if (deployJava.debug) { - alert('Browser claims to be Netscape family, but no mimeTypes[] array?'); - } - return false; - } - for (var i = 0; i < navigator.mimeTypes.length; ++i) { - s = navigator.mimeTypes[i].type; - var m = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/); - if (m != null) { - if (deployJava.compareVersions(m[1], version)) { - return true; - } - } - } - return false; - }, - testUsingPluginsArray: function(version) { - if ((!navigator.plugins) || (!navigator.plugins.length)) { - return false; - } - var platform = navigator.platform.toLowerCase(); - for (var i = 0; i < navigator.plugins.length; ++i) { - s = navigator.plugins[i].description; - if (s.search(/^Java Switchable Plug-in (Cocoa)/) != -1) { - if (deployJava.compareVersions("1.5.0", version)) { - return true; - } - } else if (s.search(/^Java/) != -1) { - if (platform.indexOf('win') != -1) { - if (deployJava.compareVersions("1.5.0", version) || deployJava.compareVersions("1.6.0", version)) { - return true; - } - } - } - } - if (deployJava.compareVersions("1.5.0", version)) { - return true; - } - return false; - }, - IEInstall: function() { - location.href = deployJava.getJavaURL + ((deployJava.returnPage != null) ? ('&returnPage=' + deployJava.returnPage) : '') + ((deployJava.locale != null) ? ('&locale=' + deployJava.locale) : '') + ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : '') + ((deployJava.installType != null) ? ('&type=' + deployJava.installType) : ''); - return false; - }, - done: function(name, result) {}, - FFInstall: function() { - location.href = deployJava.getJavaURL + ((deployJava.returnPage != null) ? ('&returnPage=' + deployJava.returnPage) : '') + ((deployJava.locale != null) ? ('&locale=' + deployJava.locale) : '') + ((deployJava.brand != null) ? ('&brand=' + deployJava.brand) : '') + ((deployJava.installType != null) ? ('&type=' + deployJava.installType) : ''); - return false; - }, - compareVersions: function(installed, required) { - var a = installed.split('.'); - var b = required.split('.'); - for (var i = 0; i < a.length; ++i) { - a[i] = Number(a[i]); - } - for (var i = 0; i < b.length; ++i) { - b[i] = Number(b[i]); - } - if (a.length == 2) { - a[2] = 0; - } - if (a[0] > b[0]) return true; - if (a[0] < b[0]) return false; - if (a[1] > b[1]) return true; - if (a[1] < b[1]) return false; - if (a[2] > b[2]) return true; - if (a[2] < b[2]) return false; - return true; - }, - enableAlerts: function() { - deployJava.browserName = null; - deployJava.debug = true; - }, - poll: function() { - deployJava.refresh(); - var postInstallJREList = deployJava.getJREs(); - if ((deployJava.preInstallJREList.length == 0) && (postInstallJREList.length != 0)) { - clearInterval(deployJava.myInterval); - if (deployJava.returnPage != null) { - location.href = deployJava.returnPage; - }; - } - if ((deployJava.preInstallJREList.length != 0) && (postInstallJREList.length != 0) && (deployJava.preInstallJREList[0] != postInstallJREList[0])) { - clearInterval(deployJava.myInterval); - if (deployJava.returnPage != null) { - location.href = deployJava.returnPage; - } - } - }, - writePluginTag: function() { - var browser = deployJava.getBrowser(); - if (browser == 'MSIE') { - document.write('<' + 'object classid="clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA" ' + 'id="deployJavaPlugin" width="0" height="0">' + '<' + '/' + 'object' + '>'); - } else if (browser == 'Netscape Family' && deployJava.allowPlugin()) { - deployJava.writeEmbedTag(); - } - }, - refresh: function() { - navigator.plugins.refresh(false); - var browser = deployJava.getBrowser(); - if (browser == 'Netscape Family' && deployJava.allowPlugin()) { - var plugin = document.getElementById('deployJavaPlugin'); - if (plugin == null) { - deployJava.writeEmbedTag(); - } - } - }, - writeEmbedTag: function() { - var written = false; - if (navigator.mimeTypes != null) { - for (var i = 0; i < navigator.mimeTypes.length; i++) { - if (navigator.mimeTypes[i].type == deployJava.mimeType) { - if (navigator.mimeTypes[i].enabledPlugin) { - document.write('<' + 'embed id="deployJavaPlugin" type="' + deployJava.mimeType + '" hidden="true" />'); - written = true; - } - } - } - if (!written) for (var i = 0; i < navigator.mimeTypes.length; i++) { - if (navigator.mimeTypes[i].type == deployJava.oldMimeType) { - if (navigator.mimeTypes[i].enabledPlugin) { - document.write('<' + 'embed id="deployJavaPlugin" type="' + deployJava.oldMimeType + '" hidden="true" />'); - } - } - } - } - }, - do_initialize: function() { - deployJava.writePluginTag(); - if (deployJava.locale == null) { - var loc = null; - if (loc == null) try { - loc = navigator.userLanguage; - } catch (err) {} - if (loc == null) try { - loc = navigator.systemLanguage; - } catch (err) {} - if (loc == null) try { - loc = navigator.language; - } catch (err) {} - if (loc != null) { - loc.replace("-", "_") - deployJava.locale = loc; - } - } - } -}; -deployJava.do_initialize(); diff --git a/bigbluebutton-client/resources/prod/check/lib/pre_flight_check.js b/bigbluebutton-client/resources/prod/check/lib/pre_flight_check.js deleted file mode 100755 index 549d5e759d..0000000000 --- a/bigbluebutton-client/resources/prod/check/lib/pre_flight_check.js +++ /dev/null @@ -1,55 +0,0 @@ -var registerListeners = function() { - console.log("Listening for events."); - BBBCheck.listen("MicCheckAppReadyEvent", function() { - console.log("Received [MicCheckAppReadyEvent]."); - }); - BBBCheck.listen("NewRoleEvent", function(bbbCheckEvent) { - console.log("New Role Event [amIPresenter=" + bbbCheckEvent.amIPresenter + ",role=" + bbbCheckEvent.role + ",newPresenterUserID=" + bbbCheckEvent.newPresenterUserID + "]."); - }); -} - - -var bbbCheckFlashVersion = function() { - var playerVersion = BBBCheck.getFlashPlayerVersion(); - console.log("You have Flash player " + playerVersion.major + "." + playerVersion.minor + "." + playerVersion.release + " installed"); -} - -var bbbHasMinFlashVersion = function(version) { - console.log("Q: Do I have Flash player 9.0.18 or higher installed?\nA: " + BBBCheck.hasMinFlashPlayerVersion(version)); -} - -var bbbGetBrowser = function() { - console.log("Browser = " + BBBCheck.getBrowser()); -} - -var bbbGetJREs = function() { - console.log("JREs = " + BBBCheck.getJREs()); -} - -var bbbCheckShowMicSettings = function() { - BBBCheck.showMicSettings(); -} - -var bbbCheckStartTestMic = function() { - BBBCheck.startTestMicrophone(); -} - -var bbbCheckStopTestMic = function() { - BBBCheck.stopTestMicrophone(); -} - -var bbbCheckShowCamSettings = function() { - BBBCheck.showCamSettings(); -} - -var bbbCheckTestRTMPConnection = function(host, app) { - BBBCheck.testRTMPConnection(host, app); -} - -var bbbCheckTestSocketConnection = function(host, port) { - BBBCheck.testSocketConnection(host, port); -} - -var bbbCheckSetSocketPolicyFileURL = function(url) { - BBBCheck.setSocketPolicyFileURL(url); -} diff --git a/bigbluebutton-client/src/SettingsModule.mxml b/bigbluebutton-client/src/SettingsModule.mxml deleted file mode 100755 index 98d3c46fc2..0000000000 --- a/bigbluebutton-client/src/SettingsModule.mxml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/SettingsPanel.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/SettingsPanel.mxml deleted file mode 100755 index 38431cf94d..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/SettingsPanel.mxml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/DeskShareChecker.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/DeskShareChecker.mxml deleted file mode 100755 index b064d7d0c1..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/DeskShareChecker.mxml +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/MicChecker.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/MicChecker.mxml deleted file mode 100755 index 676e257b41..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/MicChecker.mxml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/SystemCheck.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/SystemCheck.mxml deleted file mode 100755 index aefa2be7e3..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/SystemCheck.mxml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - Number(flashVersions[i])) showFlashError(flashVersion, Requirements.flash_required_version); - } - - } - - private function checkOS():void{ - trace("Operating System: " + Capabilities.os); - var os:Array = Capabilities.os.split(" "); - //Check for this bug: http://reviews.cnet.com/8301-13727_7-20022842-263.html - //Fix is to download new flash player 10.2 or above - if (os[0] == "Mac" && os[1] == "OS" && os[2] == "10.6.5"){ - showMacOS1065iSightError(); - } - } - - private function checkJava():void{ - var javas:Array = JavaCheck.getJREs(); - - if (javas.length == 0) showFlashError("NO JAVA INSTALLED", Requirements.java_required_version); - - trace("Java version required is: " + Requirements.java_required_version); - trace("Java versions installed: "); - var highestJava:String = javas[0]; - for each (var java:String in javas){ - trace("Found java " + java); - var highest:Array = highestJava.split("."); - var iter:Array = java.split("."); - - if (Number(iter[0]) > Number(highest[0])){ - highestJava = java; - } else if (Number(iter[0]) == Number(highest[0]) && Number(iter[1]) > Number(highest[1])){ - highestJava = java; - } else if (Number(iter[0]) == Number(highest[0]) && Number(iter[1]) == Number(highest[1])){ - var iterMinor:Number = Number((iter[2] as String).split("_")[1]); - var highestMinor:Number = Number((highest[2] as String).split("_")[1]); - if (iterMinor > highestMinor) highestJava = java; - } - } - - var passedJava:Boolean = true; - var required:Array = Requirements.java_required_version.split("."); - highest = highestJava.split("."); - if (Number(required[0]) > Number(highest[0])){ - passedJava = false; - } else if (Number(required[0]) == Number(highest[0]) && Number(required[1]) > Number(highest[1])){ - passedJava = false; - } else if (Number(required[0]) == Number(highest[0]) && Number(required[1]) == Number(highest[1])){ - var requiredMinor:Number = Number((required[2] as String).split("_")[1]); - var highestJavaMinor:Number = Number((highest[2] as String).split("_")[1]); - if (requiredMinor > highestJavaMinor) passedJava = false; - } - - if (!passedJava) showJavaError(highestJava, Requirements.java_required_version); - else sendJavaOK(); - } - - private function checkBBBApps():void{ - var appsConnector:AppsConnector = new AppsConnector(); - } - - private function sendJavaOK():void{ - dispatchEvent(new JavaOKEvent(JavaOKEvent.JAVA_A_OK)); - } - - private function showJavaError(hasVersion:String, needsVersion:String):void{ - var e:WarningEvent = new WarningEvent(WarningEvent.WARNING_EVENT); - e.warningLabel = ResourceUtil.getInstance().getString('bbb.settings.java.label'); - e.warningText = javaError(hasVersion, needsVersion); - e.optionalCommandText = ResourceUtil.getInstance().getString('bbb.settings.java.command'); - e.optionalCallbackFunction = installNewestJava; - dispatchEvent(e); - } - - private function installNewestJava():void{ - JavaCheck.installLatestJRE(); - } - - private function showFlashError(hasVersion:String, needsVersion:String):void{ - var e:WarningEvent = new WarningEvent(WarningEvent.WARNING_EVENT); - e.warningLabel = ResourceUtil.getInstance().getString('bbb.settings.flash.label'); - e.warningText = flashError(hasVersion, needsVersion); - e.optionalCommandText = ResourceUtil.getInstance().getString('bbb.settings.flash.command'); - e.optionalCallbackFunction = installNewestFlash; - dispatchEvent(e); - } - - private function installNewestFlash():void{ - navigateToURL(new URLRequest("http://get.adobe.com/flashplayer/"), "_self"); - } - - private function showMacOS1065iSightError():void{ - var e:WarningEvent = new WarningEvent(WarningEvent.WARNING_EVENT); - e.warningLabel = ResourceUtil.getInstance().getString('bbb.settings.isight.label'); - e.warningText = iSightErrorOSX1065(); - e.optionalCommandText = ResourceUtil.getInstance().getString('bbb.settings.isight.command'); - e.optionalCallbackFunction = installFlash102RC2; - dispatchEvent(e); - } - - private function installFlash102RC2():void{ - navigateToURL(new URLRequest("http://labs.adobe.com/downloads/flashplayer10.html"), "_self"); - } - - private static function iSightErrorOSX1065():String{ - return ResourceUtil.getInstance().getString('bbb.settings.isight.text'); - } - - private static function javaError(hasVersion:String, needsVersion:String):String{ - return ResourceUtil.getInstance().getString('bbb.settings.java.text', [hasVersion, needsVersion]); - } - - private static function flashError(hasVersion:String, needsVersion:String):String{ - return ResourceUtil.getInstance().getString('bbb.settings.flash.text', [hasVersion, needsVersion]); - } - ]]> - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/WebcamChecker.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/WebcamChecker.mxml deleted file mode 100755 index 0605f9e3f2..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/checkers/WebcamChecker.mxml +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AppsConnector.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AppsConnector.as deleted file mode 100755 index c3f655acc0..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AppsConnector.as +++ /dev/null @@ -1,27 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). -* -* This program 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.0 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, see . -* -*/ -package org.bigbluebutton.modules.settings.connectors -{ - public class AppsConnector - { - public function AppsConnector() - { - } - } -} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AudioConnector.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AudioConnector.as deleted file mode 100755 index 32baa4bcd1..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/AudioConnector.as +++ /dev/null @@ -1,142 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). -* -* This program 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.0 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, see . -* -*/ -package org.bigbluebutton.modules.settings.connectors -{ - import flash.events.AsyncErrorEvent; - import flash.events.IOErrorEvent; - import flash.events.NetStatusEvent; - import flash.events.SecurityErrorEvent; - import flash.media.Microphone; - import flash.media.SoundCodec; - import flash.net.NetConnection; - import flash.net.NetStream; - - import mx.controls.Alert; - - import org.bigbluebutton.modules.settings.util.Requirements; - - public class AudioConnector - { - public static const CONNECT_SUCCESS:String = "NetConnection.Connect.Success"; - public static const CONNECT_FAILED:String = "NetConnection.Connect.Failed"; - public static const CONNECT_CLOSED:String = "NetConnection.Connect.Closed"; - public static const INVALID_APP:String = "NetConnection.Connect.InvalidApp"; - public static const APP_SHUTDOWN:String = "NetConnection.Connect.AppShutDown"; - public static const CONNECT_REJECTED:String = "NetConnection.Connect.Rejected"; - - private var audioCodec:String = "SPEEX"; - - private var connection:NetConnection; - private var outgoingStream:NetStream; - private var incomingStream:NetStream; - - private var streamName:String; - - private var mic:Microphone; - - public function AudioConnector(mic:Microphone) - { - this.mic = mic; - - connection = new NetConnection(); - connection.proxyType = "best"; - connection.client = this; - connection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); - connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); - connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); - connection.addEventListener(IOErrorEvent.IO_ERROR, onIOError); - connection.connect(Requirements.bbb_voice_url); - } - - private function onNetStatus(e:NetStatusEvent):void{ - switch(e.info.code){ - case CONNECT_SUCCESS: - connectAudio(); - break; - case CONNECT_FAILED: - trace("AudioConnector::onNetStatus - connection to Audio App failed"); - break; - case CONNECT_CLOSED: - trace("AudioConnector::onNetStatus - connection to Audio App closed"); - break; - case CONNECT_REJECTED: - trace("AudioConnector::onNetStatus - connection to Audio App rejected"); - break; - default: - trace("AudioConnector::onNetStatus - something else happened: " + e.info.code); - break; - } - } - - private function onAsyncError(e:AsyncErrorEvent):void{ - trace("AudioConnector::onAsyncError - an async error occured on the audio connection"); - } - - private function onSecurityError(e:SecurityErrorEvent):void{ - trace("AudioConnector::onSecurityError - a security error occured on the audio connection"); - } - - private function onIOError(e:IOErrorEvent):void{ - trace("AudioConnector::onIOError - an IO error occured on the audio connection"); - } - - private function connectAudio():void{ - outgoingStream = new NetStream(connection); - outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); - - streamName = Math.random().toString(); - - setupMicrophone(); - outgoingStream.attachAudio(mic); - outgoingStream.publish(streamName, "live"); - } - - public function changeMic(mic:Microphone):void{ - this.mic = mic; - setupMicrophone(); - outgoingStream.attachAudio(mic); - } - - private function setupMicrophone():void { - mic.setUseEchoSuppression(true); - //TODO Set loopBack to false once this is connected to the Asterisk/Freeswitch echo application - mic.setLoopBack(true); - mic.setSilenceLevel(0,20000); - if (audioCodec == "SPEEX") { - mic.encodeQuality = 6; - mic.codec = SoundCodec.SPEEX; - mic.framesPerPacket = 1; - mic.rate = 16; - } else { - mic.codec = SoundCodec.NELLYMOSER; - mic.rate = 8; - } - mic.gain = 60; - } - - public function stop():void{ - if (mic != null){ - mic.setLoopBack(false); - mic = null; - } - if (outgoingStream != null) outgoingStream.close(); - if (incomingStream != null) incomingStream.close(); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/DeskShareConnector.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/DeskShareConnector.as deleted file mode 100755 index 7e169d43df..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/DeskShareConnector.as +++ /dev/null @@ -1,249 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). -* -* This program 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.0 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, see . -* -*/ -package org.bigbluebutton.modules.settings.connectors -{ - import flash.events.AsyncErrorEvent; - import flash.events.IOErrorEvent; - import flash.events.NetStatusEvent; - import flash.events.SecurityErrorEvent; - import flash.net.NetConnection; - import flash.net.Responder; - import flash.net.SharedObject; - - import org.bigbluebutton.modules.settings.util.Requirements; - - /** - * The DeskShareProxy communicates with the Red5 deskShare server application - * @author Snap - * - */ - public class DeskShareConnector - { - public static const CONNECT_SUCCESS:String = "NetConnection.Connect.Success"; - public static const CONNECT_FAILED:String = "NetConnection.Connect.Failed"; - public static const CONNECT_CLOSED:String = "NetConnection.Connect.Closed"; - public static const INVALID_APP:String = "NetConnection.Connect.InvalidApp"; - public static const APP_SHUTDOWN:String = "NetConnection.Connect.AppShutDown"; - public static const CONNECT_REJECTED:String = "NetConnection.Connect.Rejected"; - public static const NETSTREAM_PUBLISH:String = "NetStream.Publish.Start"; - - public var nc:NetConnection; - private var deskSO:SharedObject; - private var responder:Responder; - - private var width:Number; - private var height:Number; - private var uri:String; - - public var room:String = Math.random().toString();; - - private var appletStartedCallback:Function; - private var startViewingCallback:Function; - private var stopViewingCallback:Function; - - public function DeskShareConnector(appletStartedCallback:Function, startViewingCallback:Function, stopViewingCallback:Function) - { - this.appletStartedCallback = appletStartedCallback; - this.startViewingCallback = startViewingCallback; - this.stopViewingCallback = stopViewingCallback; - - connect(); - } - - public function connect():void { - this.uri = Requirements.bbb_deskshare_url + "/" + this.room; - trace("Deskshare Service connecting to " + uri); - nc = new NetConnection() - nc.proxyType = "best"; - nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); - nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); - nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); - nc.addEventListener(IOErrorEvent.IO_ERROR, onIOError); - nc.connect(uri); - - responder = new Responder( - function(result:Object):void{ - if (result != null && (result.publishing as Boolean)){ - width = result.width as Number; - height = result.height as Number; - trace("Desk Share stream is streaming [" + width + "," + height + "]"); - - startViewingCallback(width, height); - } else { - trace("No deskshare stream being published"); - } - }, - function(status:Object):void{ - trace("Error while trying to call remote mathod on server"); - } - ); - } - - public function disconnect():void{ - if (nc != null) nc.close(); - } - - private function onNetStatus(e:NetStatusEvent):void{ - switch(e.info.code){ - case CONNECT_SUCCESS: - connectionSuccessHandler(); - break; - case CONNECT_FAILED: - trace("VideoConnector::onNetStatus - connection to Video App failed"); - break; - case CONNECT_CLOSED: - trace("VideoConnector::onNetStatus - connection to Video App closed"); - break; - case CONNECT_REJECTED: - trace("VideoConnector::onNetStatus - connection to Video App rejected"); - break; - case NETSTREAM_PUBLISH: - - break; - default: - trace("VideoConnector::onNetStatus - something else happened: " + e.info.code); - break; - } - } - - private function onAsyncError(e:AsyncErrorEvent):void{ - trace("VideoConnector::onAsyncError - an async error occured on the video connection"); - } - - private function onSecurityError(e:SecurityErrorEvent):void{ - trace("VideoConnector::onSecurityError - a security error occured on the video connection"); - } - - private function onIOError(e:IOErrorEvent):void{ - trace("VideoConnector::onIOError - an IO error occured on the video connection"); - } - - private function connectionSuccessHandler():void{ - trace("Successully connection to " + uri); - deskSO = SharedObject.getRemote("deskSO", uri, false); - deskSO.client = this; - deskSO.connect(nc); - - checkIfStreamIsPublishing(); - } - - public function getConnection():NetConnection{ - return nc; - } - - /** - * Called by server when client connects. - */ - public function onBWDone():void{ - // do nothing - } - - /** - * Invoked on the server once the clients' applet has started sharing and the server has started a video stream - * - */ - public function appletStarted(videoWidth:Number, videoHeight:Number):void{ - trace("Got applet started"); - - appletStartedCallback(videoWidth, videoHeight); - } - - /** - * Call this method to send out a room-wide notification to start viewing the stream - * - */ - public function sendStartViewingNotification(captureWidth:Number, captureHeight:Number):void{ - try{ - deskSO.send("startViewing", captureWidth, captureHeight); - } catch(e:Error){ - trace("error while trying to send start viewing notification"); - } - } - - public function sendStartedViewingNotification():void{ - trace("Sending start viewing to server"); - nc.call("deskshare.startedToViewStream", null); - } - - /** - * Called by the server when a notification is received to start viewing the broadcast stream . - * This method is called on successful execution of sendStartViewingNotification() - * - */ - public function startViewing(videoWidth:Number, videoHeight:Number):void{ - trace("startViewing invoked by server"); - - startViewingCallback(videoWidth, videoHeight); - } - - /** - * Sends a notification through the server to all the participants in the room to stop viewing the stream - * - */ - public function sendStopViewingNotification():void{ - trace("Sending stop viewing notification to other clients."); - try{ - deskSO.send("stopViewing"); - } catch(e:Error){ - trace("could not send stop viewing notification"); - } - } - - /** - * Called by the server to notify clients that the deskshare stream has stooped. - */ - public function deskshareStreamStopped():void { - stopViewing(); - } - - /** - * Sends a notification to the module to stop viewing the stream - * This method is called on successful execution of sendStopViewingNotification() - * - */ - public function stopViewing():void{ - trace("Received dekskshareStreamStopped"); - - stopViewingCallback(); - } - - public function mouseLocationCallback(x:Number, y:Number):void { - //var event:CursorEvent = new CursorEvent(CursorEvent.UPDATE_CURSOR_LOC_EVENT); - //event.x = x; - //event.y = y; - //dispatcher.dispatchEvent(event); - } - - /** - * Check if anybody is publishing the stream for this room - * This method is useful for clients which have joined a room where somebody is already publishing - * - */ - private function checkIfStreamIsPublishing():void{ - trace("checking if desk share stream is publishing"); - nc.call("deskshare.checkIfStreamIsPublishing", responder); - } - - public function calculateEncodingDimensions(captureWidth:Number, captureHeight:Number):void{ - height = captureHeight; - width = captureWidth; - } - - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/VideoConnector.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/VideoConnector.as deleted file mode 100755 index 5ccef515e8..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/connectors/VideoConnector.as +++ /dev/null @@ -1,120 +0,0 @@ -/** -* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ -* -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). -* -* This program 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.0 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, see . -* -*/ -package org.bigbluebutton.modules.settings.connectors -{ - import flash.events.AsyncErrorEvent; - import flash.events.IOErrorEvent; - import flash.events.NetStatusEvent; - import flash.events.SecurityErrorEvent; - import flash.media.Camera; - import flash.media.Video; - import flash.net.NetConnection; - import flash.net.NetStream; - - import org.bigbluebutton.modules.settings.util.Requirements; - - public class VideoConnector - { - public static const CONNECT_SUCCESS:String = "NetConnection.Connect.Success"; - public static const CONNECT_FAILED:String = "NetConnection.Connect.Failed"; - public static const CONNECT_CLOSED:String = "NetConnection.Connect.Closed"; - public static const INVALID_APP:String = "NetConnection.Connect.InvalidApp"; - public static const APP_SHUTDOWN:String = "NetConnection.Connect.AppShutDown"; - public static const CONNECT_REJECTED:String = "NetConnection.Connect.Rejected"; - public static const NETSTREAM_PUBLISH:String = "NetStream.Publish.Start"; - - public var connection:NetConnection; - private var outgoingStream:NetStream; - private var incomingStream:NetStream; - - private var camera:Camera; - private var streamListener:Function; - - public var streamName:String; - - public function VideoConnector(connectionListener:Function) - { - connection = new NetConnection(); - connection.proxyType = "best"; - connection.client = this; - connection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); - connection.addEventListener(NetStatusEvent.NET_STATUS, connectionListener); - connection.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); - connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); - connection.addEventListener(IOErrorEvent.IO_ERROR, onIOError); - - connectToServer(); - } - - public function connectToServer():void{ - connection.connect(Requirements.bbb_video_url); - } - - private function onNetStatus(e:NetStatusEvent):void{ - switch(e.info.code){ - case CONNECT_SUCCESS: - //connectVideo(); - break; - case CONNECT_FAILED: - trace("VideoConnector::onNetStatus - connection to Video App failed"); - break; - case CONNECT_CLOSED: - trace("VideoConnector::onNetStatus - connection to Video App closed"); - break; - case CONNECT_REJECTED: - trace("VideoConnector::onNetStatus - connection to Video App rejected"); - break; - case NETSTREAM_PUBLISH: - - break; - default: - trace("VideoConnector::onNetStatus - something else happened: " + e.info.code); - break; - } - } - - private function onAsyncError(e:AsyncErrorEvent):void{ - trace("VideoConnector::onAsyncError - an async error occured on the video connection"); - } - - private function onSecurityError(e:SecurityErrorEvent):void{ - trace("VideoConnector::onSecurityError - a security error occured on the video connection"); - } - - private function onIOError(e:IOErrorEvent):void{ - trace("VideoConnector::onIOError - an IO error occured on the video connection"); - } - - public function connectVideo(camera:Camera, streamListener:Function):void{ - outgoingStream = new NetStream(connection); - outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus); - outgoingStream.addEventListener(NetStatusEvent.NET_STATUS, streamListener); - - streamName = Math.random().toString(); - - outgoingStream.attachCamera(camera); - outgoingStream.publish(streamName); - } - - public function changeCamera(camera:Camera):void{ - this.camera = camera; - outgoingStream.attachCamera(camera); - } - } -} diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/JavaOKEvent.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/JavaOKEvent.as deleted file mode 100755 index 1ec258285a..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/JavaOKEvent.as +++ /dev/null @@ -1,32 +0,0 @@ -/** - * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ - * - * Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). - * - * This program 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.0 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, see . - * - */ -package org.bigbluebutton.modules.settings.uihelpers -{ - import flash.events.Event; - - public class JavaOKEvent extends Event - { - public static const JAVA_A_OK:String = "Java is alright, sometimes"; - - public function JavaOKEvent(type:String) - { - super(type, true, false); - } - } -} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/UserAlert.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/UserAlert.mxml deleted file mode 100755 index a2f170e7f4..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/UserAlert.mxml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningEvent.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningEvent.as deleted file mode 100755 index eaf5711dae..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningEvent.as +++ /dev/null @@ -1,37 +0,0 @@ -/** - * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ - * - * Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). - * - * This program 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.0 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, see . - * - */ -package org.bigbluebutton.modules.settings.uihelpers -{ - import flash.events.Event; - - public class WarningEvent extends Event - { - public static const WARNING_EVENT:String = "BBB_CHECKER_WARNING"; - - public var warningLabel:String; - public var warningText:String; - public var optionalCommandText:String; - public var optionalCallbackFunction:Function; - - public function WarningEvent(type:String) - { - super(type, true, false); - } - } -} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningItem.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningItem.mxml deleted file mode 100755 index dbbeb0b199..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningItem.mxml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningsList.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningsList.mxml deleted file mode 100755 index 297a52a751..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/uihelpers/WarningsList.mxml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/FlashCheck.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/FlashCheck.as deleted file mode 100755 index 7d673da8e3..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/FlashCheck.as +++ /dev/null @@ -1,27 +0,0 @@ -/** - * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ - * - * Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). - * - * This program 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.0 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, see . - * - */ -package org.bigbluebutton.modules.settings.util -{ - public class FlashCheck - { - public function FlashCheck() - { - } - } -} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/JavaCheck.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/JavaCheck.as deleted file mode 100755 index 0d53aea1e2..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/JavaCheck.as +++ /dev/null @@ -1,115 +0,0 @@ -/** - * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ - * - * Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). - * - * This program 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.0 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, see . - * - */ -package org.bigbluebutton.modules.settings.util -{ - import flash.external.ExternalInterface; - - public class JavaCheck - { - public static function createWebStartLaunchButton(jnlp:String, minimumVersion:String):void{ - var response:Object = ExternalInterface.call("deployJava.createWebStartLaunchButton", jnlp, minimumVersion); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function createWebStartLaunchButtonEx(jnlp:String, minimumVersion:String):void{ - var response:Object = ExternalInterface.call("deployJava.createWebStartLaunchButtonEx", jnlp, minimumVersion); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function getBrowser():String{ - var browser:String = ExternalInterface.call("deployJava.getBrowser"); - - if (browser == null) throw new Error("Javascript files not found."); - - return browser; - } - - public static function getJREs():Array{ - var installedJREs:Array = ExternalInterface.call("deployJava.getJREs"); - - if (installedJREs == null) throw new Error("Javascript files not found."); - - return installedJREs; - } - - public static function installJRE(requestVersion:String):void{ - var response:Object = ExternalInterface.call("deployJava.installJRE", requestVersion); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function installLatestJRE():void{ - var response:Object = ExternalInterface.call("deployJava.installLatestJRE"); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function isPlugin2():Boolean{ - var plugin2:String = ExternalInterface.call("deployJava.isPlugin2"); - - if (plugin2 == null) throw new Error("Javascript files not found."); - - if (plugin2 == "true") return true; - else return false; - } - - public static function isWebStartInstalled(minimumVersion:String):Boolean{ - var webstartInstalled:String = ExternalInterface.call("deployJava.isWebStartInstalled", minimumVersion); - - if (webstartInstalled == null) throw new Error("Javascript files not found."); - - if (webstartInstalled == "true") return true; - else return false; - } - - public static function runApplet(attributes:Object, parameters:Object, minimumVersion:String):void{ - var response:Object = ExternalInterface.call("deployJava.runApplet", attributes, parameters, minimumVersion); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function setAdditionalPackages(packageList:Object):void{ - var response:Object = ExternalInterface.call("deployJava.setAdditionalPackages", packageList); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function setInstallerType(type:String):void{ - var response:Object = ExternalInterface.call("deployJava.setInstallerType", type); - - if (response == null) throw new Error("Javascript files not found."); - } - - public static function versionCheck(version:String):String{ - var version:String = ExternalInterface.call("deployJava.versionCheck", version); - - if (version == null) throw new Error("Javascript files not found."); - - return version; - } - - public static function writeAppletTag(attributes:Object, parameters:Object = null):void{ - var response:Object = ExternalInterface.call("deployJava.writeAppletTag", attributes, parameters); - - if (response == null) throw new Error("Javascript files not found."); - } - } -} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/PersistUserPreferences.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/PersistUserPreferences.as deleted file mode 100755 index c5028f9504..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/PersistUserPreferences.as +++ /dev/null @@ -1,74 +0,0 @@ -/** - * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ - * - * Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). - * - * This program 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.0 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, see . - * - */ -package org.bigbluebutton.modules.settings.util -{ - import flash.net.SharedObject; - - public class PersistUserPreferences - { - private static var sharedObject:SharedObject = SharedObject.getLocal("bbbUserProperties", "/"); - - public static function storeData(preference:String, data:String):void{ - sharedObject.data[preference] = data; - try{ - sharedObject.flush(1000); - } catch(err:Error){ - trace("Could not flush shared object"); - } - } - - public static function saveWebcamPreference(webcam:String):void{ - sharedObject.data["webcam"] = webcam; - try{ - sharedObject.flush(1000); - } catch(err:Error){ - trace("Could not flush shared object"); - } - } - - public static function saveMicrophonePreference(microphone:String):void{ - sharedObject.data["microphone"] = microphone; - try{ - sharedObject.flush(1000); - } catch(err:Error){ - trace("Could not flush shared object"); - } - } - - public static function saveMicrophoneGain(gain:Number):void{ - if (gain > 100 || gain < 0) return; - - sharedObject.data["gain"] = gain; - try{ - sharedObject.flush(1000); - } catch(err:Error){ - trace("Could not flush shared object"); - } - } - - public static function saveSettingsVisited():void{ - sharedObject.data["previouslyvisited"] = true; - try{ - sharedObject.flush(1000); - } catch(err:Error){ - trace("Could not flush shared object"); - } - } - } -} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/Requirements.as b/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/Requirements.as deleted file mode 100755 index 686ed9e5a4..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/settings/util/Requirements.as +++ /dev/null @@ -1,58 +0,0 @@ -/** - * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ - * - * Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). - * - * This program 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.0 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, see . - * - */ -package org.bigbluebutton.modules.settings.util -{ - import flash.events.Event; - import flash.net.URLLoader; - import flash.net.URLRequest; - import flash.net.URLRequestHeader; - import flash.net.URLRequestMethod; - - import mx.collections.ArrayCollection; - - public class Requirements - { - public static var bbb_apps_url:String; - public static var bbb_voice_url:String; - public static var bbb_video_url:String; - public static var bbb_deskshare_url:String; - public static var flash_required_version:String; - public static var java_required_version:String; - public static var check_deskshare:String = "false"; - - private static var loader:URLLoader; - private static var isLoaded:Boolean = false; - private static var loadingStarted:Boolean = false; - - - public static function setRequirements(attributes:Object):void{ - isLoaded = true; - - //bbb_apps_url = xml.bigbluebutton_apps.@url; - bbb_video_url = attributes.video; - bbb_voice_url = attributes.voice; - bbb_deskshare_url = attributes.deskshare; - - flash_required_version = attributes.flash_required; - java_required_version = attributes.java_required; - check_deskshare = attributes.check_deskshare; - } - - } -} \ No newline at end of file From 94377d5da933211bf2cefd7d70eb8220e84ddbf5 Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Thu, 15 Jan 2015 15:13:44 -0800 Subject: [PATCH 06/11] removed old js files from html experiment --- .../resources/prod/js/collections/users.js | 0 .../prod/js/libs/backbone/backbone-min.js | 39 ------------------- .../resources/prod/js/libs/require/require.js | 34 ---------------- .../prod/js/libs/underscore/underscore-min.js | 5 --- .../resources/prod/js/models/chat.js | 0 .../resources/prod/js/models/presentation.js | 0 .../resources/prod/js/models/users.js | 0 .../resources/prod/js/models/whiteboard.js | 0 .../resources/prod/js/views/users/list.js | 0 .../resources/prod/js/views/users/user.js | 0 10 files changed, 78 deletions(-) delete mode 100644 bigbluebutton-client/resources/prod/js/collections/users.js delete mode 100644 bigbluebutton-client/resources/prod/js/libs/backbone/backbone-min.js delete mode 100644 bigbluebutton-client/resources/prod/js/libs/require/require.js delete mode 100644 bigbluebutton-client/resources/prod/js/libs/underscore/underscore-min.js delete mode 100644 bigbluebutton-client/resources/prod/js/models/chat.js delete mode 100644 bigbluebutton-client/resources/prod/js/models/presentation.js delete mode 100644 bigbluebutton-client/resources/prod/js/models/users.js delete mode 100644 bigbluebutton-client/resources/prod/js/models/whiteboard.js delete mode 100644 bigbluebutton-client/resources/prod/js/views/users/list.js delete mode 100644 bigbluebutton-client/resources/prod/js/views/users/user.js diff --git a/bigbluebutton-client/resources/prod/js/collections/users.js b/bigbluebutton-client/resources/prod/js/collections/users.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bigbluebutton-client/resources/prod/js/libs/backbone/backbone-min.js b/bigbluebutton-client/resources/prod/js/libs/backbone/backbone-min.js deleted file mode 100644 index ffd4b7ec5c..0000000000 --- a/bigbluebutton-client/resources/prod/js/libs/backbone/backbone-min.js +++ /dev/null @@ -1,39 +0,0 @@ -// Backbone.js 0.9.2 - -// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Backbone may be freely distributed under the MIT license. -// For all details and documentation: -// http://backbonejs.org -(function(h,g){typeof exports!=="undefined"?g(h,exports,require("underscore")):typeof define==="function"&&define.amd?define(["underscore","jquery","exports"],function(f,i,p){h.Backbone=g(h,p,f,i)}):h.Backbone=g(h,{},h._,h.jQuery||h.Zepto||h.ender)})(this,function(h,g,f,i){var p=h.Backbone,y=Array.prototype.slice,z=Array.prototype.splice;g.VERSION="0.9.2";g.setDomLibrary=function(a){i=a};g.noConflict=function(){h.Backbone=p;return g};g.emulateHTTP=false;g.emulateJSON=false;var q=/\s+/,l=g.Events= -{on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(q);for(d=this._callbacks||(this._callbacks={});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,k,g,j,h;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(q):f.keys(e);d=a.shift();)if(k=e[d],delete e[d],k&&(b||c))for(g=k.tail;(k=k.next)!==g;)if(j=k.callback,h=k.context,b&&j!==b||c&&h!==c)this.on(d,j,h);return this}}, -trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(q);for(g=y.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};l.bind=l.on;l.unbind=l.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);if(b&&b.collection)this.collection=b.collection; -this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent={};this._pending={};this.set(a,{silent:true});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,l,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b; -if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(b==null?"":""+b)},has:function(a){return this.get(a)!=null},set:function(a,b,c){var d,e;f.isObject(a)||a==null?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;if(d instanceof o)d=d.attributes;if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return false;if(this.idAttribute in d)this.id=d[this.idAttribute];var b=c.changes={},g=this.attributes,h=this._escapedAttributes,j=this._previousAttributes|| -{};for(e in d){a=d[e];if(!f.isEqual(g[e],a)||c.unset&&f.has(g,e))delete h[e],(c.silent?this._silent:b)[e]=true;c.unset?delete g[e]:g[e]=a;!f.isEqual(j[e],a)||f.has(g,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=true)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=true;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=true;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a= -a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return false;c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||a==null?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return false;e=f.clone(this.attributes)}a=f.extend({},c,{silent:true});if(d&&!this.set(d,c.wait?a:c))return false;var k=this,h=c.success;c.success=function(a,b,e){b=k.parse(a,e); -c.wait&&(delete c.wait,b=f.extend(d||{},b));if(!k.set(b,c))return false;h?h(k,a):k.trigger("sync",k,a,c)};c.error=g.wrapError(c.error,k,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),false;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync|| -g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();return this.isNew()?a:a+(a.charAt(a.length-1)=="/"?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return this.id==null},change:function(a){a||(a={});var b=this._changing;this._changing=true;for(var c in this._silent)this._pending[c]=true;var d=f.extend({},a.changes,this._silent); -this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending={};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=false;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed): -false;var b,c=false,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return true;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return true;b&&b.error? -b.error(this,c,b):this.trigger("error",this,c,b);return false}});var r=g.Collection=function(a,b){b||(b={});if(b.model)this.model=b.model;if(b.comparator)this.comparator=b.comparator;this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:true,parse:b.parse})};f.extend(r.prototype,l,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,h,j={},i={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];for(c=0,d= -a.length;c').hide().appendTo("body")[0].contentWindow,this.navigate(a);if(this._hasPushState)i(window).bind("popstate", -this.checkUrl);else if(this._wantsHashChange&&"onhashchange"in window&&!b)i(window).bind("hashchange",this.checkUrl);else if(this._wantsHashChange)this._checkUrlInterval=setInterval(this.checkUrl,this.interval);this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,true),window.location.replace(this.options.root+"#"+this.fragment),true;else if(this._wantsPushState&&this._hasPushState&& -b&&a.hash)this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment);if(!this.options.silent)return this.loadUrl()},stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=false},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe))); -if(a==this.fragment)return false;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),true})},navigate:function(a,b){if(!m.started)return false;if(!b||b===true)b={trigger:b};var c=(a||"").replace(s,"");if(this.fragment!=c)this._hasPushState?(c.indexOf(this.options.root)!=0&&(c=this.options.root+c),this.fragment=c,window.history[b.replace? -"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a)},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid= -f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},E=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");f.extend(v.prototype,l,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c!=null&&i(a).html(c);return a},setElement:function(a, -b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];b!==false&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(E),e=d[1],d=d[2],c=f.bind(c,this);e+=".delegateEvents"+this.cid;d===""?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+ -this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b-1;d-=1)if(b[d]&&c(b[d],d,b))break}}function A(b,c){for(var d in b)if(b.hasOwnProperty(d)&&c(b[d],d))break}function O(b,c,d,g){c&&A(c,function(c,j){if(d||!F.call(b,j))g&&typeof c!=="string"?(b[j]||(b[j]={}),O(b[j],c,d,g)):b[j]=c});return b}function r(b,c){return function(){return c.apply(b, -arguments)}}function X(b){if(!b)return b;var c=W;t(b.split("."),function(b){c=c[b]});return c}function G(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;if(d)c.originalError=d;return c}function ba(){if(H&&H.readyState==="interactive")return H;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return H=b});return H}var g,s,u,y,q,B,H,I,Y,Z,ca=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,da=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, -$=/\.js$/,ea=/^\.\//;s=Object.prototype;var M=s.toString,F=s.hasOwnProperty,fa=Array.prototype.splice,v=!!(typeof window!=="undefined"&&navigator&&document),aa=!v&&typeof importScripts!=="undefined",ga=v&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,R=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",w={},n={},P=[],J=!1;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(D(requirejs))return;n=requirejs;requirejs=void 0}typeof require!=="undefined"&& -!D(require)&&(n=require,require=void 0);g=requirejs=function(b,c,d,p){var i,j="_";!E(b)&&typeof b!=="string"&&(i=b,E(c)?(b=c,c=d,d=p):b=[]);if(i&&i.context)j=i.context;(p=w[j])||(p=w[j]=g.s.newContext(j));i&&p.configure(i);return p.require(b,c,d)};g.config=function(b){return g(b)};g.nextTick=typeof setTimeout!=="undefined"?function(b){setTimeout(b,4)}:function(b){b()};require||(require=g);g.version="2.1.1";g.jsExtRegExp=/^\/|:|\?|\.js$/;g.isBrowser=v;s=g.s={contexts:w,newContext:function(b){function c(a, -f,x){var e,m,b,c,d,h,i,g=f&&f.split("/");e=g;var j=k.map,l=j&&j["*"];if(a&&a.charAt(0)===".")if(f){e=k.pkgs[f]?g=[f]:g.slice(0,g.length-1);f=a=e.concat(a.split("/"));for(e=0;f[e];e+=1)if(m=f[e],m===".")f.splice(e,1),e-=1;else if(m==="..")if(e===1&&(f[2]===".."||f[0]===".."))break;else e>0&&(f.splice(e-1,2),e-=2);e=k.pkgs[f=a[0]];a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else a.indexOf("./")===0&&(a=a.substring(2));if(x&&(g||l)&&j){f=a.split("/");for(e=f.length;e>0;e-=1){b=f.slice(0,e).join("/");if(g)for(m= -g.length;m>0;m-=1)if(x=j[g.slice(0,m).join("/")])if(x=x[b]){c=x;d=e;break}if(c)break;!h&&l&&l[b]&&(h=l[b],i=e)}!c&&h&&(c=h,d=i);c&&(f.splice(0,d,c),a=f.join("/"))}return a}function d(a){v&&t(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===h.contextName)return f.parentNode.removeChild(f),!0})}function p(a){var f=k.paths[a];if(f&&E(f)&&f.length>1)return d(a),f.shift(),h.require.undef(a),h.require([a]),!0}function i(a){var f, -b=a?a.indexOf("!"):-1;b>-1&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function j(a,f,b,e){var m,K,d=null,g=f?f.name:null,j=a,l=!0,k="";a||(l=!1,a="_@r"+(M+=1));a=i(a);d=a[0];a=a[1];d&&(d=c(d,g,e),K=o[d]);a&&(d?k=K&&K.normalize?K.normalize(a,function(a){return c(a,g,e)}):c(a,g,e):(k=c(a,g,e),a=i(k),d=a[0],k=a[1],b=!0,m=h.nameToUrl(k)));b=d&&!K&&!b?"_unnormalized"+(N+=1):"";return{prefix:d,name:k,parentMap:f,unnormalized:!!b,url:m,originalName:j,isDefine:l,id:(d?d+"!"+k:k)+b}}function n(a){var f= -a.id,b=l[f];b||(b=l[f]=new h.Module(a));return b}function q(a,f,b){var e=a.id,m=l[e];if(F.call(o,e)&&(!m||m.defineEmitComplete))f==="defined"&&b(o[e]);else n(a).on(f,b)}function z(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(t(b,function(f){if(f=l[f])f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)g.onError(a)}function s(){P.length&&(fa.apply(C,[C.length-1,0].concat(P)),P=[])}function u(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,t(a.depMaps,function(e,c){var d=e.id, -g=l[d];g&&!a.depMatched[c]&&!b[d]&&(f[d]?(a.defineDep(c,o[d]),a.check()):u(g,f,b))}),b[e]=!0)}function w(){var a,f,b,e,m=(b=k.waitSeconds*1E3)&&h.startTime+b<(new Date).getTime(),c=[],g=[],i=!1,j=!0;if(!S){S=!0;A(l,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||g.push(b),!b.error))if(!b.inited&&m)p(f)?i=e=!0:(c.push(f),d(f));else if(!b.inited&&b.fetched&&a.isDefine&&(i=!0,!a.prefix))return j=!1});if(m&&c.length)return b=G("timeout","Load timeout for modules: "+c,null,c),b.contextName=h.contextName, -z(b);j&&t(g,function(a){u(a,{},{})});if((!m||e)&&i)if((v||aa)&&!T)T=setTimeout(function(){T=0;w()},50);S=!1}}function y(a){n(j(a[0],null,!0)).init(a[1],a[2])}function B(a){var a=a.currentTarget||a.srcElement,b=h.onScriptLoad;a.detachEvent&&!R?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=h.onScriptError;a.detachEvent&&!R||a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function I(){var a;for(s();C.length;)if(a=C.shift(),a[0]=== -null)return z(G("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));else y(a)}var S,U,h,L,T,k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},map:{},config:{}},l={},V={},C=[],o={},Q={},M=1,N=1;L={require:function(a){return a.require?a.require:a.require=h.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=o[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&& -k.config[a.map.id]||{}},exports:o[a.map.id]}}};U=function(a){this.events=V[a.id]||{};this.map=a;this.shim=k.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};U.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=r(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}}, -defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)h.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],r(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;Q[a]||(Q[a]=!0,h.load(this.map.id,a))},check:function(){if(this.enabled&& -!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,m=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(D(m)){if(this.events.error)try{e=h.execCb(c,m,b,e)}catch(d){a=d}else e=h.execCb(c,m,b,e);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)e=b.exports;else if(e===void 0&&this.usingExports)e=this.exports;if(a)return a.requireMap=this.map, -a.requireModules=[this.map.id],a.requireType="define",z(this.error=a)}else e=m;this.exports=e;if(this.map.isDefine&&!this.ignore&&(o[c]=e,g.onResourceLoad))g.onResourceLoad(h,this.map,this.depMaps);delete l[c];this.defined=!0}this.defining=!1;if(this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=j(a.prefix);this.depMaps.push(d);q(d,"defined",r(this,function(e){var m, -d;d=this.map.name;var x=this.map.parentMap?this.map.parentMap.name:null,i=h.makeRequire(a.parentMap,{enableBuildCallback:!0,skipMap:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,x,!0)})||""),e=j(a.prefix+"!"+d,this.map.parentMap),q(e,"defined",r(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=l[e.id]){this.depMaps.push(e);if(this.events.error)d.on("error",r(this,function(a){this.emit("error",a)}));d.enable()}}else m=r(this, -function(a){this.init([],function(){return a},null,{enabled:!0})}),m.error=r(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];A(l,function(a){a.map.id.indexOf(b+"_unnormalized")===0&&delete l[a.map.id]});z(a)}),m.fromText=r(this,function(b,e){var f=a.name,c=j(f),d=J;e&&(b=e);d&&(J=!1);n(c);try{g.exec(b)}catch(x){throw Error("fromText eval for "+f+" failed: "+x);}d&&(J=!0);this.depMaps.push(c);h.completeLoad(f);i([f],m)}),e.load(a.name,i,m,k)}));h.enable(d,this);this.pluginMaps[d.id]= -d},enable:function(){this.enabling=this.enabled=!0;t(this.depMaps,r(this,function(a,b){var c,e;if(typeof a==="string"){a=j(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=L[a.id]){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",r(this,function(a){this.defineDep(b,a);this.check()}));this.errback&&q(a,"error",this.errback)}c=a.id;e=l[c];!L[c]&&e&&!e.enabled&&h.enable(a,this)}));A(this.pluginMaps,r(this,function(a){var b=l[a.id];b&&!b.enabled&& -h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){t(this.events[a],function(a){a(b)});a==="error"&&delete this.events[a]}};h={config:k,contextName:b,registry:l,defined:o,urlFetched:Q,defQueue:C,Module:U,makeModuleMap:j,nextTick:g.nextTick,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e={paths:!0,config:!0,map:!0};A(a,function(a,b){e[b]? -b==="map"?O(k[b],a,!0,!0):O(k[b],a,!0):k[b]=a});if(a.shim)A(a.shim,function(a,b){E(a)&&(a={deps:a});if(a.exports&&!a.exportsFn)a.exportsFn=h.makeShimExports(a);c[b]=a}),k.shim=c;if(a.packages)t(a.packages,function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ea,"").replace($,"")}}),k.pkgs=b;A(l,function(a,b){if(!a.inited&&!a.map.unnormalized)a.map=j(b)});if(a.deps||a.callback)h.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b; -a.init&&(b=a.init.apply(W,arguments));return b||X(a.exports)}},makeRequire:function(a,f){function d(e,c,i){var k,p;if(f.enableBuildCallback&&c&&D(c))c.__requireJsBuild=!0;if(typeof e==="string"){if(D(c))return z(G("requireargs","Invalid require call"),i);if(a&&L[e])return L[e](l[a.id]);if(g.get)return g.get(h,e,a);k=j(e,a,!1,!0);k=k.id;return!F.call(o,k)?z(G("notloaded",'Module name "'+k+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):o[k]}I();h.nextTick(function(){I();p= -n(j(null,a));p.skipMap=f.skipMap;p.init(e,c,i,{enabled:!0});w()});return d}f=f||{};O(d,{isBrowser:v,toUrl:function(b){var d=b.lastIndexOf("."),f=null;d!==-1&&(f=b.substring(d,b.length),b=b.substring(0,d));return h.nameToUrl(c(b,a&&a.id,!0),f)},defined:function(b){b=j(b,a,!1,!0).id;return F.call(o,b)},specified:function(b){b=j(b,a,!1,!0).id;return F.call(o,b)||F.call(l,b)}});if(!a)d.undef=function(b){s();var c=j(b,a,!0),d=l[b];delete o[b];delete Q[c.url];delete V[b];if(d){if(d.events.defined)V[b]= -d.events;delete l[b]}};return d},enable:function(a){l[a.id]&&n(a).enable()},completeLoad:function(a){var b,c,d=k.shim[a]||{},g=d.exports;for(s();C.length;){c=C.shift();if(c[0]===null){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);y(c)}c=l[a];if(!b&&!o[a]&&c&&!c.inited)if(k.enforceDefine&&(!g||!X(g)))if(p(a))return;else return z(G("nodefine","No define call for "+a,null,[a]));else y([a,d.deps||[],d.exportsFn]);w()},nameToUrl:function(a,b){var c,d,i,h,j,l;if(g.jsExtRegExp.test(a))h=a+(b||"");else{c= -k.paths;d=k.pkgs;h=a.split("/");for(j=h.length;j>0;j-=1)if(l=h.slice(0,j).join("/"),i=d[l],l=c[l]){E(l)&&(l=l[0]);h.splice(0,j,l);break}else if(i){c=a===i.name?i.location+"/"+i.main:i.location;h.splice(0,j,c);break}h=h.join("/");h+=b||(/\?/.test(h)?"":".js");h=(h.charAt(0)==="/"||h.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+h}return k.urlArgs?h+((h.indexOf("?")===-1?"?":"&")+k.urlArgs):h},load:function(a,b){g.load(h,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if(a.type=== -"load"||ga.test((a.currentTarget||a.srcElement).readyState))H=null,a=B(a),h.completeLoad(a.id)},onScriptError:function(a){var b=B(a);if(!p(b.id))return z(G("scripterror","Script error",a,[b.id]))}};h.require=h.makeRequire();return h}};g({});t(["toUrl","undef","defined","specified"],function(b){g[b]=function(){var c=w._;return c.require[b].apply(c,arguments)}});if(v&&(u=s.head=document.getElementsByTagName("head")[0],y=document.getElementsByTagName("base")[0]))u=s.head=y.parentNode;g.onError=function(b){throw b; -};g.load=function(b,c,d){var g=b&&b.config||{},i;if(v)return i=g.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),i.type=g.scriptType||"text/javascript",i.charset="utf-8",i.async=!0,i.setAttribute("data-requirecontext",b.contextName),i.setAttribute("data-requiremodule",c),i.attachEvent&&!(i.attachEvent.toString&&i.attachEvent.toString().indexOf("[native code")<0)&&!R?(J=!0,i.attachEvent("onreadystatechange",b.onScriptLoad)):(i.addEventListener("load", -b.onScriptLoad,!1),i.addEventListener("error",b.onScriptError,!1)),i.src=d,I=i,y?u.insertBefore(i,y):u.appendChild(i),I=null,i;else aa&&(importScripts(d),b.completeLoad(c))};v&&N(document.getElementsByTagName("script"),function(b){if(!u)u=b.parentNode;if(q=b.getAttribute("data-main")){if(!n.baseUrl)B=q.split("/"),Y=B.pop(),Z=B.length?B.join("/")+"/":"./",n.baseUrl=Z,q=Y;q=q.replace($,"");n.deps=n.deps?n.deps.concat(q):[q];return!0}});define=function(b,c,d){var g,i;typeof b!=="string"&&(d=c,c=b,b= -null);E(c)||(d=c,c=[]);!c.length&&D(d)&&d.length&&(d.toString().replace(ca,"").replace(da,function(b,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(J&&(g=I||ba()))b||(b=g.getAttribute("data-requiremodule")),i=w[g.getAttribute("data-requirecontext")];(i?i.defQueue:P).push([b,c,d])};define.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(n)}})(this); diff --git a/bigbluebutton-client/resources/prod/js/libs/underscore/underscore-min.js b/bigbluebutton-client/resources/prod/js/libs/underscore/underscore-min.js deleted file mode 100644 index 20597eec37..0000000000 --- a/bigbluebutton-client/resources/prod/js/libs/underscore/underscore-min.js +++ /dev/null @@ -1,5 +0,0 @@ -// Underscore.js 1.4.1 -// http://underscorejs.org -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore may be freely distributed under the MIT license. -((function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=Function.prototype,g=d.push,h=d.slice,i=d.concat,j=d.unshift,k=e.toString,l=e.hasOwnProperty,m=d.forEach,n=d.map,o=d.reduce,p=d.reduceRight,q=d.filter,r=d.every,s=d.some,t=d.indexOf,u=d.lastIndexOf,v=Array.isArray,w=Object.keys,x=f.bind,y=function(a){if(a instanceof y)return a;if(this instanceof y)this._wrapped=a;else return new y(a)};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=y),exports._=y):a._=y,y.VERSION="1.4.1";var z=y.each=y.forEach=function(a,b,d){if(m&&a.forEach===m)a.forEach(b,d);else if(a.length===+a.length){for(var e=0,f=a.length;e2;if(o&&a.reduce===o)return d&&(b=y.bind(b,d)),e?a.reduce(b,c):a.reduce(b);z(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},y.reduceRight=y.foldr=function(a,b,c,d){var e=arguments.length>2;if(p&&a.reduceRight===p)return d&&(b=y.bind(b,d)),arguments.length>2?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=y.keys(a);f=g.length}z(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},y.find=y.detect=function(a,b,c){var d;return A(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},y.filter=y.select=function(a,b,c){var d=[];return q&&a.filter===q?a.filter(b,c):(z(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},y.reject=function(a,b,c){var d=[];return z(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d},y.every=y.all=function(a,b,d){b||(b=y.identity);var e=!0;return r&&a.every===r?a.every(b,d):(z(a,function(a,f,g){if(!(e=e&&b.call(d,a,f,g)))return c}),!!e)};var A=y.some=y.any=function(a,b,d){b||(b=y.identity);var e=!1;return s&&a.some===s?a.some(b,d):(z(a,function(a,f,g){if(e||(e=b.call(d,a,f,g)))return c}),!!e)};y.contains=y.include=function(a,b){var c=!1;return t&&a.indexOf===t?a.indexOf(b)!=-1:(c=A(a,function(a){return a===b}),c)},y.invoke=function(a,b){var c=h.call(arguments,2);return y.map(a,function(a){return(y.isFunction(b)?b:a[b]).apply(a,c)})},y.pluck=function(a,b){return y.map(a,function(a){return a[b]})},y.where=function(a,b){return y.isEmpty(b)?[]:y.filter(a,function(a){for(var c in b)if(b[c]!==a[c])return!1;return!0})},y.max=function(a,b,c){if(!b&&y.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);if(!b&&y.isEmpty(a))return-Infinity;var d={computed:-Infinity};return z(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},y.min=function(a,b,c){if(!b&&y.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);if(!b&&y.isEmpty(a))return Infinity;var d={computed:Infinity};return z(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;gd||c===void 0)return 1;if(c>>1;c.call(d,a[h])=0})})},y.difference=function(a){var b=i.apply(d,h.call(arguments,1));return y.filter(a,function(a){return!y.contains(b,a)})},y.zip=function(){var a=h.call(arguments),b=y.max(y.pluck(a,"length")),c=new Array(b);for(var d=0;d=0;c--)b=[a[c].apply(this,b)];return b[0]}},y.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}},y.keys=w||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)y.has(a,c)&&(b[b.length]=c);return b},y.values=function(a){var b=[];for(var c in a)y.has(a,c)&&b.push(a[c]);return b},y.pairs=function(a){var b=[];for(var c in a)y.has(a,c)&&b.push([c,a[c]]);return b},y.invert=function(a){var b={};for(var c in a)y.has(a,c)&&(b[a[c]]=c);return b},y.functions=y.methods=function(a){var b=[];for(var c in a)y.isFunction(a[c])&&b.push(c);return b.sort()},y.extend=function(a){return z(h.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},y.pick=function(a){var b={},c=i.apply(d,h.call(arguments,1));return z(c,function(c){c in a&&(b[c]=a[c])}),b},y.omit=function(a){var b={},c=i.apply(d,h.call(arguments,1));for(var e in a)y.contains(c,e)||(b[e]=a[e]);return b},y.defaults=function(a){return z(h.call(arguments,1),function(b){for(var c in b)a[c]==null&&(a[c]=b[c])}),a},y.clone=function(a){return y.isObject(a)?y.isArray(a)?a.slice():y.extend({},a):a},y.tap=function(a,b){return b(a),a};var F=function(a,b,c,d){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;a instanceof y&&(a=a._wrapped),b instanceof y&&(b=b._wrapped);var e=k.call(a);if(e!=k.call(b))return!1;switch(e){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if(typeof a!="object"||typeof b!="object")return!1;var f=c.length;while(f--)if(c[f]==a)return d[f]==b;c.push(a),d.push(b);var g=0,h=!0;if(e=="[object Array]"){g=a.length,h=g==b.length;if(h)while(g--)if(!(h=F(a[g],b[g],c,d)))break}else{var i=a.constructor,j=b.constructor;if(i!==j&&!(y.isFunction(i)&&i instanceof i&&y.isFunction(j)&&j instanceof j))return!1;for(var l in a)if(y.has(a,l)){g++;if(!(h=y.has(b,l)&&F(a[l],b[l],c,d)))break}if(h){for(l in b)if(y.has(b,l)&&!(g--))break;h=!g}}return c.pop(),d.pop(),h};y.isEqual=function(a,b){return F(a,b,[],[])},y.isEmpty=function(a){if(a==null)return!0;if(y.isArray(a)||y.isString(a))return a.length===0;for(var b in a)if(y.has(a,b))return!1;return!0},y.isElement=function(a){return!!a&&a.nodeType===1},y.isArray=v||function(a){return k.call(a)=="[object Array]"},y.isObject=function(a){return a===Object(a)},z(["Arguments","Function","String","Number","Date","RegExp"],function(a){y["is"+a]=function(b){return k.call(b)=="[object "+a+"]"}}),y.isArguments(arguments)||(y.isArguments=function(a){return!!a&&!!y.has(a,"callee")}),typeof /./!="function"&&(y.isFunction=function(a){return typeof a=="function"}),y.isFinite=function(a){return y.isNumber(a)&&isFinite(a)},y.isNaN=function(a){return y.isNumber(a)&&a!=+a},y.isBoolean=function(a){return a===!0||a===!1||k.call(a)=="[object Boolean]"},y.isNull=function(a){return a===null},y.isUndefined=function(a){return a===void 0},y.has=function(a,b){return l.call(a,b)},y.noConflict=function(){return a._=b,this},y.identity=function(a){return a},y.times=function(a,b,c){for(var d=0;d":">",'"':""","'":"'","/":"/"}};G.unescape=y.invert(G.escape);var H={escape:new RegExp("["+y.keys(G.escape).join("")+"]","g"),unescape:new RegExp("("+y.keys(G.unescape).join("|")+")","g")};y.each(["escape","unescape"],function(a){y[a]=function(b){return b==null?"":(""+b).replace(H[a],function(b){return G[a][b]})}}),y.result=function(a,b){if(a==null)return null;var c=a[b];return y.isFunction(c)?c.call(a):c},y.mixin=function(a){z(y.functions(a),function(b){var c=y[b]=a[b];y.prototype[b]=function(){var a=[this._wrapped];return g.apply(a,arguments),M.call(this,c.apply(y,a))}})};var I=0;y.uniqueId=function(a){var b=I++;return a?a+b:b},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var J=/(.)^/,K={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},L=/\\|'|\r|\n|\t|\u2028|\u2029/g;y.template=function(a,b,c){c=y.defaults({},c,y.templateSettings);var d=new RegExp([(c.escape||J).source,(c.interpolate||J).source,(c.evaluate||J).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){f+=a.slice(e,h).replace(L,function(a){return"\\"+K[a]}),f+=c?"'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?"'+\n((__t=("+d+"))==null?'':__t)+\n'":g?"';\n"+g+"\n__p+='":"",e=h+b.length}),f+="';\n",c.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(c.variable||"obj","_",f)}catch(h){throw h.source=f,h}if(b)return g(b,y);var i=function(a){return g.call(this,a,y)};return i.source="function("+(c.variable||"obj")+"){\n"+f+"}",i},y.chain=function(a){return y(a).chain()};var M=function(a){return this._chain?y(a).chain():a};y.mixin(y),z(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];y.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),(a=="shift"||a=="splice")&&c.length===0&&delete c[0],M.call(this,c)}}),z(["concat","join","slice"],function(a){var b=d[a];y.prototype[a]=function(){return M.call(this,b.apply(this._wrapped,arguments))}}),y.extend(y.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),typeof define=="function"&&define.amd&&define("underscore",function(){return y})})).call(this) \ No newline at end of file diff --git a/bigbluebutton-client/resources/prod/js/models/chat.js b/bigbluebutton-client/resources/prod/js/models/chat.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bigbluebutton-client/resources/prod/js/models/presentation.js b/bigbluebutton-client/resources/prod/js/models/presentation.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bigbluebutton-client/resources/prod/js/models/users.js b/bigbluebutton-client/resources/prod/js/models/users.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bigbluebutton-client/resources/prod/js/models/whiteboard.js b/bigbluebutton-client/resources/prod/js/models/whiteboard.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bigbluebutton-client/resources/prod/js/views/users/list.js b/bigbluebutton-client/resources/prod/js/views/users/list.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/bigbluebutton-client/resources/prod/js/views/users/user.js b/bigbluebutton-client/resources/prod/js/views/users/user.js deleted file mode 100644 index e69de29bb2..0000000000 From 985f08895ac44e6c11c3476128c1d0b2c701ce10 Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Thu, 15 Jan 2015 15:15:30 -0800 Subject: [PATCH 07/11] removed the unused jssip library --- bigbluebutton-client/build.xml | 5 +- .../resources/prod/lib/jssip-0.3.7.js | 19313 ---------------- 2 files changed, 1 insertion(+), 19317 deletions(-) delete mode 100755 bigbluebutton-client/resources/prod/lib/jssip-0.3.7.js diff --git a/bigbluebutton-client/build.xml b/bigbluebutton-client/build.xml index c85d549fd1..95eda2e7df 100755 --- a/bigbluebutton-client/build.xml +++ b/bigbluebutton-client/build.xml @@ -418,10 +418,7 @@ - - - - + diff --git a/bigbluebutton-client/resources/prod/lib/jssip-0.3.7.js b/bigbluebutton-client/resources/prod/lib/jssip-0.3.7.js deleted file mode 100755 index 4868eb9a1c..0000000000 --- a/bigbluebutton-client/resources/prod/lib/jssip-0.3.7.js +++ /dev/null @@ -1,19313 +0,0 @@ -/* - * JsSIP version 0.3.7 - * Copyright (c) 2012-2014 José Luis Millán - Versatica - * Homepage: http://jssip.net - * License: http://jssip.net/license - */ - - -/*global console: false*/ - -/** - * @name JsSIP - * @namespace - */ -(function(window) { - -var JsSIP = (function() { - "use strict"; - - var JsSIP = {}; - - Object.defineProperties(JsSIP, { - version: { - get: function(){ return '0.3.7'; } - }, - name: { - get: function(){ return 'JsSIP'; } - } - }); - - return JsSIP; -}()); - - - -/** - * @fileoverview EventEmitter - */ - -/** - * @augments JsSIP - * @class Class creating an event emitter. - */ -(function(JsSIP) { -var - EventEmitter, - Event, - LOG_PREFIX = JsSIP.name +' | '+ 'EVENT EMITTER' +' | '; - -EventEmitter = function(){}; -EventEmitter.prototype = { - /** - * Initialize events dictionary. - * @param {Array} events - */ - initEvents: function(events) { - var i = events.length; - - this.events = {}; - this.onceNotFired = []; // Array containing events with _once_ defined tat didn't fire yet. - this.maxListeners = 10; - this.events.newListener = function(event) { // Default newListener callback - console.log(LOG_PREFIX +'new listener added to event '+ event); - }; - - while (i--) { - console.log(LOG_PREFIX +'adding event '+ events[i]); - this.events[events[i]] = []; - } - }, - - /** - * Check whether an event exists or not. - * @param {String} event - * @returns {Boolean} - */ - checkEvent: function(event) { - if (!this.events[event]) { - console.error(LOG_PREFIX +'no event named '+ event); - return false; - } else { - return true; - } - }, - - /** - * Add a listener to the end of the listeners array for the specified event. - * @param {String} event - * @param {Function} listener - */ - addListener: function(event, listener) { - if (!this.checkEvent(event)) { - return; - } - - if (this.events[event].length >= this.maxListeners) { - console.warn(LOG_PREFIX +'max listeners exceeded for event '+ event); - } - - this.events[event].push(listener); - this.events.newListener.call(null, event); - }, - - on: function(event, listener) { - this.addListener(event, listener); - }, - - /** - * Add a one time listener for the event. - * The listener is invoked only the first time the event is fired, after which it is removed. - * @param {String} event - * @param {Function} listener - */ - once: function(event, listener) { - this.events[event].unshift(listener); - this.onceNotFired.push(event); - }, - - /** - * Remove a listener from the listener array for the specified event. - * Caution: changes array indices in the listener array behind the listener. - * @param {String} event - * @param {Function} listener - */ - removeListener: function(event, listener) { - if (!this.checkEvent(event)) { - return; - } - - var array = this.events[event], i = 0, length = array.length; - - while ( i < length ) { - if (array[i] && array[i].toString() === listener.toString()) { - array.splice(i, 1); - } else { - i++; - } - } - }, - - /** - * Remove all listeners from the listener array for the specified event. - * @param {String} event - */ - removeAllListener: function(event) { - if (!this.checkEvent(event)) { - return; - } - - this.events[event] = []; - }, - - /** - * By default EventEmitter will print a warning - * if more than 10 listeners are added for a particular event. - * This function allows that limit to be modified. - * @param {Number} listeners - */ - setMaxListeners: function(listeners) { - if (Number(listeners)) { - this.maxListeners = listeners; - } - }, - - /** - * Get the listeners for a specific event. - * @param {String} event - * @returns {Array} Array of listeners for the specified event. - */ - listeners: function(event) { - return this.events[event]; - }, - - /** - * Execute each of the listeners in order with the supplied arguments. - * @param {String} events - * @param {Array} args - */ - emit: function(event, sender, data) { - var listeners, length, - emitter = this; - - if (!this.checkEvent(event)) { - return; - } - - console.log(LOG_PREFIX +'emitting event '+event); - - listeners = this.events[event]; - length = listeners.length; - - var e = new JsSIP.Event(event, sender, data); - - window.setTimeout( - function(){ - var idx=0; - - for (idx; idx this.ua.configuration.ws_server_max_reconnection) { - console.warn(LOG_PREFIX +'maximum reconnection attempts for WebSocket ' + this.server.ws_uri); - this.ua.onTransportError(this); - } else { - console.log(LOG_PREFIX +'trying to reconnect to WebSocket ' + this.server.ws_uri + ' (reconnection attempt ' + this.reconnection_attempts + ')'); - - this.reconnectTimer = window.setTimeout(function() { - transport.connect(); - transport.reconnectTimer = null; - }, this.ua.configuration.ws_server_reconnection_timeout * 1000); - } - } -}; - -Transport.C = C; -JsSIP.Transport = Transport; -}(JsSIP)); - - - -/** - * @fileoverview SIP Message Parser - */ - -/** - * Extract and parse every header of a SIP message. - * @augments JsSIP - * @namespace - */ -(function(JsSIP) { -var Parser, - LOG_PREFIX = JsSIP.name +' | '+ 'PARSER' +' | '; - -function getHeader(data, headerStart) { - var - // 'start' position of the header. - start = headerStart, - // 'end' position of the header. - end = 0, - // 'partial end' position of the header. - partialEnd = 0; - - //End of message. - if (data.substring(start, start + 2).match(/(^\r\n)/)) { - return -2; - } - - while(end === 0) { - // Partial End of Header. - partialEnd = data.indexOf('\r\n', start); - - // 'indexOf' returns -1 if the value to be found never occurs. - if (partialEnd === -1) { - return partialEnd; - } - - if(!data.substring(partialEnd + 2, partialEnd + 4).match(/(^\r\n)/) && data.charAt(partialEnd + 2).match(/(^\s+)/)) { - // Not the end of the message. Continue from the next position. - start = partialEnd + 2; - } else { - end = partialEnd; - } - } - - return end; -} - -function parseHeader(message, data, headerStart, headerEnd) { - var header, idx, length, parsed, - hcolonIndex = data.indexOf(':', headerStart), - headerName = data.substring(headerStart, hcolonIndex).trim(), - headerValue = data.substring(hcolonIndex + 1, headerEnd).trim(); - - // If header-field is well-known, parse it. - switch(headerName.toLowerCase()) { - case 'via': - case 'v': - message.addHeader('via', headerValue); - if(message.countHeader('via') === 1) { - parsed = message.parseHeader('Via'); - if(parsed) { - message.via = parsed; - message.via_branch = parsed.branch; - } - } else { - parsed = 0; - } - break; - case 'from': - case 'f': - message.setHeader('from', headerValue); - parsed = message.parseHeader('from'); - if(parsed) { - message.from = parsed; - message.from_tag = parsed.getParam('tag'); - } - break; - case 'to': - case 't': - message.setHeader('to', headerValue); - parsed = message.parseHeader('to'); - if(parsed) { - message.to = parsed; - message.to_tag = parsed.getParam('tag'); - } - break; - case 'record-route': - parsed = JsSIP.Grammar.parse(headerValue, 'Record_Route'); - - if (parsed === -1) { - parsed = undefined; - } - - length = parsed.length; - for (idx = 0; idx < length; idx++) { - header = parsed[idx]; - message.addHeader('record-route', headerValue.substring(header.possition, header.offset)); - message.headers['Record-Route'][message.countHeader('record-route')-1].parsed = header.parsed; - } - break; - case 'call-id': - case 'i': - message.setHeader('call-id', headerValue); - parsed = message.parseHeader('call-id'); - if(parsed) { - message.call_id = headerValue; - } - break; - case 'contact': - case 'm': - parsed = JsSIP.Grammar.parse(headerValue, 'Contact'); - - if (parsed === -1) { - parsed = undefined; - } - - length = parsed.length; - for (idx = 0; idx < length; idx++) { - header = parsed[idx]; - message.addHeader('contact', headerValue.substring(header.possition, header.offset)); - message.headers['Contact'][message.countHeader('contact')-1].parsed = header.parsed; - } - break; - case 'content-length': - case 'l': - message.setHeader('content-length', headerValue); - parsed = message.parseHeader('content-length'); - break; - case 'content-type': - case 'c': - message.setHeader('content-type', headerValue); - parsed = message.parseHeader('content-type'); - break; - case 'cseq': - message.setHeader('cseq', headerValue); - parsed = message.parseHeader('cseq'); - if(parsed) { - message.cseq = parsed.value; - } - if(message instanceof JsSIP.IncomingResponse) { - message.method = parsed.method; - } - break; - case 'max-forwards': - message.setHeader('max-forwards', headerValue); - parsed = message.parseHeader('max-forwards'); - break; - case 'www-authenticate': - message.setHeader('www-authenticate', headerValue); - parsed = message.parseHeader('www-authenticate'); - break; - case 'proxy-authenticate': - message.setHeader('proxy-authenticate', headerValue); - parsed = message.parseHeader('proxy-authenticate'); - break; - default: - // Do not parse this header. - message.setHeader(headerName, headerValue); - parsed = 0; - } - - if (parsed === undefined) { - return false; - } else { - return true; - } -} - -/** Parse SIP Message - * @function - * @param {String} message SIP message. - * @returns {JsSIP.IncomingRequest|JsSIP.IncomingResponse|undefined} - */ -Parser = {}; -Parser.parseMessage = function(data) { - var message, firstLine, contentLength, bodyStart, parsed, - headerStart = 0, - headerEnd = data.indexOf('\r\n'); - - if(headerEnd === -1) { - console.warn(LOG_PREFIX +'no CRLF found, not a SIP message, discarded'); - return; - } - - // Parse first line. Check if it is a Request or a Reply. - firstLine = data.substring(0, headerEnd); - parsed = JsSIP.Grammar.parse(firstLine, 'Request_Response'); - - if(parsed === -1) { - console.warn(LOG_PREFIX +'error parsing first line of SIP message: "' + firstLine + '"'); - return; - } else if(!parsed.status_code) { - message = new JsSIP.IncomingRequest(); - message.method = parsed.method; - message.ruri = parsed.uri; - } else { - message = new JsSIP.IncomingResponse(); - message.status_code = parsed.status_code; - message.reason_phrase = parsed.reason_phrase; - } - - message.data = data; - headerStart = headerEnd + 2; - - /* Loop over every line in data. Detect the end of each header and parse - * it or simply add to the headers collection. - */ - while(true) { - headerEnd = getHeader(data, headerStart); - - // The SIP message has normally finished. - if(headerEnd === -2) { - bodyStart = headerStart + 2; - break; - } - // data.indexOf returned -1 due to a malformed message. - else if(headerEnd === -1) { - return; - } - - parsed = parseHeader(message, data, headerStart, headerEnd); - - if(!parsed) { - return; - } - - headerStart = headerEnd + 2; - } - - /* RFC3261 18.3. - * If there are additional bytes in the transport packet - * beyond the end of the body, they MUST be discarded. - */ - if(message.hasHeader('content-length')) { - contentLength = message.getHeader('content-length'); - message.body = data.substr(bodyStart, contentLength); - } else { - message.body = data.substring(bodyStart); - } - - return message; -}; - -JsSIP.Parser = Parser; -}(JsSIP)); - - - -/** - * @fileoverview SIP Message - */ - -(function(JsSIP) { -var - OutgoingRequest, - IncomingMessage, - IncomingRequest, - IncomingResponse, - LOG_PREFIX = JsSIP.name +' | '+ 'SIP MESSAGE' +' | '; - -/** - * @augments JsSIP - * @class Class for outgoing SIP request. - * @param {String} method request method - * @param {String} ruri request uri - * @param {JsSIP.UA} ua - * @param {Object} params parameters that will have priority over ua.configuration parameters: - *
- * - cseq, call_id, from_tag, from_uri, from_display_name, to_uri, to_tag, route_set - * @param {Object} [headers] extra headers - * @param {String} [body] - */ -OutgoingRequest = function(method, ruri, ua, params, extraHeaders, body) { - var - to, - from, - call_id, - cseq; - - params = params || {}; - - // Mandatory parameters check - if(!method || !ruri || !ua) { - return null; - } - - this.headers = {}; - this.method = method; - this.ruri = ruri; - this.body = body; - this.extraHeaders = extraHeaders || []; - - // Fill the Common SIP Request Headers - - // Route - if (params.route_set) { - this.setHeader('route', params.route_set); - } else if (ua.configuration.use_preloaded_route){ - this.setHeader('route', ua.transport.server.sip_uri); - } - - // Via - // Empty Via header. Will be filled by the client transaction. - this.setHeader('via', ''); - - // Max-Forwards - this.setHeader('max-forwards', JsSIP.UA.C.MAX_FORWARDS); - - // To - to = (params.to_display_name || params.to_display_name === 0) ? '"' + params.to_display_name + '" ' : ''; - to += '<' + (params.to_uri || ruri) + '>'; - to += params.to_tag ? ';tag=' + params.to_tag : ''; - this.to = new JsSIP.NameAddrHeader.parse(to); - this.setHeader('to', to); - - // From - if (params.from_display_name || params.from_display_name === 0) { - from = '"' + params.from_display_name + '" '; - } else if (ua.configuration.display_name) { - from = '"' + ua.configuration.display_name + '" '; - } else { - from = ''; - } - from += '<' + (params.from_uri || ua.configuration.uri) + '>;tag='; - from += params.from_tag || JsSIP.Utils.newTag(); - this.from = new JsSIP.NameAddrHeader.parse(from); - this.setHeader('from', from); - - // Call-ID - call_id = params.call_id || (ua.configuration.jssip_id + JsSIP.Utils.createRandomToken(15)); - this.call_id = call_id; - this.setHeader('call-id', call_id); - - // CSeq - cseq = params.cseq || Math.floor(Math.random() * 10000); - this.cseq = cseq; - this.setHeader('cseq', cseq + ' ' + method); -}; - -OutgoingRequest.prototype = { - /** - * Replace the the given header by the given value. - * @param {String} name header name - * @param {String | Array} value header value - */ - setHeader: function(name, value) { - this.headers[JsSIP.Utils.headerize(name)] = (value instanceof Array) ? value : [value]; - }, - toString: function() { - var msg = '', header, length, idx; - - msg += this.method + ' ' + this.ruri + ' SIP/2.0\r\n'; - - for (header in this.headers) { - length = this.headers[header].length; - for (idx = 0; idx < length; idx++) { - msg += header + ': ' + this.headers[header][idx] + '\r\n'; - } - } - - length = this.extraHeaders.length; - for (idx = 0; idx < length; idx++) { - msg += this.extraHeaders[idx] +'\r\n'; - } - - msg += 'Supported: ' + JsSIP.UA.C.SUPPORTED +'\r\n'; - msg += 'User-Agent: ' + JsSIP.C.USER_AGENT +'\r\n'; - - if(this.body) { - length = JsSIP.Utils.str_utf8_length(this.body); - msg += 'Content-Length: ' + length + '\r\n\r\n'; - msg += this.body; - } else { - msg += 'Content-Length: 0\r\n\r\n'; - } - - return msg; - } -}; - -/** - * @augments JsSIP - * @class Class for incoming SIP message. - */ -IncomingMessage = function(){ - this.data = null; - this.headers = null; - this.method = null; - this.via = null; - this.via_branch = null; - this.call_id = null; - this.cseq = null; - this.from = null; - this.from_tag = null; - this.to = null; - this.to_tag = null; - this.body = null; -}; - -IncomingMessage.prototype = { - /** - * Insert a header of the given name and value into the last position of the - * header array. - * @param {String} name header name - * @param {String} value header value - */ - addHeader: function(name, value) { - var header = { raw: value }; - - name = JsSIP.Utils.headerize(name); - - if(this.headers[name]) { - this.headers[name].push(header); - } else { - this.headers[name] = [header]; - } - }, - - /** - * Count the number of headers of the given header name. - * @param {String} name header name - * @returns {Number} Number of headers with the given name - */ - countHeader: function(name) { - var header = this.headers[JsSIP.Utils.headerize(name)]; - - if(header) { - return header.length; - } else { - return 0; - } - }, - - /** - * Get the value of the given header name at the given position. - * @param {String} name header name - * @param {Number} [idx=0] header index - * @returns {String|undefined} Returns the specified header, null if header doesn't exist. - */ - getHeader: function(name, idx) { - var header = this.headers[JsSIP.Utils.headerize(name)]; - - idx = idx || 0; - - if(header) { - if(header[idx]) { - return header[idx].raw; - } - } else { - return; - } - }, - - /** - * Get the header/s of the given name. - * @param {String} name header name - * @returns {Array} Array with all the headers of the specified name. - */ - getHeaderAll: function(name) { - var idx, length, - header = this.headers[JsSIP.Utils.headerize(name)], - result = []; - - if(!header) { - return []; - } - - length = header.length; - for (idx = 0; idx < length; idx++) { - result.push(header[idx].raw); - } - - return result; - }, - - /** - * Verify the existence of the given header. - * @param {String} name header name - * @returns {boolean} true if header with given name exists, false otherwise - */ - hasHeader: function(name) { - return(this.headers[JsSIP.Utils.headerize(name)]) ? true : false; - }, - - /** - * Parse the given header on the given index. - * @param {String} name header name - * @param {Number} [idx=0] header index - * @returns {Object|undefined} Parsed header object, undefined if the header is not present or in case of a parsing error. - */ - parseHeader: function(name, idx) { - var header, value, parsed; - - name = JsSIP.Utils.headerize(name); - - idx = idx || 0; - - if(!this.headers[name]) { - console.log(LOG_PREFIX +'header "' + name + '" not present'); - return; - } else if(idx >= this.headers[name].length) { - console.log(LOG_PREFIX +'not so many "' + name + '" headers present'); - return; - } - - header = this.headers[name][idx]; - value = header.raw; - - if(header.parsed) { - return header.parsed; - } - - //substitute '-' by '_' for grammar rule matching. - parsed = JsSIP.Grammar.parse(value, name.replace(/-/g, '_')); - - if(parsed === -1) { - this.headers[name].splice(idx, 1); //delete from headers - console.warn(LOG_PREFIX +'error parsing "' + name + '" header field with value "' + value + '"'); - return; - } else { - header.parsed = parsed; - return parsed; - } - }, - - /** - * Message Header attribute selector. Alias of parseHeader. - * @param {String} name header name - * @param {Number} [idx=0] header index - * @returns {Object|undefined} Parsed header object, undefined if the header is not present or in case of a parsing error. - * - * @example - * message.s('via',3).port - */ - s: function(name, idx) { - return this.parseHeader(name, idx); - }, - - /** - * Replace the value of the given header by the value. - * @param {String} name header name - * @param {String} value header value - */ - setHeader: function(name, value) { - var header = { raw: value }; - this.headers[JsSIP.Utils.headerize(name)] = [header]; - }, - - toString: function() { - return this.data; - } -}; - -/** - * @augments IncomingMessage - * @class Class for incoming SIP request. - */ -IncomingRequest = function() { - this.headers = {}; - this.ruri = null; - this.transport = null; - this.server_transaction = null; -}; -IncomingRequest.prototype = new IncomingMessage(); - -/** -* Stateful reply. -* @param {Number} code status code -* @param {String} reason reason phrase -* @param {Object} headers extra headers -* @param {String} body body -* @param {Function} [onSuccess] onSuccess callback -* @param {Function} [onFailure] onFailure callback -*/ -IncomingRequest.prototype.reply = function(code, reason, extraHeaders, body, onSuccess, onFailure) { - var rr, vias, length, idx, response, - to = this.getHeader('To'), - r = 0, - v = 0; - - code = code || null; - reason = reason || null; - - // Validate code and reason values - if (!code || (code < 100 || code > 699)) { - throw new TypeError('Invalid status_code: '+ code); - } else if (reason && typeof reason !== 'string' && !(reason instanceof String)) { - throw new TypeError('Invalid reason_phrase: '+ reason); - } - - reason = reason || JsSIP.C.REASON_PHRASE[code] || ''; - extraHeaders = extraHeaders || []; - - response = 'SIP/2.0 ' + code + ' ' + reason + '\r\n'; - - if(this.method === JsSIP.C.INVITE && code > 100 && code <= 200) { - rr = this.countHeader('record-route'); - - for(r; r < rr; r++) { - response += 'Record-Route: ' + this.getHeader('record-route', r) + '\r\n'; - } - } - - vias = this.countHeader('via'); - - for(v; v < vias; v++) { - response += 'Via: ' + this.getHeader('via', v) + '\r\n'; - } - - if(!this.to_tag && code > 100) { - to += ';tag=' + JsSIP.Utils.newTag(); - } else if(this.to_tag && !this.s('to').hasParam('tag')) { - to += ';tag=' + this.to_tag; - } - - response += 'To: ' + to + '\r\n'; - response += 'From: ' + this.getHeader('From') + '\r\n'; - response += 'Call-ID: ' + this.call_id + '\r\n'; - response += 'CSeq: ' + this.cseq + ' ' + this.method + '\r\n'; - - length = extraHeaders.length; - for (idx = 0; idx < length; idx++) { - response += extraHeaders[idx] +'\r\n'; - } - - if(body) { - length = JsSIP.Utils.str_utf8_length(body); - response += 'Content-Type: application/sdp\r\n'; - response += 'Content-Length: ' + length + '\r\n\r\n'; - response += body; - } else { - response += 'Content-Length: ' + 0 + '\r\n\r\n'; - } - - this.server_transaction.receiveResponse(code, response, onSuccess, onFailure); -}; - -/** -* Stateless reply. -* @param {Number} code status code -* @param {String} reason reason phrase -*/ -IncomingRequest.prototype.reply_sl = function(code, reason) { - var to, response, - vias = this.countHeader('via'); - - code = code || null; - reason = reason || null; - - // Validate code and reason values - if (!code || (code < 100 || code > 699)) { - throw new TypeError('Invalid status_code: '+ code); - } else if (reason && typeof reason !== 'string' && !(reason instanceof String)) { - throw new TypeError('Invalid reason_phrase: '+ reason); - } - - reason = reason || JsSIP.C.REASON_PHRASE[code] || ''; - - response = 'SIP/2.0 ' + code + ' ' + reason + '\r\n'; - - for(var v = 0; v < vias; v++) { - response += 'Via: ' + this.getHeader('via', v) + '\r\n'; - } - - to = this.getHeader('To'); - - if(!this.to_tag && code > 100) { - to += ';tag=' + JsSIP.Utils.newTag(); - } else if(this.to_tag && !this.s('to').hasParam('tag')) { - to += ';tag=' + this.to_tag; - } - - response += 'To: ' + to + '\r\n'; - response += 'From: ' + this.getHeader('From') + '\r\n'; - response += 'Call-ID: ' + this.call_id + '\r\n'; - response += 'CSeq: ' + this.cseq + ' ' + this.method + '\r\n'; - response += 'Content-Length: ' + 0 + '\r\n\r\n'; - - this.transport.send(response); -}; - - -/** - * @augments IncomingMessage - * @class Class for incoming SIP response. - */ -IncomingResponse = function() { - this.headers = {}; - this.status_code = null; - this.reason_phrase = null; -}; -IncomingResponse.prototype = new IncomingMessage(); - -JsSIP.OutgoingRequest = OutgoingRequest; -JsSIP.IncomingRequest = IncomingRequest; -JsSIP.IncomingResponse = IncomingResponse; -}(JsSIP)); - - - -/** - * @fileoverview SIP URI - */ - -/** - * @augments JsSIP - * @class Class creating a SIP URI. - * - * @param {String} [scheme] - * @param {String} [user] - * @param {String} host - * @param {String} [port] - * @param {Object} [parameters] - * @param {Object} [headers] - * - */ -(function(JsSIP) { -var URI; - -URI = function(scheme, user, host, port, parameters, headers) { - var param, header; - - // Checks - if(!host) { - throw new TypeError('missing or invalid "host" parameter'); - } - - // Initialize parameters - scheme = scheme || JsSIP.C.SIP; - this.parameters = {}; - this.headers = {}; - - for (param in parameters) { - this.setParam(param, parameters[param]); - } - - for (header in headers) { - this.setHeader(header, headers[header]); - } - - Object.defineProperties(this, { - scheme: { - get: function(){ return scheme; }, - set: function(value){ - scheme = value.toLowerCase(); - } - }, - - user: { - get: function(){ return user; }, - set: function(value){ - user = value; - } - }, - - host: { - get: function(){ return host; }, - set: function(value){ - host = value.toLowerCase(); - } - }, - - port: { - get: function(){ return port; }, - set: function(value){ - port = value === 0 ? value : (parseInt(value,10) || null); - } - } - }); -}; -URI.prototype = { - setParam: function(key, value) { - if(key) { - this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null) ? null : value.toString().toLowerCase(); - } - }, - - getParam: function(key) { - if(key) { - return this.parameters[key.toLowerCase()]; - } - }, - - hasParam: function(key) { - if(key) { - return (this.parameters.hasOwnProperty(key.toLowerCase()) && true) || false; - } - }, - - deleteParam: function(parameter) { - var value; - parameter = parameter.toLowerCase(); - if (this.parameters.hasOwnProperty(parameter)) { - value = this.parameters[parameter]; - delete this.parameters[parameter]; - return value; - } - }, - - clearParams: function() { - this.parameters = {}; - }, - - setHeader: function(name, value) { - this.headers[JsSIP.Utils.headerize(name)] = (value instanceof Array) ? value : [value]; - }, - - getHeader: function(name) { - if(name) { - return this.headers[JsSIP.Utils.headerize(name)]; - } - }, - - hasHeader: function(name) { - if(name) { - return (this.headers.hasOwnProperty(JsSIP.Utils.headerize(name)) && true) || false; - } - }, - - deleteHeader: function(header) { - var value; - header = JsSIP.Utils.headerize(header); - if(this.headers.hasOwnProperty(header)) { - value = this.headers[header]; - delete this.headers[header]; - return value; - } - }, - - clearHeaders: function() { - this.headers = {}; - }, - - clone: function() { - return new URI( - this.scheme, - this.user, - this.host, - this.port, - window.JSON.parse(window.JSON.stringify(this.parameters)), - window.JSON.parse(window.JSON.stringify(this.headers))); - }, - - toString: function(){ - var header, parameter, idx, uri, - headers = []; - - uri = this.scheme + ':'; - if (this.user) { - uri += JsSIP.Utils.escapeUser(this.user) + '@'; - } - uri += this.host; - if (this.port || this.port === 0) { - uri += ':' + this.port; - } - - for (parameter in this.parameters) { - uri += ';' + parameter; - - if (this.parameters[parameter] !== null) { - uri += '='+ this.parameters[parameter]; - } - } - - for(header in this.headers) { - for(idx in this.headers[header]) { - headers.push(header + '=' + this.headers[header][idx]); - } - } - - if (headers.length > 0) { - uri += '?' + headers.join('&'); - } - - return uri; - }, - - toAor: function(show_port){ - var aor; - - aor = this.scheme + ':'; - if (this.user) { - aor += JsSIP.Utils.escapeUser(this.user) + '@'; - } - aor += this.host; - if (show_port && (this.port || this.port === 0)) { - aor += ':' + this.port; - } - - return aor; - } -}; - - -/** - * Parse the given string and returns a JsSIP.URI instance or undefined if - * it is an invalid URI. - * @public - * @param {String} uri - */ -URI.parse = function(uri) { - uri = JsSIP.Grammar.parse(uri,'SIP_URI'); - - if (uri !== -1) { - return uri; - } else { - return undefined; - } -}; - -JsSIP.URI = URI; -}(JsSIP)); - - - -/** - * @fileoverview JsSIP NameAddrHeader - */ - -/** - * @augments JsSIP - * @class Class creating a Name Address SIP header. - * - * @param {JsSIP.URI} uri - * @param {String} [display_name] - * @param {Object} [parameters] - * - */ -(function(JsSIP) { -var NameAddrHeader; - -NameAddrHeader = function(uri, display_name, parameters) { - var param; - - // Checks - if(!uri || !(uri instanceof JsSIP.URI)) { - throw new TypeError('missing or invalid "uri" parameter'); - } - - // Initialize parameters - this.uri = uri; - this.parameters = {}; - - for (param in parameters) { - this.setParam(param, parameters[param]); - } - - Object.defineProperties(this, { - display_name: { - get: function() { return display_name; }, - set: function(value) { - display_name = (value === 0) ? '0' : value; - } - } - }); -}; -NameAddrHeader.prototype = { - setParam: function(key, value) { - if (key) { - this.parameters[key.toLowerCase()] = (typeof value === 'undefined' || value === null) ? null : value.toString(); - } - }, - - getParam: function(key) { - if(key) { - return this.parameters[key.toLowerCase()]; - } - }, - - hasParam: function(key) { - if(key) { - return (this.parameters.hasOwnProperty(key.toLowerCase()) && true) || false; - } - }, - - deleteParam: function(parameter) { - var value; - parameter = parameter.toLowerCase(); - if (this.parameters.hasOwnProperty(parameter)) { - value = this.parameters[parameter]; - delete this.parameters[parameter]; - return value; - } - }, - - clearParams: function() { - this.parameters = {}; - }, - - clone: function() { - return new NameAddrHeader( - this.uri.clone(), - this.display_name, - window.JSON.parse(window.JSON.stringify(this.parameters))); - }, - - toString: function() { - var body, parameter; - - body = (this.display_name || this.display_name === 0) ? '"' + this.display_name + '" ' : ''; - body += '<' + this.uri.toString() + '>'; - - for (parameter in this.parameters) { - body += ';' + parameter; - - if (this.parameters[parameter] !== null) { - body += '='+ this.parameters[parameter]; - } - } - - return body; - } -}; - - -/** - * Parse the given string and returns a JsSIP.NameAddrHeader instance or undefined if - * it is an invalid NameAddrHeader. - * @public - * @param {String} name_addr_header - */ -NameAddrHeader.parse = function(name_addr_header) { - name_addr_header = JsSIP.Grammar.parse(name_addr_header,'Name_Addr_Header'); - - if (name_addr_header !== -1) { - return name_addr_header; - } else { - return undefined; - } -}; - -JsSIP.NameAddrHeader = NameAddrHeader; -}(JsSIP)); - - - -/** - * @fileoverview SIP Transactions - */ - -/** - * SIP Transactions module. - * @augments JsSIP - */ -(function(JsSIP) { -var Transactions, - LOG_PREFIX = JsSIP.name +' | '+ 'TRANSACTION' +' | ', - C = { - // Transaction states - STATUS_TRYING: 1, - STATUS_PROCEEDING: 2, - STATUS_CALLING: 3, - STATUS_ACCEPTED: 4, - STATUS_COMPLETED: 5, - STATUS_TERMINATED: 6, - STATUS_CONFIRMED: 7 - }; - -Transactions = {}; - -/** -* @class Client Transaction -* @private -*/ -var ClientTransaction = function() { - this.init = function(request_sender, request, transport) { - var via; - - this.transport = transport; - this.id = 'z9hG4bK' + Math.floor(Math.random() * 10000000); - this.request_sender = request_sender; - this.request = request; - - via = 'SIP/2.0/' + (request_sender.ua.configuration.hack_via_tcp ? 'TCP' : transport.server.scheme); - via += ' ' + request_sender.ua.configuration.via_host + ';branch=' + this.id; - - this.request.setHeader('via', via); - }; -}; - -/** -* @class Non Invite Client Transaction Prototype -* @private -*/ -var NonInviteClientTransactionPrototype = function() { - this.send = function() { - var tr = this; - - this.state = C.STATUS_TRYING; - this.F = window.setTimeout(function() {tr.timer_F();}, JsSIP.Timers.TIMER_F); - - if(!this.transport.send(this.request)) { - this.onTransportError(); - } - }; - - this.onTransportError = function() { - console.log(LOG_PREFIX +'transport error occurred, deleting non-INVITE client transaction ' + this.id); - window.clearTimeout(this.F); - window.clearTimeout(this.K); - delete this.request_sender.ua.transactions.nict[this.id]; - this.request_sender.onTransportError(); - }; - - this.timer_F = function() { - console.log(LOG_PREFIX +'Timer F expired for non-INVITE client transaction ' + this.id); - this.state = C.STATUS_TERMINATED; - this.request_sender.onRequestTimeout(); - delete this.request_sender.ua.transactions.nict[this.id]; - }; - - this.timer_K = function() { - this.state = C.STATUS_TERMINATED; - delete this.request_sender.ua.transactions.nict[this.id]; - }; - - this.receiveResponse = function(response) { - var - tr = this, - status_code = response.status_code; - - if(status_code < 200) { - switch(this.state) { - case C.STATUS_TRYING: - case C.STATUS_PROCEEDING: - this.state = C.STATUS_PROCEEDING; - this.request_sender.receiveResponse(response); - break; - } - } else { - switch(this.state) { - case C.STATUS_TRYING: - case C.STATUS_PROCEEDING: - this.state = C.STATUS_COMPLETED; - window.clearTimeout(this.F); - - if(status_code === 408) { - this.request_sender.onRequestTimeout(); - } else { - this.request_sender.receiveResponse(response); - } - - this.K = window.setTimeout(function() {tr.timer_K();}, JsSIP.Timers.TIMER_K); - break; - case C.STATUS_COMPLETED: - break; - } - } - }; -}; -NonInviteClientTransactionPrototype.prototype = new ClientTransaction(); - - -/** - * @class Invite Client Transaction Prototype - * @private - */ -var InviteClientTransactionPrototype = function() { - - this.send = function() { - var tr = this; - this.state = C.STATUS_CALLING; - this.B = window.setTimeout(function() { - tr.timer_B(); - }, JsSIP.Timers.TIMER_B); - - if(!this.transport.send(this.request)) { - this.onTransportError(); - } - }; - - this.onTransportError = function() { - console.log(LOG_PREFIX +'transport error occurred, deleting INVITE client transaction ' + this.id); - window.clearTimeout(this.B); - window.clearTimeout(this.D); - window.clearTimeout(this.M); - delete this.request_sender.ua.transactions.ict[this.id]; - - if (this.state !== C.STATUS_ACCEPTED) { - this.request_sender.onTransportError(); - } - }; - - // RFC 6026 7.2 - this.timer_M = function() { - console.log(LOG_PREFIX +'Timer M expired for INVITE client transaction ' + this.id); - - if(this.state === C.STATUS_ACCEPTED) { - this.state = C.STATUS_TERMINATED; - window.clearTimeout(this.B); - delete this.request_sender.ua.transactions.ict[this.id]; - } - }; - - // RFC 3261 17.1.1 - this.timer_B = function() { - console.log(LOG_PREFIX +'Timer B expired for INVITE client transaction ' + this.id); - if(this.state === C.STATUS_CALLING) { - this.state = C.STATUS_TERMINATED; - this.request_sender.onRequestTimeout(); - delete this.request_sender.ua.transactions.ict[this.id]; - } - }; - - this.timer_D = function() { - console.log(LOG_PREFIX +'Timer D expired for INVITE client transaction ' + this.id); - this.state = C.STATUS_TERMINATED; - window.clearTimeout(this.B); - delete this.request_sender.ua.transactions.ict[this.id]; - }; - - this.sendACK = function(response) { - var tr = this; - - this.ack = 'ACK ' + this.request.ruri + ' SIP/2.0\r\n'; - this.ack += 'Via: ' + this.request.headers['Via'].toString() + '\r\n'; - - if(this.request.headers['Route']) { - this.ack += 'Route: ' + this.request.headers['Route'].toString() + '\r\n'; - } - - this.ack += 'To: ' + response.getHeader('to') + '\r\n'; - this.ack += 'From: ' + this.request.headers['From'].toString() + '\r\n'; - this.ack += 'Call-ID: ' + this.request.headers['Call-ID'].toString() + '\r\n'; - this.ack += 'CSeq: ' + this.request.headers['CSeq'].toString().split(' ')[0]; - this.ack += ' ACK\r\n\r\n'; - - this.D = window.setTimeout(function() {tr.timer_D();}, JsSIP.Timers.TIMER_D); - - this.transport.send(this.ack); - }; - - this.cancel_request = function(tr, reason) { - var request = tr.request; - - this.cancel = JsSIP.C.CANCEL + ' ' + request.ruri + ' SIP/2.0\r\n'; - this.cancel += 'Via: ' + request.headers['Via'].toString() + '\r\n'; - - if(this.request.headers['Route']) { - this.cancel += 'Route: ' + request.headers['Route'].toString() + '\r\n'; - } - - this.cancel += 'To: ' + request.headers['To'].toString() + '\r\n'; - this.cancel += 'From: ' + request.headers['From'].toString() + '\r\n'; - this.cancel += 'Call-ID: ' + request.headers['Call-ID'].toString() + '\r\n'; - this.cancel += 'CSeq: ' + request.headers['CSeq'].toString().split(' ')[0] + - ' CANCEL\r\n'; - - if(reason) { - this.cancel += 'Reason: ' + reason + '\r\n'; - } - - this.cancel += 'Content-Length: 0\r\n\r\n'; - - // Send only if a provisional response (>100) has been received. - if(this.state === C.STATUS_PROCEEDING) { - this.transport.send(this.cancel); - } - }; - - this.receiveResponse = function(response) { - var - tr = this, - status_code = response.status_code; - - if(status_code >= 100 && status_code <= 199) { - switch(this.state) { - case C.STATUS_CALLING: - this.state = C.STATUS_PROCEEDING; - this.request_sender.receiveResponse(response); - if(this.cancel) { - this.transport.send(this.cancel); - } - break; - case C.STATUS_PROCEEDING: - this.request_sender.receiveResponse(response); - break; - } - } else if(status_code >= 200 && status_code <= 299) { - switch(this.state) { - case C.STATUS_CALLING: - case C.STATUS_PROCEEDING: - this.state = C.STATUS_ACCEPTED; - this.M = window.setTimeout(function() { - tr.timer_M(); - }, JsSIP.Timers.TIMER_M); - this.request_sender.receiveResponse(response); - break; - case C.STATUS_ACCEPTED: - this.request_sender.receiveResponse(response); - break; - } - } else if(status_code >= 300 && status_code <= 699) { - switch(this.state) { - case C.STATUS_CALLING: - case C.STATUS_PROCEEDING: - this.state = C.STATUS_COMPLETED; - this.sendACK(response); - this.request_sender.receiveResponse(response); - break; - case C.STATUS_COMPLETED: - this.sendACK(response); - break; - } - } - }; -}; -InviteClientTransactionPrototype.prototype = new ClientTransaction(); - -/** - * @class Server Transaction - * @private - */ -var ServerTransaction = function() { - this.init = function(request, ua) { - this.id = request.via_branch; - this.request = request; - this.transport = request.transport; - this.ua = ua; - this.last_response = ''; - request.server_transaction = this; - }; -}; - -/** - * @class Non Invite Server Transaction Prototype - * @private - */ -var NonInviteServerTransactionPrototype = function() { - this.timer_J = function() { - console.log(LOG_PREFIX +'Timer J expired for non-INVITE server transaction ' + this.id); - this.state = C.STATUS_TERMINATED; - delete this.ua.transactions.nist[this.id]; - }; - - this.onTransportError = function() { - if (!this.transportError) { - this.transportError = true; - - console.log(LOG_PREFIX +'transport error occurred, deleting non-INVITE server transaction ' + this.id); - - window.clearTimeout(this.J); - delete this.ua.transactions.nist[this.id]; - } - }; - - this.receiveResponse = function(status_code, response, onSuccess, onFailure) { - var tr = this; - - if(status_code === 100) { - /* RFC 4320 4.1 - * 'A SIP element MUST NOT - * send any provisional response with a - * Status-Code other than 100 to a non-INVITE request.' - */ - switch(this.state) { - case C.STATUS_TRYING: - this.state = C.STATUS_PROCEEDING; - if(!this.transport.send(response)) { - this.onTransportError(); - } - break; - case C.STATUS_PROCEEDING: - this.last_response = response; - if(!this.transport.send(response)) { - this.onTransportError(); - if (onFailure) { - onFailure(); - } - } else if (onSuccess) { - onSuccess(); - } - break; - } - } else if(status_code >= 200 && status_code <= 699) { - switch(this.state) { - case C.STATUS_TRYING: - case C.STATUS_PROCEEDING: - this.state = C.STATUS_COMPLETED; - this.last_response = response; - this.J = window.setTimeout(function() { - tr.timer_J(); - }, JsSIP.Timers.TIMER_J); - if(!this.transport.send(response)) { - this.onTransportError(); - if (onFailure) { - onFailure(); - } - } else if (onSuccess) { - onSuccess(); - } - break; - case C.STATUS_COMPLETED: - break; - } - } - }; -}; -NonInviteServerTransactionPrototype.prototype = new ServerTransaction(); - -/** - * @class Invite Server Transaction Prototype - * @private - */ -var InviteServerTransactionPrototype = function() { - this.timer_H = function() { - console.log(LOG_PREFIX +'Timer H expired for INVITE server transaction ' + this.id); - - if(this.state === C.STATUS_COMPLETED) { - console.warn(LOG_PREFIX +'transactions', 'ACK for INVITE server transaction was never received, call will be terminated'); - this.state = C.STATUS_TERMINATED; - } - - delete this.ua.transactions.ist[this.id]; - }; - - this.timer_I = function() { - this.state = C.STATUS_TERMINATED; - delete this.ua.transactions.ist[this.id]; - }; - - // RFC 6026 7.1 - this.timer_L = function() { - console.log(LOG_PREFIX +'Timer L expired for INVITE server transaction ' + this.id); - - if(this.state === C.STATUS_ACCEPTED) { - this.state = C.STATUS_TERMINATED; - delete this.ua.transactions.ist[this.id]; - } - }; - - this.onTransportError = function() { - if (!this.transportError) { - this.transportError = true; - - console.log(LOG_PREFIX +'transport error occurred, deleting INVITE server transaction ' + this.id); - - if (this.resendProvisionalTimer !== null) { - window.clearInterval(this.resendProvisionalTimer); - this.resendProvisionalTimer = null; - } - window.clearTimeout(this.L); - window.clearTimeout(this.H); - window.clearTimeout(this.I); - delete this.ua.transactions.ist[this.id]; - } - }; - - this.resend_provisional = function() { - if(!this.transport.send(this.last_response)) { - this.onTransportError(); - } - }; - - // INVITE Server Transaction RFC 3261 17.2.1 - this.receiveResponse = function(status_code, response, onSuccess, onFailure) { - var tr = this; - - if(status_code >= 100 && status_code <= 199) { - switch(this.state) { - case C.STATUS_PROCEEDING: - if(!this.transport.send(response)) { - this.onTransportError(); - } - this.last_response = response; - break; - } - } - - if(status_code > 100 && status_code <= 199 && this.state === C.STATUS_PROCEEDING) { - // Trigger the resendProvisionalTimer only for the first non 100 provisional response. - if(this.resendProvisionalTimer === null) { - this.resendProvisionalTimer = window.setInterval(function() { - tr.resend_provisional();}, JsSIP.Timers.PROVISIONAL_RESPONSE_INTERVAL); - } - } else if(status_code >= 200 && status_code <= 299) { - switch(this.state) { - case C.STATUS_PROCEEDING: - this.state = C.STATUS_ACCEPTED; - this.last_response = response; - this.L = window.setTimeout(function() { - tr.timer_L(); - }, JsSIP.Timers.TIMER_L); - if (this.resendProvisionalTimer !== null) { - window.clearInterval(this.resendProvisionalTimer); - this.resendProvisionalTimer = null; - } - /* falls through */ - case C.STATUS_ACCEPTED: - // Note that this point will be reached for proceeding tr.state also. - if(!this.transport.send(response)) { - this.onTransportError(); - if (onFailure) { - onFailure(); - } - } else if (onSuccess) { - onSuccess(); - } - break; - } - } else if(status_code >= 300 && status_code <= 699) { - switch(this.state) { - case C.STATUS_PROCEEDING: - if (this.resendProvisionalTimer !== null) { - window.clearInterval(this.resendProvisionalTimer); - this.resendProvisionalTimer = null; - } - if(!this.transport.send(response)) { - this.onTransportError(); - if (onFailure) { - onFailure(); - } - } else { - this.state = C.STATUS_COMPLETED; - this.H = window.setTimeout(function() { - tr.timer_H(); - }, JsSIP.Timers.TIMER_H); - if (onSuccess) { - onSuccess(); - } - } - break; - } - } - }; -}; -InviteServerTransactionPrototype.prototype = new ServerTransaction(); - -/** -* @augments JsSIP.Transactions -* @class Non Invite Client Transaction -* @param {JsSIP.RequestSender} request_sender -* @param {JsSIP.OutgoingRequest} request -* @param {JsSIP.Transport} transport -*/ -Transactions.NonInviteClientTransaction = function(request_sender, request, transport) { - this.init(request_sender, request, transport); - this.request_sender.ua.transactions.nict[this.id] = this; -}; -Transactions.NonInviteClientTransaction.prototype = new NonInviteClientTransactionPrototype(); - -/** -* @augments JsSIP.Transactions -* @class Invite Client Transaction -* @param {JsSIP.RequestSender} request_sender -* @param {JsSIP.OutgoingRequest} request -* @param {JsSIP.Transport} transport -*/ -Transactions.InviteClientTransaction = function(request_sender, request, transport) { - var tr = this; - - this.init(request_sender, request, transport); - this.request_sender.ua.transactions.ict[this.id] = this; - - // Add the cancel property to the request. - //Will be called from the request instance, not the transaction itself. - this.request.cancel = function(reason) { - tr.cancel_request(tr, reason); - }; -}; -Transactions.InviteClientTransaction.prototype = new InviteClientTransactionPrototype(); - -Transactions.AckClientTransaction = function(request_sender, request, transport) { - this.init(request_sender, request, transport); - this.send = function() { - this.transport.send(request); - }; -}; -Transactions.AckClientTransaction.prototype = new NonInviteClientTransactionPrototype(); - - -/** -* @augments JsSIP.Transactions -* @class Non Invite Server Transaction -* @param {JsSIP.IncomingRequest} request -* @param {JsSIP.UA} ua -*/ -Transactions.NonInviteServerTransaction = function(request, ua) { - this.init(request, ua); - this.state = C.STATUS_TRYING; - - ua.transactions.nist[this.id] = this; -}; -Transactions.NonInviteServerTransaction.prototype = new NonInviteServerTransactionPrototype(); - - - -/** -* @augments JsSIP.Transactions -* @class Invite Server Transaction -* @param {JsSIP.IncomingRequest} request -* @param {JsSIP.UA} ua -*/ -Transactions.InviteServerTransaction = function(request, ua) { - this.init(request, ua); - this.state = C.STATUS_PROCEEDING; - - ua.transactions.ist[this.id] = this; - - this.resendProvisionalTimer = null; - - request.reply(100); -}; -Transactions.InviteServerTransaction.prototype = new InviteServerTransactionPrototype(); - -/** - * @function - * @param {JsSIP.UA} ua - * @param {JsSIP.IncomingRequest} request - * - * @return {boolean} - * INVITE: - * _true_ if retransmission - * _false_ new request - * - * ACK: - * _true_ ACK to non2xx response - * _false_ ACK must be passed to TU (accepted state) - * ACK to 2xx response - * - * CANCEL: - * _true_ no matching invite transaction - * _false_ matching invite transaction and no final response sent - * - * OTHER: - * _true_ retransmission - * _false_ new request - */ -Transactions.checkTransaction = function(ua, request) { - var tr; - - switch(request.method) { - case JsSIP.C.INVITE: - tr = ua.transactions.ist[request.via_branch]; - if(tr) { - switch(tr.state) { - case C.STATUS_PROCEEDING: - tr.transport.send(tr.last_response); - break; - - // RFC 6026 7.1 Invite retransmission - //received while in C.STATUS_ACCEPTED state. Absorb it. - case C.STATUS_ACCEPTED: - break; - } - return true; - } - break; - case JsSIP.C.ACK: - tr = ua.transactions.ist[request.via_branch]; - - // RFC 6026 7.1 - if(tr) { - if(tr.state === C.STATUS_ACCEPTED) { - return false; - } else if(tr.state === C.STATUS_COMPLETED) { - tr.state = C.STATUS_CONFIRMED; - tr.I = window.setTimeout(function() {tr.timer_I();}, JsSIP.Timers.TIMER_I); - return true; - } - } - - // ACK to 2XX Response. - else { - return false; - } - break; - case JsSIP.C.CANCEL: - tr = ua.transactions.ist[request.via_branch]; - if(tr) { - request.reply_sl(200); - if(tr.state === C.STATUS_PROCEEDING) { - return false; - } else { - return true; - } - } else { - request.reply_sl(481); - return true; - } - break; - default: - - // Non-INVITE Server Transaction RFC 3261 17.2.2 - tr = ua.transactions.nist[request.via_branch]; - if(tr) { - switch(tr.state) { - case C.STATUS_TRYING: - break; - case C.STATUS_PROCEEDING: - case C.STATUS_COMPLETED: - tr.transport.send(tr.last_response); - break; - } - return true; - } - break; - } -}; - -Transactions.C = C; -JsSIP.Transactions = Transactions; -}(JsSIP)); - - - -/** - * @fileoverview SIP Dialog - */ - -/** - * @augments JsSIP - * @class Class creating a SIP dialog. - * @param {JsSIP.Session} session - * @param {JsSIP.IncomingRequest|JsSIP.IncomingResponse} message - * @param {Enum} type UAC / UAS - * @param {Enum} state JsSIP.Dialog.C.STATUS_EARLY / JsSIP.Dialog.C.STATUS_CONFIRMED - */ -(function(JsSIP) { -var Dialog, - LOG_PREFIX = JsSIP.name +' | '+ 'DIALOG' +' | ', - C = { - // Dialog states - STATUS_EARLY: 1, - STATUS_CONFIRMED: 2 - }; - -// RFC 3261 12.1 -Dialog = function(session, message, type, state) { - var contact; - - if(!message.hasHeader('contact')) { - console.error(LOG_PREFIX +'unable to create a Dialog without Contact header field'); - return false; - } - - if(message instanceof JsSIP.IncomingResponse) { - state = (message.status_code < 200) ? C.STATUS_EARLY : C.STATUS_CONFIRMED; - } else { - // Create confirmed dialog if state is not defined - state = state || C.STATUS_CONFIRMED; - } - - contact = message.parseHeader('contact'); - - // RFC 3261 12.1.1 - if(type === 'UAS') { - this.id = { - call_id: message.call_id, - local_tag: message.to_tag, - remote_tag: message.from_tag, - toString: function() { - return this.call_id + this.local_tag + this.remote_tag; - } - }; - this.state = state; - this.remote_seqnum = message.cseq; - this.local_uri = message.parseHeader('to').uri; - this.remote_uri = message.parseHeader('from').uri; - this.remote_target = contact.uri; - this.route_set = message.getHeaderAll('record-route'); - } - // RFC 3261 12.1.2 - else if(type === 'UAC') { - this.id = { - call_id: message.call_id, - local_tag: message.from_tag, - remote_tag: message.to_tag, - toString: function() { - return this.call_id + this.local_tag + this.remote_tag; - } - }; - this.state = state; - this.local_seqnum = message.cseq; - this.local_uri = message.parseHeader('from').uri; - this.remote_uri = message.parseHeader('to').uri; - this.remote_target = contact.uri; - this.route_set = message.getHeaderAll('record-route').reverse(); - } - - this.session = session; - session.ua.dialogs[this.id.toString()] = this; - console.log(LOG_PREFIX +'new ' + type + ' dialog created with status ' + (this.state === C.STATUS_EARLY ? 'EARLY': 'CONFIRMED')); -}; - -Dialog.prototype = { - /** - * @param {JsSIP.IncomingMessage} message - * @param {Enum} UAC/UAS - */ - update: function(message, type) { - this.state = C.STATUS_CONFIRMED; - - console.log(LOG_PREFIX +'dialog '+ this.id.toString() +' changed to CONFIRMED state'); - - if(type === 'UAC') { - // RFC 3261 13.2.2.4 - this.route_set = message.getHeaderAll('record-route').reverse(); - } - }, - - terminate: function() { - console.log(LOG_PREFIX +'dialog ' + this.id.toString() + ' deleted'); - delete this.session.ua.dialogs[this.id.toString()]; - }, - - /** - * @param {String} method request method - * @param {Object} extraHeaders extra headers - * @returns {JsSIP.OutgoingRequest} - */ - - // RFC 3261 12.2.1.1 - createRequest: function(method, extraHeaders) { - var cseq, request; - extraHeaders = extraHeaders || []; - - if(!this.local_seqnum) { this.local_seqnum = Math.floor(Math.random() * 10000); } - - cseq = (method === JsSIP.C.CANCEL || method === JsSIP.C.ACK) ? this.local_seqnum : this.local_seqnum += 1; - - request = new JsSIP.OutgoingRequest( - method, - this.remote_target, - this.session.ua, { - 'cseq': cseq, - 'call_id': this.id.call_id, - 'from_uri': this.local_uri, - 'from_tag': this.id.local_tag, - 'to_uri': this.remote_uri, - 'to_tag': this.id.remote_tag, - 'route_set': this.route_set - }, extraHeaders); - - request.dialog = this; - - return request; - }, - - /** - * @param {JsSIP.IncomingRequest} request - * @returns {Boolean} - */ - - // RFC 3261 12.2.2 - checkInDialogRequest: function(request) { - if(!this.remote_seqnum) { - this.remote_seqnum = request.cseq; - } else if(request.method !== JsSIP.C.INVITE && request.cseq < this.remote_seqnum) { - //Do not try to reply to an ACK request. - if (request.method !== JsSIP.C.ACK) { - request.reply(500); - } - return false; - } else if(request.cseq > this.remote_seqnum) { - this.remote_seqnum = request.cseq; - } - - switch(request.method) { - // RFC3261 14.2 Modifying an Existing Session -UAS BEHAVIOR- - case JsSIP.C.INVITE: - if(request.cseq < this.remote_seqnum) { - if(this.state === C.STATUS_EARLY) { - var retryAfter = (Math.random() * 10 | 0) + 1; - request.reply(500, null, ['Retry-After:'+ retryAfter]); - } else { - request.reply(500); - } - return false; - } - // RFC3261 14.2 - if(this.state === C.STATUS_EARLY) { - request.reply(491); - return false; - } - // RFC3261 12.2.2 Replace the dialog`s remote target URI - if(request.hasHeader('contact')) { - this.remote_target = request.parseHeader('contact').uri; - } - break; - case JsSIP.C.NOTIFY: - // RFC6655 3.2 Replace the dialog`s remote target URI - if(request.hasHeader('contact')) { - this.remote_target = request.parseHeader('contact').uri; - } - break; - } - - return true; - }, - - /** - * @param {JsSIP.IncomingRequest} request - */ - receiveRequest: function(request) { - //Check in-dialog request - if(!this.checkInDialogRequest(request)) { - return; - } - - this.session.receiveRequest(request); - } -}; - -Dialog.C = C; -JsSIP.Dialog = Dialog; -}(JsSIP)); - - - - -/** - * @fileoverview Request Sender - */ - -/** - * @augments JsSIP - * @class Class creating a request sender. - * @param {Object} applicant - * @param {JsSIP.UA} ua - */ -(function(JsSIP) { -var RequestSender, - LOG_PREFIX = JsSIP.name +' | '+ 'REQUEST SENDER' +' | '; - -RequestSender = function(applicant, ua) { - this.ua = ua; - this.applicant = applicant; - this.method = applicant.request.method; - this.request = applicant.request; - this.credentials = null; - this.challenged = false; - this.staled = false; - - // If ua is in closing process or even closed just allow sending Bye and ACK - if (ua.status === JsSIP.UA.C.STATUS_USER_CLOSED && (this.method !== JsSIP.C.BYE || this.method !== JsSIP.C.ACK)) { - this.onTransportError(); - } -}; - -/** -* Create the client transaction and send the message. -*/ -RequestSender.prototype = { - send: function() { - switch(this.method) { - case "INVITE": - this.clientTransaction = new JsSIP.Transactions.InviteClientTransaction(this, this.request, this.ua.transport); - break; - case "ACK": - this.clientTransaction = new JsSIP.Transactions.AckClientTransaction(this, this.request, this.ua.transport); - break; - default: - this.clientTransaction = new JsSIP.Transactions.NonInviteClientTransaction(this, this.request, this.ua.transport); - } - this.clientTransaction.send(); - }, - - /** - * Callback fired when receiving a request timeout error from the client transaction. - * To be re-defined by the applicant. - * @event - */ - onRequestTimeout: function() { - this.applicant.onRequestTimeout(); - }, - - /** - * Callback fired when receiving a transport error from the client transaction. - * To be re-defined by the applicant. - * @event - */ - onTransportError: function() { - this.applicant.onTransportError(); - }, - - /** - * Called from client transaction when receiving a correct response to the request. - * Authenticate request if needed or pass the response back to the applicant. - * @param {JsSIP.IncomingResponse} response - */ - receiveResponse: function(response) { - var cseq, challenge, authorization_header_name, - status_code = response.status_code; - - /* - * Authentication - * Authenticate once. _challenged_ flag used to avoid infinite authentications. - */ - if ((status_code === 401 || status_code === 407) && this.ua.configuration.password !== null) { - - // Get and parse the appropriate WWW-Authenticate or Proxy-Authenticate header. - if (response.status_code === 401) { - challenge = response.parseHeader('www-authenticate'); - authorization_header_name = 'authorization'; - } else { - challenge = response.parseHeader('proxy-authenticate'); - authorization_header_name = 'proxy-authorization'; - } - - // Verify it seems a valid challenge. - if (! challenge) { - console.warn(LOG_PREFIX + response.status_code + ' with wrong or missing challenge, cannot authenticate'); - this.applicant.receiveResponse(response); - return; - } - - if (!this.challenged || (!this.staled && challenge.stale === true)) { - if (!this.credentials) { - this.credentials = new JsSIP.DigestAuthentication(this.ua); - } - - // Verify that the challenge is really valid. - if (!this.credentials.authenticate(this.request, challenge)) { - this.applicant.receiveResponse(response); - return; - } - this.challenged = true; - - if (challenge.stale) { - this.staled = true; - } - - if (response.method === JsSIP.C.REGISTER) { - cseq = this.applicant.cseq += 1; - } else if (this.request.dialog){ - cseq = this.request.dialog.local_seqnum += 1; - } else { - cseq = this.request.cseq + 1; - this.request.cseq = cseq; - } - this.request.setHeader('cseq', cseq +' '+ this.method); - - this.request.setHeader(authorization_header_name, this.credentials.toString()); - this.send(); - } else { - this.applicant.receiveResponse(response); - } - } else { - this.applicant.receiveResponse(response); - } - } -}; - -JsSIP.RequestSender = RequestSender; -}(JsSIP)); - - - -/** - * @fileoverview In-Dialog Request Sender - */ - -/** - * @augments JsSIP - * @class Class creating an In-dialog request sender. - * @param {Object} applicant - */ -/** - * @fileoverview in-Dialog Request Sender - */ - -(function(JsSIP) { -var InDialogRequestSender; - -InDialogRequestSender = function(applicant) { - this.applicant = applicant; - this.request = applicant.request; -}; - -InDialogRequestSender.prototype = { - send: function() { - var request_sender = new JsSIP.RequestSender(this, this.applicant.session.ua); - request_sender.send(); - }, - - onRequestTimeout: function() { - this.applicant.session.onRequestTimeout(); - this.applicant.onRequestTimeout(); - }, - - onTransportError: function() { - this.applicant.session.onTransportError(); - this.applicant.onTransportError(); - }, - - receiveResponse: function(response) { - // RFC3261 14.1. Terminate the dialog if a 408 or 481 is received from a re-Invite. - if (response.status_code === 408 || response.status_code === 481) { - this.applicant.session.ended('remote', response, JsSIP.C.causes.DIALOG_ERROR); - } - this.applicant.receiveResponse(response); - } -}; - -JsSIP.InDialogRequestSender = InDialogRequestSender; -}(JsSIP)); - - - -/** - * @fileoverview Registrator Agent - */ - -/** - * @augments JsSIP - * @class Class creating a registrator agent. - * @param {JsSIP.UA} ua - * @param {JsSIP.Transport} transport - */ -(function(JsSIP) { -var Registrator, - LOG_PREFIX = JsSIP.name +' | '+ 'REGISTRATOR' +' | '; - -Registrator = function(ua, transport) { - var reg_id=1; //Force reg_id to 1. - - this.ua = ua; - this.transport = transport; - - this.registrar = ua.configuration.registrar_server; - this.expires = ua.configuration.register_expires; - - // Call-ID and CSeq values RFC3261 10.2 - this.call_id = JsSIP.Utils.createRandomToken(22); - this.cseq = 80; - - // this.to_uri - this.to_uri = ua.configuration.uri; - - this.registrationTimer = null; - - // Set status - this.registered = this.registered_before = false; - - // Save into ua instance - this.ua.registrator = this; - - // Contact header - this.contact = this.ua.contact.toString(); - - if(reg_id) { - this.contact += ';reg-id='+ reg_id; - this.contact += ';+sip.instance=""'; - } -}; - -Registrator.prototype = { - /** - * @param {Object} [options] - */ - register: function(options) { - var request_sender, cause, extraHeaders, - self = this; - - options = options || {}; - extraHeaders = options.extraHeaders || []; - extraHeaders.push('Contact: '+ this.contact + ';expires=' + this.expires); - extraHeaders.push('Allow: '+ JsSIP.Utils.getAllowedMethods(this.ua)); - - this.request = new JsSIP.OutgoingRequest(JsSIP.C.REGISTER, this.registrar, this.ua, { - 'to_uri': this.to_uri, - 'call_id': this.call_id, - 'cseq': (this.cseq += 1) - }, extraHeaders); - - request_sender = new JsSIP.RequestSender(this, this.ua); - - /** - * @private - */ - this.receiveResponse = function(response) { - var contact, expires, - contacts = response.countHeader('contact'); - - // Discard responses to older REGISTER/un-REGISTER requests. - if(response.cseq !== this.cseq) { - return; - } - - // Clear registration timer - if (this.registrationTimer !== null) { - window.clearTimeout(this.registrationTimer); - this.registrationTimer = null; - } - - switch(true) { - case /^1[0-9]{2}$/.test(response.status_code): - // Ignore provisional responses. - break; - case /^2[0-9]{2}$/.test(response.status_code): - if(response.hasHeader('expires')) { - expires = response.getHeader('expires'); - } - - // Search the Contact pointing to us and update the expires value accordingly. - if (!contacts) { - console.warn(LOG_PREFIX +'no Contact header in response to REGISTER, response ignored'); - break; - } - - while(contacts--) { - contact = response.parseHeader('contact', contacts); - if(contact.uri.user === this.ua.contact.uri.user) { - expires = contact.getParam('expires'); - break; - } else { - contact = null; - } - } - - if (!contact) { - console.warn(LOG_PREFIX +'no Contact header pointing to us, response ignored'); - break; - } - - if(!expires) { - expires = this.expires; - } - - // Re-Register before the expiration interval has elapsed. - // For that, decrease the expires value. ie: 3 seconds - this.registrationTimer = window.setTimeout(function() { - self.registrationTimer = null; - self.register(); - }, (expires * 1000) - 3000); - - //Save gruu values - if (contact.hasParam('temp-gruu')) { - this.ua.contact.temp_gruu = contact.getParam('temp-gruu').replace(/"/g,''); - } - if (contact.hasParam('pub-gruu')) { - this.ua.contact.pub_gruu = contact.getParam('pub-gruu').replace(/"/g,''); - } - - this.registered = true; - this.ua.emit('registered', this.ua, { - response: response - }); - break; - // Interval too brief RFC3261 10.2.8 - case /^423$/.test(response.status_code): - if(response.hasHeader('min-expires')) { - // Increase our registration interval to the suggested minimum - this.expires = response.getHeader('min-expires'); - // Attempt the registration again immediately - this.register(); - } else { //This response MUST contain a Min-Expires header field - console.warn(LOG_PREFIX +'423 response received for REGISTER without Min-Expires'); - this.registrationFailure(response, JsSIP.C.causes.SIP_FAILURE_CODE); - } - break; - default: - cause = JsSIP.Utils.sipErrorCause(response.status_code); - this.registrationFailure(response, cause); - } - }; - - /** - * @private - */ - this.onRequestTimeout = function() { - this.registrationFailure(null, JsSIP.C.causes.REQUEST_TIMEOUT); - }; - - /** - * @private - */ - this.onTransportError = function() { - this.registrationFailure(null, JsSIP.C.causes.CONNECTION_ERROR); - }; - - request_sender.send(); - }, - - /** - * @param {Object} [options] - */ - unregister: function(options) { - var extraHeaders; - - if(!this.registered) { - console.warn(LOG_PREFIX +'already unregistered'); - return; - } - - options = options || {}; - extraHeaders = options.extraHeaders || []; - - this.registered = false; - - // Clear the registration timer. - if (this.registrationTimer !== null) { - window.clearTimeout(this.registrationTimer); - this.registrationTimer = null; - } - - if(options.all) { - extraHeaders.push('Contact: *'); - extraHeaders.push('Expires: 0'); - - this.request = new JsSIP.OutgoingRequest(JsSIP.C.REGISTER, this.registrar, this.ua, { - 'to_uri': this.to_uri, - 'call_id': this.call_id, - 'cseq': (this.cseq += 1) - }, extraHeaders); - } else { - extraHeaders.push('Contact: '+ this.contact + ';expires=0'); - - this.request = new JsSIP.OutgoingRequest(JsSIP.C.REGISTER, this.registrar, this.ua, { - 'to_uri': this.to_uri, - 'call_id': this.call_id, - 'cseq': (this.cseq += 1) - }, extraHeaders); - } - - var request_sender = new JsSIP.RequestSender(this, this.ua); - - /** - * @private - */ - this.receiveResponse = function(response) { - var cause; - - switch(true) { - case /^1[0-9]{2}$/.test(response.status_code): - // Ignore provisional responses. - break; - case /^2[0-9]{2}$/.test(response.status_code): - this.unregistered(response); - break; - default: - cause = JsSIP.Utils.sipErrorCause(response.status_code); - this.unregistered(response, cause); - } - }; - - /** - * @private - */ - this.onRequestTimeout = function() { - this.unregistered(null, JsSIP.C.causes.REQUEST_TIMEOUT); - }; - - /** - * @private - */ - this.onTransportError = function() { - this.unregistered(null, JsSIP.C.causes.CONNECTION_ERROR); - }; - - request_sender.send(); - }, - - /** - * @private - */ - registrationFailure: function(response, cause) { - this.ua.emit('registrationFailed', this.ua, { - response: response || null, - cause: cause - }); - - if (this.registered) { - this.registered = false; - this.ua.emit('unregistered', this.ua, { - response: response || null, - cause: cause - }); - } - }, - - /** - * @private - */ - unregistered: function(response, cause) { - this.registered = false; - this.ua.emit('unregistered', this.ua, { - response: response || null, - cause: cause || null - }); - }, - - /** - * @private - */ - onTransportClosed: function() { - this.registered_before = this.registered; - if (this.registrationTimer !== null) { - window.clearTimeout(this.registrationTimer); - this.registrationTimer = null; - } - - if(this.registered) { - this.registered = false; - this.ua.emit('unregistered', this.ua); - } - }, - - /** - * @private - */ - onTransportConnected: function() { - this.register(); - }, - - /** - * @private - */ - close: function() { - this.registered_before = this.registered; - this.unregister(); - } -}; - -JsSIP.Registrator = Registrator; -}(JsSIP)); - - -/** - * @fileoverview Session - */ - -/** - * @augments JsSIP - * @class Invite Session - */ -(function(JsSIP) { - -// Load dependencies -var RequestSender = /** - * @fileoverview RequestSender - */ - -/** - * @class Session RequestSender - * @param {JsSIP.RTCSession | RTCSession applicant} applicant - * @param {JsSIP.OutgoingRequest} [request] - */ -(function(JsSIP){ - -var RequestSender = function(applicant, request) { - this.applicant = applicant; - this.request = request || applicant.request; - this.session = (applicant instanceof JsSIP.RTCSession)? applicant : applicant.session; - this.reattempt = false; - this.reatemptTimer = null; - this.request_sender = new JsSIP.InDialogRequestSender(this); -}; - -RequestSender.prototype = { - receiveResponse: function(response) { - var - self = this, - status_code = response.status_code; - - if (response.method === JsSIP.C.INVITE && status_code === 491) { - if (!this.reattempt) { - this.request.cseq.value = this.request.dialog.local_seqnum += 1; - this.reatemptTimer = window.setTimeout( - function() { - if (self.session.status !== JsSIP.RTCSession.C.STATUS_TERMINATED) { - self.reattempt = true; - self.request_sender.send(); - } - }, - this.getReattemptTimeout() - ); - } else { - this.applicant.receiveResponse(response); - } - } else { - this.applicant.receiveResponse(response); - } - }, - - send: function() { - this.request_sender.send(); - }, - - onRequestTimeout: function() { - this.applicant.onRequestTimeout(); - }, - - onTransportError: function() { - this.applicant.onTransportError(); - }, - - // RFC3261 14.1 - getReattemptTimeout: function() { - if(this.session.direction === 'outgoing') { - return (Math.random() * (4 - 2.1) + 2.1).toFixed(2); - } else { - return (Math.random() * 2).toFixed(2); - } - } -}; - -return RequestSender; -}(JsSIP)); - -var RTCMediaHandler = /** - * @fileoverview RTCMediaHandler - */ - -/* RTCMediaHandler - * @class PeerConnection helper Class. - * @param {JsSIP.RTCSession} session - * @param {Object} [contraints] - */ -(function(JsSIP){ - -var RTCMediaHandler = function(session, constraints) { - constraints = constraints || {}; - - this.session = session; - this.localMedia = null; - this.peerConnection = null; - - this.init(constraints); -}; - -RTCMediaHandler.prototype = { - - createOffer: function(onSuccess, onFailure) { - var - self = this, - sent = false; - - this.onIceCompleted = function() { - if (!sent) { - sent = true; - onSuccess(self.peerConnection.localDescription.sdp); - } - }; - - this.peerConnection.createOffer( - function(sessionDescription){ - self.setLocalDescription( - sessionDescription, - onFailure - ); - }, - function(e) { - console.error(LOG_PREFIX +'unable to create offer'); - console.error(e); - onFailure(); - } - ); - }, - - createAnswer: function(onSuccess, onFailure) { - var - self = this, - sent = false; - - this.onIceCompleted = function() { - if (!sent) { - sent = true; - onSuccess(self.peerConnection.localDescription.sdp); - } - }; - - this.peerConnection.createAnswer( - function(sessionDescription){ - self.setLocalDescription( - sessionDescription, - onFailure - ); - }, - function(e) { - console.error(LOG_PREFIX +'unable to create answer'); - console.error(e); - onFailure(); - } - ); - }, - - setLocalDescription: function(sessionDescription, onFailure) { - this.peerConnection.setLocalDescription( - sessionDescription, - function(){}, - function(e) { - console.error(LOG_PREFIX +'unable to set local description'); - console.error(e); - onFailure(); - } - ); - }, - - addStream: function(stream, onSuccess, onFailure, constraints) { - try { - this.peerConnection.addStream(stream, constraints); - } catch(e) { - console.error(LOG_PREFIX +'error adding stream'); - console.error(e); - onFailure(); - return; - } - - onSuccess(); - }, - - /** - * peerConnection creation. - * @param {Function} onSuccess Fired when there are no more ICE candidates - */ - init: function(constraints) { - var idx, length, server, - self = this, - servers = [], - config = this.session.ua.configuration; - - servers.push({'url': config.stun_servers}); - - length = config.turn_servers.length; - for (idx = 0; idx < length; idx++) { - server = config.turn_servers[idx]; - servers.push({ - 'url': server.urls, - 'username': server.username, - 'credential': server.password - }); - } - - this.peerConnection = new JsSIP.WebRTC.RTCPeerConnection({'iceServers': servers}, constraints); - - this.peerConnection.onaddstream = function(e) { - console.log(LOG_PREFIX +'stream added: '+ e.stream.id); - }; - - this.peerConnection.onremovestream = function(e) { - console.log(LOG_PREFIX +'stream removed: '+ e.stream.id); - }; - - this.peerConnection.onicecandidate = function(e) { - if (e.candidate) { - console.log(LOG_PREFIX +'ICE candidate received: '+ e.candidate.candidate); - } else if (self.onIceCompleted !== undefined) { - self.onIceCompleted(); - } - }; - - // To be deprecated as per https://code.google.com/p/webrtc/issues/detail?id=1393 - this.peerConnection.ongatheringchange = function(e) { - if (e.currentTarget.iceGatheringState === 'complete' && this.iceConnectionState !== 'closed') { - self.onIceCompleted(); - } - }; - - this.peerConnection.onicechange = function() { - console.log(LOG_PREFIX +'ICE connection state changed to "'+ this.iceConnectionState +'"'); - }; - - this.peerConnection.onstatechange = function() { - console.log(LOG_PREFIX +'PeerConnection state changed to "'+ this.readyState +'"'); - }; - }, - - close: function() { - console.log(LOG_PREFIX + 'closing PeerConnection'); - if(this.peerConnection) { - this.peerConnection.close(); - - if(this.localMedia) { - this.localMedia.stop(); - } - } - }, - - /** - * @param {Object} mediaConstraints - * @param {Function} onSuccess - * @param {Function} onFailure - */ - getUserMedia: function(onSuccess, onFailure, constraints) { - var self = this; - - console.log(LOG_PREFIX + 'requesting access to local media'); - - JsSIP.WebRTC.getUserMedia(constraints, - function(stream) { - console.log(LOG_PREFIX + 'got local media stream'); - self.localMedia = stream; - onSuccess(stream); - }, - function(e) { - console.error(LOG_PREFIX +'unable to get user media'); - console.error(e); - onFailure(); - } - ); - }, - - /** - * Message reception. - * @param {String} type - * @param {String} sdp - * @param {Function} onSuccess - * @param {Function} onFailure - */ - onMessage: function(type, body, onSuccess, onFailure) { - this.peerConnection.setRemoteDescription( - new JsSIP.WebRTC.RTCSessionDescription({type: type, sdp:body}), - onSuccess, - onFailure - ); - } -}; - -// Return since it will be assigned to a variable. -return RTCMediaHandler; -}(JsSIP)); - -var DTMF = /** - * @fileoverview DTMF - */ - -/** - * @class DTMF - * @param {JsSIP.RTCSession} session - */ -(function(JsSIP) { - -var DTMF, - C = { - MIN_DURATION: 70, - MAX_DURATION: 6000, - DEFAULT_DURATION: 100, - MIN_INTER_TONE_GAP: 50, - DEFAULT_INTER_TONE_GAP: 500 - }; - -DTMF = function(session) { - var events = [ - 'succeeded', - 'failed' - ]; - - this.session = session; - this.direction = null; - this.tone = null; - this.duration = null; - - this.initEvents(events); -}; -DTMF.prototype = new JsSIP.EventEmitter(); - - -DTMF.prototype.send = function(tone, options) { - var request_sender, event, eventHandlers, extraHeaders; - - if (tone === undefined) { - throw new TypeError('Not enough arguments'); - } - - this.direction = 'outgoing'; - - // Check RTCSession Status - if (this.session.status !== JsSIP.RTCSession.C.STATUS_CONFIRMED && this.session.status !== JsSIP.RTCSession.C.STATUS_WAITING_FOR_ACK) { - throw new JsSIP.Exceptions.InvalidStateError(this.session.status); - } - - // Get DTMF options - options = options || {}; - extraHeaders = options.extraHeaders ? options.extraHeaders.slice() : []; - eventHandlers = options.eventHandlers || {}; - - // Check tone type - if (typeof tone === 'string' ) { - tone = tone.toUpperCase(); - } else if (typeof tone === 'number') { - tone = tone.toString(); - } else { - throw new TypeError('Invalid tone: '+ tone); - } - - // Check tone value - if (!tone.match(/^[0-9A-D#*]$/)) { - throw new TypeError('Invalid tone: '+ tone); - } else { - this.tone = tone; - } - - // Duration is checked/corrected in RTCSession - this.duration = options.duration; - - // Set event handlers - for (event in eventHandlers) { - this.on(event, eventHandlers[event]); - } - - extraHeaders.push('Content-Type: application/dtmf-relay'); - - this.request = this.session.dialog.createRequest(JsSIP.C.INFO, extraHeaders); - - this.request.body = "Signal= " + this.tone + "\r\n"; - this.request.body += "Duration= " + this.duration; - - request_sender = new RequestSender(this); - - this.session.emit('newDTMF', this.session, { - originator: 'local', - dtmf: this, - request: this.request - }); - - request_sender.send(); -}; - -/** - * @private - */ -DTMF.prototype.receiveResponse = function(response) { - var cause; - - switch(true) { - case /^1[0-9]{2}$/.test(response.status_code): - // Ignore provisional responses. - break; - - case /^2[0-9]{2}$/.test(response.status_code): - this.emit('succeeded', this, { - originator: 'remote', - response: response - }); - break; - - default: - cause = JsSIP.Utils.sipErrorCause(response.status_code); - this.emit('failed', this, { - originator: 'remote', - response: response, - cause: cause - }); - break; - } -}; - -/** - * @private - */ -DTMF.prototype.onRequestTimeout = function() { - this.emit('failed', this, { - originator: 'system', - cause: JsSIP.C.causes.REQUEST_TIMEOUT - }); -}; - -/** - * @private - */ -DTMF.prototype.onTransportError = function() { - this.emit('failed', this, { - originator: 'system', - cause: JsSIP.C.causes.CONNECTION_ERROR - }); -}; - -/** - * @private - */ -DTMF.prototype.init_incoming = function(request) { - var body, - reg_tone = /^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/, - reg_duration = /^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/; - - this.direction = 'incoming'; - this.request = request; - - request.reply(200); - - if (request.body) { - body = request.body.split('\r\n'); - if (body.length === 2) { - if (reg_tone.test(body[0])) { - this.tone = body[0].replace(reg_tone,"$2"); - } - if (reg_duration.test(body[1])) { - this.duration = parseInt(body[1].replace(reg_duration,"$2"), 10); - } - } - } - - if (!this.tone || !this.duration) { - console.warn(LOG_PREFIX +'invalid INFO DTMF received, discarded'); - } else { - this.session.emit('newDTMF', this.session, { - originator: 'remote', - dtmf: this, - request: request - }); - } -}; - -DTMF.C = C; -return DTMF; -}(JsSIP)); - - -var RTCSession, - LOG_PREFIX = JsSIP.name +' | '+ 'RTC SESSION' +' | ', - C = { - // RTCSession states - STATUS_NULL: 0, - STATUS_INVITE_SENT: 1, - STATUS_1XX_RECEIVED: 2, - STATUS_INVITE_RECEIVED: 3, - STATUS_WAITING_FOR_ANSWER: 4, - STATUS_ANSWERED: 5, - STATUS_WAITING_FOR_ACK: 6, - STATUS_CANCELED: 7, - STATUS_TERMINATED: 8, - STATUS_CONFIRMED: 9 - }; - - -RTCSession = function(ua) { - var events = [ - 'progress', - 'failed', - 'started', - 'ended', - 'newDTMF' - ]; - - this.ua = ua; - this.status = C.STATUS_NULL; - this.dialog = null; - this.earlyDialogs = {}; - this.rtcMediaHandler = null; - - // Session Timers - this.timers = { - ackTimer: null, - expiresTimer: null, - invite2xxTimer: null, - userNoAnswerTimer: null - }; - - // Session info - this.direction = null; - this.local_identity = null; - this.remote_identity = null; - this.start_time = null; - this.end_time = null; - this.tones = null; - - // Custom session empty object for high level use - this.data = {}; - - this.initEvents(events); -}; -RTCSession.prototype = new JsSIP.EventEmitter(); - - -/** - * User API - */ - -/** - * Terminate the call. - * @param {Object} [options] - */ -RTCSession.prototype.terminate = function(options) { - options = options || {}; - - var cancel_reason, - status_code = options.status_code, - reason_phrase = options.reason_phrase, - extraHeaders = options.extraHeaders || [], - body = options.body; - - // Check Session Status - if (this.status === C.STATUS_TERMINATED) { - throw new JsSIP.Exceptions.InvalidStateError(this.status); - } - - switch(this.status) { - // - UAC - - case C.STATUS_NULL: - case C.STATUS_INVITE_SENT: - case C.STATUS_1XX_RECEIVED: - console.log(LOG_PREFIX +'canceling RTCSession'); - - if (status_code && (status_code < 200 || status_code >= 700)) { - throw new TypeError('Invalid status_code: '+ status_code); - } else if (status_code) { - reason_phrase = reason_phrase || JsSIP.C.REASON_PHRASE[status_code] || ''; - cancel_reason = 'SIP ;cause=' + status_code + ' ;text="' + reason_phrase + '"'; - } - - // Check Session Status - if (this.status === C.STATUS_NULL) { - this.isCanceled = true; - this.cancelReason = cancel_reason; - } else if (this.status === C.STATUS_INVITE_SENT) { - if(this.received_100) { - this.request.cancel(cancel_reason); - } else { - this.isCanceled = true; - this.cancelReason = cancel_reason; - } - } else if(this.status === C.STATUS_1XX_RECEIVED) { - this.request.cancel(cancel_reason); - } - - this.failed('local', null, JsSIP.C.causes.CANCELED); - break; - - // - UAS - - case C.STATUS_WAITING_FOR_ANSWER: - case C.STATUS_ANSWERED: - console.log(LOG_PREFIX +'rejecting RTCSession'); - - status_code = status_code || 480; - - if (status_code < 300 || status_code >= 700) { - throw new TypeError('Invalid status_code: '+ status_code); - } - - this.request.reply(status_code, reason_phrase, extraHeaders, body); - this.failed('local', null, JsSIP.C.causes.REJECTED); - break; - case C.STATUS_WAITING_FOR_ACK: - case C.STATUS_CONFIRMED: - console.log(LOG_PREFIX +'terminating RTCSession'); - - // Send Bye - this.sendBye(options); - this.ended('local', null, JsSIP.C.causes.BYE); - break; - } - - this.close(); -}; - -/** - * Answer the call. - * @param {Object} [options] - */ -RTCSession.prototype.answer = function(options) { - options = options || {}; - - var - self = this, - request = this.request, - extraHeaders = options.extraHeaders || [], - mediaConstraints = options.mediaConstraints || {'audio':true, 'video':true}, - - // User media succeeded - userMediaSucceeded = function(stream) { - self.rtcMediaHandler.addStream( - stream, - streamAdditionSucceeded, - streamAdditionFailed - ); - }, - - // User media failed - userMediaFailed = function() { - request.reply(480); - self.failed('local', null, JsSIP.C.causes.USER_DENIED_MEDIA_ACCESS); - }, - - // rtcMediaHandler.addStream successfully added - streamAdditionSucceeded = function() { - self.rtcMediaHandler.createAnswer( - answerCreationSucceeded, - answerCreationFailed - ); - }, - - // rtcMediaHandler.addStream failed - streamAdditionFailed = function() { - if (self.status === C.STATUS_TERMINATED) { - return; - } - - self.failed('local', null, JsSIP.C.causes.WEBRTC_ERROR); - }, - - // rtcMediaHandler.createAnswer succeeded - answerCreationSucceeded = function(body) { - var - // run for reply success callback - replySucceeded = function() { - var timeout = JsSIP.Timers.T1; - - self.status = C.STATUS_WAITING_FOR_ACK; - - /** - * RFC3261 13.3.1.4 - * Response retransmissions cannot be accomplished by transaction layer - * since it is destroyed when receiving the first 2xx answer - */ - self.timers.invite2xxTimer = window.setTimeout(function invite2xxRetransmission() { - if (self.status !== C.STATUS_WAITING_FOR_ACK) { - return; - } - - request.reply(200, null, ['Contact: '+ self.contact], body); - - if (timeout < JsSIP.Timers.T2) { - timeout = timeout * 2; - if (timeout > JsSIP.Timers.T2) { - timeout = JsSIP.Timers.T2; - } - } - self.timers.invite2xxTimer = window.setTimeout( - invite2xxRetransmission, timeout - ); - }, - timeout - ); - - /** - * RFC3261 14.2 - * If a UAS generates a 2xx response and never receives an ACK, - * it SHOULD generate a BYE to terminate the dialog. - */ - self.timers.ackTimer = window.setTimeout(function() { - if(self.status === C.STATUS_WAITING_FOR_ACK) { - console.log(LOG_PREFIX + 'no ACK received, terminating the call'); - window.clearTimeout(self.timers.invite2xxTimer); - self.sendBye(); - self.ended('remote', null, JsSIP.C.causes.NO_ACK); - } - }, - JsSIP.Timers.TIMER_H - ); - - self.started('local'); - }, - - // run for reply failure callback - replyFailed = function() { - self.failed('system', null, JsSIP.C.causes.CONNECTION_ERROR); - }; - - extraHeaders.push('Contact: ' + self.contact); - - request.reply(200, null, extraHeaders, - body, - replySucceeded, - replyFailed - ); - }, - - // rtcMediaHandler.createAnsewr failed - answerCreationFailed = function() { - if (self.status === C.STATUS_TERMINATED) { - return; - } - - self.failed('local', null, JsSIP.C.causes.WEBRTC_ERROR); - }; - - - // Check Session Direction and Status - if (this.direction !== 'incoming') { - throw new TypeError('Invalid method "answer" for an outgoing call'); - } else if (this.status !== C.STATUS_WAITING_FOR_ANSWER) { - throw new JsSIP.Exceptions.InvalidStateError(this.status); - } - - this.status = C.STATUS_ANSWERED; - - // An error on dialog creation will fire 'failed' event - if(!this.createDialog(request, 'UAS')) { - request.reply(500, 'Missing Contact header field'); - return; - } - - window.clearTimeout(this.timers.userNoAnswerTimer); - - this.rtcMediaHandler.getUserMedia( - userMediaSucceeded, - userMediaFailed, - mediaConstraints - ); -}; - -/** - * Send a DTMF - * - * @param {String|Number} tones - * @param {Object} [options] - */ -RTCSession.prototype.sendDTMF = function(tones, options) { - var duration, interToneGap, - position = 0, - self = this; - - options = options || {}; - duration = options.duration || null; - interToneGap = options.interToneGap || null; - - if (tones === undefined) { - throw new TypeError('Not enough arguments'); - } - - // Check Session Status - if (this.status !== C.STATUS_CONFIRMED && this.status !== C.STATUS_WAITING_FOR_ACK) { - throw new JsSIP.Exceptions.InvalidStateError(this.status); - } - - // Check tones - if (!tones || (typeof tones !== 'string' && typeof tones !== 'number') || !tones.toString().match(/^[0-9A-D#*,]+$/i)) { - throw new TypeError('Invalid tones: '+ tones); - } - - tones = tones.toString(); - - // Check duration - if (duration && !JsSIP.Utils.isDecimal(duration)) { - throw new TypeError('Invalid tone duration: '+ duration); - } else if (!duration) { - duration = DTMF.C.DEFAULT_DURATION; - } else if (duration < DTMF.C.MIN_DURATION) { - console.warn(LOG_PREFIX +'"duration" value is lower than the minimum allowed, setting it to '+ DTMF.C.MIN_DURATION+ ' milliseconds'); - duration = DTMF.C.MIN_DURATION; - } else if (duration > DTMF.C.MAX_DURATION) { - console.warn(LOG_PREFIX +'"duration" value is greater than the maximum allowed, setting it to '+ DTMF.C.MAX_DURATION +' milliseconds'); - duration = DTMF.C.MAX_DURATION; - } else { - duration = Math.abs(duration); - } - options.duration = duration; - - // Check interToneGap - if (interToneGap && !JsSIP.Utils.isDecimal(interToneGap)) { - throw new TypeError('Invalid interToneGap: '+ interToneGap); - } else if (!interToneGap) { - interToneGap = DTMF.C.DEFAULT_INTER_TONE_GAP; - } else if (interToneGap < DTMF.C.MIN_INTER_TONE_GAP) { - console.warn(LOG_PREFIX +'"interToneGap" value is lower than the minimum allowed, setting it to '+ DTMF.C.MIN_INTER_TONE_GAP +' milliseconds'); - interToneGap = DTMF.C.MIN_INTER_TONE_GAP; - } else { - interToneGap = Math.abs(interToneGap); - } - - if (this.tones) { - // Tones are already queued, just add to the queue - this.tones += tones; - return; - } - - // New set of tones to start sending - this.tones = tones; - - var sendDTMF = function () { - var tone, timeout, - tones = self.tones; - - if (self.status === C.STATUS_TERMINATED || !tones || position >= tones.length) { - // Stop sending DTMF - self.tones = null; - return; - } - - tone = tones[position]; - position += 1; - - if (tone === ',') { - timeout = 2000; - } else { - var dtmf = new DTMF(self); - dtmf.on('failed', function(){self.tones = null;}); - dtmf.send(tone, options); - timeout = duration + interToneGap; - } - - // Set timeout for the next tone - window.setTimeout(sendDTMF, timeout); - }; - - // Send the first tone - sendDTMF(); -}; - - -/** - * RTCPeerconnection handlers - */ -RTCSession.prototype.getLocalStreams = function() { - return this.rtcMediaHandler && - this.rtcMediaHandler.peerConnection && - this.rtcMediaHandler.peerConnection.getLocalStreams() || []; -}; - -RTCSession.prototype.getRemoteStreams = function() { - return this.rtcMediaHandler && - this.rtcMediaHandler.peerConnection && - this.rtcMediaHandler.peerConnection.getRemoteStreams() || []; -}; - - -/** - * Session Management - */ - -/** -* @private -*/ -RTCSession.prototype.init_incoming = function(request) { - var expires, - self = this, - contentType = request.getHeader('Content-Type'); - - // Check body and content type - if(!request.body || (contentType !== 'application/sdp')) { - request.reply(415); - return; - } - - // Session parameter initialization - this.status = C.STATUS_INVITE_RECEIVED; - this.from_tag = request.from_tag; - this.id = request.call_id + this.from_tag; - this.request = request; - this.contact = this.ua.contact.toString(); - - //Save the session into the ua sessions collection. - this.ua.sessions[this.id] = this; - - //Get the Expires header value if exists - if(request.hasHeader('expires')) { - expires = request.getHeader('expires') * 1000; - } - - /* Set the to_tag before - * replying a response code that will create a dialog. - */ - request.to_tag = JsSIP.Utils.newTag(); - - // An error on dialog creation will fire 'failed' event - if(!this.createDialog(request, 'UAS', true)) { - request.reply(500, 'Missing Contact header field'); - return; - } - - //Initialize Media Session - this.rtcMediaHandler = new RTCMediaHandler(this, - {"optional": [{'DtlsSrtpKeyAgreement': 'true'}]} - ); - this.rtcMediaHandler.onMessage( - 'offer', - request.body, - /* - * onSuccess - * SDP Offer is valid. Fire UA newRTCSession - */ - function() { - request.reply(180, null, ['Contact: ' + self.contact]); - self.status = C.STATUS_WAITING_FOR_ANSWER; - - // Set userNoAnswerTimer - self.timers.userNoAnswerTimer = window.setTimeout(function() { - request.reply(408); - self.failed('local',null, JsSIP.C.causes.NO_ANSWER); - }, self.ua.configuration.no_answer_timeout - ); - - /* Set expiresTimer - * RFC3261 13.3.1 - */ - if (expires) { - self.timers.expiresTimer = window.setTimeout(function() { - if(self.status === C.STATUS_WAITING_FOR_ANSWER) { - request.reply(487); - self.failed('system', null, JsSIP.C.causes.EXPIRES); - } - }, expires - ); - } - - self.newRTCSession('remote', request); - }, - /* - * onFailure - * Bad media description - */ - function(e) { - console.warn(LOG_PREFIX +'invalid SDP'); - console.warn(e); - request.reply(488); - } - ); -}; - -/** - * @private - */ -RTCSession.prototype.connect = function(target, options) { - options = options || {}; - - var event, requestParams, - invalidTarget = false, - eventHandlers = options.eventHandlers || {}, - extraHeaders = options.extraHeaders || [], - mediaConstraints = options.mediaConstraints || {audio: true, video: true}, - RTCConstraints = options.RTCConstraints || {}; - - if (target === undefined) { - throw new TypeError('Not enough arguments'); - } - - // Check Session Status - if (this.status !== C.STATUS_NULL) { - throw new JsSIP.Exceptions.InvalidStateError(this.status); - } - - // Set event handlers - for (event in eventHandlers) { - this.on(event, eventHandlers[event]); - } - - // Check target validity - try { - target = JsSIP.Utils.normalizeURI(target, this.ua.configuration.hostport_params); - } catch(e) { - target = JsSIP.URI.parse(JsSIP.C.INVALID_TARGET_URI); - invalidTarget = true; - } - - // Session parameter initialization - this.from_tag = JsSIP.Utils.newTag(); - this.rtcMediaHandler = new RTCMediaHandler(this, RTCConstraints); - - // Set anonymous property - this.anonymous = options.anonymous; - - // OutgoingSession specific parameters - this.isCanceled = false; - this.received_100 = false; - - requestParams = {from_tag: this.from_tag}; - - this.contact = this.ua.contact.toString({ - anonymous: this.anonymous, - outbound: true - }); - - if (this.anonymous) { - requestParams.from_display_name = 'Anonymous'; - requestParams.from_uri = 'sip:anonymous@anonymous.invalid'; - - extraHeaders.push('P-Preferred-Identity: '+ this.ua.configuration.uri.toString()); - extraHeaders.push('Privacy: id'); - } - - extraHeaders.push('Contact: '+ this.contact); - extraHeaders.push('Allow: '+ JsSIP.Utils.getAllowedMethods(this.ua)); - extraHeaders.push('Content-Type: application/sdp'); - - this.request = new JsSIP.OutgoingRequest(JsSIP.C.INVITE, target, this.ua, requestParams, extraHeaders); - - this.id = this.request.call_id + this.from_tag; - - //Save the session into the ua sessions collection. - this.ua.sessions[this.id] = this; - - this.newRTCSession('local', this.request); - - if (invalidTarget) { - this.failed('local', null, JsSIP.C.causes.INVALID_TARGET); - } else if (!JsSIP.WebRTC.isSupported) { - this.failed('local', null, JsSIP.C.causes.WEBRTC_NOT_SUPPORTED); - } else { - this.sendInitialRequest(mediaConstraints); - } -}; - -/** -* @private -*/ -RTCSession.prototype.close = function() { - var idx; - - if(this.status === C.STATUS_TERMINATED) { - return; - } - - console.log(LOG_PREFIX +'closing INVITE session ' + this.id); - - // 1st Step. Terminate media. - if (this.rtcMediaHandler){ - this.rtcMediaHandler.close(); - } - - // 2nd Step. Terminate signaling. - - // Clear session timers - for(idx in this.timers) { - window.clearTimeout(this.timers[idx]); - } - - // Terminate dialogs - - // Terminate confirmed dialog - if(this.dialog) { - this.dialog.terminate(); - delete this.dialog; - } - - // Terminate early dialogs - for(idx in this.earlyDialogs) { - this.earlyDialogs[idx].terminate(); - delete this.earlyDialogs[idx]; - } - - this.status = C.STATUS_TERMINATED; - - delete this.ua.sessions[this.id]; -}; - -/** - * Dialog Management - * @private - */ -RTCSession.prototype.createDialog = function(message, type, early) { - var dialog, early_dialog, - local_tag = (type === 'UAS') ? message.to_tag : message.from_tag, - remote_tag = (type === 'UAS') ? message.from_tag : message.to_tag, - id = message.call_id + local_tag + remote_tag; - - early_dialog = this.earlyDialogs[id]; - - // Early Dialog - if (early) { - if (early_dialog) { - return true; - } else { - early_dialog = new JsSIP.Dialog(this, message, type, JsSIP.Dialog.C.STATUS_EARLY); - - // Dialog has been successfully created. - if(early_dialog.id) { - this.earlyDialogs[id] = early_dialog; - return true; - } - // Dialog not created due to an error. - else { - this.failed('remote', message, JsSIP.C.causes.INTERNAL_ERROR); - return false; - } - } - } - - // Confirmed Dialog - else { - // In case the dialog is in _early_ state, update it - if (early_dialog) { - early_dialog.update(message, type); - this.dialog = early_dialog; - delete this.earlyDialogs[id]; - return true; - } - - // Otherwise, create a _confirmed_ dialog - dialog = new JsSIP.Dialog(this, message, type); - - if(dialog.id) { - this.to_tag = message.to_tag; - this.dialog = dialog; - return true; - } - // Dialog not created due to an error - else { - this.failed('remote', message, JsSIP.C.causes.INTERNAL_ERROR); - return false; - } - } -}; - - -/** - * In dialog Request Reception - * @private - */ -RTCSession.prototype.receiveRequest = function(request) { - var contentType; - - if(request.method === JsSIP.C.CANCEL) { - /* RFC3261 15 States that a UAS may have accepted an invitation while a CANCEL - * was in progress and that the UAC MAY continue with the session established by - * any 2xx response, or MAY terminate with BYE. JsSIP does continue with the - * established session. So the CANCEL is processed only if the session is not yet - * established. - */ - - /* - * Terminate the whole session in case the user didn't accept nor reject the - *request opening the session. - */ - if(this.status === C.STATUS_WAITING_FOR_ANSWER) { - this.status = C.STATUS_CANCELED; - this.request.reply(487); - this.failed('remote', request, JsSIP.C.causes.CANCELED); - } - } else { - // Requests arriving here are in-dialog requests. - switch(request.method) { - case JsSIP.C.ACK: - if(this.status === C.STATUS_WAITING_FOR_ACK) { - window.clearTimeout(this.timers.ackTimer); - window.clearTimeout(this.timers.invite2xxTimer); - this.status = C.STATUS_CONFIRMED; - } - break; - case JsSIP.C.BYE: - if(this.status === C.STATUS_CONFIRMED) { - request.reply(200); - this.ended('remote', request, JsSIP.C.causes.BYE); - } - break; - case JsSIP.C.INVITE: - if(this.status === C.STATUS_CONFIRMED) { - console.log(LOG_PREFIX +'re-INVITE received'); - } - break; - case JsSIP.C.INFO: - if(this.status === C.STATUS_CONFIRMED || this.status === C.STATUS_WAITING_FOR_ACK) { - contentType = request.getHeader('content-type'); - if (contentType && (contentType.match(/^application\/dtmf-relay/i))) { - new DTMF(this).init_incoming(request); - } - } - } - } -}; - - -/** - * Initial Request Sender - * @private - */ -RTCSession.prototype.sendInitialRequest = function(constraints) { - var - self = this, - request_sender = new JsSIP.RequestSender(self, this.ua), - - // User media succeeded - userMediaSucceeded = function(stream) { - self.rtcMediaHandler.addStream( - stream, - streamAdditionSucceeded, - streamAdditionFailed - ); - }, - - // User media failed - userMediaFailed = function() { - if (self.status === C.STATUS_TERMINATED) { - return; - } - - self.failed('local', null, JsSIP.C.causes.USER_DENIED_MEDIA_ACCESS); - }, - - // rtcMediaHandler.addStream successfully added - streamAdditionSucceeded = function() { - self.rtcMediaHandler.createOffer( - offerCreationSucceeded, - offerCreationFailed - ); - }, - - // rtcMediaHandler.addStream failed - streamAdditionFailed = function() { - if (self.status === C.STATUS_TERMINATED) { - return; - } - - self.failed('local', null, JsSIP.C.causes.WEBRTC_ERROR); - }, - - // rtcMediaHandler.createOffer succeeded - offerCreationSucceeded = function(offer) { - if (self.isCanceled || self.status === C.STATUS_TERMINATED) { - return; - } - - self.request.body = offer; - self.status = C.STATUS_INVITE_SENT; - request_sender.send(); - }, - - // rtcMediaHandler.createOffer failed - offerCreationFailed = function() { - if (self.status === C.STATUS_TERMINATED) { - return; - } - - self.failed('local', null, JsSIP.C.causes.WEBRTC_ERROR); - }; - - this.rtcMediaHandler.getUserMedia( - userMediaSucceeded, - userMediaFailed, - constraints - ); -}; - -/** - * Reception of Response for Initial Request - * @private - */ -RTCSession.prototype.receiveResponse = function(response) { - var cause, - session = this; - - if(this.status !== C.STATUS_INVITE_SENT && this.status !== C.STATUS_1XX_RECEIVED) { - return; - } - - // Proceed to cancellation if the user requested. - if(this.isCanceled) { - if(response.status_code >= 100 && response.status_code < 200) { - this.request.cancel(this.cancelReason); - } else if(response.status_code >= 200 && response.status_code < 299) { - this.acceptAndTerminate(response); - } - return; - } - - switch(true) { - case /^100$/.test(response.status_code): - this.received_100 = true; - break; - case /^1[0-9]{2}$/.test(response.status_code): - // Do nothing with 1xx responses without To tag. - if(!response.to_tag) { - console.warn(LOG_PREFIX +'1xx response received without to tag'); - break; - } - - // Create Early Dialog if 1XX comes with contact - if(response.hasHeader('contact')) { - // An error on dialog creation will fire 'failed' event - this.createDialog(response, 'UAC', true); - } - - this.status = C.STATUS_1XX_RECEIVED; - this.progress('remote', response); - break; - case /^2[0-9]{2}$/.test(response.status_code): - // Do nothing if this.dialog is already confirmed - if (this.dialog) { - break; - } - - if(!response.body) { - this.acceptAndTerminate(response, 400, 'Missing session description'); - this.failed('remote', response, JsSIP.C.causes.BAD_MEDIA_DESCRIPTION); - break; - } - - // An error on dialog creation will fire 'failed' event - if (!this.createDialog(response, 'UAC')) { - break; - } - - this.rtcMediaHandler.onMessage( - 'answer', - response.body, - /* - * onSuccess - * SDP Answer fits with Offer. Media will start - */ - function() { - session.status = C.STATUS_CONFIRMED; - session.sendACK(); - session.started('remote', response); - }, - /* - * onFailure - * SDP Answer does not fit the Offer. Accept the call and Terminate. - */ - function(e) { - console.warn(e); - session.acceptAndTerminate(response, 488, 'Not Acceptable Here'); - session.failed('remote', response, JsSIP.C.causes.BAD_MEDIA_DESCRIPTION); - } - ); - break; - default: - cause = JsSIP.Utils.sipErrorCause(response.status_code); - this.failed('remote', response, cause); - } -}; - - -/** -* @private -*/ -RTCSession.prototype.acceptAndTerminate = function(response, status_code, reason_phrase) { - // Send ACK and BYE - // An error on dialog creation will fire 'failed' event - if (this.dialog || this.createDialog(response, 'UAC')) { - this.sendACK(); - this.sendBye({ - status_code: status_code, - reason_phrase: reason_phrase - }); - } -}; - -/** -* @private -*/ -RTCSession.prototype.sendACK = function() { - var request = this.dialog.createRequest(JsSIP.C.ACK); - - this.sendRequest(request); -}; - -/** -* @private -*/ -RTCSession.prototype.sendBye = function(options) { - options = options || {}; - - var request, reason, - status_code = options.status_code, - reason_phrase = options.reason_phrase || JsSIP.C.REASON_PHRASE[status_code] || '', - extraHeaders = options.extraHeaders || [], - body = options.body; - - if (status_code && (status_code < 200 || status_code >= 700)) { - throw new TypeError('Invalid status_code: '+ status_code); - } else if (status_code) { - reason = 'SIP ;cause=' + status_code + '; text="' + reason_phrase + '"'; - extraHeaders.push('Reason: '+ reason); - } - - request = this.dialog.createRequest(JsSIP.C.BYE, extraHeaders); - request.body = body; - - this.sendRequest(request); -}; - -/** - * @private - */ -RTCSession.prototype.sendRequest = function(request) { - var request_sender = new RequestSender(this, request); - request_sender.send(); -}; - -/** - * Session Callbacks - */ - -/** -* Callback to be called from UA instance when TransportError occurs -* @private -*/ -RTCSession.prototype.onTransportError = function() { - if(this.status !== C.STATUS_TERMINATED) { - if (this.status === C.STATUS_CONFIRMED) { - this.ended('system', null, JsSIP.C.causes.CONNECTION_ERROR); - } else { - this.failed('system', null, JsSIP.C.causes.CONNECTION_ERROR); - } - } -}; - -/** -* Callback to be called from UA instance when RequestTimeout occurs -* @private -*/ -RTCSession.prototype.onRequestTimeout = function() { - if(this.status !== C.STATUS_TERMINATED) { - if (this.status === C.STATUS_CONFIRMED) { - this.ended('system', null, JsSIP.C.causes.REQUEST_TIMEOUT); - } else { - this.failed('system', null, JsSIP.C.causes.CONNECTION_ERROR); - } - } -}; - -/** - * Internal Callbacks - */ - -/** - * @private - */ -RTCSession.prototype.newRTCSession = function(originator, request) { - var session = this, - event_name = 'newRTCSession'; - - if (originator === 'remote') { - session.direction = 'incoming'; - session.local_identity = request.to; - session.remote_identity = request.from; - } else if (originator === 'local'){ - session.direction = 'outgoing'; - session.local_identity = request.from; - session.remote_identity = request.to; - } - - session.ua.emit(event_name, session.ua, { - originator: originator, - session: session, - request: request - }); -}; - -/** - * @private - */ -RTCSession.prototype.connecting = function(originator, request) { - var session = this, - event_name = 'connecting'; - - session.emit(event_name, session, { - originator: 'local', - request: request - }); -}; - -/** - * @private - */ -RTCSession.prototype.progress = function(originator, response) { - var session = this, - event_name = 'progress'; - - session.emit(event_name, session, { - originator: originator, - response: response || null - }); -}; - -/** - * @private - */ -RTCSession.prototype.started = function(originator, message) { - var session = this, - event_name = 'started'; - - session.start_time = new Date(); - - session.emit(event_name, session, { - originator: originator, - response: message || null - }); -}; - -/** - * @private - */ -RTCSession.prototype.ended = function(originator, message, cause) { - var session = this, - event_name = 'ended'; - - session.end_time = new Date(); - - session.close(); - session.emit(event_name, session, { - originator: originator, - message: message || null, - cause: cause - }); -}; - -/** - * @private - */ -RTCSession.prototype.failed = function(originator, message, cause) { - var session = this, - event_name = 'failed'; - - session.close(); - session.emit(event_name, session, { - originator: originator, - message: message || null, - cause: cause - }); -}; - - -RTCSession.C = C; -JsSIP.RTCSession = RTCSession; -}(JsSIP)); - - - -/** - * @fileoverview Message - */ - -/** - * @augments JsSIP - * @class Class creating SIP MESSAGE request. - * @param {JsSIP.UA} ua - */ -(function(JsSIP) { -var Message; - -Message = function(ua) { - this.ua = ua; - this.direction = null; - this.local_identity = null; - this.remote_identity = null; - - // Custom message empty object for high level use - this.data = {}; -}; -Message.prototype = new JsSIP.EventEmitter(); - - -Message.prototype.send = function(target, body, options) { - var request_sender, event, contentType, eventHandlers, extraHeaders, - events = [ - 'succeeded', - 'failed' - ], - invalidTarget = false; - - if (target === undefined || body === undefined) { - throw new TypeError('Not enough arguments'); - } - - this.initEvents(events); - - // Get call options - options = options || {}; - extraHeaders = options.extraHeaders || []; - eventHandlers = options.eventHandlers || {}; - contentType = options.contentType || 'text/plain'; - - // Set event handlers - for (event in eventHandlers) { - this.on(event, eventHandlers[event]); - } - - // Check target validity - try { - target = JsSIP.Utils.normalizeURI(target, this.ua.configuration.hostport_params); - } catch(e) { - target = JsSIP.URI.parse(JsSIP.C.INVALID_TARGET_URI); - invalidTarget = true; - } - - // Message parameter initialization - this.direction = 'outgoing'; - this.local_identity = this.ua.configuration.uri; - this.remote_identity = target; - - this.closed = false; - this.ua.applicants[this] = this; - - extraHeaders.push('Content-Type: '+ contentType); - - this.request = new JsSIP.OutgoingRequest(JsSIP.C.MESSAGE, target, this.ua, null, extraHeaders); - - if(body) { - this.request.body = body; - } - - request_sender = new JsSIP.RequestSender(this, this.ua); - - this.ua.emit('newMessage', this.ua, { - originator: 'local', - message: this, - request: this.request - }); - - if (invalidTarget) { - this.emit('failed', this, { - originator: 'local', - cause: JsSIP.C.causes.INVALID_TARGET - }); - } else { - request_sender.send(); - } -}; - -/** -* @private -*/ -Message.prototype.receiveResponse = function(response) { - var cause; - - if(this.closed) { - return; - } - switch(true) { - case /^1[0-9]{2}$/.test(response.status_code): - // Ignore provisional responses. - break; - - case /^2[0-9]{2}$/.test(response.status_code): - delete this.ua.applicants[this]; - this.emit('succeeded', this, { - originator: 'remote', - response: response - }); - break; - - default: - delete this.ua.applicants[this]; - cause = JsSIP.Utils.sipErrorCause(response.status_code); - this.emit('failed', this, { - originator: 'remote', - response: response, - cause: cause - }); - break; - } -}; - - -/** -* @private -*/ -Message.prototype.onRequestTimeout = function() { - if(this.closed) { - return; - } - this.emit('failed', this, { - originator: 'system', - cause: JsSIP.C.causes.REQUEST_TIMEOUT - }); -}; - -/** -* @private -*/ -Message.prototype.onTransportError = function() { - if(this.closed) { - return; - } - this.emit('failed', this, { - originator: 'system', - cause: JsSIP.C.causes.CONNECTION_ERROR - }); -}; - -/** -* @private -*/ -Message.prototype.close = function() { - this.closed = true; - delete this.ua.applicants[this]; -}; - -/** - * @private - */ -Message.prototype.init_incoming = function(request) { - var transaction, - contentType = request.getHeader('content-type'); - - this.direction = 'incoming'; - this.request = request; - this.local_identity = request.to.uri; - this.remote_identity = request.from.uri; - - if (contentType && (contentType.match(/^text\/plain(\s*;\s*.+)*$/i) || contentType.match(/^text\/html(\s*;\s*.+)*$/i))) { - this.ua.emit('newMessage', this.ua, { - originator: 'remote', - message: this, - request: request - }); - - transaction = this.ua.transactions.nist[request.via_branch]; - - if (transaction && (transaction.state === JsSIP.Transactions.C.STATUS_TRYING || transaction.state === JsSIP.Transactions.C.STATUS_PROCEEDING)) { - request.reply(200); - } - } else { - request.reply(415, null, ['Accept: text/plain, text/html']); - } -}; - -/** - * Accept the incoming Message - * Only valid for incoming Messages - */ -Message.prototype.accept = function(options) { - options = options || {}; - - var - extraHeaders = options.extraHeaders || [], - body = options.body; - - if (this.direction !== 'incoming') { - throw new TypeError('Invalid method "accept" for an outgoing message'); - } - - this.request.reply(200, null, extraHeaders, body); -}; - -/** - * Reject the incoming Message - * Only valid for incoming Messages - * - * @param {Number} status_code - * @param {String} [reason_phrase] - */ -Message.prototype.reject = function(options) { - options = options || {}; - - var - status_code = options.status_code || 480, - reason_phrase = options.reason_phrase, - extraHeaders = options.extraHeaders || [], - body = options.body; - - if (this.direction !== 'incoming') { - throw new TypeError('Invalid method "reject" for an outgoing message'); - } - - if (status_code < 300 || status_code >= 700) { - throw new TypeError('Invalid status_code: '+ status_code); - } - - this.request.reply(status_code, reason_phrase, extraHeaders, body); -}; - -JsSIP.Message = Message; -}(JsSIP)); - - - -/** - * @fileoverview SIP User Agent - */ - - -/** - * @augments JsSIP - * @class Class creating a SIP User Agent. - */ -(function(JsSIP) { -var UA, - LOG_PREFIX = JsSIP.name +' | '+ 'UA' +' | ', - C = { - // UA status codes - STATUS_INIT : 0, - STATUS_READY: 1, - STATUS_USER_CLOSED: 2, - STATUS_NOT_READY: 3, - - // UA error codes - CONFIGURATION_ERROR: 1, - NETWORK_ERROR: 2, - - /* UA events and corresponding SIP Methods. - * Dynamically added to 'Allow' header field if the - * corresponding event handler is set. - */ - EVENT_METHODS: { - 'newRTCSession': 'INVITE', - 'newMessage': 'MESSAGE' - }, - - ALLOWED_METHODS: [ - 'ACK', - 'CANCEL', - 'BYE', - 'OPTIONS' - ], - - ACCEPTED_BODY_TYPES: [ - 'application/sdp', - 'application/dtmf-relay' - ], - - SUPPORTED: 'path, outbound, gruu', - - MAX_FORWARDS: 69, - TAG_LENGTH: 10 - }; - -UA = function(configuration) { - var events = [ - 'connected', - 'disconnected', - 'registered', - 'unregistered', - 'registrationFailed', - 'newRTCSession', - 'newMessage' - ]; - - // Set Accepted Body Types - C.ACCEPTED_BODY_TYPES = C.ACCEPTED_BODY_TYPES.toString(); - - this.cache = { - credentials: {} - }; - - this.configuration = {}; - this.dialogs = {}; - - //User actions outside any session/dialog (MESSAGE) - this.applicants = {}; - - this.sessions = {}; - this.transport = null; - this.contact = null; - this.status = C.STATUS_INIT; - this.error = null; - this.transactions = { - nist: {}, - nict: {}, - ist: {}, - ict: {} - }; - - this.transportRecoverAttempts = 0; - this.transportRecoveryTimer = null; - - /** - * Load configuration - * - * @throws {JsSIP.Exceptions.ConfigurationError} - * @throws {TypeError} - */ - - if(configuration === undefined) { - throw new TypeError('Not enough arguments'); - } - - try { - this.loadConfig(configuration); - this.initEvents(events); - } catch(e) { - this.status = C.STATUS_NOT_READY; - this.error = C.CONFIGURATION_ERROR; - throw e; - } - - // Initialize registrator - this.registrator = new JsSIP.Registrator(this); -}; -UA.prototype = new JsSIP.EventEmitter(); - -//================= -// High Level API -//================= - -/** - * Register. - * - * - */ -UA.prototype.register = function(options) { - this.configuration.register = true; - this.registrator.register(options); -}; - -/** - * Unregister. - * - * @param {Boolean} [all] unregister all user bindings. - * - */ -UA.prototype.unregister = function(options) { - this.configuration.register = false; - this.registrator.unregister(options); -}; - -/** - * Registration state. - * @param {Boolean} - */ -UA.prototype.isRegistered = function() { - if(this.registrator.registered) { - return true; - } else { - return false; - } -}; - -/** - * Connection state. - * @param {Boolean} - */ -UA.prototype.isConnected = function() { - if(this.transport) { - return this.transport.connected; - } else { - return false; - } -}; - -/** - * Make an outgoing call. - * - * @param {String} target - * @param {Object} views - * @param {Object} [options] - * - * @throws {TypeError} - * - */ -UA.prototype.call = function(target, options) { - var session; - - session = new JsSIP.RTCSession(this); - session.connect(target, options); -}; - -/** - * Send a message. - * - * @param {String} target - * @param {String} body - * @param {Object} [options] - * - * @throws {TypeError} - * - */ -UA.prototype.sendMessage = function(target, body, options) { - var message; - - message = new JsSIP.Message(this); - message.send(target, body, options); -}; - -/** - * Gracefully close. - * - */ -UA.prototype.stop = function() { - var session, applicant, - ua = this; - - console.log(LOG_PREFIX +'user requested closure...'); - - if(this.status === C.STATUS_USER_CLOSED) { - console.warn('UA already closed'); - return; - } - - // Clear transportRecoveryTimer - window.clearTimeout(this.transportRecoveryTimer); - - // Close registrator - console.log(LOG_PREFIX +'closing registrator'); - this.registrator.close(); - - // Run _terminate_ on every Session - for(session in this.sessions) { - console.log(LOG_PREFIX +'closing session ' + session); - this.sessions[session].terminate(); - } - - // Run _close_ on every applicant - for(applicant in this.applicants) { - this.applicants[applicant].close(); - } - - this.status = C.STATUS_USER_CLOSED; - this.shutdownGraceTimer = window.setTimeout( - function() { ua.transport.disconnect(); }, - '5000' - ); -}; - -/** - * Connect to the WS server if status = STATUS_INIT. - * Resume UA after being closed. - * - */ -UA.prototype.start = function() { - var server; - - console.log(LOG_PREFIX +'user requested startup...'); - - if (this.status === C.STATUS_INIT) { - server = this.getNextWsServer(); - new JsSIP.Transport(this, server); - } else if(this.status === C.STATUS_USER_CLOSED) { - console.log(LOG_PREFIX +'resuming'); - this.status = C.STATUS_READY; - this.transport.connect(); - } else if (this.status === C.STATUS_READY) { - console.log(LOG_PREFIX +'UA is in READY status, not resuming'); - } else { - console.error('Connection is down. Auto-Recovery system is trying to connect'); - } -}; - - -//=============================== -// Private (For internal use) -//=============================== - -UA.prototype.saveCredentials = function(credentials) { - this.cache.credentials[credentials.realm] = this.cache.credentials[credentials.realm] || {}; - this.cache.credentials[credentials.realm][credentials.uri] = credentials; -}; - -UA.prototype.getCredentials = function(request) { - var realm, credentials; - - realm = request.ruri.host; - - if (this.cache.credentials[realm] && this.cache.credentials[realm][request.ruri]) { - credentials = this.cache.credentials[realm][request.ruri]; - credentials.method = request.method; - } - - return credentials; -}; - - -//========================== -// Event Handlers -//========================== - -/** - * Transport Close event. - * @private - * @event - * @param {JsSIP.Transport} transport. - */ -UA.prototype.onTransportClosed = function(transport) { - // Run _onTransportError_ callback on every client transaction using _transport_ - var type, idx, length, - client_transactions = ['nict', 'ict', 'nist', 'ist']; - - transport.server.status = JsSIP.Transport.C.STATUS_DISCONNECTED; - console.log(LOG_PREFIX +'connection state set to '+ JsSIP.Transport.C.STATUS_DISCONNECTED); - - length = client_transactions.length; - for (type = 0; type < length; type++) { - for(idx in this.transactions[client_transactions[type]]) { - this.transactions[client_transactions[type]][idx].onTransportError(); - } - } - - // Close sessions if GRUU is not being used - if (!this.contact.pub_gruu) { - this.closeSessionsOnTransportError(); - } - -}; - -/** - * Unrecoverable transport event. - * Connection reattempt logic has been done and didn't success. - * @private - * @event - * @param {JsSIP.Transport} transport. - */ -UA.prototype.onTransportError = function(transport) { - var server; - - console.log(LOG_PREFIX +'transport ' + transport.server.ws_uri + ' failed | connection state set to '+ JsSIP.Transport.C.STATUS_ERROR); - - // Close sessions. - //Mark this transport as 'down' and try the next one - transport.server.status = JsSIP.Transport.C.STATUS_ERROR; - - this.emit('disconnected', this, { - transport: transport, - code: transport.lastTransportError.code, - reason: transport.lastTransportError.reason - }); - - server = this.getNextWsServer(); - - if(server) { - new JsSIP.Transport(this, server); - }else { - this.closeSessionsOnTransportError(); - if (!this.error || this.error !== C.NETWORK_ERROR) { - this.status = C.STATUS_NOT_READY; - this.error = C.NETWORK_ERROR; - } - // Transport Recovery process - this.recoverTransport(); - } -}; - -/** - * Transport connection event. - * @private - * @event - * @param {JsSIP.Transport} transport. - */ -UA.prototype.onTransportConnected = function(transport) { - this.transport = transport; - - // Reset transport recovery counter - this.transportRecoverAttempts = 0; - - transport.server.status = JsSIP.Transport.C.STATUS_READY; - console.log(LOG_PREFIX +'connection state set to '+ JsSIP.Transport.C.STATUS_READY); - - if(this.status === C.STATUS_USER_CLOSED) { - return; - } - - this.status = C.STATUS_READY; - this.error = null; - this.emit('connected', this, { - transport: transport - }); - - if(this.configuration.register) { - this.registrator.onTransportConnected(); - } -}; - -//========================= -// receiveRequest -//========================= - -/** - * Request reception - * @private - * @param {JsSIP.IncomingRequest} request. - */ -UA.prototype.receiveRequest = function(request) { - var dialog, session, message, - method = request.method; - - // Check that Ruri points to us - if(request.ruri.user !== this.configuration.uri.user && request.ruri.user !== this.contact.uri.user) { - console.warn(LOG_PREFIX +'Request-URI does not point to us'); - if (request.method !== JsSIP.C.ACK) { - request.reply_sl(404); - } - return; - } - - // Check transaction - if(JsSIP.Transactions.checkTransaction(this, request)) { - return; - } - - // Create the server transaction - if(method === JsSIP.C.INVITE) { - new JsSIP.Transactions.InviteServerTransaction(request, this); - } else if(method !== JsSIP.C.ACK) { - new JsSIP.Transactions.NonInviteServerTransaction(request, this); - } - - /* RFC3261 12.2.2 - * Requests that do not change in any way the state of a dialog may be - * received within a dialog (for example, an OPTIONS request). - * They are processed as if they had been received outside the dialog. - */ - if(method === JsSIP.C.OPTIONS) { - request.reply(200, null, [ - 'Allow: '+ JsSIP.Utils.getAllowedMethods(this), - 'Accept: '+ C.ACCEPTED_BODY_TYPES - ]); - } else if (method === JsSIP.C.MESSAGE) { - if (!this.checkEvent('newMessage') || this.listeners('newMessage').length === 0) { - request.reply(405, null, ['Allow: '+ JsSIP.Utils.getAllowedMethods(this)]); - return; - } - message = new JsSIP.Message(this); - message.init_incoming(request); - } - - // Initial Request - if(!request.to_tag) { - if(!this.isRegistered()) { - // High user does not want to be contacted - request.reply(410); - return; - } - - switch(method) { - case JsSIP.C.INVITE: - if(JsSIP.WebRTC.isSupported) { - session = new JsSIP.RTCSession(this); - session.init_incoming(request); - } else { - console.warn(LOG_PREFIX +'INVITE received but WebRTC is not supported'); - request.reply(488); - } - break; - case JsSIP.C.BYE: - // Out of dialog BYE received - request.reply(481); - break; - case JsSIP.C.CANCEL: - session = this.findSession(request); - if(session) { - session.receiveRequest(request); - } else { - console.warn(LOG_PREFIX +'received CANCEL request for a non existent session'); - } - break; - case JsSIP.C.ACK: - /* Absorb it. - * ACK request without a corresponding Invite Transaction - * and without To tag. - */ - break; - default: - request.reply(405); - break; - } - } - // In-dialog request - else { - dialog = this.findDialog(request); - - if(dialog) { - dialog.receiveRequest(request); - } else if (method === JsSIP.C.NOTIFY) { - session = this.findSession(request); - if(session) { - session.receiveRequest(request); - } else { - console.warn(LOG_PREFIX +'received NOTIFY request for a non existent session'); - request.reply(481, 'Subscription does not exist'); - } - } - /* RFC3261 12.2.2 - * Request with to tag, but no matching dialog found. - * Exception: ACK for an Invite request for which a dialog has not - * been created. - */ - else { - if(method !== JsSIP.C.ACK) { - request.reply(481); - } - } - } -}; - -//================= -// Utils -//================= - -/** - * Get the session to which the request belongs to, if any. - * @private - * @param {JsSIP.IncomingRequest} request. - * @returns {JsSIP.OutgoingSession|JsSIP.IncomingSession|null} - */ -UA.prototype.findSession = function(request) { - var - sessionIDa = request.call_id + request.from_tag, - sessionA = this.sessions[sessionIDa], - sessionIDb = request.call_id + request.to_tag, - sessionB = this.sessions[sessionIDb]; - - if(sessionA) { - return sessionA; - } else if(sessionB) { - return sessionB; - } else { - return null; - } -}; - -/** - * Get the dialog to which the request belongs to, if any. - * @private - * @param {JsSIP.IncomingRequest} - * @returns {JsSIP.Dialog|null} - */ -UA.prototype.findDialog = function(request) { - var - id = request.call_id + request.from_tag + request.to_tag, - dialog = this.dialogs[id]; - - if(dialog) { - return dialog; - } else { - id = request.call_id + request.to_tag + request.from_tag; - dialog = this.dialogs[id]; - if(dialog) { - return dialog; - } else { - return null; - } - } -}; - -/** - * Retrieve the next server to which connect. - * @private - * @returns {Object} ws_server - */ -UA.prototype.getNextWsServer = function() { - // Order servers by weight - var idx, length, ws_server, - candidates = []; - - length = this.configuration.ws_servers.length; - for (idx = 0; idx < length; idx++) { - ws_server = this.configuration.ws_servers[idx]; - - if (ws_server.status === JsSIP.Transport.C.STATUS_ERROR) { - continue; - } else if (candidates.length === 0) { - candidates.push(ws_server); - } else if (ws_server.weight > candidates[0].weight) { - candidates = [ws_server]; - } else if (ws_server.weight === candidates[0].weight) { - candidates.push(ws_server); - } - } - - idx = Math.floor((Math.random()* candidates.length)); - - return candidates[idx]; -}; - -/** - * Close all sessions on transport error. - * @private - */ -UA.prototype.closeSessionsOnTransportError = function() { - var idx; - - // Run _transportError_ for every Session - for(idx in this.sessions) { - this.sessions[idx].onTransportError(); - } - // Call registrator _onTransportClosed_ - this.registrator.onTransportClosed(); -}; - -UA.prototype.recoverTransport = function(ua) { - var idx, length, k, nextRetry, count, server; - - ua = ua || this; - count = ua.transportRecoverAttempts; - - length = ua.configuration.ws_servers.length; - for (idx = 0; idx < length; idx++) { - ua.configuration.ws_servers[idx].status = 0; - } - - server = ua.getNextWsServer(); - - k = Math.floor((Math.random() * Math.pow(2,count)) +1); - nextRetry = k * ua.configuration.connection_recovery_min_interval; - - if (nextRetry > ua.configuration.connection_recovery_max_interval) { - console.log(LOG_PREFIX + 'time for next connection attempt exceeds connection_recovery_max_interval, resetting counter'); - nextRetry = ua.configuration.connection_recovery_min_interval; - count = 0; - } - - console.log(LOG_PREFIX + 'next connection attempt in '+ nextRetry +' seconds'); - - this.transportRecoveryTimer = window.setTimeout( - function(){ - ua.transportRecoverAttempts = count + 1; - new JsSIP.Transport(ua, server); - }, nextRetry * 1000); -}; - -/** - * Configuration load. - * @private - * returns {Boolean} - */ -UA.prototype.loadConfig = function(configuration) { - // Settings and default values - var parameter, value, checked_value, hostport_params, registrar_server, - settings = { - /* Host address - * Value to be set in Via sent_by and host part of Contact FQDN - */ - via_host: JsSIP.Utils.createRandomToken(12) + '.invalid', - - // Password - password: null, - - // Registration parameters - register_expires: 600, - register_min_expires: 120, - register: true, - registrar_server: null, - - // Transport related parameters - ws_server_max_reconnection: 3, - ws_server_reconnection_timeout: 4, - - connection_recovery_min_interval: 2, - connection_recovery_max_interval: 30, - - use_preloaded_route: false, - - // Session parameters - no_answer_timeout: 60, - stun_servers: ['stun:stun.l.google.com:19302'], - turn_servers: [], - - // Logging parameters - trace_sip: false, - - // Hacks - hack_via_tcp: false, - hack_ip_in_contact: false - }; - - // Pre-Configuration - - // Check Mandatory parameters - for(parameter in UA.configuration_check.mandatory) { - if(!configuration.hasOwnProperty(parameter)) { - throw new JsSIP.Exceptions.ConfigurationError(parameter); - } else { - value = configuration[parameter]; - checked_value = UA.configuration_check.mandatory[parameter](value); - if (checked_value !== undefined) { - settings[parameter] = checked_value; - } else { - throw new JsSIP.Exceptions.ConfigurationError(parameter, value); - } - } - } - - // Check Optional parameters - for(parameter in UA.configuration_check.optional) { - if(configuration.hasOwnProperty(parameter)) { - value = configuration[parameter]; - - // If the parameter value is null, empty string or undefined then apply its default value. - if(value === null || value === "" || value === undefined) { continue; } - // If it's a number with NaN value then also apply its default value. - // NOTE: JS does not allow "value === NaN", the following does the work: - else if(typeof(value) === 'number' && window.isNaN(value)) { continue; } - - checked_value = UA.configuration_check.optional[parameter](value); - if (checked_value !== undefined) { - settings[parameter] = checked_value; - } else { - throw new JsSIP.Exceptions.ConfigurationError(parameter, value); - } - } - } - - // Sanity Checks - - // Connection recovery intervals - if(settings.connection_recovery_max_interval < settings.connection_recovery_min_interval) { - throw new JsSIP.Exceptions.ConfigurationError('connection_recovery_max_interval', settings.connection_recovery_max_interval); - } - - // Post Configuration Process - - // Allow passing 0 number as display_name. - if (settings.display_name === 0) { - settings.display_name = '0'; - } - - // Instance-id for GRUU - settings.instance_id = JsSIP.Utils.newUUID(); - - // jssip_id instance parameter. Static random tag of length 5 - settings.jssip_id = JsSIP.Utils.createRandomToken(5); - - // String containing settings.uri without scheme and user. - hostport_params = settings.uri.clone(); - hostport_params.user = null; - settings.hostport_params = hostport_params.toString().replace(/^sip:/i, ''); - - /* Check whether authorization_user is explicitly defined. - * Take 'settings.uri.user' value if not. - */ - if (!settings.authorization_user) { - settings.authorization_user = settings.uri.user; - } - - /* If no 'registrar_server' is set use the 'uri' value without user portion. */ - if (!settings.registrar_server) { - registrar_server = settings.uri.clone(); - registrar_server.user = null; - settings.registrar_server = registrar_server; - } - - // User no_answer_timeout - settings.no_answer_timeout = settings.no_answer_timeout * 1000; - - // Via Host - if (settings.hack_ip_in_contact) { - settings.via_host = JsSIP.Utils.getRandomTestNetIP(); - } - - this.contact = { - pub_gruu: null, - temp_gruu: null, - uri: new JsSIP.URI('sip', JsSIP.Utils.createRandomToken(8), settings.via_host, null, {transport: 'ws'}), - toString: function(options){ - options = options || {}; - - var - anonymous = options.anonymous || null, - outbound = options.outbound || null, - contact = '<'; - - if (anonymous) { - contact += this.temp_gruu || 'sip:anonymous@anonymous.invalid;transport=ws'; - } else { - contact += this.pub_gruu || this.uri.toString(); - } - - if (outbound) { - contact += ';ob'; - } - - contact += '>'; - - return contact; - } - }; - - // Fill the value of the configuration_skeleton - console.log(LOG_PREFIX + 'configuration parameters after validation:'); - for(parameter in settings) { - switch(parameter) { - case 'uri': - case 'registrar_server': - console.log('· ' + parameter + ': ' + settings[parameter]); - break; - case 'password': - console.log('· ' + parameter + ': ' + 'NOT SHOWN'); - break; - default: - console.log('· ' + parameter + ': ' + window.JSON.stringify(settings[parameter])); - } - UA.configuration_skeleton[parameter].value = settings[parameter]; - } - - Object.defineProperties(this.configuration, UA.configuration_skeleton); - - // Clean UA.configuration_skeleton - for(parameter in settings) { - UA.configuration_skeleton[parameter].value = ''; - } - - return; -}; - - -/** - * Configuration Object skeleton. - * @private - */ -UA.configuration_skeleton = (function() { - var idx, parameter, - skeleton = {}, - parameters = [ - // Internal parameters - "instance_id", - "jssip_id", - "register_min_expires", - "ws_server_max_reconnection", - "ws_server_reconnection_timeout", - "hostport_params", - - // Mandatory user configurable parameters - "uri", - "ws_servers", - - // Optional user configurable parameters - "authorization_user", - "connection_recovery_max_interval", - "connection_recovery_min_interval", - "display_name", - "hack_via_tcp", // false. - "hack_ip_in_contact", //false - "no_answer_timeout", // 30 seconds. - "password", - "register_expires", // 600 seconds. - "registrar_server", - "stun_servers", - "trace_sip", - "turn_servers", - "use_preloaded_route", - - // Post-configuration generated parameters - "via_core_value", - "via_host" - ]; - - for(idx in parameters) { - parameter = parameters[idx]; - skeleton[parameter] = { - value: '', - writable: false, - configurable: false - }; - } - - skeleton['register'] = { - value: '', - writable: true, - configurable: false - }; - - return skeleton; -}()); - -/** - * Configuration checker. - * @private - * @return {Boolean} - */ -UA.configuration_check = { - mandatory: { - - uri: function(uri) { - var parsed; - - if (!/^sip:/i.test(uri)) { - uri = JsSIP.C.SIP + ':' + uri; - } - parsed = JsSIP.URI.parse(uri); - - if(!parsed) { - return; - } else if(!parsed.user) { - return; - } else { - return parsed; - } - }, - - ws_servers: function(ws_servers) { - var idx, length, url; - - /* Allow defining ws_servers parameter as: - * String: "host" - * Array of Strings: ["host1", "host2"] - * Array of Objects: [{ws_uri:"host1", weight:1}, {ws_uri:"host2", weight:0}] - * Array of Objects and Strings: [{ws_uri:"host1"}, "host2"] - */ - if (typeof ws_servers === 'string') { - ws_servers = [{ws_uri: ws_servers}]; - } else if (ws_servers instanceof Array) { - length = ws_servers.length; - for (idx = 0; idx < length; idx++) { - if (typeof ws_servers[idx] === 'string'){ - ws_servers[idx] = {ws_uri: ws_servers[idx]}; - } - } - } else { - return; - } - - if (ws_servers.length === 0) { - return false; - } - - length = ws_servers.length; - for (idx = 0; idx < length; idx++) { - if (!ws_servers[idx].ws_uri) { - console.error(LOG_PREFIX +'missing "ws_uri" attribute in ws_servers parameter'); - return; - } - if (ws_servers[idx].weight && !Number(ws_servers[idx].weight)) { - console.error(LOG_PREFIX +'"weight" attribute in ws_servers parameter must be a Number'); - return; - } - - url = JsSIP.Grammar.parse(ws_servers[idx].ws_uri, 'absoluteURI'); - - if(url === -1) { - console.error(LOG_PREFIX +'invalid "ws_uri" attribute in ws_servers parameter: ' + ws_servers[idx].ws_uri); - return; - } else if(url.scheme !== 'wss' && url.scheme !== 'ws') { - console.error(LOG_PREFIX +'invalid URI scheme in ws_servers parameter: ' + url.scheme); - return; - } else { - ws_servers[idx].sip_uri = ''; - - if (!ws_servers[idx].weight) { - ws_servers[idx].weight = 0; - } - - ws_servers[idx].status = 0; - ws_servers[idx].scheme = url.scheme.toUpperCase(); - } - } - return ws_servers; - } - }, - - optional: { - - authorization_user: function(authorization_user) { - if(JsSIP.Grammar.parse('"'+ authorization_user +'"', 'quoted_string') === -1) { - return; - } else { - return authorization_user; - } - }, - - connection_recovery_max_interval: function(connection_recovery_max_interval) { - var value; - if(JsSIP.Utils.isDecimal(connection_recovery_max_interval)) { - value = window.Number(connection_recovery_max_interval); - if(value > 0) { - return value; - } - } - }, - - connection_recovery_min_interval: function(connection_recovery_min_interval) { - var value; - if(JsSIP.Utils.isDecimal(connection_recovery_min_interval)) { - value = window.Number(connection_recovery_min_interval); - if(value > 0) { - return value; - } - } - }, - - display_name: function(display_name) { - if(JsSIP.Grammar.parse('"' + display_name + '"', 'display_name') === -1) { - return; - } else { - return display_name; - } - }, - - hack_via_tcp: function(hack_via_tcp) { - if (typeof hack_via_tcp === 'boolean') { - return hack_via_tcp; - } - }, - - hack_ip_in_contact: function(hack_ip_in_contact) { - if (typeof hack_ip_in_contact === 'boolean') { - return hack_ip_in_contact; - } - }, - - no_answer_timeout: function(no_answer_timeout) { - var value; - if (JsSIP.Utils.isDecimal(no_answer_timeout)) { - value = window.Number(no_answer_timeout); - if (value > 0) { - return value; - } - } - }, - - password: function(password) { - return String(password); - }, - - register: function(register) { - if (typeof register === 'boolean') { - return register; - } - }, - - register_expires: function(register_expires) { - var value; - if (JsSIP.Utils.isDecimal(register_expires)) { - value = window.Number(register_expires); - if (value > 0) { - return value; - } - } - }, - - registrar_server: function(registrar_server) { - var parsed; - - if (!/^sip:/i.test(registrar_server)) { - registrar_server = JsSIP.C.SIP + ':' + registrar_server; - } - parsed = JsSIP.URI.parse(registrar_server); - - if(!parsed) { - return; - } else if(parsed.user) { - return; - } else { - return parsed; - } - }, - - stun_servers: function(stun_servers) { - var idx, length, stun_server; - - if (typeof stun_servers === 'string') { - stun_servers = [stun_servers]; - } else if (!(stun_servers instanceof Array)) { - return; - } - - length = stun_servers.length; - for (idx = 0; idx < length; idx++) { - stun_server = stun_servers[idx]; - if (!(/^stuns?:/.test(stun_server))) { - stun_server = 'stun:' + stun_server; - } - - if(JsSIP.Grammar.parse(stun_server, 'stun_URI') === -1) { - return; - } else { - stun_servers[idx] = stun_server; - } - } - return stun_servers; - }, - - trace_sip: function(trace_sip) { - if (typeof trace_sip === 'boolean') { - return trace_sip; - } - }, - - turn_servers: function(turn_servers) { - var idx, length, turn_server, url; - - if (turn_servers instanceof Array) { - // Do nothing - } else { - turn_servers = [turn_servers]; - } - - length = turn_servers.length; - for (idx = 0; idx < length; idx++) { - turn_server = turn_servers[idx]; - - // Backward compatibility: - //Allow defining the turn_server url with the 'server' property. - if (turn_server.server) { - turn_server.urls = [turn_server.server]; - } - - if (!turn_server.urls || !turn_server.username || !turn_server.password) { - return; - } - - if (!turn_server.urls instanceof Array) { - turn_server.urls = [turn_server.urls]; - } - - length = turn_server.urls.length; - for (idx = 0; idx < length; idx++) { - url = turn_server.urls[idx]; - - if (!(/^turns?:/.test(url))) { - url = 'turn:' + url; - } - - if(JsSIP.Grammar.parse(url, 'turn_URI') === -1) { - return; - } - } - } - return turn_servers; - }, - - use_preloaded_route: function(use_preloaded_route) { - if (typeof use_preloaded_route === 'boolean') { - return use_preloaded_route; - } - } - } -}; - -UA.C = C; -JsSIP.UA = UA; -}(JsSIP)); - - - -/** - * @fileoverview Utils - */ - -(function(JsSIP) { -var Utils; - -Utils= { - - str_utf8_length: function(string) { - return window.unescape(encodeURIComponent(string)).length; - }, - - isFunction: function(fn) { - if (fn !== undefined) { - return (Object.prototype.toString.call(fn) === '[object Function]')? true : false; - } else { - return false; - } - }, - - isDecimal: function (num) { - return !isNaN(num) && (parseFloat(num) === parseInt(num,10)); - }, - - createRandomToken: function(size, base) { - var i, r, - token = ''; - - base = base || 32; - - for( i=0; i < size; i++ ) { - r = Math.random() * base|0; - token += r.toString(base); - } - - return token; - }, - - newTag: function() { - return JsSIP.Utils.createRandomToken(JsSIP.UA.C.TAG_LENGTH); - }, - - // http://stackoverflow.com/users/109538/broofa - newUUID: function() { - var UUID = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }); - - return UUID; - }, - - hostType: function(host) { - if (!host) { - return; - } else { - host = JsSIP.Grammar.parse(host,'host'); - if (host !== -1) { - return host.host_type; - } - } - }, - - /** - * Normalize SIP URI. - * NOTE: It does not allow a SIP URI without username. - * Accepts 'sip', 'sips' and 'tel' URIs and convert them into 'sip'. - * Detects the domain part (if given) and properly hex-escapes the user portion. - * If the user portion has only 'tel' number symbols the user portion is clean of 'tel' visual separators. - * @private - * @param {String} target - * @param {String} [domain] - */ - normalizeURI: function(target, domain) { - var uri, target_array, target_user, target_domain, - original_target = target; - - // If no target is given then raise an error. - if (!target) { - throw new JsSIP.Exceptions.InvalidTargetError(original_target); - - // If a JsSIP.URI instance is given then return it. - } else if (target instanceof JsSIP.URI) { - return target; - - // If a string is given split it by '@': - // - Last fragment is the desired domain. - // - Otherwise append the given domain argument. - } else if (typeof target === 'string') { - target_array = target.split('@'); - - switch(target_array.length) { - case 1: - if (!domain) { - throw new JsSIP.Exceptions.InvalidTargetError(original_target); - } - target_user = target; - target_domain = domain; - break; - case 2: - target_user = target_array[0]; - target_domain = target_array[1]; - break; - default: - target_user = target_array.slice(0, target_array.length-1).join('@'); - target_domain = target_array[target_array.length-1]; - } - - // Remove the URI scheme (if present). - target_user = target_user.replace(/^(sips?|tel):/i, ''); - - // Remove 'tel' visual separators if the user portion just contains 'tel' number symbols. - if (/^[\-\.\(\)]*\+?[0-9\-\.\(\)]+$/.test(target_user)) { - target_user = target_user.replace(/[\-\.\(\)]/g, ''); - } - - // Build the complete SIP URI. - target = JsSIP.C.SIP + ':' + JsSIP.Utils.escapeUser(target_user) + '@' + target_domain; - - // Finally parse the resulting URI. - if (uri = JsSIP.URI.parse(target)) { - return uri; - } else { - throw new JsSIP.Exceptions.InvalidTargetError(original_target); - } - } - - // Otherwise raise an error. - else { - throw new JsSIP.Exceptions.InvalidTargetError(original_target); - } - }, - - /** - * Hex-escape a SIP URI user. - * @private - * @param {String} user - */ - escapeUser: function(user) { - // Don't hex-escape ':' (%3A), '+' (%2B), '?' (%3F"), '/' (%2F). - return window.encodeURIComponent(window.decodeURIComponent(user)).replace(/%3A/ig, ':').replace(/%2B/ig, '+').replace(/%3F/ig, '?').replace(/%2F/ig, '/'); - }, - - headerize: function(string) { - var exceptions = { - 'Call-Id': 'Call-ID', - 'Cseq': 'CSeq', - 'Www-Authenticate': 'WWW-Authenticate' - }, - name = string.toLowerCase().replace(/_/g,'-').split('-'), - hname = '', - parts = name.length, part; - - for (part = 0; part < parts; part++) { - if (part !== 0) { - hname +='-'; - } - hname += name[part].charAt(0).toUpperCase()+name[part].substring(1); - } - if (exceptions[hname]) { - hname = exceptions[hname]; - } - return hname; - }, - - sipErrorCause: function(status_code) { - var cause; - - for (cause in JsSIP.C.SIP_ERROR_CAUSES) { - if (JsSIP.C.SIP_ERROR_CAUSES[cause].indexOf(status_code) !== -1) { - return JsSIP.C.causes[cause]; - } - } - - return JsSIP.C.causes.SIP_FAILURE_CODE; - }, - - /** - * Generate a random Test-Net IP (http://tools.ietf.org/html/rfc5735) - * @private - */ - getRandomTestNetIP: function() { - function getOctet(from,to) { - return window.Math.floor(window.Math.random()*(to-from+1)+from); - } - return '192.0.2.' + getOctet(1, 254); - }, - - getAllowedMethods: function(ua) { - var event, - allowed = JsSIP.UA.C.ALLOWED_METHODS.toString(); - - for (event in JsSIP.UA.C.EVENT_METHODS) { - if (ua.checkEvent(event) && ua.listeners(event).length > 0) { - allowed += ','+ JsSIP.UA.C.EVENT_METHODS[event]; - } - } - - return allowed; - }, - - // MD5 (Message-Digest Algorithm) http://www.webtoolkit.info - calculateMD5: function(string) { - function RotateLeft(lValue, iShiftBits) { - return (lValue<>>(32-iShiftBits)); - } - - function AddUnsigned(lX,lY) { - var lX4,lY4,lX8,lY8,lResult; - lX8 = (lX & 0x80000000); - lY8 = (lY & 0x80000000); - lX4 = (lX & 0x40000000); - lY4 = (lY & 0x40000000); - lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); - if (lX4 & lY4) { - return (lResult ^ 0x80000000 ^ lX8 ^ lY8); - } - if (lX4 | lY4) { - if (lResult & 0x40000000) { - return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); - } else { - return (lResult ^ 0x40000000 ^ lX8 ^ lY8); - } - } else { - return (lResult ^ lX8 ^ lY8); - } - } - - function F(x,y,z) { - return (x & y) | ((~x) & z); - } - - function G(x,y,z) { - return (x & z) | (y & (~z)); - } - - function H(x,y,z) { - return (x ^ y ^ z); - } - - function I(x,y,z) { - return (y ^ (x | (~z))); - } - - function FF(a,b,c,d,x,s,ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - } - - function GG(a,b,c,d,x,s,ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - } - - function HH(a,b,c,d,x,s,ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - } - - function II(a,b,c,d,x,s,ac) { - a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); - return AddUnsigned(RotateLeft(a, s), b); - } - - function ConvertToWordArray(string) { - var lWordCount; - var lMessageLength = string.length; - var lNumberOfWords_temp1=lMessageLength + 8; - var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; - var lNumberOfWords = (lNumberOfWords_temp2+1)*16; - var lWordArray=Array(lNumberOfWords-1); - var lBytePosition = 0; - var lByteCount = 0; - while ( lByteCount < lMessageLength ) { - lWordCount = (lByteCount-(lByteCount % 4))/4; - lBytePosition = (lByteCount % 4)*8; - lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<>>29; - return lWordArray; - } - - function WordToHex(lValue) { - var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; - for (lCount = 0;lCount<=3;lCount++) { - lByte = (lValue>>>(lCount*8)) & 255; - WordToHexValue_temp = "0" + lByte.toString(16); - WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); - } - return WordToHexValue; - } - - function Utf8Encode(string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - } - return utftext; - } - - var x=[]; - var k,AA,BB,CC,DD,a,b,c,d; - var S11=7, S12=12, S13=17, S14=22; - var S21=5, S22=9 , S23=14, S24=20; - var S31=4, S32=11, S33=16, S34=23; - var S41=6, S42=10, S43=15, S44=21; - - string = Utf8Encode(string); - - x = ConvertToWordArray(string); - - a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; - - for (k=0;k 1) { - console.warn(LOG_PREFIX +'More than one Via header field present in the response. Dropping the response'); - return false; - } -} - -function rfc3261_18_1_2() { - var via_host = ua.configuration.via_host; - if(message.via.host !== via_host) { - console.warn(LOG_PREFIX +'Via host in the response does not match UA Via host value. Dropping the response'); - return false; - } -} - -function rfc3261_18_3_response() { - var - len = JsSIP.Utils.str_utf8_length(message.body), - contentLength = message.getHeader('content-length'); - - if(len < contentLength) { - console.warn(LOG_PREFIX +'Message body length is lower than the value in Content-Length header field. Dropping the response'); - return false; - } -} - -// Sanity Check functions for requests and responses -function minimumHeaders() { - var - mandatoryHeaders = ['from', 'to', 'call_id', 'cseq', 'via'], - idx = mandatoryHeaders.length; - - while(idx--) { - if(!message.hasHeader(mandatoryHeaders[idx])) { - console.warn(LOG_PREFIX +'Missing mandatory header field : '+ mandatoryHeaders[idx] +'. Dropping the response'); - return false; - } - } -} - -// Reply -function reply(status_code) { - var to, - response = "SIP/2.0 " + status_code + " " + JsSIP.C.REASON_PHRASE[status_code] + "\r\n", - via_length = message.countHeader('via'), - idx = 0; - - for(idx; idx < via_length; idx++) { - response += "Via: " + message.getHeader('via', idx) + "\r\n"; - } - - to = message.getHeader('To'); - - if(!message.to_tag) { - to += ';tag=' + JsSIP.Utils.newTag(); - } - - response += "To: " + to + "\r\n"; - response += "From: " + message.getHeader('From') + "\r\n"; - response += "Call-ID: " + message.call_id + "\r\n"; - response += "CSeq: " + message.cseq + " " + message.method + "\r\n"; - response += "\r\n"; - - transport.send(response); -} - -requests.push(rfc3261_8_2_2_1); -requests.push(rfc3261_16_3_4); -requests.push(rfc3261_18_3_request); -requests.push(rfc3261_8_2_2_2); - -responses.push(rfc3261_8_1_3_3); -responses.push(rfc3261_18_1_2); -responses.push(rfc3261_18_3_response); - -all.push(minimumHeaders); - -sanityCheck = function(m, u, t) { - var len, pass; - - message = m; - ua = u; - transport = t; - - len = all.length; - while(len--) { - pass = all[len](message); - if(pass === false) { - return false; - } - } - - if(message instanceof JsSIP.IncomingRequest) { - len = requests.length; - while(len--) { - pass = requests[len](message); - if(pass === false) { - return false; - } - } - } - - else if(message instanceof JsSIP.IncomingResponse) { - len = responses.length; - while(len--) { - pass = responses[len](message); - if(pass === false) { - return false; - } - } - } - - //Everything is OK - return true; -}; - -JsSIP.sanityCheck = sanityCheck; -}(JsSIP)); - - - - -/** - * @fileoverview SIP Digest Authentication - */ - -/** - * SIP Digest Authentication. - * @augments JsSIP. - * @function Digest Authentication - * @param {JsSIP.UA} ua - */ -(function(JsSIP) { -var DigestAuthentication, - LOG_PREFIX = JsSIP.name +' | '+ 'DIGEST AUTHENTICATION' +' | '; - -DigestAuthentication = function(ua) { - this.username = ua.configuration.authorization_user; - this.password = ua.configuration.password; - this.cnonce = null; - this.nc = 0; - this.ncHex = '00000000'; - this.response = null; -}; - - -/** -* Performs Digest authentication given a SIP request and the challenge -* received in a response to that request. -* Returns true if credentials were successfully generated, false otherwise. -* -* @param {JsSIP.OutgoingRequest} request -* @param {Object} challenge -*/ -DigestAuthentication.prototype.authenticate = function(request, challenge) { - // Inspect and validate the challenge. - - this.algorithm = challenge.algorithm; - this.realm = challenge.realm; - this.nonce = challenge.nonce; - this.opaque = challenge.opaque; - this.stale = challenge.stale; - - if (this.algorithm) { - if (this.algorithm !== 'MD5') { - console.warn(LOG_PREFIX + 'challenge with Digest algorithm different than "MD5", authentication aborted'); - return false; - } - } else { - this.algorithm = 'MD5'; - } - - if (! this.realm) { - console.warn(LOG_PREFIX + 'challenge without Digest realm, authentication aborted'); - return false; - } - - if (! this.nonce) { - console.warn(LOG_PREFIX + 'challenge without Digest nonce, authentication aborted'); - return false; - } - - // 'qop' can contain a list of values (Array). Let's choose just one. - if (challenge.qop) { - if (challenge.qop.indexOf('auth') > -1) { - this.qop = 'auth'; - } else if (challenge.qop.indexOf('auth-int') > -1) { - this.qop = 'auth-int'; - } else { - // Otherwise 'qop' is present but does not contain 'auth' or 'auth-int', so abort here. - console.warn(LOG_PREFIX + 'challenge without Digest qop different than "auth" or "auth-int", authentication aborted'); - return false; - } - } else { - this.qop = null; - } - - // Fill other attributes. - - this.method = request.method; - this.uri = request.ruri; - this.cnonce = JsSIP.Utils.createRandomToken(12); - this.nc += 1; - this.updateNcHex(); - - // nc-value = 8LHEX. Max value = 'FFFFFFFF'. - if (this.nc === 4294967296) { - this.nc = 1; - this.ncHex = '00000001'; - } - - // Calculate the Digest "response" value. - this.calculateResponse(); - - return true; -}; - - -/** -* Generate Digest 'response' value. -* @private -*/ -DigestAuthentication.prototype.calculateResponse = function() { - var ha1, ha2; - - // HA1 = MD5(A1) = MD5(username:realm:password) - ha1 = JsSIP.Utils.calculateMD5(this.username + ":" + this.realm + ":" + this.password); - - if (this.qop === 'auth') { - // HA2 = MD5(A2) = MD5(method:digestURI) - ha2 = JsSIP.Utils.calculateMD5(this.method + ":" + this.uri); - // response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2) - this.response = JsSIP.Utils.calculateMD5(ha1 + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth:" + ha2); - - } else if (this.qop === 'auth-int') { - // HA2 = MD5(A2) = MD5(method:digestURI:MD5(entityBody)) - ha2 = JsSIP.Utils.calculateMD5(this.method + ":" + this.uri + ":" + JsSIP.Utils.calculateMD5(this.body ? this.body : "")); - // response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2) - this.response = JsSIP.Utils.calculateMD5(ha1 + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth-int:" + ha2); - - } else if (this.qop === null) { - // HA2 = MD5(A2) = MD5(method:digestURI) - ha2 = JsSIP.Utils.calculateMD5(this.method + ":" + this.uri); - // response = MD5(HA1:nonce:HA2) - this.response = JsSIP.Utils.calculateMD5(ha1 + ":" + this.nonce + ":" + ha2); - } -}; - - -/** -* Return the Proxy-Authorization or WWW-Authorization header value. -*/ -DigestAuthentication.prototype.toString = function() { - var auth_params = []; - - if (! this.response) { - throw new Error('response field does not exist, cannot generate Authorization header'); - } - - auth_params.push('algorithm=' + this.algorithm); - auth_params.push('username="' + this.username + '"'); - auth_params.push('realm="' + this.realm + '"'); - auth_params.push('nonce="' + this.nonce + '"'); - auth_params.push('uri="' + this.uri + '"'); - auth_params.push('response="' + this.response + '"'); - if (this.opaque) { - auth_params.push('opaque="' + this.opaque + '"'); - } - if (this.qop) { - auth_params.push('qop=' + this.qop); - auth_params.push('cnonce="' + this.cnonce + '"'); - auth_params.push('nc=' + this.ncHex); - } - - return 'Digest ' + auth_params.join(', '); -}; - - -/** -* Generate the 'nc' value as required by Digest in this.ncHex by reading this.nc. -* @private -*/ -DigestAuthentication.prototype.updateNcHex = function() { - var hex = Number(this.nc).toString(16); - this.ncHex = '00000000'.substr(0, 8-hex.length) + hex; -}; - -JsSIP.DigestAuthentication = DigestAuthentication; -}(JsSIP)); - - -/** - * @fileoverview WebRTC - */ - -(function(JsSIP) { -var WebRTC; - -WebRTC = {}; - -// getUserMedia -if (window.navigator.webkitGetUserMedia) { - WebRTC.getUserMedia = window.navigator.webkitGetUserMedia.bind(navigator); -} -else if (window.navigator.mozGetUserMedia) { - WebRTC.getUserMedia = window.navigator.mozGetUserMedia.bind(navigator); -} -else if (window.navigator.getUserMedia) { - WebRTC.getUserMedia = window.navigator.getUserMedia.bind(navigator); -} - -// RTCPeerConnection -if (window.webkitRTCPeerConnection) { - WebRTC.RTCPeerConnection = window.webkitRTCPeerConnection; -} -else if (window.mozRTCPeerConnection) { - WebRTC.RTCPeerConnection = window.mozRTCPeerConnection; -} -else if (window.RTCPeerConnection) { - WebRTC.RTCPeerConnection = window.RTCPeerConnection; -} - -// RTCSessionDescription -if (window.webkitRTCSessionDescription) { - WebRTC.RTCSessionDescription = window.webkitRTCSessionDescription; -} -else if (window.mozRTCSessionDescription) { - WebRTC.RTCSessionDescription = window.mozRTCSessionDescription; -} -else if (window.RTCSessionDescription) { - WebRTC.RTCSessionDescription = window.RTCSessionDescription; -} - -// New syntax for getting streams in Chrome M26. -if (WebRTC.RTCPeerConnection && WebRTC.RTCPeerConnection.prototype) { - if (!WebRTC.RTCPeerConnection.prototype.getLocalStreams) { - WebRTC.RTCPeerConnection.prototype.getLocalStreams = function() { - return this.localStreams; - }; - WebRTC.RTCPeerConnection.prototype.getRemoteStreams = function() { - return this.remoteStreams; - }; - } -} - -// isSupported attribute. -if (WebRTC.getUserMedia && WebRTC.RTCPeerConnection && WebRTC.RTCSessionDescription) { - WebRTC.isSupported = true; -} -else { - WebRTC.isSupported = false; -} - -JsSIP.WebRTC = WebRTC; -}(JsSIP)); - - - -window.JsSIP = JsSIP; -}(window)); - - -JsSIP.Grammar = (function(){ - /* - * Generated by PEG.js 0.7.0. - * - * http://pegjs.majda.cz/ - */ - - function quote(s) { - /* - * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a - * string literal except for the closing quote character, backslash, - * carriage return, line separator, paragraph separator, and line feed. - * Any character may appear in the form of an escape sequence. - * - * For portability, we also escape escape all control and non-ASCII - * characters. Note that "\0" and "\v" escape sequences are not used - * because JSHint does not like the first and IE the second. - */ - return '"' + s - .replace(/\\/g, '\\\\') // backslash - .replace(/"/g, '\\"') // closing quote character - .replace(/\x08/g, '\\b') // backspace - .replace(/\t/g, '\\t') // horizontal tab - .replace(/\n/g, '\\n') // line feed - .replace(/\f/g, '\\f') // form feed - .replace(/\r/g, '\\r') // carriage return - .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) - + '"'; - } - - var result = { - /* - * Parses the input with a generated parser. If the parsing is successfull, - * returns a value explicitly or implicitly specified by the grammar from - * which the parser was generated (see |PEG.buildParser|). If the parsing is - * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. - */ - parse: function(input, startRule) { - var parseFunctions = { - "CRLF": parse_CRLF, - "DIGIT": parse_DIGIT, - "ALPHA": parse_ALPHA, - "HEXDIG": parse_HEXDIG, - "WSP": parse_WSP, - "OCTET": parse_OCTET, - "DQUOTE": parse_DQUOTE, - "SP": parse_SP, - "HTAB": parse_HTAB, - "alphanum": parse_alphanum, - "reserved": parse_reserved, - "unreserved": parse_unreserved, - "mark": parse_mark, - "escaped": parse_escaped, - "LWS": parse_LWS, - "SWS": parse_SWS, - "HCOLON": parse_HCOLON, - "TEXT_UTF8_TRIM": parse_TEXT_UTF8_TRIM, - "TEXT_UTF8char": parse_TEXT_UTF8char, - "UTF8_NONASCII": parse_UTF8_NONASCII, - "UTF8_CONT": parse_UTF8_CONT, - "LHEX": parse_LHEX, - "token": parse_token, - "token_nodot": parse_token_nodot, - "separators": parse_separators, - "word": parse_word, - "STAR": parse_STAR, - "SLASH": parse_SLASH, - "EQUAL": parse_EQUAL, - "LPAREN": parse_LPAREN, - "RPAREN": parse_RPAREN, - "RAQUOT": parse_RAQUOT, - "LAQUOT": parse_LAQUOT, - "COMMA": parse_COMMA, - "SEMI": parse_SEMI, - "COLON": parse_COLON, - "LDQUOT": parse_LDQUOT, - "RDQUOT": parse_RDQUOT, - "comment": parse_comment, - "ctext": parse_ctext, - "quoted_string": parse_quoted_string, - "quoted_string_clean": parse_quoted_string_clean, - "qdtext": parse_qdtext, - "quoted_pair": parse_quoted_pair, - "SIP_URI_noparams": parse_SIP_URI_noparams, - "SIP_URI": parse_SIP_URI, - "uri_scheme": parse_uri_scheme, - "userinfo": parse_userinfo, - "user": parse_user, - "user_unreserved": parse_user_unreserved, - "password": parse_password, - "hostport": parse_hostport, - "host": parse_host, - "hostname": parse_hostname, - "domainlabel": parse_domainlabel, - "toplabel": parse_toplabel, - "IPv6reference": parse_IPv6reference, - "IPv6address": parse_IPv6address, - "h16": parse_h16, - "ls32": parse_ls32, - "IPv4address": parse_IPv4address, - "dec_octet": parse_dec_octet, - "port": parse_port, - "uri_parameters": parse_uri_parameters, - "uri_parameter": parse_uri_parameter, - "transport_param": parse_transport_param, - "user_param": parse_user_param, - "method_param": parse_method_param, - "ttl_param": parse_ttl_param, - "maddr_param": parse_maddr_param, - "lr_param": parse_lr_param, - "other_param": parse_other_param, - "pname": parse_pname, - "pvalue": parse_pvalue, - "paramchar": parse_paramchar, - "param_unreserved": parse_param_unreserved, - "headers": parse_headers, - "header": parse_header, - "hname": parse_hname, - "hvalue": parse_hvalue, - "hnv_unreserved": parse_hnv_unreserved, - "Request_Response": parse_Request_Response, - "Request_Line": parse_Request_Line, - "Request_URI": parse_Request_URI, - "absoluteURI": parse_absoluteURI, - "hier_part": parse_hier_part, - "net_path": parse_net_path, - "abs_path": parse_abs_path, - "opaque_part": parse_opaque_part, - "uric": parse_uric, - "uric_no_slash": parse_uric_no_slash, - "path_segments": parse_path_segments, - "segment": parse_segment, - "param": parse_param, - "pchar": parse_pchar, - "scheme": parse_scheme, - "authority": parse_authority, - "srvr": parse_srvr, - "reg_name": parse_reg_name, - "query": parse_query, - "SIP_Version": parse_SIP_Version, - "INVITEm": parse_INVITEm, - "ACKm": parse_ACKm, - "OPTIONSm": parse_OPTIONSm, - "BYEm": parse_BYEm, - "CANCELm": parse_CANCELm, - "REGISTERm": parse_REGISTERm, - "SUBSCRIBEm": parse_SUBSCRIBEm, - "NOTIFYm": parse_NOTIFYm, - "Method": parse_Method, - "Status_Line": parse_Status_Line, - "Status_Code": parse_Status_Code, - "extension_code": parse_extension_code, - "Reason_Phrase": parse_Reason_Phrase, - "Allow_Events": parse_Allow_Events, - "Call_ID": parse_Call_ID, - "Contact": parse_Contact, - "contact_param": parse_contact_param, - "name_addr": parse_name_addr, - "display_name": parse_display_name, - "contact_params": parse_contact_params, - "c_p_q": parse_c_p_q, - "c_p_expires": parse_c_p_expires, - "delta_seconds": parse_delta_seconds, - "qvalue": parse_qvalue, - "generic_param": parse_generic_param, - "gen_value": parse_gen_value, - "Content_Disposition": parse_Content_Disposition, - "disp_type": parse_disp_type, - "disp_param": parse_disp_param, - "handling_param": parse_handling_param, - "Content_Encoding": parse_Content_Encoding, - "Content_Length": parse_Content_Length, - "Content_Type": parse_Content_Type, - "media_type": parse_media_type, - "m_type": parse_m_type, - "discrete_type": parse_discrete_type, - "composite_type": parse_composite_type, - "extension_token": parse_extension_token, - "x_token": parse_x_token, - "m_subtype": parse_m_subtype, - "m_parameter": parse_m_parameter, - "m_value": parse_m_value, - "CSeq": parse_CSeq, - "CSeq_value": parse_CSeq_value, - "Expires": parse_Expires, - "Event": parse_Event, - "event_type": parse_event_type, - "From": parse_From, - "from_param": parse_from_param, - "tag_param": parse_tag_param, - "Max_Forwards": parse_Max_Forwards, - "Min_Expires": parse_Min_Expires, - "Name_Addr_Header": parse_Name_Addr_Header, - "Proxy_Authenticate": parse_Proxy_Authenticate, - "challenge": parse_challenge, - "other_challenge": parse_other_challenge, - "auth_param": parse_auth_param, - "digest_cln": parse_digest_cln, - "realm": parse_realm, - "realm_value": parse_realm_value, - "domain": parse_domain, - "URI": parse_URI, - "nonce": parse_nonce, - "nonce_value": parse_nonce_value, - "opaque": parse_opaque, - "stale": parse_stale, - "algorithm": parse_algorithm, - "qop_options": parse_qop_options, - "qop_value": parse_qop_value, - "Proxy_Require": parse_Proxy_Require, - "Record_Route": parse_Record_Route, - "rec_route": parse_rec_route, - "Require": parse_Require, - "Route": parse_Route, - "route_param": parse_route_param, - "Subscription_State": parse_Subscription_State, - "substate_value": parse_substate_value, - "subexp_params": parse_subexp_params, - "event_reason_value": parse_event_reason_value, - "Subject": parse_Subject, - "Supported": parse_Supported, - "To": parse_To, - "to_param": parse_to_param, - "Via": parse_Via, - "via_parm": parse_via_parm, - "via_params": parse_via_params, - "via_ttl": parse_via_ttl, - "via_maddr": parse_via_maddr, - "via_received": parse_via_received, - "via_branch": parse_via_branch, - "response_port": parse_response_port, - "sent_protocol": parse_sent_protocol, - "protocol_name": parse_protocol_name, - "transport": parse_transport, - "sent_by": parse_sent_by, - "via_host": parse_via_host, - "via_port": parse_via_port, - "ttl": parse_ttl, - "WWW_Authenticate": parse_WWW_Authenticate, - "extension_header": parse_extension_header, - "header_value": parse_header_value, - "message_body": parse_message_body, - "stun_URI": parse_stun_URI, - "stun_scheme": parse_stun_scheme, - "stun_host_port": parse_stun_host_port, - "stun_host": parse_stun_host, - "reg_name": parse_reg_name, - "stun_unreserved": parse_stun_unreserved, - "sub_delims": parse_sub_delims, - "turn_URI": parse_turn_URI, - "turn_scheme": parse_turn_scheme, - "turn_transport": parse_turn_transport - }; - - if (startRule !== undefined) { - if (parseFunctions[startRule] === undefined) { - throw new Error("Invalid rule name: " + quote(startRule) + "."); - } - } else { - startRule = "CRLF"; - } - - var pos = 0; - var reportFailures = 0; - var rightmostFailuresPos = 0; - var rightmostFailuresExpected = []; - - function padLeft(input, padding, length) { - var result = input; - - var padLength = length - input.length; - for (var i = 0; i < padLength; i++) { - result = padding + result; - } - - return result; - } - - function escape(ch) { - var charCode = ch.charCodeAt(0); - var escapeChar; - var length; - - if (charCode <= 0xFF) { - escapeChar = 'x'; - length = 2; - } else { - escapeChar = 'u'; - length = 4; - } - - return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); - } - - function matchFailed(failure) { - if (pos < rightmostFailuresPos) { - return; - } - - if (pos > rightmostFailuresPos) { - rightmostFailuresPos = pos; - rightmostFailuresExpected = []; - } - - rightmostFailuresExpected.push(failure); - } - - function parse_CRLF() { - var result0; - - if (input.substr(pos, 2) === "\r\n") { - result0 = "\r\n"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\r\\n\""); - } - } - return result0; - } - - function parse_DIGIT() { - var result0; - - if (/^[0-9]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[0-9]"); - } - } - return result0; - } - - function parse_ALPHA() { - var result0; - - if (/^[a-zA-Z]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z]"); - } - } - return result0; - } - - function parse_HEXDIG() { - var result0; - - if (/^[0-9a-fA-F]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[0-9a-fA-F]"); - } - } - return result0; - } - - function parse_WSP() { - var result0; - - result0 = parse_SP(); - if (result0 === null) { - result0 = parse_HTAB(); - } - return result0; - } - - function parse_OCTET() { - var result0; - - if (/^[\0-\xFF]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\0-\\xFF]"); - } - } - return result0; - } - - function parse_DQUOTE() { - var result0; - - if (/^["]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\"]"); - } - } - return result0; - } - - function parse_SP() { - var result0; - - if (input.charCodeAt(pos) === 32) { - result0 = " "; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\" \""); - } - } - return result0; - } - - function parse_HTAB() { - var result0; - - if (input.charCodeAt(pos) === 9) { - result0 = "\t"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\t\""); - } - } - return result0; - } - - function parse_alphanum() { - var result0; - - if (/^[a-zA-Z0-9]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z0-9]"); - } - } - return result0; - } - - function parse_reserved() { - var result0; - - if (input.charCodeAt(pos) === 59) { - result0 = ";"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 63) { - result0 = "?"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 64) { - result0 = "@"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 38) { - result0 = "&"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_unreserved() { - var result0; - - result0 = parse_alphanum(); - if (result0 === null) { - result0 = parse_mark(); - } - return result0; - } - - function parse_mark() { - var result0; - - if (input.charCodeAt(pos) === 45) { - result0 = "-"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 95) { - result0 = "_"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 46) { - result0 = "."; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 33) { - result0 = "!"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 126) { - result0 = "~"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 42) { - result0 = "*"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 39) { - result0 = "'"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 40) { - result0 = "("; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 41) { - result0 = ")"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_escaped() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 37) { - result0 = "%"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result0 !== null) { - result1 = parse_HEXDIG(); - if (result1 !== null) { - result2 = parse_HEXDIG(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, escaped) {return escaped.join(''); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_LWS() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - pos2 = pos; - result0 = []; - result1 = parse_WSP(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_WSP(); - } - if (result0 !== null) { - result1 = parse_CRLF(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos2; - } - } else { - result0 = null; - pos = pos2; - } - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result2 = parse_WSP(); - if (result2 !== null) { - result1 = []; - while (result2 !== null) { - result1.push(result2); - result2 = parse_WSP(); - } - } else { - result1 = null; - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return " "; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_SWS() { - var result0; - - result0 = parse_LWS(); - result0 = result0 !== null ? result0 : ""; - return result0; - } - - function parse_HCOLON() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = []; - result1 = parse_SP(); - if (result1 === null) { - result1 = parse_HTAB(); - } - while (result1 !== null) { - result0.push(result1); - result1 = parse_SP(); - if (result1 === null) { - result1 = parse_HTAB(); - } - } - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return ':'; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_TEXT_UTF8_TRIM() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result1 = parse_TEXT_UTF8char(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_TEXT_UTF8char(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = []; - result3 = parse_LWS(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_LWS(); - } - if (result2 !== null) { - result3 = parse_TEXT_UTF8char(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = []; - result3 = parse_LWS(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_LWS(); - } - if (result2 !== null) { - result3 = parse_TEXT_UTF8char(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_TEXT_UTF8char() { - var result0; - - if (/^[!-~]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[!-~]"); - } - } - if (result0 === null) { - result0 = parse_UTF8_NONASCII(); - } - return result0; - } - - function parse_UTF8_NONASCII() { - var result0; - - if (/^[\x80-\uFFFF]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\x80-\\uFFFF]"); - } - } - return result0; - } - - function parse_UTF8_CONT() { - var result0; - - if (/^[\x80-\xBF]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\x80-\\xBF]"); - } - } - return result0; - } - - function parse_LHEX() { - var result0; - - result0 = parse_DIGIT(); - if (result0 === null) { - if (/^[a-f]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[a-f]"); - } - } - } - return result0; - } - - function parse_token() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_alphanum(); - if (result1 === null) { - if (input.charCodeAt(pos) === 45) { - result1 = "-"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 33) { - result1 = "!"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 37) { - result1 = "%"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 95) { - result1 = "_"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 96) { - result1 = "`"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 39) { - result1 = "'"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 126) { - result1 = "~"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - } - } - } - } - } - } - } - } - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_alphanum(); - if (result1 === null) { - if (input.charCodeAt(pos) === 45) { - result1 = "-"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 33) { - result1 = "!"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 37) { - result1 = "%"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 95) { - result1 = "_"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 96) { - result1 = "`"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 39) { - result1 = "'"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 126) { - result1 = "~"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - } - } - } - } - } - } - } - } - } - } - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_token_nodot() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_alphanum(); - if (result1 === null) { - if (input.charCodeAt(pos) === 45) { - result1 = "-"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 33) { - result1 = "!"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 37) { - result1 = "%"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 95) { - result1 = "_"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 96) { - result1 = "`"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 39) { - result1 = "'"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 126) { - result1 = "~"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - } - } - } - } - } - } - } - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_alphanum(); - if (result1 === null) { - if (input.charCodeAt(pos) === 45) { - result1 = "-"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 33) { - result1 = "!"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 37) { - result1 = "%"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 95) { - result1 = "_"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 96) { - result1 = "`"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 39) { - result1 = "'"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 126) { - result1 = "~"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - } - } - } - } - } - } - } - } - } - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_separators() { - var result0; - - if (input.charCodeAt(pos) === 40) { - result0 = "("; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 41) { - result0 = ")"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 60) { - result0 = "<"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"<\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 62) { - result0 = ">"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\">\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 64) { - result0 = "@"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 59) { - result0 = ";"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 92) { - result0 = "\\"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\""); - } - } - if (result0 === null) { - result0 = parse_DQUOTE(); - if (result0 === null) { - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 91) { - result0 = "["; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 93) { - result0 = "]"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 63) { - result0 = "?"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 123) { - result0 = "{"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"{\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 125) { - result0 = "}"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"}\""); - } - } - if (result0 === null) { - result0 = parse_SP(); - if (result0 === null) { - result0 = parse_HTAB(); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_word() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_alphanum(); - if (result1 === null) { - if (input.charCodeAt(pos) === 45) { - result1 = "-"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 33) { - result1 = "!"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 37) { - result1 = "%"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 95) { - result1 = "_"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 96) { - result1 = "`"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 39) { - result1 = "'"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 126) { - result1 = "~"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 40) { - result1 = "("; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 41) { - result1 = ")"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 60) { - result1 = "<"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"<\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 62) { - result1 = ">"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\">\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 92) { - result1 = "\\"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\""); - } - } - if (result1 === null) { - result1 = parse_DQUOTE(); - if (result1 === null) { - if (input.charCodeAt(pos) === 47) { - result1 = "/"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 91) { - result1 = "["; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 93) { - result1 = "]"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 63) { - result1 = "?"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 123) { - result1 = "{"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"{\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 125) { - result1 = "}"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"}\""); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_alphanum(); - if (result1 === null) { - if (input.charCodeAt(pos) === 45) { - result1 = "-"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 33) { - result1 = "!"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 37) { - result1 = "%"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"%\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 95) { - result1 = "_"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 96) { - result1 = "`"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"`\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 39) { - result1 = "'"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 126) { - result1 = "~"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 40) { - result1 = "("; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 41) { - result1 = ")"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 60) { - result1 = "<"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"<\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 62) { - result1 = ">"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\">\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 92) { - result1 = "\\"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\""); - } - } - if (result1 === null) { - result1 = parse_DQUOTE(); - if (result1 === null) { - if (input.charCodeAt(pos) === 47) { - result1 = "/"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 91) { - result1 = "["; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 93) { - result1 = "]"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 63) { - result1 = "?"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 123) { - result1 = "{"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"{\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 125) { - result1 = "}"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"}\""); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_STAR() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 42) { - result1 = "*"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "*"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_SLASH() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 47) { - result1 = "/"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "/"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_EQUAL() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "="; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_LPAREN() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 40) { - result1 = "("; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "("; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_RPAREN() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 41) { - result1 = ")"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return ")"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_RAQUOT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 62) { - result0 = ">"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\">\""); - } - } - if (result0 !== null) { - result1 = parse_SWS(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return ">"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_LAQUOT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 60) { - result1 = "<"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"<\""); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "<"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_COMMA() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 44) { - result1 = ","; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return ","; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_SEMI() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 59) { - result1 = ";"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return ";"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_COLON() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_SWS(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return ":"; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_LDQUOT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - result1 = parse_DQUOTE(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "\""; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_RDQUOT() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_DQUOTE(); - if (result0 !== null) { - result1 = parse_SWS(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) {return "\""; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_comment() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_LPAREN(); - if (result0 !== null) { - result1 = []; - result2 = parse_ctext(); - if (result2 === null) { - result2 = parse_quoted_pair(); - if (result2 === null) { - result2 = parse_comment(); - } - } - while (result2 !== null) { - result1.push(result2); - result2 = parse_ctext(); - if (result2 === null) { - result2 = parse_quoted_pair(); - if (result2 === null) { - result2 = parse_comment(); - } - } - } - if (result1 !== null) { - result2 = parse_RPAREN(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_ctext() { - var result0; - - if (/^[!-']/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[!-']"); - } - } - if (result0 === null) { - if (/^[*-[]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[*-[]"); - } - } - if (result0 === null) { - if (/^[\]-~]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\]-~]"); - } - } - if (result0 === null) { - result0 = parse_UTF8_NONASCII(); - if (result0 === null) { - result0 = parse_LWS(); - } - } - } - } - return result0; - } - - function parse_quoted_string() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - result1 = parse_DQUOTE(); - if (result1 !== null) { - result2 = []; - result3 = parse_qdtext(); - if (result3 === null) { - result3 = parse_quoted_pair(); - } - while (result3 !== null) { - result2.push(result3); - result3 = parse_qdtext(); - if (result3 === null) { - result3 = parse_quoted_pair(); - } - } - if (result2 !== null) { - result3 = parse_DQUOTE(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_quoted_string_clean() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_SWS(); - if (result0 !== null) { - result1 = parse_DQUOTE(); - if (result1 !== null) { - result2 = []; - result3 = parse_qdtext(); - if (result3 === null) { - result3 = parse_quoted_pair(); - } - while (result3 !== null) { - result2.push(result3); - result3 = parse_qdtext(); - if (result3 === null) { - result3 = parse_quoted_pair(); - } - } - if (result2 !== null) { - result3 = parse_DQUOTE(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos-1, offset+1); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_qdtext() { - var result0; - - result0 = parse_LWS(); - if (result0 === null) { - if (input.charCodeAt(pos) === 33) { - result0 = "!"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result0 === null) { - if (/^[#-[]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[#-[]"); - } - } - if (result0 === null) { - if (/^[\]-~]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[\\]-~]"); - } - } - if (result0 === null) { - result0 = parse_UTF8_NONASCII(); - } - } - } - } - return result0; - } - - function parse_quoted_pair() { - var result0, result1; - var pos0; - - pos0 = pos; - if (input.charCodeAt(pos) === 92) { - result0 = "\\"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"\\\\\""); - } - } - if (result0 !== null) { - if (/^[\0-\t]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\0-\\t]"); - } - } - if (result1 === null) { - if (/^[\x0B-\f]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\x0B-\\f]"); - } - } - if (result1 === null) { - if (/^[\x0E-]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[\\x0E-]"); - } - } - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_SIP_URI_noparams() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_uri_scheme(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_userinfo(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse_hostport(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - try { - data.uri = new JsSIP.URI(data.scheme, data.user, data.host, data.port); - delete data.scheme; - delete data.user; - delete data.host; - delete data.host_type; - delete data.port; - } catch(e) { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_SIP_URI() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_uri_scheme(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_userinfo(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse_hostport(); - if (result3 !== null) { - result4 = parse_uri_parameters(); - if (result4 !== null) { - result5 = parse_headers(); - result5 = result5 !== null ? result5 : ""; - if (result5 !== null) { - result0 = [result0, result1, result2, result3, result4, result5]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - var header; - try { - data.uri = new JsSIP.URI(data.scheme, data.user, data.host, data.port, data.uri_params, data.uri_headers); - delete data.scheme; - delete data.user; - delete data.host; - delete data.host_type; - delete data.port; - delete data.uri_params; - - if (startRule === 'SIP_URI') { data = data.uri;} - } catch(e) { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_uri_scheme() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 3).toLowerCase() === "sip") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"sip\""); - } - } - if (result0 !== null) { - result0 = (function(offset, uri_scheme) { - data.scheme = uri_scheme.toLowerCase(); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_userinfo() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_user(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_password(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - if (input.charCodeAt(pos) === 64) { - result2 = "@"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.user = window.decodeURIComponent(input.substring(pos-1, offset));})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_user() { - var result0, result1; - - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - result1 = parse_user_unreserved(); - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - result1 = parse_user_unreserved(); - } - } - } - } else { - result0 = null; - } - return result0; - } - - function parse_user_unreserved() { - var result0; - - if (input.charCodeAt(pos) === 38) { - result0 = "&"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 59) { - result0 = ";"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 63) { - result0 = "?"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_password() { - var result0, result1; - var pos0; - - pos0 = pos; - result0 = []; - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - if (input.charCodeAt(pos) === 38) { - result1 = "&"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 36) { - result1 = "$"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 44) { - result1 = ","; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - } - } - } - } - } - } - while (result1 !== null) { - result0.push(result1); - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - if (input.charCodeAt(pos) === 38) { - result1 = "&"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 36) { - result1 = "$"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 44) { - result1 = ","; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - } - } - } - } - } - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.password = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_hostport() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - result0 = parse_host(); - if (result0 !== null) { - pos1 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_port(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_host() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_hostname(); - if (result0 === null) { - result0 = parse_IPv4address(); - if (result0 === null) { - result0 = parse_IPv6reference(); - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.host = input.substring(pos, offset).toLowerCase(); - return data.host; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_hostname() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = []; - pos2 = pos; - result1 = parse_domainlabel(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - while (result1 !== null) { - result0.push(result1); - pos2 = pos; - result1 = parse_domainlabel(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - } - if (result0 !== null) { - result1 = parse_toplabel(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.host_type = 'domain'; - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_domainlabel() { - var result0, result1; - - if (/^[a-zA-Z0-9_\-]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z0-9_\\-]"); - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[a-zA-Z0-9_\-]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z0-9_\\-]"); - } - } - } - } else { - result0 = null; - } - return result0; - } - - function parse_toplabel() { - var result0, result1; - - if (/^[a-zA-Z_\-]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z_\\-]"); - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - if (/^[a-zA-Z_\-]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[a-zA-Z_\\-]"); - } - } - } - } else { - result0 = null; - } - return result0; - } - - function parse_IPv6reference() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 91) { - result0 = "["; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - if (result0 !== null) { - result1 = parse_IPv6address(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 93) { - result2 = "]"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.host_type = 'IPv6'; - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_IPv6address() { - var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - result6 = parse_h16(); - if (result6 !== null) { - if (input.charCodeAt(pos) === 58) { - result7 = ":"; - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result7 !== null) { - result8 = parse_h16(); - if (result8 !== null) { - if (input.charCodeAt(pos) === 58) { - result9 = ":"; - pos++; - } else { - result9 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result9 !== null) { - result10 = parse_h16(); - if (result10 !== null) { - if (input.charCodeAt(pos) === 58) { - result11 = ":"; - pos++; - } else { - result11 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result11 !== null) { - result12 = parse_ls32(); - if (result12 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_h16(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - if (input.charCodeAt(pos) === 58) { - result6 = ":"; - pos++; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - result7 = parse_h16(); - if (result7 !== null) { - if (input.charCodeAt(pos) === 58) { - result8 = ":"; - pos++; - } else { - result8 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result8 !== null) { - result9 = parse_h16(); - if (result9 !== null) { - if (input.charCodeAt(pos) === 58) { - result10 = ":"; - pos++; - } else { - result10 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result10 !== null) { - result11 = parse_ls32(); - if (result11 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_h16(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - if (input.charCodeAt(pos) === 58) { - result6 = ":"; - pos++; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - result7 = parse_h16(); - if (result7 !== null) { - if (input.charCodeAt(pos) === 58) { - result8 = ":"; - pos++; - } else { - result8 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result8 !== null) { - result9 = parse_ls32(); - if (result9 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_h16(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - if (input.charCodeAt(pos) === 58) { - result6 = ":"; - pos++; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - result7 = parse_ls32(); - if (result7 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_h16(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_ls32(); - if (result5 !== null) { - result0 = [result0, result1, result2, result3, result4, result5]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_h16(); - if (result1 !== null) { - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_ls32(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_ls32(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - if (input.substr(pos, 2) === "::") { - result0 = "::"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result0 !== null) { - result1 = parse_h16(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - if (input.substr(pos, 2) === "::") { - result1 = "::"; - pos += 2; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - result6 = parse_h16(); - if (result6 !== null) { - if (input.charCodeAt(pos) === 58) { - result7 = ":"; - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result7 !== null) { - result8 = parse_h16(); - if (result8 !== null) { - if (input.charCodeAt(pos) === 58) { - result9 = ":"; - pos++; - } else { - result9 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result9 !== null) { - result10 = parse_ls32(); - if (result10 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - if (input.substr(pos, 2) === "::") { - result2 = "::"; - pos += 2; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - if (input.charCodeAt(pos) === 58) { - result6 = ":"; - pos++; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - result7 = parse_h16(); - if (result7 !== null) { - if (input.charCodeAt(pos) === 58) { - result8 = ":"; - pos++; - } else { - result8 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result8 !== null) { - result9 = parse_ls32(); - if (result9 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - if (input.substr(pos, 2) === "::") { - result3 = "::"; - pos += 2; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - result6 = parse_h16(); - if (result6 !== null) { - if (input.charCodeAt(pos) === 58) { - result7 = ":"; - pos++; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result7 !== null) { - result8 = parse_ls32(); - if (result8 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos2; - } - } else { - result3 = null; - pos = pos2; - } - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - if (input.substr(pos, 2) === "::") { - result4 = "::"; - pos += 2; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - if (input.charCodeAt(pos) === 58) { - result6 = ":"; - pos++; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - result7 = parse_ls32(); - if (result7 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos2; - } - } else { - result3 = null; - pos = pos2; - } - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos2; - } - } else { - result4 = null; - pos = pos2; - } - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - if (input.substr(pos, 2) === "::") { - result5 = "::"; - pos += 2; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result5 !== null) { - result6 = parse_ls32(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos2; - } - } else { - result3 = null; - pos = pos2; - } - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos2; - } - } else { - result4 = null; - pos = pos2; - } - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - result6 = parse_h16(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos2; - } - } else { - result5 = null; - pos = pos2; - } - result5 = result5 !== null ? result5 : ""; - if (result5 !== null) { - if (input.substr(pos, 2) === "::") { - result6 = "::"; - pos += 2; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result6 !== null) { - result7 = parse_h16(); - if (result7 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - pos1 = pos; - result0 = parse_h16(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result2 = ":"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result2 !== null) { - result3 = parse_h16(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result3 = ":"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result3 !== null) { - result4 = parse_h16(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos2; - } - } else { - result3 = null; - pos = pos2; - } - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result4 = ":"; - pos++; - } else { - result4 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result4 !== null) { - result5 = parse_h16(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos2; - } - } else { - result4 = null; - pos = pos2; - } - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result5 = ":"; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result5 !== null) { - result6 = parse_h16(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos2; - } - } else { - result5 = null; - pos = pos2; - } - result5 = result5 !== null ? result5 : ""; - if (result5 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 58) { - result6 = ":"; - pos++; - } else { - result6 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result6 !== null) { - result7 = parse_h16(); - if (result7 !== null) { - result6 = [result6, result7]; - } else { - result6 = null; - pos = pos2; - } - } else { - result6 = null; - pos = pos2; - } - result6 = result6 !== null ? result6 : ""; - if (result6 !== null) { - if (input.substr(pos, 2) === "::") { - result7 = "::"; - pos += 2; - } else { - result7 = null; - if (reportFailures === 0) { - matchFailed("\"::\""); - } - } - if (result7 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6, result7]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.host_type = 'IPv6'; - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_h16() { - var result0, result1, result2, result3; - var pos0; - - pos0 = pos; - result0 = parse_HEXDIG(); - if (result0 !== null) { - result1 = parse_HEXDIG(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result2 = parse_HEXDIG(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse_HEXDIG(); - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_ls32() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_h16(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_h16(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - result0 = parse_IPv4address(); - } - return result0; - } - - function parse_IPv4address() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_dec_octet(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 !== null) { - result2 = parse_dec_octet(); - if (result2 !== null) { - if (input.charCodeAt(pos) === 46) { - result3 = "."; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result3 !== null) { - result4 = parse_dec_octet(); - if (result4 !== null) { - if (input.charCodeAt(pos) === 46) { - result5 = "."; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result5 !== null) { - result6 = parse_dec_octet(); - if (result6 !== null) { - result0 = [result0, result1, result2, result3, result4, result5, result6]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.host_type = 'IPv4'; - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_dec_octet() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - if (input.substr(pos, 2) === "25") { - result0 = "25"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"25\""); - } - } - if (result0 !== null) { - if (/^[0-5]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[0-5]"); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.charCodeAt(pos) === 50) { - result0 = "2"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"2\""); - } - } - if (result0 !== null) { - if (/^[0-4]/.test(input.charAt(pos))) { - result1 = input.charAt(pos); - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("[0-4]"); - } - } - if (result1 !== null) { - result2 = parse_DIGIT(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (input.charCodeAt(pos) === 49) { - result0 = "1"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"1\""); - } - } - if (result0 !== null) { - result1 = parse_DIGIT(); - if (result1 !== null) { - result2 = parse_DIGIT(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - if (/^[1-9]/.test(input.charAt(pos))) { - result0 = input.charAt(pos); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("[1-9]"); - } - } - if (result0 !== null) { - result1 = parse_DIGIT(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - result0 = parse_DIGIT(); - } - } - } - } - return result0; - } - - function parse_port() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_DIGIT(); - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse_DIGIT(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result2 = parse_DIGIT(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse_DIGIT(); - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result4 = parse_DIGIT(); - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, port) { - port = parseInt(port.join('')); - data.port = port; - return port; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_uri_parameters() { - var result0, result1, result2; - var pos0; - - result0 = []; - pos0 = pos; - if (input.charCodeAt(pos) === 59) { - result1 = ";"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result1 !== null) { - result2 = parse_uri_parameter(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos0; - } - } else { - result1 = null; - pos = pos0; - } - while (result1 !== null) { - result0.push(result1); - pos0 = pos; - if (input.charCodeAt(pos) === 59) { - result1 = ";"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result1 !== null) { - result2 = parse_uri_parameter(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos0; - } - } else { - result1 = null; - pos = pos0; - } - } - return result0; - } - - function parse_uri_parameter() { - var result0; - - result0 = parse_transport_param(); - if (result0 === null) { - result0 = parse_user_param(); - if (result0 === null) { - result0 = parse_method_param(); - if (result0 === null) { - result0 = parse_ttl_param(); - if (result0 === null) { - result0 = parse_maddr_param(); - if (result0 === null) { - result0 = parse_lr_param(); - if (result0 === null) { - result0 = parse_other_param(); - } - } - } - } - } - } - return result0; - } - - function parse_transport_param() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 10).toLowerCase() === "transport=") { - result0 = input.substr(pos, 10); - pos += 10; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"transport=\""); - } - } - if (result0 !== null) { - if (input.substr(pos, 3).toLowerCase() === "udp") { - result1 = input.substr(pos, 3); - pos += 3; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"udp\""); - } - } - if (result1 === null) { - if (input.substr(pos, 3).toLowerCase() === "tcp") { - result1 = input.substr(pos, 3); - pos += 3; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"tcp\""); - } - } - if (result1 === null) { - if (input.substr(pos, 4).toLowerCase() === "sctp") { - result1 = input.substr(pos, 4); - pos += 4; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"sctp\""); - } - } - if (result1 === null) { - if (input.substr(pos, 3).toLowerCase() === "tls") { - result1 = input.substr(pos, 3); - pos += 3; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"tls\""); - } - } - if (result1 === null) { - result1 = parse_token(); - } - } - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, transport) { - if(!data.uri_params) data.uri_params={}; - data.uri_params['transport'] = transport.toLowerCase(); })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_user_param() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 5).toLowerCase() === "user=") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"user=\""); - } - } - if (result0 !== null) { - if (input.substr(pos, 5).toLowerCase() === "phone") { - result1 = input.substr(pos, 5); - pos += 5; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"phone\""); - } - } - if (result1 === null) { - if (input.substr(pos, 2).toLowerCase() === "ip") { - result1 = input.substr(pos, 2); - pos += 2; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"ip\""); - } - } - if (result1 === null) { - result1 = parse_token(); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, user) { - if(!data.uri_params) data.uri_params={}; - data.uri_params['user'] = user.toLowerCase(); })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_method_param() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 7).toLowerCase() === "method=") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"method=\""); - } - } - if (result0 !== null) { - result1 = parse_Method(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, method) { - if(!data.uri_params) data.uri_params={}; - data.uri_params['method'] = method; })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_ttl_param() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 4).toLowerCase() === "ttl=") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ttl=\""); - } - } - if (result0 !== null) { - result1 = parse_ttl(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, ttl) { - if(!data.params) data.params={}; - data.params['ttl'] = ttl; })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_maddr_param() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 6).toLowerCase() === "maddr=") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"maddr=\""); - } - } - if (result0 !== null) { - result1 = parse_host(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, maddr) { - if(!data.uri_params) data.uri_params={}; - data.uri_params['maddr'] = maddr; })(pos0, result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_lr_param() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 2).toLowerCase() === "lr") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"lr\""); - } - } - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 !== null) { - result2 = parse_token(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - if(!data.uri_params) data.uri_params={}; - data.uri_params['lr'] = undefined; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_other_param() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_pname(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 !== null) { - result2 = parse_pvalue(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, param, value) { - if(!data.uri_params) data.uri_params = {}; - if (typeof value === 'undefined'){ - value = undefined; - } - else { - value = value[1]; - } - data.uri_params[param.toLowerCase()] = value && value.toLowerCase();})(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_pname() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_paramchar(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_paramchar(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, pname) {return pname.join(''); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_pvalue() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_paramchar(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_paramchar(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, pvalue) {return pvalue.join(''); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_paramchar() { - var result0; - - result0 = parse_param_unreserved(); - if (result0 === null) { - result0 = parse_unreserved(); - if (result0 === null) { - result0 = parse_escaped(); - } - } - return result0; - } - - function parse_param_unreserved() { - var result0; - - if (input.charCodeAt(pos) === 91) { - result0 = "["; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 93) { - result0 = "]"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 38) { - result0 = "&"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - } - } - } - } - } - } - return result0; - } - - function parse_headers() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - if (input.charCodeAt(pos) === 63) { - result0 = "?"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result0 !== null) { - result1 = parse_header(); - if (result1 !== null) { - result2 = []; - pos1 = pos; - if (input.charCodeAt(pos) === 38) { - result3 = "&"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result3 !== null) { - result4 = parse_header(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos1; - } - } else { - result3 = null; - pos = pos1; - } - while (result3 !== null) { - result2.push(result3); - pos1 = pos; - if (input.charCodeAt(pos) === 38) { - result3 = "&"; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result3 !== null) { - result4 = parse_header(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos1; - } - } else { - result3 = null; - pos = pos1; - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_header() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_hname(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 !== null) { - result2 = parse_hvalue(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, hname, hvalue) { - hname = hname.join('').toLowerCase(); - hvalue = hvalue.join(''); - if(!data.uri_headers) data.uri_headers = {}; - if (!data.uri_headers[hname]) { - data.uri_headers[hname] = [hvalue]; - } else { - data.uri_headers[hname].push(hvalue); - }})(pos0, result0[0], result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_hname() { - var result0, result1; - - result1 = parse_hnv_unreserved(); - if (result1 === null) { - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_hnv_unreserved(); - if (result1 === null) { - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - } - } - } - } else { - result0 = null; - } - return result0; - } - - function parse_hvalue() { - var result0, result1; - - result0 = []; - result1 = parse_hnv_unreserved(); - if (result1 === null) { - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - } - } - while (result1 !== null) { - result0.push(result1); - result1 = parse_hnv_unreserved(); - if (result1 === null) { - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - } - } - } - return result0; - } - - function parse_hnv_unreserved() { - var result0; - - if (input.charCodeAt(pos) === 91) { - result0 = "["; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"[\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 93) { - result0 = "]"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"]\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 63) { - result0 = "?"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - } - } - } - } - } - } - return result0; - } - - function parse_Request_Response() { - var result0; - - result0 = parse_Status_Line(); - if (result0 === null) { - result0 = parse_Request_Line(); - } - return result0; - } - - function parse_Request_Line() { - var result0, result1, result2, result3, result4; - var pos0; - - pos0 = pos; - result0 = parse_Method(); - if (result0 !== null) { - result1 = parse_SP(); - if (result1 !== null) { - result2 = parse_Request_URI(); - if (result2 !== null) { - result3 = parse_SP(); - if (result3 !== null) { - result4 = parse_SIP_Version(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Request_URI() { - var result0; - - result0 = parse_SIP_URI(); - if (result0 === null) { - result0 = parse_absoluteURI(); - } - return result0; - } - - function parse_absoluteURI() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_scheme(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_hier_part(); - if (result2 === null) { - result2 = parse_opaque_part(); - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_hier_part() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - result0 = parse_net_path(); - if (result0 === null) { - result0 = parse_abs_path(); - } - if (result0 !== null) { - pos1 = pos; - if (input.charCodeAt(pos) === 63) { - result1 = "?"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result1 !== null) { - result2 = parse_query(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_net_path() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - if (input.substr(pos, 2) === "//") { - result0 = "//"; - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"//\""); - } - } - if (result0 !== null) { - result1 = parse_authority(); - if (result1 !== null) { - result2 = parse_abs_path(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_abs_path() { - var result0, result1; - var pos0; - - pos0 = pos; - if (input.charCodeAt(pos) === 47) { - result0 = "/"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result0 !== null) { - result1 = parse_path_segments(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_opaque_part() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_uric_no_slash(); - if (result0 !== null) { - result1 = []; - result2 = parse_uric(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_uric(); - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_uric() { - var result0; - - result0 = parse_reserved(); - if (result0 === null) { - result0 = parse_unreserved(); - if (result0 === null) { - result0 = parse_escaped(); - } - } - return result0; - } - - function parse_uric_no_slash() { - var result0; - - result0 = parse_unreserved(); - if (result0 === null) { - result0 = parse_escaped(); - if (result0 === null) { - if (input.charCodeAt(pos) === 59) { - result0 = ";"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 63) { - result0 = "?"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"?\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 64) { - result0 = "@"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 38) { - result0 = "&"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_path_segments() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_segment(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - if (input.charCodeAt(pos) === 47) { - result2 = "/"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result2 !== null) { - result3 = parse_segment(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - if (input.charCodeAt(pos) === 47) { - result2 = "/"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result2 !== null) { - result3 = parse_segment(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_segment() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = []; - result1 = parse_pchar(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_pchar(); - } - if (result0 !== null) { - result1 = []; - pos1 = pos; - if (input.charCodeAt(pos) === 59) { - result2 = ";"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result2 !== null) { - result3 = parse_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - if (input.charCodeAt(pos) === 59) { - result2 = ";"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result2 !== null) { - result3 = parse_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_param() { - var result0, result1; - - result0 = []; - result1 = parse_pchar(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_pchar(); - } - return result0; - } - - function parse_pchar() { - var result0; - - result0 = parse_unreserved(); - if (result0 === null) { - result0 = parse_escaped(); - if (result0 === null) { - if (input.charCodeAt(pos) === 58) { - result0 = ":"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 64) { - result0 = "@"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 38) { - result0 = "&"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_scheme() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_ALPHA(); - if (result0 !== null) { - result1 = []; - result2 = parse_ALPHA(); - if (result2 === null) { - result2 = parse_DIGIT(); - if (result2 === null) { - if (input.charCodeAt(pos) === 43) { - result2 = "+"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result2 === null) { - if (input.charCodeAt(pos) === 45) { - result2 = "-"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result2 === null) { - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - } - } - } - } - while (result2 !== null) { - result1.push(result2); - result2 = parse_ALPHA(); - if (result2 === null) { - result2 = parse_DIGIT(); - if (result2 === null) { - if (input.charCodeAt(pos) === 43) { - result2 = "+"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result2 === null) { - if (input.charCodeAt(pos) === 45) { - result2 = "-"; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result2 === null) { - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - } - } - } - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.scheme= input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_authority() { - var result0; - - result0 = parse_srvr(); - if (result0 === null) { - result0 = parse_reg_name(); - } - return result0; - } - - function parse_srvr() { - var result0, result1; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_userinfo(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 64) { - result1 = "@"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse_hostport(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - result0 = result0 !== null ? result0 : ""; - return result0; - } - - function parse_reg_name() { - var result0, result1; - - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - if (input.charCodeAt(pos) === 36) { - result1 = "$"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 44) { - result1 = ","; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 59) { - result1 = ";"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 64) { - result1 = "@"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 38) { - result1 = "&"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - } - } - } - } - } - } - } - } - } - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - if (input.charCodeAt(pos) === 36) { - result1 = "$"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 44) { - result1 = ","; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 59) { - result1 = ";"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 64) { - result1 = "@"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 38) { - result1 = "&"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 61) { - result1 = "="; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - if (result1 === null) { - if (input.charCodeAt(pos) === 43) { - result1 = "+"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - } - } - } - } - } - } - } - } - } - } - } else { - result0 = null; - } - return result0; - } - - function parse_query() { - var result0, result1; - - result0 = []; - result1 = parse_uric(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_uric(); - } - return result0; - } - - function parse_SIP_Version() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "sip") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SIP\""); - } - } - if (result0 !== null) { - if (input.charCodeAt(pos) === 47) { - result1 = "/"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"/\""); - } - } - if (result1 !== null) { - result3 = parse_DIGIT(); - if (result3 !== null) { - result2 = []; - while (result3 !== null) { - result2.push(result3); - result3 = parse_DIGIT(); - } - } else { - result2 = null; - } - if (result2 !== null) { - if (input.charCodeAt(pos) === 46) { - result3 = "."; - pos++; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result3 !== null) { - result5 = parse_DIGIT(); - if (result5 !== null) { - result4 = []; - while (result5 !== null) { - result4.push(result5); - result5 = parse_DIGIT(); - } - } else { - result4 = null; - } - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.sip_version = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_INVITEm() { - var result0; - - if (input.substr(pos, 6) === "INVITE") { - result0 = "INVITE"; - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"INVITE\""); - } - } - return result0; - } - - function parse_ACKm() { - var result0; - - if (input.substr(pos, 3) === "ACK") { - result0 = "ACK"; - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ACK\""); - } - } - return result0; - } - - function parse_OPTIONSm() { - var result0; - - if (input.substr(pos, 7) === "OPTIONS") { - result0 = "OPTIONS"; - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"OPTIONS\""); - } - } - return result0; - } - - function parse_BYEm() { - var result0; - - if (input.substr(pos, 3) === "BYE") { - result0 = "BYE"; - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"BYE\""); - } - } - return result0; - } - - function parse_CANCELm() { - var result0; - - if (input.substr(pos, 6) === "CANCEL") { - result0 = "CANCEL"; - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"CANCEL\""); - } - } - return result0; - } - - function parse_REGISTERm() { - var result0; - - if (input.substr(pos, 8) === "REGISTER") { - result0 = "REGISTER"; - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"REGISTER\""); - } - } - return result0; - } - - function parse_SUBSCRIBEm() { - var result0; - - if (input.substr(pos, 9) === "SUBSCRIBE") { - result0 = "SUBSCRIBE"; - pos += 9; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SUBSCRIBE\""); - } - } - return result0; - } - - function parse_NOTIFYm() { - var result0; - - if (input.substr(pos, 6) === "NOTIFY") { - result0 = "NOTIFY"; - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"NOTIFY\""); - } - } - return result0; - } - - function parse_Method() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_INVITEm(); - if (result0 === null) { - result0 = parse_ACKm(); - if (result0 === null) { - result0 = parse_OPTIONSm(); - if (result0 === null) { - result0 = parse_BYEm(); - if (result0 === null) { - result0 = parse_CANCELm(); - if (result0 === null) { - result0 = parse_REGISTERm(); - if (result0 === null) { - result0 = parse_SUBSCRIBEm(); - if (result0 === null) { - result0 = parse_NOTIFYm(); - if (result0 === null) { - result0 = parse_token(); - } - } - } - } - } - } - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.method = input.substring(pos, offset); - return data.method; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Status_Line() { - var result0, result1, result2, result3, result4; - var pos0; - - pos0 = pos; - result0 = parse_SIP_Version(); - if (result0 !== null) { - result1 = parse_SP(); - if (result1 !== null) { - result2 = parse_Status_Code(); - if (result2 !== null) { - result3 = parse_SP(); - if (result3 !== null) { - result4 = parse_Reason_Phrase(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Status_Code() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_extension_code(); - if (result0 !== null) { - result0 = (function(offset, status_code) { - data.status_code = parseInt(status_code.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_extension_code() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_DIGIT(); - if (result0 !== null) { - result1 = parse_DIGIT(); - if (result1 !== null) { - result2 = parse_DIGIT(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Reason_Phrase() { - var result0, result1; - var pos0; - - pos0 = pos; - result0 = []; - result1 = parse_reserved(); - if (result1 === null) { - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - result1 = parse_UTF8_NONASCII(); - if (result1 === null) { - result1 = parse_UTF8_CONT(); - if (result1 === null) { - result1 = parse_SP(); - if (result1 === null) { - result1 = parse_HTAB(); - } - } - } - } - } - } - while (result1 !== null) { - result0.push(result1); - result1 = parse_reserved(); - if (result1 === null) { - result1 = parse_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - result1 = parse_UTF8_NONASCII(); - if (result1 === null) { - result1 = parse_UTF8_CONT(); - if (result1 === null) { - result1 = parse_SP(); - if (result1 === null) { - result1 = parse_HTAB(); - } - } - } - } - } - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.reason_phrase = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Allow_Events() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_event_type(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_event_type(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_event_type(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Call_ID() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_word(); - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 64) { - result1 = "@"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"@\""); - } - } - if (result1 !== null) { - result2 = parse_word(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Contact() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - result0 = parse_STAR(); - if (result0 === null) { - pos1 = pos; - result0 = parse_contact_param(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_contact_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_contact_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } - if (result0 !== null) { - result0 = (function(offset) { - var idx, length; - length = data.multi_header.length; - for (idx = 0; idx < length; idx++) { - if (data.multi_header[idx].parsed === null) { - data = null; - break; - } - } - if (data !== null) { - data = data.multi_header; - } else { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_contact_param() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_SIP_URI_noparams(); - if (result0 === null) { - result0 = parse_name_addr(); - } - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_contact_params(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_contact_params(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - var header; - if(!data.multi_header) data.multi_header = []; - try { - header = new JsSIP.NameAddrHeader(data.uri, data.display_name, data.params); - delete data.uri; - delete data.display_name; - delete data.params; - } catch(e) { - header = null; - } - data.multi_header.push( { 'possition': pos, - 'offset': offset, - 'parsed': header - });})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_name_addr() { - var result0, result1, result2, result3; - var pos0; - - pos0 = pos; - result0 = parse_display_name(); - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse_LAQUOT(); - if (result1 !== null) { - result2 = parse_SIP_URI(); - if (result2 !== null) { - result3 = parse_RAQUOT(); - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_display_name() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_LWS(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_LWS(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 === null) { - result0 = parse_quoted_string(); - } - if (result0 !== null) { - result0 = (function(offset, display_name) { - display_name = input.substring(pos, offset).trim(); - if (display_name[0] === '\"') { - display_name = display_name.substring(1, display_name.length-1); - } - data.display_name = display_name; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_contact_params() { - var result0; - - result0 = parse_c_p_q(); - if (result0 === null) { - result0 = parse_c_p_expires(); - if (result0 === null) { - result0 = parse_generic_param(); - } - } - return result0; - } - - function parse_c_p_q() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 1).toLowerCase() === "q") { - result0 = input.substr(pos, 1); - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"q\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_qvalue(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, q) { - if(!data.params) data.params = {}; - data.params['q'] = q; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_c_p_expires() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 7).toLowerCase() === "expires") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"expires\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_delta_seconds(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, expires) { - if(!data.params) data.params = {}; - data.params['expires'] = expires; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_delta_seconds() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_DIGIT(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_DIGIT(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, delta_seconds) { - return parseInt(delta_seconds.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_qvalue() { - var result0, result1, result2, result3, result4; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.charCodeAt(pos) === 48) { - result0 = "0"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"0\""); - } - } - if (result0 !== null) { - pos2 = pos; - if (input.charCodeAt(pos) === 46) { - result1 = "."; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result1 !== null) { - result2 = parse_DIGIT(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse_DIGIT(); - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result4 = parse_DIGIT(); - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - result1 = [result1, result2, result3, result4]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - return parseFloat(input.substring(pos, offset)); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_generic_param() { - var result0, result1, result2; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_token(); - if (result0 !== null) { - pos2 = pos; - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_gen_value(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, param, value) { - if(!data.params) data.params = {}; - if (typeof value === 'undefined'){ - value = undefined; - } - else { - value = value[1]; - } - data.params[param.toLowerCase()] = value;})(pos0, result0[0], result0[1]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_gen_value() { - var result0; - - result0 = parse_token(); - if (result0 === null) { - result0 = parse_host(); - if (result0 === null) { - result0 = parse_quoted_string(); - } - } - return result0; - } - - function parse_Content_Disposition() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_disp_type(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_disp_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_disp_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_disp_type() { - var result0; - - if (input.substr(pos, 6).toLowerCase() === "render") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"render\""); - } - } - if (result0 === null) { - if (input.substr(pos, 7).toLowerCase() === "session") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"session\""); - } - } - if (result0 === null) { - if (input.substr(pos, 4).toLowerCase() === "icon") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"icon\""); - } - } - if (result0 === null) { - if (input.substr(pos, 5).toLowerCase() === "alert") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"alert\""); - } - } - if (result0 === null) { - result0 = parse_token(); - } - } - } - } - return result0; - } - - function parse_disp_param() { - var result0; - - result0 = parse_handling_param(); - if (result0 === null) { - result0 = parse_generic_param(); - } - return result0; - } - - function parse_handling_param() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - if (input.substr(pos, 8).toLowerCase() === "handling") { - result0 = input.substr(pos, 8); - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"handling\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - if (input.substr(pos, 8).toLowerCase() === "optional") { - result2 = input.substr(pos, 8); - pos += 8; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"optional\""); - } - } - if (result2 === null) { - if (input.substr(pos, 8).toLowerCase() === "required") { - result2 = input.substr(pos, 8); - pos += 8; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"required\""); - } - } - if (result2 === null) { - result2 = parse_token(); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Content_Encoding() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Content_Length() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_DIGIT(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_DIGIT(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, length) { - data = parseInt(length.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Content_Type() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_media_type(); - if (result0 !== null) { - result0 = (function(offset) { - data = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_media_type() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = pos; - result0 = parse_m_type(); - if (result0 !== null) { - result1 = parse_SLASH(); - if (result1 !== null) { - result2 = parse_m_subtype(); - if (result2 !== null) { - result3 = []; - pos1 = pos; - result4 = parse_SEMI(); - if (result4 !== null) { - result5 = parse_m_parameter(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - while (result4 !== null) { - result3.push(result4); - pos1 = pos; - result4 = parse_SEMI(); - if (result4 !== null) { - result5 = parse_m_parameter(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - } - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_m_type() { - var result0; - - result0 = parse_discrete_type(); - if (result0 === null) { - result0 = parse_composite_type(); - } - return result0; - } - - function parse_discrete_type() { - var result0; - - if (input.substr(pos, 4).toLowerCase() === "text") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"text\""); - } - } - if (result0 === null) { - if (input.substr(pos, 5).toLowerCase() === "image") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"image\""); - } - } - if (result0 === null) { - if (input.substr(pos, 5).toLowerCase() === "audio") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"audio\""); - } - } - if (result0 === null) { - if (input.substr(pos, 5).toLowerCase() === "video") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"video\""); - } - } - if (result0 === null) { - if (input.substr(pos, 11).toLowerCase() === "application") { - result0 = input.substr(pos, 11); - pos += 11; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"application\""); - } - } - if (result0 === null) { - result0 = parse_extension_token(); - } - } - } - } - } - return result0; - } - - function parse_composite_type() { - var result0; - - if (input.substr(pos, 7).toLowerCase() === "message") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"message\""); - } - } - if (result0 === null) { - if (input.substr(pos, 9).toLowerCase() === "multipart") { - result0 = input.substr(pos, 9); - pos += 9; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"multipart\""); - } - } - if (result0 === null) { - result0 = parse_extension_token(); - } - } - return result0; - } - - function parse_extension_token() { - var result0; - - result0 = parse_token(); - if (result0 === null) { - result0 = parse_x_token(); - } - return result0; - } - - function parse_x_token() { - var result0, result1; - var pos0; - - pos0 = pos; - if (input.substr(pos, 2).toLowerCase() === "x-") { - result0 = input.substr(pos, 2); - pos += 2; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"x-\""); - } - } - if (result0 !== null) { - result1 = parse_token(); - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_m_subtype() { - var result0; - - result0 = parse_extension_token(); - if (result0 === null) { - result0 = parse_token(); - } - return result0; - } - - function parse_m_parameter() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_m_value(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_m_value() { - var result0; - - result0 = parse_token(); - if (result0 === null) { - result0 = parse_quoted_string(); - } - return result0; - } - - function parse_CSeq() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_CSeq_value(); - if (result0 !== null) { - result1 = parse_LWS(); - if (result1 !== null) { - result2 = parse_Method(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_CSeq_value() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_DIGIT(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_DIGIT(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, cseq_value) { - data.value=parseInt(cseq_value.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Expires() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_delta_seconds(); - if (result0 !== null) { - result0 = (function(offset, expires) {data = expires; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Event() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_event_type(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_generic_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_generic_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, event_type) { - data.event = event_type.join('').toLowerCase(); })(pos0, result0[0]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_event_type() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_token_nodot(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result2 !== null) { - result3 = parse_token_nodot(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - if (input.charCodeAt(pos) === 46) { - result2 = "."; - pos++; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result2 !== null) { - result3 = parse_token_nodot(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_From() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_SIP_URI_noparams(); - if (result0 === null) { - result0 = parse_name_addr(); - } - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_from_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_from_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - var tag = data.tag; - try { - data = new JsSIP.NameAddrHeader(data.uri, data.display_name, data.params); - if (tag) {data.setParam('tag',tag)} - } catch(e) { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_from_param() { - var result0; - - result0 = parse_tag_param(); - if (result0 === null) { - result0 = parse_generic_param(); - } - return result0; - } - - function parse_tag_param() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "tag") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"tag\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_token(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, tag) {data.tag = tag; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Max_Forwards() { - var result0, result1; - var pos0; - - pos0 = pos; - result1 = parse_DIGIT(); - if (result1 !== null) { - result0 = []; - while (result1 !== null) { - result0.push(result1); - result1 = parse_DIGIT(); - } - } else { - result0 = null; - } - if (result0 !== null) { - result0 = (function(offset, forwards) { - data = parseInt(forwards.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Min_Expires() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_delta_seconds(); - if (result0 !== null) { - result0 = (function(offset, min_expires) {data = min_expires; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Name_Addr_Header() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = []; - result1 = parse_display_name(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_display_name(); - } - if (result0 !== null) { - result1 = parse_LAQUOT(); - if (result1 !== null) { - result2 = parse_SIP_URI(); - if (result2 !== null) { - result3 = parse_RAQUOT(); - if (result3 !== null) { - result4 = []; - pos2 = pos; - result5 = parse_SEMI(); - if (result5 !== null) { - result6 = parse_generic_param(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos2; - } - } else { - result5 = null; - pos = pos2; - } - while (result5 !== null) { - result4.push(result5); - pos2 = pos; - result5 = parse_SEMI(); - if (result5 !== null) { - result6 = parse_generic_param(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos2; - } - } else { - result5 = null; - pos = pos2; - } - } - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - try { - data = new JsSIP.NameAddrHeader(data.uri, data.display_name, data.params); - } catch(e) { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Proxy_Authenticate() { - var result0; - - result0 = parse_challenge(); - return result0; - } - - function parse_challenge() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "digest") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"Digest\""); - } - } - if (result0 !== null) { - result1 = parse_LWS(); - if (result1 !== null) { - result2 = parse_digest_cln(); - if (result2 !== null) { - result3 = []; - pos1 = pos; - result4 = parse_COMMA(); - if (result4 !== null) { - result5 = parse_digest_cln(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - while (result4 !== null) { - result3.push(result4); - pos1 = pos; - result4 = parse_COMMA(); - if (result4 !== null) { - result5 = parse_digest_cln(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - } - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - if (result0 === null) { - result0 = parse_other_challenge(); - } - return result0; - } - - function parse_other_challenge() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = parse_LWS(); - if (result1 !== null) { - result2 = parse_auth_param(); - if (result2 !== null) { - result3 = []; - pos1 = pos; - result4 = parse_COMMA(); - if (result4 !== null) { - result5 = parse_auth_param(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - while (result4 !== null) { - result3.push(result4); - pos1 = pos; - result4 = parse_COMMA(); - if (result4 !== null) { - result5 = parse_auth_param(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - } - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_auth_param() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_token(); - if (result2 === null) { - result2 = parse_quoted_string(); - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_digest_cln() { - var result0; - - result0 = parse_realm(); - if (result0 === null) { - result0 = parse_domain(); - if (result0 === null) { - result0 = parse_nonce(); - if (result0 === null) { - result0 = parse_opaque(); - if (result0 === null) { - result0 = parse_stale(); - if (result0 === null) { - result0 = parse_algorithm(); - if (result0 === null) { - result0 = parse_qop_options(); - if (result0 === null) { - result0 = parse_auth_param(); - } - } - } - } - } - } - } - return result0; - } - - function parse_realm() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "realm") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"realm\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_realm_value(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_realm_value() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_quoted_string_clean(); - if (result0 !== null) { - result0 = (function(offset, realm) { data.realm = realm; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_domain() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "domain") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"domain\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_LDQUOT(); - if (result2 !== null) { - result3 = parse_URI(); - if (result3 !== null) { - result4 = []; - pos1 = pos; - result6 = parse_SP(); - if (result6 !== null) { - result5 = []; - while (result6 !== null) { - result5.push(result6); - result6 = parse_SP(); - } - } else { - result5 = null; - } - if (result5 !== null) { - result6 = parse_URI(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos1; - } - } else { - result5 = null; - pos = pos1; - } - while (result5 !== null) { - result4.push(result5); - pos1 = pos; - result6 = parse_SP(); - if (result6 !== null) { - result5 = []; - while (result6 !== null) { - result5.push(result6); - result6 = parse_SP(); - } - } else { - result5 = null; - } - if (result5 !== null) { - result6 = parse_URI(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos1; - } - } else { - result5 = null; - pos = pos1; - } - } - if (result4 !== null) { - result5 = parse_RDQUOT(); - if (result5 !== null) { - result0 = [result0, result1, result2, result3, result4, result5]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_URI() { - var result0; - - result0 = parse_absoluteURI(); - if (result0 === null) { - result0 = parse_abs_path(); - } - return result0; - } - - function parse_nonce() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "nonce") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"nonce\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_nonce_value(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_nonce_value() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_quoted_string_clean(); - if (result0 !== null) { - result0 = (function(offset, nonce) { data.nonce=nonce; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_opaque() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 6).toLowerCase() === "opaque") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"opaque\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_quoted_string_clean(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, opaque) { data.opaque=opaque; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_stale() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "stale") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"stale\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - pos1 = pos; - if (input.substr(pos, 4).toLowerCase() === "true") { - result2 = input.substr(pos, 4); - pos += 4; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"true\""); - } - } - if (result2 !== null) { - result2 = (function(offset) { data.stale=true; })(pos1); - } - if (result2 === null) { - pos = pos1; - } - if (result2 === null) { - pos1 = pos; - if (input.substr(pos, 5).toLowerCase() === "false") { - result2 = input.substr(pos, 5); - pos += 5; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"false\""); - } - } - if (result2 !== null) { - result2 = (function(offset) { data.stale=false; })(pos1); - } - if (result2 === null) { - pos = pos1; - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_algorithm() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 9).toLowerCase() === "algorithm") { - result0 = input.substr(pos, 9); - pos += 9; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"algorithm\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - if (input.substr(pos, 3).toLowerCase() === "md5") { - result2 = input.substr(pos, 3); - pos += 3; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"MD5\""); - } - } - if (result2 === null) { - if (input.substr(pos, 8).toLowerCase() === "md5-sess") { - result2 = input.substr(pos, 8); - pos += 8; - } else { - result2 = null; - if (reportFailures === 0) { - matchFailed("\"MD5-sess\""); - } - } - if (result2 === null) { - result2 = parse_token(); - } - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, algorithm) { - data.algorithm=algorithm.toUpperCase(); })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_qop_options() { - var result0, result1, result2, result3, result4, result5, result6; - var pos0, pos1, pos2; - - pos0 = pos; - if (input.substr(pos, 3).toLowerCase() === "qop") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"qop\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_LDQUOT(); - if (result2 !== null) { - pos1 = pos; - result3 = parse_qop_value(); - if (result3 !== null) { - result4 = []; - pos2 = pos; - if (input.charCodeAt(pos) === 44) { - result5 = ","; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result5 !== null) { - result6 = parse_qop_value(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos2; - } - } else { - result5 = null; - pos = pos2; - } - while (result5 !== null) { - result4.push(result5); - pos2 = pos; - if (input.charCodeAt(pos) === 44) { - result5 = ","; - pos++; - } else { - result5 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result5 !== null) { - result6 = parse_qop_value(); - if (result6 !== null) { - result5 = [result5, result6]; - } else { - result5 = null; - pos = pos2; - } - } else { - result5 = null; - pos = pos2; - } - } - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos1; - } - } else { - result3 = null; - pos = pos1; - } - if (result3 !== null) { - result4 = parse_RDQUOT(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_qop_value() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 8).toLowerCase() === "auth-int") { - result0 = input.substr(pos, 8); - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"auth-int\""); - } - } - if (result0 === null) { - if (input.substr(pos, 4).toLowerCase() === "auth") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"auth\""); - } - } - if (result0 === null) { - result0 = parse_token(); - } - } - if (result0 !== null) { - result0 = (function(offset, qop_value) { - data.qop || (data.qop=[]); - data.qop.push(qop_value.toLowerCase()); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Proxy_Require() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Record_Route() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_rec_route(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_rec_route(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_rec_route(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - var idx, length; - length = data.multi_header.length; - for (idx = 0; idx < length; idx++) { - if (data.multi_header[idx].parsed === null) { - data = null; - break; - } - } - if (data !== null) { - data = data.multi_header; - } else { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_rec_route() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_name_addr(); - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_generic_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_generic_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - var header; - if(!data.multi_header) data.multi_header = []; - try { - header = new JsSIP.NameAddrHeader(data.uri, data.display_name, data.params); - delete data.uri; - delete data.display_name; - delete data.params; - } catch(e) { - header = null; - } - data.multi_header.push( { 'possition': pos, - 'offset': offset, - 'parsed': header - });})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_Require() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Route() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_route_param(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_route_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_route_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_route_param() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_name_addr(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_generic_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_generic_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_Subscription_State() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_substate_value(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_subexp_params(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_subexp_params(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_substate_value() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 6).toLowerCase() === "active") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"active\""); - } - } - if (result0 === null) { - if (input.substr(pos, 7).toLowerCase() === "pending") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"pending\""); - } - } - if (result0 === null) { - if (input.substr(pos, 10).toLowerCase() === "terminated") { - result0 = input.substr(pos, 10); - pos += 10; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"terminated\""); - } - } - if (result0 === null) { - result0 = parse_token(); - } - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.state = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_subexp_params() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 6).toLowerCase() === "reason") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"reason\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_event_reason_value(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, reason) { - if (typeof reason !== 'undefined') data.reason = reason; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 7).toLowerCase() === "expires") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"expires\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_delta_seconds(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, expires) { - if (typeof expires !== 'undefined') data.expires = expires; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 11).toLowerCase() === "retry_after") { - result0 = input.substr(pos, 11); - pos += 11; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"retry_after\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_delta_seconds(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, retry_after) { - if (typeof retry_after !== 'undefined') data.retry_after = retry_after; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - if (result0 === null) { - result0 = parse_generic_param(); - } - } - } - return result0; - } - - function parse_event_reason_value() { - var result0; - - if (input.substr(pos, 11).toLowerCase() === "deactivated") { - result0 = input.substr(pos, 11); - pos += 11; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"deactivated\""); - } - } - if (result0 === null) { - if (input.substr(pos, 9).toLowerCase() === "probation") { - result0 = input.substr(pos, 9); - pos += 9; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"probation\""); - } - } - if (result0 === null) { - if (input.substr(pos, 8).toLowerCase() === "rejected") { - result0 = input.substr(pos, 8); - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"rejected\""); - } - } - if (result0 === null) { - if (input.substr(pos, 7).toLowerCase() === "timeout") { - result0 = input.substr(pos, 7); - pos += 7; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"timeout\""); - } - } - if (result0 === null) { - if (input.substr(pos, 6).toLowerCase() === "giveup") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"giveup\""); - } - } - if (result0 === null) { - if (input.substr(pos, 10).toLowerCase() === "noresource") { - result0 = input.substr(pos, 10); - pos += 10; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"noresource\""); - } - } - if (result0 === null) { - if (input.substr(pos, 9).toLowerCase() === "invariant") { - result0 = input.substr(pos, 9); - pos += 9; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"invariant\""); - } - } - if (result0 === null) { - result0 = parse_token(); - } - } - } - } - } - } - } - return result0; - } - - function parse_Subject() { - var result0; - - result0 = parse_TEXT_UTF8_TRIM(); - result0 = result0 !== null ? result0 : ""; - return result0; - } - - function parse_Supported() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_token(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - result0 = result0 !== null ? result0 : ""; - return result0; - } - - function parse_To() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - result0 = parse_SIP_URI_noparams(); - if (result0 === null) { - result0 = parse_name_addr(); - } - if (result0 !== null) { - result1 = []; - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_to_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - while (result2 !== null) { - result1.push(result2); - pos2 = pos; - result2 = parse_SEMI(); - if (result2 !== null) { - result3 = parse_to_param(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos2; - } - } else { - result2 = null; - pos = pos2; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - var tag = data.tag; - try { - data = new JsSIP.NameAddrHeader(data.uri, data.display_name, data.params); - if (tag) {data.setParam('tag',tag)} - } catch(e) { - data = -1; - }})(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_to_param() { - var result0; - - result0 = parse_tag_param(); - if (result0 === null) { - result0 = parse_generic_param(); - } - return result0; - } - - function parse_Via() { - var result0, result1, result2, result3; - var pos0, pos1; - - pos0 = pos; - result0 = parse_via_parm(); - if (result0 !== null) { - result1 = []; - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_via_parm(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - while (result2 !== null) { - result1.push(result2); - pos1 = pos; - result2 = parse_COMMA(); - if (result2 !== null) { - result3 = parse_via_parm(); - if (result3 !== null) { - result2 = [result2, result3]; - } else { - result2 = null; - pos = pos1; - } - } else { - result2 = null; - pos = pos1; - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_via_parm() { - var result0, result1, result2, result3, result4, result5; - var pos0, pos1; - - pos0 = pos; - result0 = parse_sent_protocol(); - if (result0 !== null) { - result1 = parse_LWS(); - if (result1 !== null) { - result2 = parse_sent_by(); - if (result2 !== null) { - result3 = []; - pos1 = pos; - result4 = parse_SEMI(); - if (result4 !== null) { - result5 = parse_via_params(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - while (result4 !== null) { - result3.push(result4); - pos1 = pos; - result4 = parse_SEMI(); - if (result4 !== null) { - result5 = parse_via_params(); - if (result5 !== null) { - result4 = [result4, result5]; - } else { - result4 = null; - pos = pos1; - } - } else { - result4 = null; - pos = pos1; - } - } - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_via_params() { - var result0; - - result0 = parse_via_ttl(); - if (result0 === null) { - result0 = parse_via_maddr(); - if (result0 === null) { - result0 = parse_via_received(); - if (result0 === null) { - result0 = parse_via_branch(); - if (result0 === null) { - result0 = parse_response_port(); - if (result0 === null) { - result0 = parse_generic_param(); - } - } - } - } - } - return result0; - } - - function parse_via_ttl() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 3).toLowerCase() === "ttl") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"ttl\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_ttl(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, via_ttl_value) { - data.ttl = via_ttl_value; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_via_maddr() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 5).toLowerCase() === "maddr") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"maddr\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_host(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, via_maddr) { - data.maddr = via_maddr; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_via_received() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 8).toLowerCase() === "received") { - result0 = input.substr(pos, 8); - pos += 8; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"received\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_IPv4address(); - if (result2 === null) { - result2 = parse_IPv6address(); - } - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, via_received) { - data.received = via_received; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_via_branch() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 6).toLowerCase() === "branch") { - result0 = input.substr(pos, 6); - pos += 6; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"branch\""); - } - } - if (result0 !== null) { - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = parse_token(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, via_branch) { - data.branch = via_branch; })(pos0, result0[2]); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_response_port() { - var result0, result1, result2, result3; - var pos0, pos1, pos2; - - pos0 = pos; - pos1 = pos; - if (input.substr(pos, 5).toLowerCase() === "rport") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"rport\""); - } - } - if (result0 !== null) { - pos2 = pos; - result1 = parse_EQUAL(); - if (result1 !== null) { - result2 = []; - result3 = parse_DIGIT(); - while (result3 !== null) { - result2.push(result3); - result3 = parse_DIGIT(); - } - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos2; - } - } else { - result1 = null; - pos = pos2; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - if(typeof response_port !== 'undefined') - data.rport = response_port.join(''); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_sent_protocol() { - var result0, result1, result2, result3, result4; - var pos0; - - pos0 = pos; - result0 = parse_protocol_name(); - if (result0 !== null) { - result1 = parse_SLASH(); - if (result1 !== null) { - result2 = parse_token(); - if (result2 !== null) { - result3 = parse_SLASH(); - if (result3 !== null) { - result4 = parse_transport(); - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_protocol_name() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 3).toLowerCase() === "sip") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SIP\""); - } - } - if (result0 === null) { - result0 = parse_token(); - } - if (result0 !== null) { - result0 = (function(offset, via_protocol) { - data.protocol = via_protocol; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_transport() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 3).toLowerCase() === "udp") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"UDP\""); - } - } - if (result0 === null) { - if (input.substr(pos, 3).toLowerCase() === "tcp") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"TCP\""); - } - } - if (result0 === null) { - if (input.substr(pos, 3).toLowerCase() === "tls") { - result0 = input.substr(pos, 3); - pos += 3; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"TLS\""); - } - } - if (result0 === null) { - if (input.substr(pos, 4).toLowerCase() === "sctp") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"SCTP\""); - } - } - if (result0 === null) { - result0 = parse_token(); - } - } - } - } - if (result0 !== null) { - result0 = (function(offset, via_transport) { - data.transport = via_transport; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_sent_by() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - result0 = parse_via_host(); - if (result0 !== null) { - pos1 = pos; - result1 = parse_COLON(); - if (result1 !== null) { - result2 = parse_via_port(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_via_host() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_hostname(); - if (result0 === null) { - result0 = parse_IPv4address(); - if (result0 === null) { - result0 = parse_IPv6reference(); - } - } - if (result0 !== null) { - result0 = (function(offset) { - data.host = input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_via_port() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_DIGIT(); - result0 = result0 !== null ? result0 : ""; - if (result0 !== null) { - result1 = parse_DIGIT(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result2 = parse_DIGIT(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result3 = parse_DIGIT(); - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result4 = parse_DIGIT(); - result4 = result4 !== null ? result4 : ""; - if (result4 !== null) { - result0 = [result0, result1, result2, result3, result4]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, via_sent_by_port) { - data.port = parseInt(via_sent_by_port.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_ttl() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_DIGIT(); - if (result0 !== null) { - result1 = parse_DIGIT(); - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result2 = parse_DIGIT(); - result2 = result2 !== null ? result2 : ""; - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset, ttl) { - return parseInt(ttl.join('')); })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_WWW_Authenticate() { - var result0; - - result0 = parse_challenge(); - return result0; - } - - function parse_extension_header() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_token(); - if (result0 !== null) { - result1 = parse_HCOLON(); - if (result1 !== null) { - result2 = parse_header_value(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_header_value() { - var result0, result1; - - result0 = []; - result1 = parse_TEXT_UTF8char(); - if (result1 === null) { - result1 = parse_UTF8_CONT(); - if (result1 === null) { - result1 = parse_LWS(); - } - } - while (result1 !== null) { - result0.push(result1); - result1 = parse_TEXT_UTF8char(); - if (result1 === null) { - result1 = parse_UTF8_CONT(); - if (result1 === null) { - result1 = parse_LWS(); - } - } - } - return result0; - } - - function parse_message_body() { - var result0, result1; - - result0 = []; - result1 = parse_OCTET(); - while (result1 !== null) { - result0.push(result1); - result1 = parse_OCTET(); - } - return result0; - } - - function parse_stun_URI() { - var result0, result1, result2; - var pos0; - - pos0 = pos; - result0 = parse_stun_scheme(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_stun_host_port(); - if (result2 !== null) { - result0 = [result0, result1, result2]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_stun_scheme() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "stuns") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"stuns\""); - } - } - if (result0 === null) { - if (input.substr(pos, 4).toLowerCase() === "stun") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"stun\""); - } - } - } - if (result0 !== null) { - result0 = (function(offset, scheme) { - data.scheme = scheme; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_stun_host_port() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - result0 = parse_stun_host(); - if (result0 !== null) { - pos1 = pos; - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_port(); - if (result2 !== null) { - result1 = [result1, result2]; - } else { - result1 = null; - pos = pos1; - } - } else { - result1 = null; - pos = pos1; - } - result1 = result1 !== null ? result1 : ""; - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_stun_host() { - var result0; - var pos0; - - pos0 = pos; - result0 = parse_IPv4address(); - if (result0 === null) { - result0 = parse_IPv6reference(); - if (result0 === null) { - result0 = parse_reg_name(); - } - } - if (result0 !== null) { - result0 = (function(offset, host) { - data.host = host; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_reg_name() { - var result0, result1; - var pos0; - - pos0 = pos; - result0 = []; - result1 = parse_stun_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - result1 = parse_sub_delims(); - } - } - while (result1 !== null) { - result0.push(result1); - result1 = parse_stun_unreserved(); - if (result1 === null) { - result1 = parse_escaped(); - if (result1 === null) { - result1 = parse_sub_delims(); - } - } - } - if (result0 !== null) { - result0 = (function(offset) { - return input.substring(pos, offset); })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_stun_unreserved() { - var result0; - - result0 = parse_ALPHA(); - if (result0 === null) { - result0 = parse_DIGIT(); - if (result0 === null) { - if (input.charCodeAt(pos) === 45) { - result0 = "-"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"-\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 46) { - result0 = "."; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\".\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 95) { - result0 = "_"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"_\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 126) { - result0 = "~"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"~\""); - } - } - } - } - } - } - } - return result0; - } - - function parse_sub_delims() { - var result0; - - if (input.charCodeAt(pos) === 33) { - result0 = "!"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"!\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 36) { - result0 = "$"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"$\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 38) { - result0 = "&"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"&\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 39) { - result0 = "'"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"'\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 40) { - result0 = "("; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"(\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 41) { - result0 = ")"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\")\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 42) { - result0 = "*"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"*\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 43) { - result0 = "+"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"+\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 44) { - result0 = ","; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\",\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 59) { - result0 = ";"; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\";\""); - } - } - if (result0 === null) { - if (input.charCodeAt(pos) === 61) { - result0 = "="; - pos++; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"=\""); - } - } - } - } - } - } - } - } - } - } - } - } - return result0; - } - - function parse_turn_URI() { - var result0, result1, result2, result3, result4; - var pos0, pos1; - - pos0 = pos; - result0 = parse_turn_scheme(); - if (result0 !== null) { - if (input.charCodeAt(pos) === 58) { - result1 = ":"; - pos++; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\":\""); - } - } - if (result1 !== null) { - result2 = parse_stun_host_port(); - if (result2 !== null) { - pos1 = pos; - if (input.substr(pos, 11) === "?transport=") { - result3 = "?transport="; - pos += 11; - } else { - result3 = null; - if (reportFailures === 0) { - matchFailed("\"?transport=\""); - } - } - if (result3 !== null) { - result4 = parse_transport(); - if (result4 !== null) { - result3 = [result3, result4]; - } else { - result3 = null; - pos = pos1; - } - } else { - result3 = null; - pos = pos1; - } - result3 = result3 !== null ? result3 : ""; - if (result3 !== null) { - result0 = [result0, result1, result2, result3]; - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - } else { - result0 = null; - pos = pos0; - } - return result0; - } - - function parse_turn_scheme() { - var result0; - var pos0; - - pos0 = pos; - if (input.substr(pos, 5).toLowerCase() === "turns") { - result0 = input.substr(pos, 5); - pos += 5; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"turns\""); - } - } - if (result0 === null) { - if (input.substr(pos, 4).toLowerCase() === "turn") { - result0 = input.substr(pos, 4); - pos += 4; - } else { - result0 = null; - if (reportFailures === 0) { - matchFailed("\"turn\""); - } - } - } - if (result0 !== null) { - result0 = (function(offset, scheme) { - data.scheme = scheme; })(pos0, result0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - function parse_turn_transport() { - var result0, result1, result2; - var pos0, pos1; - - pos0 = pos; - pos1 = pos; - result0 = parse_transport(); - if (result0 !== null) { - if (input.substr(pos, 3).toLowerCase() === "udp") { - result1 = input.substr(pos, 3); - pos += 3; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"udp\""); - } - } - if (result1 === null) { - if (input.substr(pos, 3).toLowerCase() === "tcp") { - result1 = input.substr(pos, 3); - pos += 3; - } else { - result1 = null; - if (reportFailures === 0) { - matchFailed("\"tcp\""); - } - } - if (result1 === null) { - result1 = []; - result2 = parse_unreserved(); - while (result2 !== null) { - result1.push(result2); - result2 = parse_unreserved(); - } - } - } - if (result1 !== null) { - result0 = [result0, result1]; - } else { - result0 = null; - pos = pos1; - } - } else { - result0 = null; - pos = pos1; - } - if (result0 !== null) { - result0 = (function(offset) { - data.transport = transport; })(pos0); - } - if (result0 === null) { - pos = pos0; - } - return result0; - } - - - function cleanupExpected(expected) { - expected.sort(); - - var lastExpected = null; - var cleanExpected = []; - for (var i = 0; i < expected.length; i++) { - if (expected[i] !== lastExpected) { - cleanExpected.push(expected[i]); - lastExpected = expected[i]; - } - } - return cleanExpected; - } - - function computeErrorPosition() { - /* - * The first idea was to use |String.split| to break the input up to the - * error position along newlines and derive the line and column from - * there. However IE's |split| implementation is so broken that it was - * enough to prevent it. - */ - - var line = 1; - var column = 1; - var seenCR = false; - - for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) { - var ch = input.charAt(i); - if (ch === "\n") { - if (!seenCR) { line++; } - column = 1; - seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { - line++; - column = 1; - seenCR = true; - } else { - column++; - seenCR = false; - } - } - - return { line: line, column: column }; - } - - var data = {}; - - var result = parseFunctions[startRule](); - - /* - * The parser is now in one of the following three states: - * - * 1. The parser successfully parsed the whole input. - * - * - |result !== null| - * - |pos === input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 2. The parser successfully parsed only a part of the input. - * - * - |result !== null| - * - |pos < input.length| - * - |rightmostFailuresExpected| may or may not contain something - * - * 3. The parser did not successfully parse any part of the input. - * - * - |result === null| - * - |pos === 0| - * - |rightmostFailuresExpected| contains at least one failure - * - * All code following this comment (including called functions) must - * handle these states. - */ - if (result === null || pos !== input.length) { - var offset = Math.max(pos, rightmostFailuresPos); - var found = offset < input.length ? input.charAt(offset) : null; - var errorPosition = computeErrorPosition(); - - new this.SyntaxError( - cleanupExpected(rightmostFailuresExpected), - found, - offset, - errorPosition.line, - errorPosition.column - ); - return -1; - } - - return data; - }, - - /* Returns the parser source code. */ - toSource: function() { return this._source; } - }; - - /* Thrown when a parser encounters a syntax error. */ - - result.SyntaxError = function(expected, found, offset, line, column) { - function buildMessage(expected, found) { - var expectedHumanized, foundHumanized; - - switch (expected.length) { - case 0: - expectedHumanized = "end of input"; - break; - case 1: - expectedHumanized = expected[0]; - break; - default: - expectedHumanized = expected.slice(0, expected.length - 1).join(", ") - + " or " - + expected[expected.length - 1]; - } - - foundHumanized = found ? quote(found) : "end of input"; - - return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; - } - - this.name = "SyntaxError"; - this.expected = expected; - this.found = found; - this.message = buildMessage(expected, found); - this.offset = offset; - this.line = line; - this.column = column; - }; - - result.SyntaxError.prototype = Error.prototype; - - return result; -})(); \ No newline at end of file From f67c68e7284be1f844ed26ff47b79e4feb0bbe8d Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Thu, 15 Jan 2015 15:16:38 -0800 Subject: [PATCH 08/11] made the chat message spacing a little tighter --- .../modules/chat/views/ChatMessageRenderer.mxml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatMessageRenderer.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatMessageRenderer.mxml index 0436a2ac6a..0182c53f61 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatMessageRenderer.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatMessageRenderer.mxml @@ -20,8 +20,9 @@ with BigBlueButton; if not, see . --> - From fa7fa71f41b3e20bd051057f1f091cbffb69445d Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Thu, 15 Jan 2015 15:19:00 -0800 Subject: [PATCH 09/11] updated ChatOptions default fontSize to match config.xml.template --- .../src/org/bigbluebutton/modules/chat/model/ChatOptions.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as index abe9200f48..0e9c80ab7f 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as @@ -27,7 +27,7 @@ package org.bigbluebutton.modules.chat.model public var privateEnabled:Boolean = true; [Bindable] - public var fontSize:String = "10"; + public var fontSize:String = "12"; [Bindable] public var position:String = "top-right"; From 1150572f3f39d79e9fcdcb910ae78a10e5c22afa Mon Sep 17 00:00:00 2001 From: Fred Dixon Date: Thu, 15 Jan 2015 18:25:30 -0500 Subject: [PATCH 10/11] Updated copyright date on home page demo --- bigbluebutton-config/web/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigbluebutton-config/web/index.html b/bigbluebutton-config/web/index.html index e287a0ef1f..1da463381f 100644 --- a/bigbluebutton-config/web/index.html +++ b/bigbluebutton-config/web/index.html @@ -194,7 +194,7 @@
-

Copyright © 2014 BigBlueButton Inc.
+

Copyright © 2015 BigBlueButton Inc.
Version 0.9.0-beta

From 9be9cca0511439fe8fc9d3af5aad257d1ed4839f Mon Sep 17 00:00:00 2001 From: Chad Pilkey Date: Thu, 15 Jan 2015 16:14:49 -0800 Subject: [PATCH 11/11] added a configuration warning system to the flash client --- .../branding/default/style/css/BBBDefault.css | 25 ++ .../style/css/assets/images/status_fail.png | Bin 0 -> 382 bytes .../css/assets/images/status_success.png | Bin 0 -> 485 bytes .../css/assets/images/status_warning.png | Bin 0 -> 774 bytes .../css/assets/images/status_warning_20.png | Bin 0 -> 529 bytes .../org/bigbluebutton/skins/ToolTipSkin.as | 283 ++++++++++++++---- .../locale/en_US/bbbResources.properties | 16 +- .../resources/config.xml.template | 1 + .../org/bigbluebutton/core/model/Config.as | 4 + .../main/events/ClientStatusEvent.as | 40 +++ .../main/views/ClientStatusItemRenderer.mxml | 34 +++ .../main/views/ClientStatusWindow.mxml | 43 +++ .../main/views/MainApplicationShell.mxml | 57 +++- .../main/views/WarningButton.mxml | 105 +++++++ .../phone/managers/WebRTCCallManager.as | 61 ++-- 15 files changed, 583 insertions(+), 86 deletions(-) mode change 100644 => 100755 bigbluebutton-client/branding/default/style/css/BBBDefault.css create mode 100755 bigbluebutton-client/branding/default/style/css/assets/images/status_fail.png create mode 100755 bigbluebutton-client/branding/default/style/css/assets/images/status_success.png create mode 100755 bigbluebutton-client/branding/default/style/css/assets/images/status_warning.png create mode 100755 bigbluebutton-client/branding/default/style/css/assets/images/status_warning_20.png mode change 100644 => 100755 bigbluebutton-client/branding/default/style/css/org/bigbluebutton/skins/ToolTipSkin.as mode change 100644 => 100755 bigbluebutton-client/src/org/bigbluebutton/core/model/Config.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/main/events/ClientStatusEvent.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusItemRenderer.mxml create mode 100755 bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusWindow.mxml create mode 100755 bigbluebutton-client/src/org/bigbluebutton/main/views/WarningButton.mxml diff --git a/bigbluebutton-client/branding/default/style/css/BBBDefault.css b/bigbluebutton-client/branding/default/style/css/BBBDefault.css old mode 100644 new mode 100755 index 238e83b0ea..a0b514a76a --- a/bigbluebutton-client/branding/default/style/css/BBBDefault.css +++ b/bigbluebutton-client/branding/default/style/css/BBBDefault.css @@ -29,6 +29,10 @@ ToolTip { cornerRadius : 3; } +.errorTip { + borderColor : #3b3b3b; +} + .mypanelTitle { color: #444444; fontFamily: Arial; @@ -827,3 +831,24 @@ Alert { .recordButtonStyleStop { icon: Embed('assets/images/control-record-stop.png'); } + +.statusImageStyle { + successImage: Embed(source='assets/images/status_success.png'); + warningImage: Embed(source='assets/images/status_warning.png'); + failImage: Embed(source='assets/images/status_fail.png'); +} + +.warningButtonStyle { + icon: Embed('assets/images/status_warning_20.png'); +} + +.statusTitleStyle { + fontWeight: bold; + fontSize: 12; + paddingBottom: 0; +} + +.statusMessageStyle { + fontSize: 12; + paddingTop: 0; +} \ No newline at end of file diff --git a/bigbluebutton-client/branding/default/style/css/assets/images/status_fail.png b/bigbluebutton-client/branding/default/style/css/assets/images/status_fail.png new file mode 100755 index 0000000000000000000000000000000000000000..f025bc6de3977fbc1419650ad14f50f08bc7a784 GIT binary patch literal 382 zcmV-^0fGLBP)ESwnhTP4ZstCt8?yM1H;T0 z0B-<(iRdK@B98M2h%joD-nGH z!<<@Fa}h)i4AC9K#vZ_NP8p4D8cY$0IFv+bQ7^(2gCxqNc^@PnL5O*AJ&CajB*4T@ zh{0ULi*(2EP1|8=kQtaX-HU}eRp=&=42%iFl$sdLL`}%jx*#(U=K3%xG6AuEu}+Nb z_1m|Kfun%>SAVS6ot*L_@n5Xb5RT)#0XPPri0E7h@f?LIU6B}sKKq9;cFH;bS{g{F)7eooCT;MD#9%=-Fl#*L8P^ND|TBLDjLFik7$_TaCjfFNddSq{|9-4nQII%nYjaSm9RnL17-_mE)ZRm0#g`- z)tV@IteXmjmI4L>@b=?YrovdFl&)ee*!fZB5=oveZ?IlsXt?u^?^D b%2@LUO8&hgHpIQB00000NkvXXu0mjf7*N;3 literal 0 HcmV?d00001 diff --git a/bigbluebutton-client/branding/default/style/css/assets/images/status_warning.png b/bigbluebutton-client/branding/default/style/css/assets/images/status_warning.png new file mode 100755 index 0000000000000000000000000000000000000000..e7a5c5ed5cb5ebb669211dc4201c27ffe6562813 GIT binary patch literal 774 zcmV+h1Nr=kP)3_(*WhVH#PT{p5joHQE9?S-CNq=s{42Du^RLuK3&9mEw9(R2I}0uRJCdDA z6ohmZp8p;q3U*hDh|!a{`^kh8?vh+~lg*tLPC5I{`#$r|?C=r(kwO0m2NHvLp6A%j zc%By~*;HZ>rPN^y;QRi~zXp=a<(4~+^Tq;%VK`VSmA-ZhlPD1>Et1SY|&c3>jtLlM1&9pBFZOvZ)jC=n^;D1c)z#jk0tkH@Ty|HLb$HZt>50I8VbH6j}Feg9RQ`nZXZ5TZ;( zI~zprxUPG_&ILhm7Qlg--ZmnDbkz6#8<8L*BO@znwb}%L{wUG7e@%nVWGa;!7#kb=GIPEuk%soKElZam zRkgb-OGGWH=%>JW21GqW(plx=<8G?U5nrPFD9``5=5=~da=YPC94sZ^%w zAX3U*w!Q0>dM7%z?bKR7T&QD+Wcv>i`Laf4I8Oz?0pn>7GAccK*Z=?k07*qoM6N<$ Ef|iJ7t^fc4 literal 0 HcmV?d00001 diff --git a/bigbluebutton-client/branding/default/style/css/assets/images/status_warning_20.png b/bigbluebutton-client/branding/default/style/css/assets/images/status_warning_20.png new file mode 100755 index 0000000000000000000000000000000000000000..1828db53023cf5fa65368ccbbd7fc402704f593b GIT binary patch literal 529 zcmV+s0`C2ZP)(_`g8%^e{{R4h=>PzAFaQARU;qF*m;eA5Z<1fd zMgRZ-mq|oHRCwB~)W1s{K@nQf~l2YrQ)%===T*GoJ$h5zWSNd@&NJl==kVMc)0awSGA? z===TxGoQ4?F%d1saeO*37>1#!)oR~}=y~fnGk-6YO7meD+JQhRPP1>VeF^|Vh@UNCds^$)J;5Ld z9%os02H-&t@UP=I&!Q;$eJ`k#`T`(myR-HqH(R8&Ug-)-DVK=o>mYxZnU{?*$Nzzz z=M`Mn{Q=-fheh2o1b|;@n$9Ij(zpXkDL07duu~RY?yz;kO=HZ_Em$s>r>wPg0FQ>O zT7QHP#cH*BMfpR#1F$w?DSWTBUZ+Z>GLfd~wh*E)ie{~CxURcTW3Slb2LBBJpVglc To41A800000NkvXXu0mjfpTgc@ literal 0 HcmV?d00001 diff --git a/bigbluebutton-client/branding/default/style/css/org/bigbluebutton/skins/ToolTipSkin.as b/bigbluebutton-client/branding/default/style/css/org/bigbluebutton/skins/ToolTipSkin.as old mode 100644 new mode 100755 index a51153dc59..9f7743e4e7 --- a/bigbluebutton-client/branding/default/style/css/org/bigbluebutton/skins/ToolTipSkin.as +++ b/bigbluebutton-client/branding/default/style/css/org/bigbluebutton/skins/ToolTipSkin.as @@ -16,19 +16,25 @@ * with BigBlueButton; if not, see . * */ + +// Most of the source is adapted from the ToolTipBorder class and the functionality is replicated here for performance reasons + package org.bigbluebutton.skins { import flash.display.Graphics; import flash.events.Event; import flash.geom.Point; - + import mx.core.EdgeMetrics; + import flash.filters.DropShadowFilter; + import mx.graphics.RectangularDropShadow; import mx.managers.ToolTipManager; - import mx.skins.halo.ToolTipBorder; + import mx.skins.RectangularBorder; - public class ToolTipSkin extends ToolTipBorder + public class ToolTipSkin extends RectangularBorder { - - private static const TOP : String = "top"; + private static const LOG : String = "ToolTipSkin - "; + + private static const TOP : String = "top"; private static const BOTTOM : String = "bottom"; private var _arrowPosition : String = TOP; @@ -38,11 +44,219 @@ package org.bigbluebutton.skins visible = false; addEventListener(Event.ENTER_FRAME, this.enterFrameHandler); } - + + //-------------------------------------------------------------------------- + // + // Overridden properties + // + //-------------------------------------------------------------------------- + + //---------------------------------- + // borderMetrics + //---------------------------------- + + /** + * @private + * Storage for the borderMetrics property. + */ + private var _borderMetrics:EdgeMetrics; + + /** + * @private + */ + override public function get borderMetrics():EdgeMetrics + { + if (_borderMetrics) + return _borderMetrics; + + var borderStyle:String = getStyle("borderStyle"); + switch (borderStyle) + { + case "errorTipRight": + { + _borderMetrics = new EdgeMetrics(15, 1, 3, 3); + break; + } + + case "errorTipAbove": + { + _borderMetrics = new EdgeMetrics(3, 1, 3, 15); + break; + } + + case "errorTipBelow": + { + _borderMetrics = new EdgeMetrics(3, 13, 3, 3); + break; + } + + default: // "toolTip" + { + _borderMetrics = new EdgeMetrics(3, 1, 3, 3); + break; + } + } + + return _borderMetrics; + } + + //-------------------------------------------------------------------------- + // + // Overridden methods + // + //-------------------------------------------------------------------------- + + /** + * @private + * If borderStyle may have changed, clear the cached border metrics. + */ + override public function styleChanged(styleProp:String):void + { + super.styleChanged(styleProp); + + if (styleProp == "borderStyle" || + styleProp == "styleName" || + styleProp == null) + { + _borderMetrics = null; + + var borderStyle:String = getStyle("borderStyle"); + switch (borderStyle) + { + case "errorTipRight": + case "errorTipAbove": + case "errorTipBelow": + { + visible = true; + break; + } + } + } + } + + /** + * @private + * Draw the background and border. + */ + override protected function updateDisplayList(w:Number, h:Number):void + { + super.updateDisplayList(w, h); + + var borderStyle:String = getStyle("borderStyle"); + var backgroundColor:uint = getStyle("backgroundColor"); + var backgroundAlpha:Number= getStyle("backgroundAlpha"); + var borderColor:uint = getStyle("borderColor"); + var cornerRadius:Number = getStyle("cornerRadius"); + + var g:Graphics = graphics; + g.clear(); + + filters = []; + + switch (borderStyle) + { + case "none": + { + // Don't draw anything + break; + } + case "errorTipRight": + { + // border + drawRoundRect( + 11, 0, w - 11, h - 2, 3, + borderColor, backgroundAlpha); + + // left pointer + g.beginFill(borderColor, backgroundAlpha); + g.moveTo(11, 7); + g.lineTo(0, 13); + g.lineTo(11, 19); + g.moveTo(11, 7); + g.endFill(); + + filters = [ new DropShadowFilter(2, 90, 0, 0.4) ]; + break; + } + + case "errorTipAbove": + { + // border + drawRoundRect( + 0, 0, w, h - 13, 3, + borderColor, backgroundAlpha); + + // bottom pointer + g.beginFill(borderColor, backgroundAlpha); + g.moveTo(w/2-6, h - 13); + g.lineTo(w/2, h - 2); + g.lineTo(w/2+6, h - 13); + g.moveTo(w/2-6, h - 13); + g.endFill(); + + filters = [ new DropShadowFilter(2, 90, 0, 0.4) ]; + break; + } + + case "errorTipBelow": + { + // border + drawRoundRect( + 0, 11, w, h - 13, 3, + borderColor, backgroundAlpha); + + // top pointer + g.beginFill(borderColor, backgroundAlpha); + g.moveTo(9, 11); + g.lineTo(15, 0); + g.lineTo(21, 11); + g.moveTo(10, 11); + g.endFill(); + + filters = [ new DropShadowFilter(2, 90, 0, 0.4) ]; + break; + } + + default: //Tooltip + { + // face + drawRoundRect( + 3, 1, w - 6, h - 4, cornerRadius, + backgroundColor, backgroundAlpha) + + // top pointer + if (_arrowPosition == TOP) { + g.beginFill(backgroundColor, backgroundAlpha); + g.moveTo((w / 2) - 6, 1); + g.lineTo((w / 2), -10); + g.lineTo((w / 2) + 6, 1); + g.moveTo((w / 2) - 5, -10); + g.endFill(); + } + else { + g.beginFill(backgroundColor, backgroundAlpha); + g.moveTo((w / 2) - 6, h - 3); + g.lineTo((w / 2), h + 7); + g.lineTo((w / 2) + 6, h - 3); + g.moveTo((w / 2) - 5, h + 7); + g.endFill(); + } + + break; + } + } + } + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + private function enterFrameHandler( event : Event ) : void { this.position(); } - + private function position() : void { if (!stage || !ToolTipManager.currentToolTip || !ToolTipManager.currentTarget) { @@ -54,11 +268,11 @@ package org.bigbluebutton.skins var globalPoint : Point = ToolTipManager.currentTarget.localToGlobal(parentCoords); var xp : Number = globalPoint.x + 5 - (ToolTipManager.currentToolTip.width / 2); var yp : Number = globalPoint.y + ToolTipManager.currentToolTip.height; - + var overhangRight : Number = ToolTipManager.currentToolTip.width + xp; var overhangBottom : Number = ToolTipManager.currentToolTip.height + yp; updateArrowPosition(TOP); - + if (overhangRight > stage.stageWidth) { xp = stage.stageWidth - ToolTipManager.currentToolTip.width; } @@ -81,61 +295,14 @@ package org.bigbluebutton.skins ToolTipManager.currentToolTip.y = yp; visible = true; } - + } - - + private function updateArrowPosition( value : String ) : void { if (_arrowPosition != value) { _arrowPosition = value; validateDisplayList(); } } - - - //-------------------------------------------------------------------------- - // - // Overridden methods - // - //-------------------------------------------------------------------------- - - - override protected function updateDisplayList( w : Number, h : Number ) : void { - super.updateDisplayList(w, h); - - var backgroundColor : uint = getStyle("backgroundColor"); - var backgroundAlpha : Number = getStyle("backgroundAlpha"); - var borderColor : uint = getStyle("borderColor"); - var cornerRadius : Number = getStyle("cornerRadius"); - - var g : Graphics = graphics; - g.clear(); - - filters = []; - - // face - drawRoundRect( - 3, 1, w - 6, h - 4, cornerRadius, - backgroundColor, backgroundAlpha) - - // top pointer - if (_arrowPosition == TOP) { - g.beginFill(backgroundColor, backgroundAlpha); - g.moveTo((w / 2) - 6, 1); - g.lineTo((w / 2), -10); - g.lineTo((w / 2) + 6, 1); - g.moveTo((w / 2) - 5, -10); - g.endFill(); - } - else { - g.beginFill(backgroundColor, backgroundAlpha); - g.moveTo((w / 2) - 6, h - 3); - g.lineTo((w / 2), h + 7); - g.lineTo((w / 2) + 6, h - 3); - g.moveTo((w / 2) - 5, h + 7); - g.endFill(); - } - - } } } diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index afbb9a69e1..e6958339b4 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -64,9 +64,7 @@ bbb.micWarning.joinBtn.label = Join anyway bbb.micWarning.testAgain.label = Test again bbb.micWarning.message = Your microphone did not show any activity, others probably won't be able to hear you during the session. bbb.webrtcWarning.message = Detected the following WebRTC issue: {0}. Do you want to try Flash instead? -bbb.webrtcWarning.mediamessage = Could not get your microphone for a WebRTC call. Do you want to try Flash instead? -bbb.webrtcWarning.endedunexpectedly = The WebRTC echo test ended unexpectedly. Do you want to try Flash instead? -bbb.webrtcWarning.title = WebRTC Connection Failed +bbb.webrtcWarning.title = WebRTC Audio Failure bbb.webrtcWarning.failedError.1001 = Error 1001: WebSocket disconnected bbb.webrtcWarning.failedError.1002 = Error 1002: Could not make a WebSocket connection bbb.webrtcWarning.failedError.1003 = Error 1003: Browser version not supported @@ -75,6 +73,8 @@ bbb.webrtcWarning.failedError.1005 = Error 1005: Call ended unexpectedly bbb.webrtcWarning.failedError.1006 = Error 1006: Call timed out bbb.webrtcWarning.failedError.1007 = Error 1007: ICE negotiation failed bbb.webrtcWarning.failedError.unknown = Error {0}: Unknown error code +bbb.webrtcWarning.failedError.mediamissing = Could not get your microphone for a WebRTC call +bbb.webrtcWarning.failedError.endedunexpectedly = The WebRTC echo test ended unexpectedly bbb.mainToolbar.helpBtn = Help bbb.mainToolbar.logoutBtn = Logout bbb.mainToolbar.logoutBtn.toolTip = Log Out @@ -95,6 +95,16 @@ bbb.mainToolbar.recordBtn..notification.message1 = You can record this meeting. bbb.mainToolbar.recordBtn..notification.message2 = You must click the Start/Stop Recording button in the title bar to begin/end recording. bbb.mainToolbar.recordingLabel.recording = (Recording) bbb.mainToolbar.recordingLabel.notRecording = Not Recording +bbb.clientstatus.title = Configuration Warnings +bbb.clientstatus.notification = There is an unread notification +bbb.clientstatus.tunneling.title = Firewall +bbb.clientstatus.tunneling.message = A firewall is preventing your client from connecting directly on port 1935 to the remote server. Recommend joining a less restrictive network for a more stable connection +bbb.clientstatus.browser.title = Browser Version +bbb.clientstatus.browser.message = Your browser ({0}) is not up-to-date. Recommend updating to the latest version. +bbb.clientstatus.flash.title = Flash Player Version +bbb.clientstatus.flash.message = Your Flash Player plugin ({0}) is out of date. Recommend updating to the latest version. +bbb.clientstatus.webrtc.title = Audio +bbb.clientstatus.webrtc.message = Your browser doesn't support higher quality audio (WebRTC). Recommend you use an up-to-date version of either Firefox or Chrome. bbb.window.minimizeBtn.toolTip = Minimize bbb.window.maximizeRestoreBtn.toolTip = Maximize bbb.window.closeBtn.toolTip = Close diff --git a/bigbluebutton-client/resources/config.xml.template b/bigbluebutton-client/resources/config.xml.template index f7351de115..0603d44b31 100755 --- a/bigbluebutton-client/resources/config.xml.template +++ b/bigbluebutton-client/resources/config.xml.template @@ -10,6 +10,7 @@ + . + * + */ + +package org.bigbluebutton.main.events +{ + import flash.events.Event; + + public class ClientStatusEvent extends Event + { + public static const SUCCESS_MESSAGE_EVENT:String = "SUCCESS_MESSAGE_EVENT"; + public static const WARNING_MESSAGE_EVENT:String = "WARNING_MESSAGE_EVENT"; + public static const FAIL_MESSAGE_EVENT:String = "FAIL_MESSAGE_EVENT"; + + public var title:String; + public var message:String; + + public function ClientStatusEvent(type:String, title:String, message:String) + { + super(type); + this.title = title; + this.message = message; + } + } +} \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusItemRenderer.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusItemRenderer.mxml new file mode 100755 index 0000000000..943ce1545e --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusItemRenderer.mxml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusWindow.mxml new file mode 100755 index 0000000000..ac9151676e --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/ClientStatusWindow.mxml @@ -0,0 +1,43 @@ + + + + + + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml index f7b7fe2689..9bc4caf5a0 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/main/views/MainApplicationShell.mxml @@ -91,6 +91,7 @@ with BigBlueButton; if not, see . import org.bigbluebutton.core.vo.LockSettingsVO; import org.bigbluebutton.main.events.AppVersionEvent; import org.bigbluebutton.main.events.BBBEvent; + import org.bigbluebutton.main.events.ClientStatusEvent; import org.bigbluebutton.main.events.ConfigEvent; import org.bigbluebutton.main.events.InvalidAuthTokenEvent; import org.bigbluebutton.main.events.LogoutEvent; @@ -299,8 +300,14 @@ with BigBlueButton; if not, see . } private function handleOpenWindowEvent(event:OpenWindowEvent):void { - isTunneling = BBB.initConnectionManager().isTunnelling; - var window:IBbbModuleWindow = event.window; + // this is a terrible place for these checks because this function runs 4 times on startup + if (BBB.initConnectionManager().isTunnelling) { + isTunneling = true; + globalDispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.WARNING_MESSAGE_EVENT, ResourceUtil.getInstance().getString("bbb.clientstatus.tunneling.title"), ResourceUtil.getInstance().getString("bbb.clientstatus.tunneling.message"))); + } + versionCheck(); + + var window:IBbbModuleWindow = event.window; mdiCanvas.addWindow(window); } @@ -309,6 +316,49 @@ with BigBlueButton; if not, see . mdiCanvas.removeWindow(window); } + private function versionCheck():void { + var xml:XML = BBB.initConfigManager().config.browserVersions; + if (xml.@chrome != undefined && xml.@firefox != undefined && xml.@flash != undefined) { + //find browser version + var browserVersion:Array = ExternalInterface.call("determineBrowser"); + //check browser version + if ((browserVersion[0].toString().toLowerCase() == "chrome" && browserVersion[1] < xml.@chrome) || browserVersion[0].toString().toLowerCase() == "firefox" && browserVersion[1] < xml.@firefox) { + globalDispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.WARNING_MESSAGE_EVENT, + ResourceUtil.getInstance().getString("bbb.clientstatus.browser.title"), + ResourceUtil.getInstance().getString("bbb.clientstatus.browser.message", [browserVersion[0]+" "+browserVersion[1]]))); + } + + //find flash version + var flashVersion:Object = getFlashVersion(); + //check flash version + if ((flashVersion.os == 'LNX' && browserVersion[0].toString().toLowerCase() != "chrome" && flashVersion.major < 11) || + ((flashVersion.os != 'LNX' || browserVersion[0].toString().toLowerCase() == "chrome") && flashVersion.major < xml.@flash)) { + globalDispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.WARNING_MESSAGE_EVENT, + ResourceUtil.getInstance().getString("bbb.clientstatus.flash.title"), + ResourceUtil.getInstance().getString("bbb.clientstatus.flash.message", [flashVersion.major+"."+flashVersion.minor+"."+flashVersion.build]))); + } + } + + //Alert.show(LOG + "version check- os: "+flashVersion.os+" major:"+flashVersion.major+" minor:"+flashVersion.minor+" build:"+flashVersion.build+" browser:"+browserVersion[0]+" version:"+browserVersion[1]); + + //find java version + //check flash version + } + + //function found here, http://www.mediacollege.com/adobe/flash/actionscript/3/player-version.html + private function getFlashVersion():Object { + var flashVersion:Object = new Object(); + var versionNumber:String = Capabilities.version;// Get the whole version string + var versionArray:Array = versionNumber.split(",");// Split it up + var osPlusVersion:Array = versionArray[0].split(" ");// The main version contains the OS (e.g. WIN), so we split that off as well. + // Populate the version object (the OS is a string, others are numbers): + flashVersion["os"] = osPlusVersion[0]; + flashVersion["major"] = parseInt(osPlusVersion[1]); + flashVersion["minor"] = parseInt(versionArray[1]); + flashVersion["build"] = parseInt(versionArray[2]); + return flashVersion; + } + private function resetLayout():void{ mdiCanvas.resetWindowLayout(); } @@ -627,6 +677,9 @@ with BigBlueButton; if not, see . id="isTunnellingLbl" visible="{isTunneling}" includeInLayout="{isTunneling}" /> + + + + + + + + + + + + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/WebRTCCallManager.as b/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/WebRTCCallManager.as index f0594687aa..c54f8985fc 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/WebRTCCallManager.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/phone/managers/WebRTCCallManager.as @@ -13,6 +13,7 @@ package org.bigbluebutton.modules.phone.managers import org.bigbluebutton.core.UsersUtil; import org.bigbluebutton.main.api.JSAPI; + import org.bigbluebutton.main.events.ClientStatusEvent; import org.bigbluebutton.modules.phone.PhoneModel; import org.bigbluebutton.modules.phone.PhoneOptions; import org.bigbluebutton.modules.phone.events.AudioSelectionWindowEvent; @@ -49,7 +50,14 @@ package org.bigbluebutton.modules.phone.managers browserType = browserInfo[0]; browserVersion = browserInfo[1]; } - options = new PhoneOptions(); + options = new PhoneOptions(); + + // only show the warning if the admin has enabled WebRTC + if (options.useWebRTCIfAvailable && !isWebRTCSupported()) { + dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.WARNING_MESSAGE_EVENT, + ResourceUtil.getInstance().getString("bbb.clientstatus.webrtc.title"), + ResourceUtil.getInstance().getString("bbb.clientstatus.webrtc.message"))); + } } private function isWebRTCSupported():Boolean { @@ -79,17 +87,17 @@ package org.bigbluebutton.modules.phone.managers } private function startWebRTCEchoTest():void { - model.state = Constants.CALLING_INTO_ECHO_TEST; + model.state = Constants.CALLING_INTO_ECHO_TEST; ExternalInterface.call("startWebRTCAudioTest"); } private function endEchoTest():void { ExternalInterface.call("stopWebRTCAudioTest"); } - - private function endEchoTestJoinConference():void { - ExternalInterface.call("stopWebRTCAudioTestJoinConference"); - } + + private function endEchoTestJoinConference():void { + ExternalInterface.call("stopWebRTCAudioTestJoinConference"); + } private function hangup():void { ExternalInterface.call("stopWebRTCAudioTest"); @@ -108,16 +116,16 @@ package org.bigbluebutton.modules.phone.managers dispatcher.dispatchEvent(new UseFlashModeCommand()); } - private var t:Timer; - + private var t:Timer; + public function handleWebRTCEchoTestHasAudioEvent():void { trace(LOG + "handleWebRTCEchoTestHasAudioEvent"); model.state = Constants.STOP_ECHO_THEN_JOIN_CONF; - endEchoTestJoinConference(); + endEchoTestJoinConference(); } public function handleWebRTCCallStartedEvent():void { - trace(LOG + "setting state to IN_CONFERENCE"); + trace(LOG + "setting state to IN_CONFERENCE"); model.state = Constants.IN_CONFERENCE; dispatcher.dispatchEvent(new WebRTCJoinedVoiceConferenceEvent()); @@ -175,31 +183,33 @@ package org.bigbluebutton.modules.phone.managers public function handleWebRTCEchoTestFailedEvent(errorCode:Number):void { model.state = Constants.INITED; endEchoTest(); - var errorString:String = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + errorCode); - if (!errorString) { - errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.unknown", [errorCode]); - } - - var alert:Alert = Alert.show(ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), Alert.YES | Alert.NO, null, handleCallFailedUserResponse, null, Alert.YES); + var errorString:String = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + errorCode); + if (!errorString) { + errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.unknown", [errorCode]); + } + + sendWebRTCAlert(ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), errorString); } public function handleWebRTCEchoTestEndedUnexpectedly():void { model.state = Constants.INITED; - var alert:Alert = Alert.show(ResourceUtil.getInstance().getString("bbb.webrtcWarning.endedunexpectedly"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), Alert.YES | Alert.NO, null, handleCallFailedUserResponse, null, Alert.YES); + var errorString:String = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.endedunexpectedly"); + sendWebRTCAlert(ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), errorString); } public function handleWebRTCCallFailedEvent(errorCode:Number):void { model.state = Constants.INITED; - var errorString:String = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + errorCode); - if (!errorString) { - errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.unknown", [errorCode]); - } - var alert:Alert = Alert.show(ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), Alert.YES | Alert.NO, null, handleCallFailedUserResponse, null, Alert.YES); + var errorString:String = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError." + errorCode); + if (!errorString) { + errorString = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.unknown", [errorCode]); + } + sendWebRTCAlert(ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), errorString); } public function handleWebRTCMediaFailedEvent():void { model.state = Constants.INITED; - var alert:Alert = Alert.show(ResourceUtil.getInstance().getString("bbb.webrtcWarning.mediamessage"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), Alert.YES | Alert.NO, null, handleCallFailedUserResponse, null, Alert.YES); + var errorString:String = ResourceUtil.getInstance().getString("bbb.webrtcWarning.failedError.mediamissing"); + sendWebRTCAlert(ResourceUtil.getInstance().getString("bbb.webrtcWarning.title"), ResourceUtil.getInstance().getString("bbb.webrtcWarning.message", [errorString]), errorString); } private function handleCallFailedUserResponse(e:CloseEvent):void { @@ -209,5 +219,10 @@ package org.bigbluebutton.modules.phone.managers dispatcher.dispatchEvent(new AudioSelectionWindowEvent(AudioSelectionWindowEvent.CLOSED_AUDIO_SELECTION)); } } + + private function sendWebRTCAlert(title:String, message:String, error:String):void { + Alert.show(message, title, Alert.YES | Alert.NO, null, handleCallFailedUserResponse, null, Alert.YES); + dispatcher.dispatchEvent(new ClientStatusEvent(ClientStatusEvent.FAIL_MESSAGE_EVENT, title, error)); + } } } \ No newline at end of file