diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index f02d2801a..000000000 --- a/.editorconfig +++ /dev/null @@ -1,5 +0,0 @@ -[*.{java,html}] -charset = utf-8 -indent_style = tab -indent_size = 4 -trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index ebf99b0ef..8bd3a0588 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,4 @@ -*.iml -*.ipr -*.iws -target -.classpath -.project -.settings/* -.idea -.gradle -classes -/bin -build/ +/target/ /.settings/ +/.classpath +/.project diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 366fe82b8..000000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: java - -jdk: -- oraclejdk7 -- oraclejdk8 -- openjdk7 - -script: -- ./gradlew test - -install: -- /bin/true - diff --git a/ANNOUNCEMENT b/ANNOUNCEMENT deleted file mode 100644 index 4bee82219..000000000 --- a/ANNOUNCEMENT +++ /dev/null @@ -1,39 +0,0 @@ -ANNOUNCEMENT: Asterisk-Java 0.3.1 released - -Asterisk-Java 0.3.1, the free Java library for Asterisk PBX integration, -has been released. - -The Asterisk-Java package consists of a set of Java classes that allow -you to easily build Java applications that interact with an Asterisk -PBX Server. Asterisk-Java supports both interfaces that Asterisk -provides for this scenario: The FastAGI protocol and the Manager API. - -Asterisk-Java 0.3.1 is a maintenance release that solves the -following issues: - * [AJ-81] - executeCliCommand() always executes "show voicemail users" - * [AJ-86] - getChannelByName doesn't return the latest channel - * [AJ-80] - getMeetMeRooms() should only return active rooms - * [AJ-68] - Support for Bridge Action - * [AJ-74] - Support Strategy property in QueueParamsEvent - -Asterisk-Java takes advantage of the features of Java 5.0 and therefore -requires a Java Virtual Machine of at least version 1.5.0. - -Asterisk-Java is used in several commercial environments and by -the following Open Source projects: - * Asterisk-JTAPI - JTAPI implementation for Asterisk. - http://asterisk-jtapi.sf.net/ - * Asterisk-IM - A plugin for the Openfire XMPP (jabber) server. It provides - integrated presence between your IM client and phone, notification - of incoming calls by IM and originate calls from supported IM - clients. - http://www.igniterealtime.org/projects/openfire/ - * Asterisk Desktop Manager (ADM) - A desktop application that will allow for automatic on-call volume - reduction, one click dial from clipboard, integrated phonebook - and more. - http://adm.hamnett.org/ - -Asterisk-Java is available under Apache 2.0 license at http://asterisk-java.org diff --git a/CHANGES b/CHANGES deleted file mode 100644 index de254ee1a..000000000 --- a/CHANGES +++ /dev/null @@ -1,145 +0,0 @@ -Asterisk-Java 1.0.0 - Warning: - Values for event properties of type String that match one of the null - literals used by Asterisk are automatically set to null in A-J 1.0.0. - The null literals are: - "", "unknown", "none", "", "-none-", "(none)", - "", "(not set)", "", "n/a", "" and - "(null)". - - -Asterisk-Java 0.3.1 - * [AJ-81] - executeCliCommand() always executes "show voicemail users" - * [AJ-86] - getChannelByName doesn't return the latest channel - * [AJ-79] - Support for the CallWeaver protocol identifier - * [AJ-80] - getMeetMeRooms() should only return active rooms - * [AJ-68] - Support for Bridge Action - * [AJ-74] - Support Strategy property in QueueParamsEvent - * [AJ-78] - Documentation needs thorough examples of the Live API - -Asterisk-Java 0.3 - * [AJ-30] - Fixed version detection when restarting Asterisk - * [AJ-59] - Fixed incorrect class and method names when using JavaLoggingLog - * [AJ-60] - Fixed DefaultManagerConnection.sendEventGeneratingAction() - for Asterisk 1.4.1 - * [AJ-50] - Finished support for Asterisk 1.4 - * [AJ-54] - Fixed AsteriskQueue observer and Park events - * [AJ-55] - Added "videoSupport" and "realtimeDevice" to PeerEntryEvent - * [AJ-56] - Added "callerIdNum" to AbstractChannelEvent - * [AJ-57] - Added "memberName" to AbstractQueueMemberEvent - * [AJ-58] - Added support for OpenPBX - * [AJ-43] - Added support for GetConfig and UpdateConfig actions - * [AJ-62] - Added executeCliCommand() method to AsteriskServer - * [AJ-2] - Updated design doc and tutorial according to AGI changes - -Asterisk-Java 0.3-m2 - * Added getManagerConnection() to AsteriskServer (AJ-41) - * Added timestamp property to ManagerEvent (AJ-35) - * Added QueueSummaryAction, QueueSummaryEvent and - QueueSummaryCompleteEvent (AJ-42) - * Added ZapRestartAction (AJ-45) - * Added PauseMontiorAction and UnpauseMonitorAction and - pauseMontior() and unpauseMonitor() methods to - AsteriskChannel (AJ-44) - * Added AbstractManagerEventListener - -Asterisk-Java 0.3-m1 - * Changed package name from net.sf.asterisk to org.asteriskjava - and renamed AGI classes to Agi to conform to Java coding - standards - * Renamed ManagerEventHandler and ManagerResponseHandler to - ManagerEventListener and SendActionCallback. - * Introduced generics and leveraged other Java5 features like - java.util.concurrent. - * Added SSL support for the Manager API. - * ManagerReader threads are now daemon threads so as soon as - all other threads are terminated the JVM will quit - * Changed log level for message about ManagerReader termination - from INFO to DEBUG - * ManagerConnectionFactory has been simplified. Usage example: - new ManagerConnectionFactory("host", "user", "pass") - .createManagerConnection(); - * Fixed timing bug in ResourceBundleMappingStrategy (AJ-25) - * Fixed interrupt in DefaultManagerConnection (AJ-27) - * Fixed accountCode always being null in AgiRequest - * Fixed synchronization bug when generating internal action ids for - the Manager API - * Fixed synchronous sendAction for responses that are received really - fast, i.e. before the thread is put asleep. - * Fixed ConnectEvent being only fired after a successful - login (AJ-32) - * Fixed no setter for the dnd field when sending - ZapShowChannelsAction (AJ-33) - * Added support for login with eventMask (AJ-28) - * Added support for using non-shared instances AgiScript, i.e. a - new instance is used for each request if you set the - shareInstances property on your MappingStrategy to false. - Default is still to use shared instances (AJ-29) - * Live objects now fire PropertyChangeEvents - * Added extraContext, extraExten, extraPriority properties to - RedirectAction to support BRIstuffed versions of Asterisk (AJ-34) - * Added recordFile and controlStreamFile methods to AgiChannel and - BaseAgiScript - * Added channel variable AJ_AGISTATUS that is set by the AgiServer - to "SUCCESS" if the AgiScript completed successfully, "FAILED" - if it threw an exception or "NOT_FOUND" if the mapping strategy - did not return a script for the requested URL. - * Added MeetMeMuteEvent and muted property for MeetMeUser. - * Added MeetMeMuteAction and MeetMeUnmuteAction. - * Added ParkAction. - * Added PlayDtmfAction and playDtmf() method for AsteriskChannel. - * Added several new event properties for Asterisk 1.4: - - MeetMeEvent: channel and uniqueId - - MeetMeLeaveEvent: callerIdNum, callerIdName and duration - - MeetMeTalkingEvent: status - - StatusEvent: callerIdNum and callerIdName - - OriginateEvent: callerIdNum and callerIdName - - JoinEvent and LeaveEvent: uniqueId - - AgentConnectEvent: brigedChannel - -Asterisk-Java 0.2 - * Added SayDateTimeCommand (AJ-23) - * Added GetFullVariableCommand (AJ-23) - * Added ReceiveTextCommand (AJ-23) - * Changed SetPriorityCommand to support labels (AJ-23) - * Added callingPres, callingAni2, callingTns and callingTon - properties to AGIRequest (AJ-22) - * Fixed CallerId information in AGIRequest for - Asterisk 1.2 (AJ-21) - -Asterisk-Java 0.2-rc2 - * Fixed mapping of Variable property in OriginateAction for - Asterisk 1.2 (AJ-15) - * Added FaxReceived event from spandsp (AJ-20) - * Added SimpleMappingStrategy and AGIServerThread to ease - integration of AGIServer when using Spring Framework - * Timeout for socket connection can now be specified for - the ManagerConnection (AJ-16) - * Added getPort() method to lookup port of an AGIServer (AJ-14) - * Readded getContext(), getExtension(), getPriority() as - convenience methods to Channel (AJ-12) - * Decreased log level for unknown events to INFO (AJ-13) - -Asterisk-Java 0.2-rc1 - * Added Support for the new Actions, Events and Commands - of Asterisk 1.2 - * Fixed getting the uniqueId from a successful originate - in the DefaultAsteriskManager - * Added isConnected() method to ManagerConnection - * Changed ManagerAction to be an interface rather that an - abstract base class. If you extended ManagerAction, please - use AbstractManagerAction instead. - * Added support for event generating Actions, i.e. Actions - that send their result as a series of Event rather than - the usual ManagerResults. See the sendEventGeneratingAction() - methods in ManagerConnection for more information. - * Deprecated AbstractAGIScript in favor of BaseAGIScript. This - allows you write cleaner AGI scripts as you don't have to - pass the channel variable to all methods. - * Added convenience constructors for manager actions - -Asterisk-Java 0.1 - * Added accessors for raw attributes in ManagerResponse - * Fixed bug in action id creation - * Changed logging to use either log4j or java.util.logging - * Fixed ExecCommand diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index d64569567..000000000 --- a/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index f207080af..c7a3227bc 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,37 @@ -README for Asterisk-Java -======================== - -INTRODUCTION ------------- - -The Asterisk-Java package consists of a set of Java classes that allow you to easily build Java applications that interact with an [Asterisk PBX Server](http://asterisk.org). Asterisk-Java supports both interfaces that Asterisk provides for this scenario: The [FastAGI](https://wiki.asterisk.org/wiki/display/AST/Application_AGI) protocol and the [Manager API](https://wiki.asterisk.org/wiki/display/AST/The+Asterisk+Manager+TCP+IP+API). - -FastAGI -------- -FastAGI lets you create a service that manages a call in a similar way to what a webserver handles a http request. FastAGI can be (and should be) used to replace dialplan. FastAGI is thousands of times faster than dialplan, easier to debug and lets you do call control in a language that you are fimilar with. - -The FastAGI implementation supports all commands currently available from Asterisk. - -Manager API ------------ -The Manager API implementation supports receiving events from the Asterisk server (e.g. call progess, registered peers, channel state) and sending actions to Asterisk (e.g. originate call, agent login/logoff, start/stop voice recording). -If you like, the Manager API allows you start and manipulate calls. -A complete list of the available events and actions is available in the javadocs. - -Activities ----------- -Activities are new to asterisk-java 2.0. The aim of Activities is to provide a high level interface to interactions with Asterisk. Whist Activities use both FastAGI and the Manager API you would normally consider Activities as a replacement for the Manager API. - -Activities provide a simple and consistent method of interaction with Asterisk without having to worry about issues such as connection management and without having to understand the intricacies of Asterisk Manager Actions and Events. - - - -See docs/tutorial.html for examples. - -GETTING ASTERISK-JAVA ---------------------- - -Asterisk-Java is available from [here](https://github.com/asterisk-java/asterisk-java/releases) - -Maven Dependency ----------------- -Asterisk 1.0 - - - org.asteriskjava - asterisk-java - 1.0.0-final - - -Asterisk 2.0 - - org.asteriskjava - asterisk-java - 2.0.0-final - - -INSTALLATION FROM SOURCE ------------------------- - - git clone https://github.com/asterisk-java/asterisk-java.git - cd asterisk-java - mvn install - -After the build is complete, the jar will then be built as target/asterisk-java.jar in the asterisk-java directory. - -EXAMPLE -------- - -The file 'examples/ExampleCallIn.java' will answer the call and playback the audio file 'tt-monkeys'. - - import org.asteriskjava.fastagi.AgiChannel; - import org.asteriskjava.fastagi.AgiException; - import org.asteriskjava.fastagi.AgiRequest; - import org.asteriskjava.fastagi.BaseAgiScript; - /* Example incoming call handler - Answer call, speak message */ - public class ExampleCallIn extends BaseAgiScript { - public void service(AgiRequest request, AgiChannel channel) throws AgiException { - answer(); - exec("Playback", "tt-monkeys"); - hangup(); - } - } - -The file 'examples/fastagi.properties' maps your Asterisk diaplan context to the class you would like to invoke above. - - callin.agi = ExampleCallIn - -To compile and run do: - - javac -cp asterisk-java.jar ExampleCallIn.java - java -cp asterisk-java.jar org.asteriskjava.fastagi.DefaultAgiServer - -SYSTEM REQUIREMENTS -------------------- - -Asterisk-Java needs a Java Virtual Machine of at least version 1.7 ([Java SE 7.0](http://www.oracle.com/technetwork/java/javase/downloads/index.html)). If you want to build the jar from source, you will -also need [Maven](http://maven.apache.org/). - -LEGAL ------ - -Asterisk-Java is subject to the terms detailed in the license agreement accompanying it. +This is the Maven Repository for asterisk java as of asterisk-java-2.0.3 + +To use this repository add these entries to your pom.xml + + + + mvn-repo + https://raw.githubusercontent.com/asterisk-java/asterisk-java/mvn-repo + + true + + + true + + + + +To add a new version to this repository: + + switch to the 'mvn repo' branch + + The existing repo in the 'mvn repo' branch needs to be copied into the target directory before the build, so that the meta data will be correctly updated + + mkdir -p target/mvn-repo + cp -R org target/mvn-repo + + change to the branch you intend to build (the target directory should be preserved as it isn't tracked by git) + + mvn deploy + + change back to the 'mvn repo' again the target directory should be preserved + + copy the files created under target/mvn-repo to the mvn-repo branch of asterisk-java + + cp -R target/mvn-repo/org . + + commit and push the changes. diff --git a/atlassian-ide-plugin.xml b/atlassian-ide-plugin.xml deleted file mode 100644 index d48888417..000000000 --- a/atlassian-ide-plugin.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - e88a6130-6bd2-45dd-aa5d-57b845f76d0f - reucon - https://secure.reucon.net/issues - false - - - 68a20e42-e943-4a1d-b807-45cad35b4f73 - reucon - https://secure.reucon.net/build - false - false - false - - - - - - - 89c4100c-3c20-4d7d-8611-0dbe1bee742e - repos - asterisk-java/trunk - e88a6130-6bd2-45dd-aa5d-57b845f76d0f - - \ No newline at end of file diff --git a/bnd.bnd b/bnd.bnd deleted file mode 100644 index 23723bf1e..000000000 --- a/bnd.bnd +++ /dev/null @@ -1,16 +0,0 @@ -Main-Class: org.asteriskjava.Cli - -Bundle-SymbolicName: org.asteriskjava -Bundle-Name: ${project.name} -Bundle-Description: ${project.description} -Bundle-DocURL: ${project.url} -Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt - --exportcontents: !*.internal.*, * - -Import-Package: \ - javax.net,\ - javax.net.ssl,\ - javax.script,\ - org.apache.log4j;resolution:=optional,\ - org.slf4j;resolution:=optional diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 6af40b84c..000000000 --- a/build.gradle +++ /dev/null @@ -1,156 +0,0 @@ -apply plugin: 'java' -apply plugin: 'maven' -apply plugin: 'idea' -apply plugin: 'eclipse' -apply plugin: 'signing' - -group = 'org.asteriskjava' -version = '2.0.0.CI-SNAPSHOT' - -description = """Asterisk-Java""" - -sourceCompatibility = 1.7 -targetCompatibility = 1.7 - -repositories { - - maven { url "http://repo.maven.apache.org/maven2" } -} - -dependencies { - compile group: 'log4j', name: 'log4j', version:'1.2.17' - compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.1' - compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.9' - testCompile group: 'org.easymock', name: 'easymock', version:'3.3' - testCompile group: 'junit', name: 'junit', version:'4.12' - testCompile group: 'ch.qos.logback', name: 'logback-classic', version:'1.1.2' -} - -test { - testLogging { - events 'started', 'passed' - } -} - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -artifacts { - archives javadocJar, sourcesJar -} - -signing { - required { gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives -} - -def ossrhUsername = hasProperty('ossrhUsername') ? ossrhUsername : '' -def ossrhPassword = hasProperty('ossrhPassword') ? ossrhPassword : '' - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - - pom.project { - name 'Asterisk-Java' - packaging 'jar' - // optionally artifactId can be defined here - description 'The free Java library for Asterisk PBX integration.' - url 'https://github.com/asterisk-java/asterisk-java' - - scm { - connection 'scm:git:https://github.com/asterisk-java/asterisk-java.git' - developerConnection 'scm:git:https://github.com/asterisk-java/asterisk-java.git' - url 'https://github.com/asterisk-java/asterisk-java' - } - - licenses { - license { - name 'Apache 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.html' - } - } - - mailingLists { - mailingList { - name 'Asterisk-Java User List' - subscribe "http://lists.sourceforge.net/mailman/listinfo/asterisk-java-users" - unsubscribe "http://lists.sourceforge.net/mailman/listinfo/asterisk-java-users" - archive "http://sourceforge.net/mailarchive/forum.php?forum=asterisk-java-users" - } - mailingList { - name "Asterisk-Java Developer List" - subscribe "http://lists.sourceforge.net/mailman/listinfo/asterisk-java-devel" - unsubscribe "http://lists.sourceforge.net/mailman/listinfo/asterisk-java-devel" - archive "http://sourceforge.net/mailarchive/forum.php?forum=asterisk-java-devel" - } - } - - developers { - developer { - id 'srt' - name 'Stefan Reuter' - email 'stefan.reuter at reucon.com' - timezone '+1' - } - developer { - name 'Pierre-Yves Roger' - id 'partoutatis' - email 'partoutatis at users.sourceforge.net' - timezone '+1' - } - developer { - name 'John Hood' - id 'squinky86' - email 'john at asteriasgi.com' - organization 'Asteria Solutions Group, Inc.' - timezone '-6' - } - developer { - name 'Martin B. Smith' - id 'martins' - email 'martins at bebr.ufl.edu' - organization 'Bureau of Economic and Business Research, University of Florida' - timezone '-5' - } - developer { - name 'S. Brett Sutton' - id 'bsutton' - email 'bsutton at noojee.com.au' - organization 'Noojee Telephony Solutions Pty Ltd' - timezone '+10' - } - developer { - name 'Octavio Luna' - id 'itaqua' - email 'octavio.luna at gmail.com' - organization 'N4Utilus Take your Business to the Cloud' - timezone '-6' - } - developer { - name 'Zoumana TRAORE' - id 'zoumhussein' - email 'github at zoumanatraore dot fr' - timezone '+1' - } - } - } - } - } -} \ No newline at end of file diff --git a/checkstyle.xml b/checkstyle.xml deleted file mode 100644 index 1ebdae55f..000000000 --- a/checkstyle.xml +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/codestyle.xml b/codestyle.xml deleted file mode 100644 index 8a7fdc97a..000000000 --- a/codestyle.xml +++ /dev/null @@ -1,251 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dist/agi/demo.groovy b/dist/agi/demo.groovy deleted file mode 100644 index 49563fa31..000000000 --- a/dist/agi/demo.groovy +++ /dev/null @@ -1,18 +0,0 @@ -// countdown -(10..0).each { digit -> channel.sayNumber(digit.toString()) } - -channel.streamFile('beep'); - -// read a few dtmf digits -while ((digit = channel.waitForDigit(10000)) != 0) -{ - if (digit == '#' || digit == '*') - { - break; - } - channel.sayDigits(digit.toString()); -} - -// beep to say good bye ;) -channel.streamFile('beep'); - diff --git a/dist/agi/demo.js b/dist/agi/demo.js deleted file mode 100644 index 58ade0537..000000000 --- a/dist/agi/demo.js +++ /dev/null @@ -1,23 +0,0 @@ -// countdown -for (var i = 10; i >= 0; i--) -{ - channel.sayNumber(i); -} - -channel.streamFile('beep'); - -// read a few dtmf digits -var code; -while ((code = channel.waitForDigit(10000)) != 0) -{ - var digit = String.fromCharCode(code); - if (digit == '#' || digit == '*') - { - break; - } - channel.sayDigits(digit); -} - -// beep to say good bye ;) -channel.streamFile('beep'); - diff --git a/dist/agi/demo.php b/dist/agi/demo.php deleted file mode 100644 index 3117f8409..000000000 --- a/dist/agi/demo.php +++ /dev/null @@ -1,24 +0,0 @@ -= 0; $i--) -{ - $channel->sayNumber($i); -} - -$channel->streamFile('beep'); - -// read a few dtmf digits -while (($digit = $channel->waitForDigit(10000)) != 0) -{ - if ($digit == '#' || $digit == '*') - { - break; - } - $channel->sayDigits($digit); -} - -// beep to say good bye ;) -$channel->streamFile('beep'); - -?> diff --git a/dist/lib/groovy-all-1.6.2.jar b/dist/lib/groovy-all-1.6.2.jar deleted file mode 100644 index 34051aa35..000000000 Binary files a/dist/lib/groovy-all-1.6.2.jar and /dev/null differ diff --git a/dist/lib/javamail-141.jar b/dist/lib/javamail-141.jar deleted file mode 100644 index 59543774f..000000000 Binary files a/dist/lib/javamail-141.jar and /dev/null differ diff --git a/dist/lib/jruby-complete-1.2.0.jar b/dist/lib/jruby-complete-1.2.0.jar deleted file mode 100644 index 02e447d7b..000000000 Binary files a/dist/lib/jruby-complete-1.2.0.jar and /dev/null differ diff --git a/dist/lib/mysql-connector-java-5.1.7-bin.jar b/dist/lib/mysql-connector-java-5.1.7-bin.jar deleted file mode 100644 index ebfe06861..000000000 Binary files a/dist/lib/mysql-connector-java-5.1.7-bin.jar and /dev/null differ diff --git a/dist/lib/quercus-3.2.1.jar b/dist/lib/quercus-3.2.1.jar deleted file mode 100644 index 1771160a6..000000000 Binary files a/dist/lib/quercus-3.2.1.jar and /dev/null differ diff --git a/dist/lib/resin-util-3.2.1.jar b/dist/lib/resin-util-3.2.1.jar deleted file mode 100644 index 66a46885a..000000000 Binary files a/dist/lib/resin-util-3.2.1.jar and /dev/null differ diff --git a/dist/lib/servlet-api-2.5.jar b/dist/lib/servlet-api-2.5.jar deleted file mode 100644 index 4729d6ed7..000000000 Binary files a/dist/lib/servlet-api-2.5.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 2322723c7..000000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index cf497ceec..000000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Tue Jun 16 01:35:27 CDT 2015 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip diff --git a/gradlew b/gradlew deleted file mode 100755 index 91a7e269e..000000000 --- a/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index aec99730b..000000000 --- a/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip new file mode 100644 index 000000000..08046b3bd Binary files /dev/null and b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip differ diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip.md5 b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip.md5 new file mode 100644 index 000000000..da6f78afd --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip.md5 @@ -0,0 +1 @@ +a42ffdbe1b54027c5e93cdfcbeca3f20 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip.sha1 b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip.sha1 new file mode 100644 index 000000000..b7769d312 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3-bin.zip.sha1 @@ -0,0 +1 @@ +0c71415d2f2cc1c7def41e33f0d23a45364e1d6f \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar new file mode 100644 index 000000000..9010b3030 Binary files /dev/null and b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar differ diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar.md5 b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar.md5 new file mode 100644 index 000000000..2670270c8 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar.md5 @@ -0,0 +1 @@ +7d86d75ba2b76e1cebdff27564b0a3a0 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar.sha1 b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar.sha1 new file mode 100644 index 000000000..91c7bd9c3 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.jar.sha1 @@ -0,0 +1 @@ +f511681ca9b52145cc25ed9ba9e3213dbbc2137d \ No newline at end of file diff --git a/pom.xml b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom similarity index 83% rename from pom.xml rename to org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom index 22c84c72b..6431933b6 100644 --- a/pom.xml +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom @@ -4,7 +4,7 @@ org.asteriskjava asterisk-java Asterisk-Java - 2.0.0.alpha-SNAPSHOT + 2.0.3 The free Java library for Asterisk PBX integration. 2004 @@ -70,33 +70,15 @@ https://github.com/asterisk-java/asterisk-java - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2 + internal + file://${project.build.directory}/mvn-repo GitHub https://github.com/asterisk-java/asterisk-java/issues - - - Asterisk-Java User List - http://lists.sourceforge.net/mailman/listinfo/asterisk-java-users - http://lists.sourceforge.net/mailman/listinfo/asterisk-java-users - http://sourceforge.net/mailarchive/forum.php?forum=asterisk-java-users - - - Asterisk-Java Developer List - http://lists.sourceforge.net/mailman/listinfo/asterisk-java-devel - http://lists.sourceforge.net/mailman/listinfo/asterisk-java-devel - http://sourceforge.net/mailarchive/forum.php?forum=asterisk-java-devel - - UTF-8 @@ -180,18 +162,18 @@ 4.12 test - - log4j - log4j - 1.2.17 - compile - org.slf4j slf4j-api 1.7.9 compile + + log4j + log4j + 1.2.17 + provided + ch.qos.logback logback-classic @@ -251,27 +233,21 @@ org.apache.maven.plugins maven-gpg-plugin 1.5 + + EA919AF2 + sign-artifacts verify + sign + - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.5 - true - - ossrh - https://oss.sonatype.org/ - false - - diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom.md5 b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom.md5 new file mode 100644 index 000000000..fa086557c --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom.md5 @@ -0,0 +1 @@ +202f84cbb341707535ba7cc20cffefa3 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom.sha1 b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom.sha1 new file mode 100644 index 000000000..81d67eec4 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.3/asterisk-java-2.0.3.pom.sha1 @@ -0,0 +1 @@ +3a2c0f758de6fea6c6d64dbe9231a4ce114f8453 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip new file mode 100644 index 000000000..72a253918 Binary files /dev/null and b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip differ diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip.md5 b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip.md5 new file mode 100644 index 000000000..b6d1167a6 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip.md5 @@ -0,0 +1 @@ +0aa34bf06c6e50624454b2c497abb0d4 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip.sha1 b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip.sha1 new file mode 100644 index 000000000..f861f3bd2 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4-bin.zip.sha1 @@ -0,0 +1 @@ +0402484ddc98b6b4234f5bdde42fda200ac58c49 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar new file mode 100644 index 000000000..bd7a3c28b Binary files /dev/null and b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar differ diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar.md5 b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar.md5 new file mode 100644 index 000000000..782aa76fb --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar.md5 @@ -0,0 +1 @@ +57fdfe9fb42d1d7c5d638f54186f53d4 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar.sha1 b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar.sha1 new file mode 100644 index 000000000..3165cdad1 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.jar.sha1 @@ -0,0 +1 @@ +67dba4d2170192bba48617b9831e191916982f84 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom new file mode 100644 index 000000000..8fd7e6614 --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom @@ -0,0 +1,255 @@ + + 4.0.0 + org.asteriskjava + asterisk-java + Asterisk-Java + 2.0.4 + The free Java library for Asterisk PBX integration. + 2004 + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + https://github.com/asterisk-java/asterisk-java + + + + Stefan Reuter + srt + stefan.reuter at reucon.com + +1 + + + Pierre-Yves Roger + partoutatis + partoutatis at users.sourceforge.net + +1 + + + John Hood + squinky86 + john at asteriasgi.com + Asteria Solutions Group, Inc. + -6 + + + Martin B. Smith + martins + martins at bebr.ufl.edu + Bureau of Economic and Business Research, University of Florida + -5 + + + S. Brett Sutton + martins + bsutton at noojee.com.au + Noojee Telephony Solutions Pty Ltd + +10 + + + Zoumana TRAORE + zoumhussein + github at zoumanatraore dot fr + +1 + + + Robert Sutton + rsutton + rsutton at noojee.com.au + +10 + + + + scm:git:git@github.com:asterisk-java/asterisk-java.git + scm:git:git@github.com:asterisk-java/asterisk-java.git + https://github.com/asterisk-java/asterisk-java + + + + internal + file://${project.build.directory}/mvn-repo + + + + GitHub + https://github.com/asterisk-java/asterisk-java/issues + + + UTF-8 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.5 + + true + + + + biz.aQute.bnd + bnd-maven-plugin + 3.2.0 + + + + bnd-process + + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + true + false + release + deploy + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.2 + + 1.7 + 1.7 + + + + maven-surefire-plugin + 2.18 + + + maven-assembly-plugin + 2.5.3 + + + ${project.basedir}/src/main/assembly/bin.xml + + + + + make-assembly + package + + attached + + + + + + ${project.artifactId} + + + + org.easymock + easymock + 3.3 + test + + + junit + junit + 4.12 + test + + + org.slf4j + slf4j-api + 1.7.9 + compile + + + log4j + log4j + 1.2.17 + provided + + + ch.qos.logback + logback-classic + 1.1.2 + test + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 2.4 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.1 + + + attach-javadocs + + jar + + + + + + + Codestin Search App + + org.asteriskjava:org.asteriskjava.fastagi:org.asteriskjava.fastagi.command:org.asteriskjava.fastagi.reply:org.asteriskjava.manager:org.asteriskjava.manager.action:org.asteriskjava.manager.response:org.asteriskjava.manager.event:org.asteriskjava.live:org.asteriskjava.util + + + + Codestin Search App + + org.asteriskjava.fastagi.internal:org.asteriskjava.manager.internal:org.asteriskjava.live.internal:org.asteriskjava.util.internal + + + +
${project.name}
+
+
+ + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + EA919AF2 + + + + sign-artifacts + verify + + + sign + + + + + +
+
+
+
+
diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom.md5 b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom.md5 new file mode 100644 index 000000000..d567239ee --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom.md5 @@ -0,0 +1 @@ +58585be68970342355e0e7c74fde0c5d \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom.sha1 b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom.sha1 new file mode 100644 index 000000000..a5051dfbe --- /dev/null +++ b/org/asteriskjava/asterisk-java/2.0.4/asterisk-java-2.0.4.pom.sha1 @@ -0,0 +1 @@ +6e3d3f389d97a8e9c03614ff689133a7b902e4d1 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/maven-metadata.xml b/org/asteriskjava/asterisk-java/maven-metadata.xml new file mode 100644 index 000000000..944c27ab6 --- /dev/null +++ b/org/asteriskjava/asterisk-java/maven-metadata.xml @@ -0,0 +1,13 @@ + + + org.asteriskjava + asterisk-java + + 2.0.4 + + 2.0.3 + 2.0.4 + + 20190130223646 + + diff --git a/org/asteriskjava/asterisk-java/maven-metadata.xml.md5 b/org/asteriskjava/asterisk-java/maven-metadata.xml.md5 new file mode 100644 index 000000000..c094b6218 --- /dev/null +++ b/org/asteriskjava/asterisk-java/maven-metadata.xml.md5 @@ -0,0 +1 @@ +57d293cc65a55ab92d506921d8e14976 \ No newline at end of file diff --git a/org/asteriskjava/asterisk-java/maven-metadata.xml.sha1 b/org/asteriskjava/asterisk-java/maven-metadata.xml.sha1 new file mode 100644 index 000000000..2ba906c01 --- /dev/null +++ b/org/asteriskjava/asterisk-java/maven-metadata.xml.sha1 @@ -0,0 +1 @@ +75590b4a8b5efdeac7ac4e37c5139fe2abc4320f \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 553c1b13b..000000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'asterisk-java' diff --git a/src/integrationtest/log4j.properties b/src/integrationtest/log4j.properties deleted file mode 100644 index d35b4c93b..000000000 --- a/src/integrationtest/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootCategory=INFO, Console -log4j.category.org.asteriskjava.live=DEBUG - -log4j.appender.Console=org.apache.log4j.ConsoleAppender -log4j.appender.Console.layout=org.apache.log4j.PatternLayout -log4j.appender.Console.layout.ConversionPattern=%d %c %p [%t] - %m\n \ No newline at end of file diff --git a/src/integrationtest/org/asteriskjava/fastagi/GetDataScript.java b/src/integrationtest/org/asteriskjava/fastagi/GetDataScript.java deleted file mode 100644 index d46c523ef..000000000 --- a/src/integrationtest/org/asteriskjava/fastagi/GetDataScript.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.asteriskjava.fastagi; - -import org.asteriskjava.manager.DefaultManagerConnection; -import org.asteriskjava.manager.ManagerConnection; - -import java.util.Date; - -public class GetDataScript extends BaseAgiScript -{ - public void service(AgiRequest request, AgiChannel channel) throws AgiException - { - channel.streamFile("tt-monkeys"); - channel.sayDateTime(new Date().getTime()); - } - - public static void main(String[] args) throws Exception - { - ManagerConnection connection; - AsyncAgiServer agiServer; - - connection = new DefaultManagerConnection("localhost", "manager", "obelisk"); - agiServer = new AsyncAgiServer(new GetDataScript()); - connection.addEventListener(agiServer); - connection.login(); - - while (true) - { - Thread.sleep(1000L); - } - } -} diff --git a/src/integrationtest/org/asteriskjava/fastagi/HangupTest.java b/src/integrationtest/org/asteriskjava/fastagi/HangupTest.java deleted file mode 100644 index 5b1ec320d..000000000 --- a/src/integrationtest/org/asteriskjava/fastagi/HangupTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.asteriskjava.fastagi; - - -import org.apache.log4j.Logger; -import org.asteriskjava.live.DefaultAsteriskServer; - -import java.io.IOException; -import java.net.InetAddress; -import java.util.Arrays; - -public class HangupTest extends BaseAgiScript -{ - private Logger logger = Logger.getLogger(HangupTest.class); - - public void service(AgiRequest request, AgiChannel channel) throws AgiException - { - System.out.println(Arrays.toString(request.getArguments())); - answer(); - - try - { - for (int i = 0; i < 5000; i++) - { - System.out.println("Saying " + i); - sayDigits(String.valueOf(i)); - } - } - catch (Exception e) - { - logger.info("Exception caught: " + e.getMessage(), e); - } - - } - - public static void main(String[] args) throws IOException - { - AgiServerThread agiServerThread = new AgiServerThread(); - agiServerThread.setAgiServer(new DefaultAgiServer()); - agiServerThread.setDaemon(false); - agiServerThread.startup(); - - DefaultAsteriskServer server = new DefaultAsteriskServer("localhost", 1234, "manager", "obelisk"); - server.initialize(); - server.originateToApplication("SIP/phone-02", "AGI", - "agi://" + InetAddress.getLocalHost().getHostAddress() + "/" + HangupTest.class.getName() - + ", arg1,,arg3", 30000); - } -} \ No newline at end of file diff --git a/src/integrationtest/org/asteriskjava/fastagi/SpeechDemo.java b/src/integrationtest/org/asteriskjava/fastagi/SpeechDemo.java deleted file mode 100644 index 7a581fde3..000000000 --- a/src/integrationtest/org/asteriskjava/fastagi/SpeechDemo.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.asteriskjava.fastagi; - -import java.io.IOException; - -public class SpeechDemo extends BaseAgiScript -{ - // the digits grammar is shipped as part of the Lumenvox engine - private final String grammarPath = "/etc/lumenvox/Lang/BuiltinGrammars/ABNFDigits.gram"; - - public void service(AgiRequest request, AgiChannel channel) throws AgiException - { - try - { - // answer the call - answer(); - - // and say hello - streamFile("speech-demo/welcome"); - - // initialize the speech engine - speechCreate(); - } - catch (AgiHangupException e) - { - System.out.println("User hung up."); - } - catch (AgiSpeechException e) - { - System.out.println("Unable to initialize speech engine: no speech engine installed or licence trouble."); - streamFile("speech-demo/engine-error"); - hangup(); - return; - } - - try - { - while (true) - { - recognizeDigits(); - } - } - catch (AgiHangupException e) - { - System.out.println("User hung up."); - } - finally - { - try - { - // make sure to destroy the speech object otherwise licenses might leak. - speechDestroy(); - } - catch (Exception e) - { - // swallow - } - } - } - - public void recognizeDigits() throws AgiException - { - final String grammarLabel = "digits"; - - // load the grammar we are going the use - speechLoadGrammar(grammarLabel, grammarPath); - - // active it - speechActivateGrammar(grammarLabel); - - // and use if for recognition - SpeechRecognitionResult result = speechRecognize("speech-demo/prompt", 10); - System.out.println(result); - - // deactivate the grammar - speechDeactivateGrammar(grammarLabel); - - // check whether speech was recognized or a DTMF digit was pressed - if (result.isSpeech()) - { - // if speech was recognized look at the confidence score - if (result.getScore() > 990) - { - streamFile("speech-demo/absolutely-sure"); - } - else if (result.getScore() > 800) - { - streamFile("speech-demo/pretty-sure"); - } - else - { - streamFile("speech-demo/not-sure"); - } - - // say what we have recognized - sayDigits(result.getText()); - } - else if (result.isDtmf()) - { - // if the user pressed a DTMF digit - streamFile("speech-demo/dtmf"); - - // read it back to him - if (result.getDigit() == '*') - { - streamFile("digits/star"); - } - else if (result.getDigit() == '#') - { - streamFile("digits/pound"); - } - else - { - sayDigits(Character.toString(result.getDigit())); - } - } - else - { - // if we received no input play an error message - streamFile("speech-demo/no-input"); - } - } - - public static void main(String[] args) throws IOException - { - AgiServerThread agiServerThread = new AgiServerThread(); - agiServerThread.setAgiServer(new DefaultAgiServer()); - agiServerThread.setDaemon(false); - agiServerThread.startup(); - } -} \ No newline at end of file diff --git a/src/integrationtest/org/asteriskjava/live/AsteriskServerTestCase.java b/src/integrationtest/org/asteriskjava/live/AsteriskServerTestCase.java deleted file mode 100644 index 5b485adc7..000000000 --- a/src/integrationtest/org/asteriskjava/live/AsteriskServerTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import junit.framework.TestCase; - -public class AsteriskServerTestCase extends TestCase -{ - protected AsteriskServer server; - - @Override - public void setUp() throws Exception - { - server = new DefaultAsteriskServer("pbx0", "manager", "obelisk"); - //server = new DefaultAsteriskServer("localhost", "manager", "obelisk"); - } - - @Override - public void tearDown() throws Exception - { - server.getManagerConnection().logoff(); - } -} diff --git a/src/integrationtest/org/asteriskjava/live/MeetMeTest.java b/src/integrationtest/org/asteriskjava/live/MeetMeTest.java deleted file mode 100644 index 91bfd9877..000000000 --- a/src/integrationtest/org/asteriskjava/live/MeetMeTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.asteriskjava.live; - -import java.util.Collection; - -public class MeetMeTest extends AsteriskServerTestCase -{ - public void testMeetMeRoom() throws Exception - { - server.originateToExtension("Local/1201@basa", "conference", "1000", 1, 5000L); - - server.getMeetMeRoom("1000"); - printRooms(); - System.out.println("waiting..."); - Thread.sleep(20000); - printRooms(); - } - - private void printRooms() throws Exception - { - Collection rooms; - rooms = server.getMeetMeRooms(); - for (MeetMeRoom room : rooms) - { - System.out.println(room); - for (MeetMeUser user : room.getUsers()) - { - System.out.println(" " + user); - } - } - } -} diff --git a/src/integrationtest/org/asteriskjava/live/MiscTest.java b/src/integrationtest/org/asteriskjava/live/MiscTest.java deleted file mode 100644 index a001c7053..000000000 --- a/src/integrationtest/org/asteriskjava/live/MiscTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -import org.asteriskjava.config.ConfigFile; - -/** - * @author srt - * @version $Id$ - */ -public class MiscTest extends AsteriskServerTestCase -{ - public void testGlobalVariables() throws Exception - { - server.setGlobalVariable("AJ_TEST_VAR", "foobar"); - assertEquals("foobar", server.getGlobalVariable("AJ_TEST_VAR")); - } - - public void testFunctions() throws Exception - { - System.err.println(server.getGlobalVariable("DB(/Agents,1301)")); - } - - public void testGetVoicemailboxes() throws Exception - { - System.err.println("mailboxes: " + server.getVoicemailboxes()); - } - - public void testGetConfig() throws Exception - { - ConfigFile config; - - config = server.getConfig("voicemail.conf"); - assertEquals("voicemail.conf", config.getFilename()); - - System.err.println(config.getCategories()); - } - -} diff --git a/src/integrationtest/org/asteriskjava/live/OriginateCauseAsyncTest.java b/src/integrationtest/org/asteriskjava/live/OriginateCauseAsyncTest.java deleted file mode 100644 index bfef9d0e2..000000000 --- a/src/integrationtest/org/asteriskjava/live/OriginateCauseAsyncTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - - -/** - * @author srt - * @version $Id$ - */ -public class OriginateCauseAsyncTest extends AsteriskServerTestCase -{ - private MyStatus status; - private MyOriginateCallback cb; - private Long timeout = 10000L; - - @Override - public void setUp() throws Exception - { - super.setUp(); - status = new MyStatus(); - cb = new MyOriginateCallback(); - } - - public void testOriginateFailure() throws Exception - { - synchronized (status) - { - server.originateToExtensionAsync("Local/none@aj-test", "aj-test", "answer", 1, timeout, cb); - status.wait(); - assertNotNull(status.failureException); - } - } - - public void testOriginateSuccess() throws Exception - { - synchronized (status) - { - server.originateToExtensionAsync("Local/answer@aj-test", "aj-test", "answer", 1, timeout, cb); - status.wait(); - status.print(); - assertNotNull(status.dialingChannel); - assertNotNull(status.successChannel); - } - } - - public void testOriginateBusy() throws Exception - { - synchronized (status) - { - server.originateToExtensionAsync("Local/busy@aj-test", "aj-test", "answer", 1, timeout, cb); - status.wait(); - status.print(); - assertNotNull(status.busyChannel); - } - } - - public void testOriginateCongestion() throws Exception - { - synchronized (status) - { - server.originateToExtensionAsync("Local/congestion@aj-test", "aj-test", "answer", 1, timeout, cb); - status.wait(); - status.print(); - // congestion is treated like busy - assertNotNull(status.busyChannel); - } - } - - public void testOriginateNoAnswer() throws Exception - { - synchronized (status) - { - server.originateToExtensionAsync("Local/noanswer@aj-test", "aj-test", "answer", 1, timeout, cb); - status.wait(); - status.print(); - assertNotNull(status.noAnswerChannel); - } - } - - void showInfo(AsteriskChannel channel) - { - String name; - String otherName; - AsteriskChannel otherChannel; - - System.err.println("linkedChannelHistory: " + channel.getLinkedChannelHistory()); - System.err.println("dialedChannelHistory: " + channel.getDialedChannelHistory()); - - name = channel.getName(); - if (name.startsWith("Local/")) - { - otherName = name.substring(0, name.length() - 1) + "2"; - System.err.println("other name: " + otherName); - try - { - otherChannel = server.getChannelByName(otherName); - } - catch (ManagerCommunicationException e) - { - e.printStackTrace(); - return; - } - System.err.println("other channel: " + otherChannel); - System.err.println("other dialedChannel: " + otherChannel.getDialedChannel()); - System.err.println("other linkedChannelHistory: " + otherChannel.getLinkedChannelHistory()); - System.err.println("other dialedChannelHistory: " + otherChannel.getDialedChannelHistory()); - } - } - - class MyOriginateCallback implements OriginateCallback - { - boolean sealed = false; - - public void onDialing(AsteriskChannel channel) - { - status.dialingChannel = channel; - } - - public void onFailure(LiveException cause) - { - status.failureException = cause; - doNotify(); - } - - public void onBusy(AsteriskChannel channel) - { - status.busyChannel = channel; - doNotify(); - } - - public void onNoAnswer(AsteriskChannel channel) - { - status.noAnswerChannel = channel; - doNotify(); - } - - public void onSuccess(AsteriskChannel channel) - { - status.successChannel = channel; - doNotify(); - } - - void doNotify() - { - if (sealed) - { - System.err.println("!!! Modifying sealed status !!!"); - } - - sealed = true; - synchronized (status) - { - status.notify(); - } - } - } - - class MyStatus - { - AsteriskChannel dialingChannel; - AsteriskChannel busyChannel; - AsteriskChannel noAnswerChannel; - AsteriskChannel successChannel; - LiveException failureException; - - void print() - { - System.out.println("dialing = " + dialingChannel); - System.out.println("busy = " + busyChannel); - System.out.println("noAnswer = " + noAnswerChannel); - System.out.println("success = " + successChannel); - System.out.println("failure = " + failureException); - } - } -} diff --git a/src/integrationtest/org/asteriskjava/live/OriginateCauseTest.java b/src/integrationtest/org/asteriskjava/live/OriginateCauseTest.java deleted file mode 100644 index e8c696353..000000000 --- a/src/integrationtest/org/asteriskjava/live/OriginateCauseTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - * @author srt - * @version $Id$ - */ -public class OriginateCauseTest extends AsteriskServerTestCase -{ - private AsteriskChannel channel; - private Long timeout = 10000L; - - @Override - public void setUp() throws Exception - { - super.setUp(); - this.channel = null; - } - - public void xtestOriginateInvalidSourceChannel() throws Exception - { - try - { - server.originateToExtension("Local/none@aj-test", "aj-test", "answer", 1, timeout); - fail("Originating from an invalid source channel must throw a NoSuchChannelException"); - } - catch (NoSuchChannelException e) - { - // ok - } - } - - public void testOriginate() throws Exception - { - AsteriskChannel channel; - - channel = server.originateToExtension("Local/answer@aj-test", "aj-test-delayed", "answer", 1, timeout); - System.err.println(channel); - - Thread.sleep(20000L); - System.err.println(channel); - } - - public void xtestOriginateAsync() throws Exception - { - final String source; - - //source = "SIP/1310"; - source = "Local/1337@from-local"; - // source = "Local/1310@from-local/n"; - server.originateToExtensionAsync(source, "conference", "1399", 1, timeout, new CallerId("AJ Test Call", - "08003301000"), null, new OriginateCallback() - { - public void onDialing(final AsteriskChannel c) - { - channel = c; - System.err.println("Dialing: " + channel); - channel.addPropertyChangeListener(new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - System.err.println("PropertyChange (" + ((AsteriskChannel) evt.getSource()).getName() + ") " + evt.getPropertyName() + ": " + evt.getOldValue() + " => " + evt.getNewValue()); - } - }); - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - scheduler.schedule(new Runnable() - { - public void run() - { - System.out.println("Tata"); - try - { - c.hangup(); - } - catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }, 10, TimeUnit.SECONDS); - } - - public void onSuccess(AsteriskChannel c) - { - channel = c; - System.err.println("Success: " + c); - showInfo(c); - try - { - /* - c.setVariable(AsteriskChannel.VARIABLE_MONITOR_EXEC, "/usr/local/bin/2wav2mp3"); - c.setVariable(AsteriskChannel.VARIABLE_MONITOR_EXEC_ARGS, "a b"); - c.startMonitoring("mtest", "wav", true); - Thread.sleep(10000L); - c.stopMonitoring(); - c.setAbsoluteTimeout(20); - */ - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void onNoAnswer(AsteriskChannel c) - { - channel = c; - System.err.println("No Answer: " + c); - showInfo(c); - } - - public void onBusy(AsteriskChannel c) - { - channel = c; - System.err.println("Busy: " + c); - showInfo(c); - } - - public void onFailure(LiveException cause) - { - System.err.println("Failed: " + cause.getMessage()); - } - }); - - Thread.sleep(20000L); - System.err.println("final state: " + channel); - if (channel != null) - { - System.err.println("final state linked channels: " + channel.getLinkedChannelHistory()); - } - } - - void showInfo(AsteriskChannel channel) - { - String name; - String otherName; - AsteriskChannel otherChannel; - - System.err.println("linkedChannelHistory: " + channel.getLinkedChannelHistory()); - System.err.println("dialedChannelHistory: " + channel.getDialedChannelHistory()); - - name = channel.getName(); - if (name.startsWith("Local/")) - { - otherName = name.substring(0, name.length() - 1) + "2"; - System.err.println("other name: " + otherName); - try - { - otherChannel = server.getChannelByName(otherName); - } - catch (ManagerCommunicationException e) - { - e.printStackTrace(); - return; - } - System.err.println("other channel: " + otherChannel); - System.err.println("other dialedChannel: " + otherChannel.getDialedChannel()); - System.err.println("other linkedChannelHistory: " + otherChannel.getLinkedChannelHistory()); - System.err.println("other dialedChannelHistory: " + otherChannel.getDialedChannelHistory()); - } - } -} diff --git a/src/integrationtest/org/asteriskjava/live/OriginateTest.java b/src/integrationtest/org/asteriskjava/live/OriginateTest.java deleted file mode 100644 index 33bdf8247..000000000 --- a/src/integrationtest/org/asteriskjava/live/OriginateTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -/** - * @author srt - * @version $Id$ - */ -public class OriginateTest extends AsteriskServerTestCase -{ - private AsteriskChannel channel; - private Long timeout = 20000L; - - @Override - public void setUp() throws Exception - { - super.setUp(); - this.channel = null; - } - - public void xtestOriginate() throws Exception - { - AsteriskChannel channel; - channel = server.originateToExtension("SIP/1310", "from-local", "1330", 1, timeout); - System.err.println(channel); - System.err.println(channel.getVariable("AJ_TRACE_ID")); - - Thread.sleep(20000L); - System.err.println(channel); - System.err.println(channel.getVariable("AJ_TRACE_ID")); - } - - public void testOriginateAsync() throws Exception - { - final String source; - - //source = "SIP/1310"; - source = "Local/1218@from-local"; - // source = "Local/1310@from-local/n"; - server.originateToExtensionAsync(source, "from-local", "1299", 1, timeout, new CallerId("AJ Test Call", - "08003301000"), null, new OriginateCallback() - { - public void onDialing(final AsteriskChannel c) - { - channel = c; - System.err.println("Dialing: " + channel); - channel.addPropertyChangeListener(new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - System.err.println("PropertyChange (" + ((AsteriskChannel) evt.getSource()).getName() + ") " + evt.getPropertyName() + ": " + evt.getOldValue() + " => " + evt.getNewValue()); - } - }); - ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); - scheduler.schedule(new Runnable() - { - public void run() - { - System.out.println("Tata"); - try - { - System.out.println("Hanging up channel from onDial " + c); - c.hangup(); - } - catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }, 10, TimeUnit.SECONDS); - } - - public void onSuccess(AsteriskChannel c) - { - channel = c; - System.err.println("Success: " + c); - showInfo(c); - try - { - /* - c.setVariable(AsteriskChannel.VARIABLE_MONITOR_EXEC, "/usr/local/bin/2wav2mp3"); - c.setVariable(AsteriskChannel.VARIABLE_MONITOR_EXEC_ARGS, "a b"); - c.startMonitoring("mtest", "wav", true); - Thread.sleep(10000L); - c.stopMonitoring(); - c.setAbsoluteTimeout(20); - */ - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void onNoAnswer(AsteriskChannel c) - { - channel = c; - System.err.println("No Answer: " + c); - showInfo(c); - } - - public void onBusy(AsteriskChannel c) - { - channel = c; - System.err.println("Busy: " + c); - showInfo(c); - } - - public void onFailure(LiveException cause) - { - System.err.println("Failed: " + cause.getMessage()); - } - }); - - Thread.sleep(20000L); - System.err.println("final state: " + channel); - if (channel != null) - { - System.err.println("final state linked channels: " + channel.getLinkedChannelHistory()); - } - } - - void showInfo(AsteriskChannel channel) - { - String name; - String otherName; - AsteriskChannel otherChannel; - - System.err.println("linkedChannelHistory: " + channel.getLinkedChannelHistory()); - System.err.println("dialedChannelHistory: " + channel.getDialedChannelHistory()); - - name = channel.getName(); - if (name.startsWith("Local/")) - { - otherName = name.substring(0, name.length() - 1) + "2"; - System.err.println("other name: " + otherName); - try - { - otherChannel = server.getChannelByName(otherName); - } - catch (ManagerCommunicationException e) - { - e.printStackTrace(); - return; - } - System.err.println("other channel: " + otherChannel); - System.err.println("other dialedChannel: " + otherChannel.getDialedChannel()); - System.err.println("other linkedChannelHistory: " + otherChannel.getLinkedChannelHistory()); - System.err.println("other dialedChannelHistory: " + otherChannel.getDialedChannelHistory()); - } - } -} diff --git a/src/integrationtest/org/asteriskjava/live/SofthangupTest.java b/src/integrationtest/org/asteriskjava/live/SofthangupTest.java deleted file mode 100644 index 436561d65..000000000 --- a/src/integrationtest/org/asteriskjava/live/SofthangupTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -import org.asteriskjava.manager.action.OriginateAction; - -/** - * @author srt - * @version $Id$ - */ -public class SofthangupTest extends AsteriskServerTestCase -{ - public void testSofthangup() throws Exception - { - OriginateAction originate; - - originate = new OriginateAction(); - originate.setChannel("Local/1310"); - originate.setContext("default"); - originate.setExten("1340"); - originate.setPriority(1); - - //ManagerResponse response = managerConnection.sendAction(originate); - //System.out.println("Response: " + response); - - Thread.sleep(10000); - } -} diff --git a/src/integrationtest/org/asteriskjava/live/TestDefaultAsteriskServer.java b/src/integrationtest/org/asteriskjava/live/TestDefaultAsteriskServer.java deleted file mode 100644 index ff7a620da..000000000 --- a/src/integrationtest/org/asteriskjava/live/TestDefaultAsteriskServer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -import java.util.Arrays; -import java.util.Collection; - - -/** - * @author srt - * @version $Id$ - */ -public class TestDefaultAsteriskServer extends AsteriskServerTestCase -{ - public void testGetChannels() throws Exception - { - System.out.println("waiting for channels..."); - - try - { - Thread.sleep(10000); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - - Collection channels = server.getChannels(); - - System.out.println("got channels. waiting to hangup..."); - - try - { - Thread.sleep(1000); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - - for (AsteriskChannel channel : channels) - { - if (!channel.getName().startsWith("SIP/1310")) - { - continue; - } - - System.out.println(channel); - try - { - channel.redirectBothLegs("default", "1399", 1); - //channel.hangup(); - } - catch (NoSuchChannelException e) - { - System.out.println(e.getMessage()); - } - } - } - - public void XtestGetQueues() throws Exception - { - System.out.println("waiting for queues..."); - - try - { - Thread.sleep(10000); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - - Collection queues = server.getQueues(); - for (AsteriskQueue queue : queues) - { - System.out.println(queue); - } - } - - public void testGetVersion() throws Exception - { - System.out.println(Arrays.toString(server.getVersion("cdr_manager.c"))); - System.out.println(server.getVersion()); - } -} diff --git a/src/integrationtest/org/asteriskjava/live/TestExtensionHistory.java b/src/integrationtest/org/asteriskjava/live/TestExtensionHistory.java deleted file mode 100644 index b8da3c757..000000000 --- a/src/integrationtest/org/asteriskjava/live/TestExtensionHistory.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -import java.util.Collection; - -/** - * @author srt - * @version $Id$ - */ -public class TestExtensionHistory extends AsteriskServerTestCase -{ - public void testGetHistory() throws Exception - { - Collection channels; - - try - { - Thread.sleep(5000); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - - channels = server.getChannels(); - System.out.println("# of active channels: " + channels.size()); - for (AsteriskChannel channel : channels) - { - System.out.println(channel); - System.out.println(" first extension: " + channel.getFirstExtension()); - System.out.println(" current extension: " + channel.getCurrentExtension()); - - for (ExtensionHistoryEntry extensionHistoryEntry : channel.getExtensionHistory()) - { - System.out.println(" " + extensionHistoryEntry); - } - } - } -} diff --git a/src/integrationtest/org/asteriskjava/live/TestLiveReconnect.java b/src/integrationtest/org/asteriskjava/live/TestLiveReconnect.java deleted file mode 100644 index 6321f3fa5..000000000 --- a/src/integrationtest/org/asteriskjava/live/TestLiveReconnect.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Oct 28, 2004 - */ -package org.asteriskjava.live; - -/** - * @author srt - * @version $Id$ - */ -public class TestLiveReconnect extends AsteriskServerTestCase -{ - public void testLiveReconnect() throws Exception - { - System.out.println("Please stop and restart the Asterisk server..."); - while (true) - { - Thread.sleep(300000); - } - } -} diff --git a/src/integrationtest/org/asteriskjava/manager/AbstractManagerTestCase.java b/src/integrationtest/org/asteriskjava/manager/AbstractManagerTestCase.java deleted file mode 100644 index cd4844a91..000000000 --- a/src/integrationtest/org/asteriskjava/manager/AbstractManagerTestCase.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.asteriskjava.manager; - -import junit.framework.TestCase; - -public abstract class AbstractManagerTestCase extends TestCase -{ - protected DefaultManagerConnection getDefaultManagerConnection() - { - DefaultManagerConnection dmc; - - dmc = new DefaultManagerConnection(); - dmc.setUsername("manager"); - dmc.setPassword("obelisk"); - dmc.setHostname("10.12.0.1"); - dmc.setPort(5038); - - return dmc; - } -} diff --git a/src/integrationtest/org/asteriskjava/manager/TestAsyncAgi.java b/src/integrationtest/org/asteriskjava/manager/TestAsyncAgi.java deleted file mode 100644 index b11709c2b..000000000 --- a/src/integrationtest/org/asteriskjava/manager/TestAsyncAgi.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Sep 24, 2004 - */ -package org.asteriskjava.manager; - -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.action.VoicemailUsersListAction; -import org.asteriskjava.manager.action.AgiAction; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.AsyncAgiEvent; -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.ManagerResponse; - -import junit.framework.TestCase; - -import java.util.Iterator; - -/** - * @author srt - * @version $Id$ - */ -public class TestAsyncAgi extends AbstractManagerTestCase -{ - public void testDialplanShow() throws Exception - { - DefaultManagerConnection managerConnection; - - managerConnection = getDefaultManagerConnection(); - managerConnection.login(); - - CommandAction commandAction = new CommandAction("sip show peers"); - ManagerResponse response = managerConnection.sendAction(commandAction); - if (response instanceof CommandResponse) - { - for (String item : ((CommandResponse) response).getResult()) - { - System.out.println(item); - } - } - } - - public void testAgiAction() throws Exception - { - DefaultManagerConnection dmc; - - dmc = getDefaultManagerConnection(); - dmc.addEventListener(new ManagerEventListener() - { - public void onManagerEvent(ManagerEvent event) - { - System.out.println("Got event: " + event); - if (event instanceof AsyncAgiEvent) - { - System.out.println("Decoded env: " + ((AsyncAgiEvent) event).decodeEnv()); - } - } - }); - dmc.login(); - System.out.println("Dial 1296"); - Thread.sleep(5000); - ManagerResponse response = dmc.sendAction(new AgiAction( - "IAX2/iax0-cgn_reucon_net-2", - "EXEC Playback tt-monkeysintro", - "myCommandId")); - System.out.println(response); - - // wait to receive events - Thread.sleep(20000); - dmc.logoff(); - Thread.sleep(3000); - } -} \ No newline at end of file diff --git a/src/integrationtest/org/asteriskjava/manager/TestConcurrentUseOfDefaultManagerConnection.java b/src/integrationtest/org/asteriskjava/manager/TestConcurrentUseOfDefaultManagerConnection.java deleted file mode 100644 index 1aa205e40..000000000 --- a/src/integrationtest/org/asteriskjava/manager/TestConcurrentUseOfDefaultManagerConnection.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Sep 24, 2004 - */ -package org.asteriskjava.manager; - -import java.util.concurrent.atomic.AtomicInteger; - -import junit.framework.TestCase; - -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.event.ManagerEvent; - -/** - * @author srt - * @version $Id$ - */ -public class TestConcurrentUseOfDefaultManagerConnection extends TestCase -{ - private static final int NUM_THREADS = 400; - private static final int NUM_LOOPS = 200; - private DefaultManagerConnection dmc; - private AtomicInteger succeeded; - private AtomicInteger failed; - private AtomicInteger total; - - @Override - protected void setUp() throws Exception - { - dmc = new DefaultManagerConnection(); - dmc.setUsername("manager"); - dmc.setPassword("obelisk"); - dmc.setHostname("pbx0"); - - succeeded = new AtomicInteger(0); - failed = new AtomicInteger(0); - total = new AtomicInteger(0); - - dmc.login(); - } - - @Override - protected void tearDown() throws Exception - { - dmc.logoff(); - } - - public void testConcurrency() throws Exception - { - Thread[] threads = new Thread[NUM_THREADS]; - long start; - long end; - - dmc.addEventListener(new ManagerEventListener() - { - public void onManagerEvent(ManagerEvent event) - { - //System.out.println("Got event: " + event); - } - }); - dmc.setDefaultEventTimeout(20000); - dmc.setDefaultResponseTimeout(20000); - - for (int i = 0; i < NUM_THREADS; i++) - { - threads[i] = new Thread(new Sender()); - threads[i].setName("Sender-" + i); - } - - start = System.currentTimeMillis(); - for (int i = 0; i < NUM_THREADS; i++) - { - threads[i].start(); - } - - for (int i = 0; i < NUM_THREADS; i++) - { - threads[i].join(); - } - end = System.currentTimeMillis(); - - Thread.sleep(1000); - - System.out.println("succeeded: " + succeeded); - System.out.println("failed: " + failed); - System.out.println("total: " + total); - System.out.println("duration: " + (end - start)); - - assertEquals("failed actions", 0, failed.get()); - } - - private class Sender implements Runnable - { - public void run() - { - for (int i = 0; i < NUM_LOOPS; i++) - { - int id = total.getAndIncrement(); - String actionId = "A_" + id; - try - { - /* - PingAction a = new PingAction(); - a.setActionId(actionId); - dmc.sendAction(a); - succeeded.getAndIncrement(); - */ - - ResponseEvents responseEvents; - StatusAction a = new StatusAction(); - a.setActionId(actionId); - responseEvents = dmc.sendEventGeneratingAction(a); - if (responseEvents.getEvents().size() == 2) - { - succeeded.getAndIncrement(); - } - else - { - failed.getAndIncrement(); - } - } - catch (Exception e) - { - failed.getAndIncrement(); - System.err.println("Error for " + actionId); - e.printStackTrace(); - } - } - } - } -} diff --git a/src/integrationtest/org/asteriskjava/manager/TestDefaultManagerConnection.java b/src/integrationtest/org/asteriskjava/manager/TestDefaultManagerConnection.java deleted file mode 100644 index 0c91f7b83..000000000 --- a/src/integrationtest/org/asteriskjava/manager/TestDefaultManagerConnection.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Sep 24, 2004 - */ -package org.asteriskjava.manager; - -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.action.SipShowPeerAction; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.SipShowPeerResponse; - -import junit.framework.TestCase; - -/** - * @author srt - * @version $Id$ - */ -public class TestDefaultManagerConnection extends TestCase -{ - private DefaultManagerConnection getDefaultManagerConnection() - { - DefaultManagerConnection dmc; - - dmc = new DefaultManagerConnection(); - dmc.setUsername("manager"); - dmc.setPassword("obelisk"); - dmc.setHostname("pbx0.reucon.net"); - dmc.setPort(5038); - //dmc.setSsl(true); - - return dmc; - } - - public void XtestLogin() throws Exception - { - DefaultManagerConnection dmc; - - dmc = getDefaultManagerConnection(); - dmc.login(); - dmc.addEventListener(new ManagerEventListener() - { - public void onManagerEvent(ManagerEvent event) - { - System.out.println("Got event: " + event); - } - }); - dmc.sendAction(new StatusAction()); - - // wait for 3 seconds to receive events - Thread.sleep(3000); - dmc.logoff(); - } - - public void testMultipleLogins() throws Exception - { - DefaultManagerConnection dmc; - CommandResponse response; - - dmc = getDefaultManagerConnection(); - dmc.setDefaultResponseTimeout(5000); - - for (int i = 0; i < 10; i++) - { - dmc.login(); - response = (CommandResponse) dmc.sendAction(new CommandAction("show version")); - assertTrue("version does not start with \"Asterisk\"", response.getResult().get(0).startsWith("Asterisk")); - dmc.logoff(); - } - } - - public void testLoginAuthenticationFailure() throws Exception - { - DefaultManagerConnection dmc; - - dmc = getDefaultManagerConnection(); - dmc.setPassword(""); - - try - { - dmc.login(); - dmc.logoff(); - fail("No AuthenticationFailedException received."); - } - catch (AuthenticationFailedException e) - { - } - } - - public void testCommandAction() throws Exception - { - DefaultManagerConnection dmc; - CommandResponse response; - - dmc = getDefaultManagerConnection(); - dmc.login(); - - response = (CommandResponse) dmc.sendAction(new CommandAction("show voicemail users")); - System.out.println("Got response: " + response.getResult()); - - dmc.logoff(); - } - - public void testSipShowPeerAction() throws Exception - { - DefaultManagerConnection dmc; - SipShowPeerResponse response; - - dmc = getDefaultManagerConnection(); - dmc.login(); - - response = (SipShowPeerResponse) dmc.sendAction(new SipShowPeerAction("phone-02")); - System.out.println("Got response: " + response); - - dmc.logoff(); - } -} diff --git a/src/integrationtest/org/asteriskjava/manager/TestVoicemailUsersListAction.java b/src/integrationtest/org/asteriskjava/manager/TestVoicemailUsersListAction.java deleted file mode 100644 index a88675993..000000000 --- a/src/integrationtest/org/asteriskjava/manager/TestVoicemailUsersListAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Sep 24, 2004 - */ -package org.asteriskjava.manager; - -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.action.VoicemailUsersListAction; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.CommandResponse; - -import junit.framework.TestCase; - -/** - * @author srt - * @version $Id$ - */ -public class TestVoicemailUsersListAction extends AbstractManagerTestCase -{ - public void testVoicemailUsersListAction() throws Exception - { - DefaultManagerConnection dmc; - - dmc = getDefaultManagerConnection(); - dmc.login(); - ResponseEvents events = dmc.sendEventGeneratingAction(new VoicemailUsersListAction()); - - System.out.println(events.getResponse()); - for (ManagerEvent event : events.getEvents()) - { - System.out.println(event); - } - - // wait for 3 seconds to receive events - Thread.sleep(3000); - dmc.logoff(); - } -} \ No newline at end of file diff --git a/src/integrationtest/org/asteriskjava/manager/TestVoid.java b/src/integrationtest/org/asteriskjava/manager/TestVoid.java deleted file mode 100644 index 8352bd7b6..000000000 --- a/src/integrationtest/org/asteriskjava/manager/TestVoid.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Sep 24, 2004 - */ -package org.asteriskjava.manager; - -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.CommandResponse; - -import junit.framework.TestCase; - -/** - * @author srt - * @version $Id$ - */ -public class TestVoid extends TestCase -{ - private DefaultManagerConnection getDefaultManagerConnection() - { - DefaultManagerConnection dmc; - - dmc = new DefaultManagerConnection(); - dmc.setUsername("manager"); - dmc.setPassword("obelisk"); - dmc.setHostname("pbx0.cologne.reucon.net"); - dmc.setPort(5038); - - return dmc; - } - - public void testPrintEvents() throws Exception - { - DefaultManagerConnection dmc; - - dmc = getDefaultManagerConnection(); - dmc.login(); - dmc.addEventListener(new ManagerEventListener() - { - public void onManagerEvent(ManagerEvent event) - { - System.out.println("Got event: " + event); - } - }); - // dmc.sendAction(new StatusAction()); - - Thread.sleep(30000); - dmc.logoff(); - } -} \ No newline at end of file diff --git a/src/main/assembly/bin.xml b/src/main/assembly/bin.xml deleted file mode 100644 index 68314d33e..000000000 --- a/src/main/assembly/bin.xml +++ /dev/null @@ -1,28 +0,0 @@ - - bin - - zip - - ${artifactId}-${version} - - - - README* - LICENSE* - NOTICE* - - - - dist - ./ - - - target - ./ - - *.jar - - - - diff --git a/src/main/java/org/asteriskjava/.gitignore b/src/main/java/org/asteriskjava/.gitignore deleted file mode 100644 index 3595ce329..000000000 --- a/src/main/java/org/asteriskjava/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/AsteriskVersion.class -/Cli.class diff --git a/src/main/java/org/asteriskjava/AsteriskVersion.java b/src/main/java/org/asteriskjava/AsteriskVersion.java deleted file mode 100644 index aea63e8f9..000000000 --- a/src/main/java/org/asteriskjava/AsteriskVersion.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava; - -import java.io.Serializable; - -/** - * Represents the version of an Asterisk server. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AsteriskVersion implements Comparable, Serializable -{ - private final int version; - private final String versionString; - - /** - * Represents the Asterisk 1.0 series. - */ - public static final AsteriskVersion ASTERISK_1_0 = new AsteriskVersion(100, "Asterisk 1.0"); - - /** - * Represents the Asterisk 1.2 series. - */ - public static final AsteriskVersion ASTERISK_1_2 = new AsteriskVersion(120, "Asterisk 1.2"); - - /** - * Represents the Asterisk 1.4 series. - * - * @since 0.3 - */ - public static final AsteriskVersion ASTERISK_1_4 = new AsteriskVersion(140, "Asterisk 1.4"); - - /** - * Represents the Asterisk 1.6 series. - * - * @since 1.0.0 - */ - public static final AsteriskVersion ASTERISK_1_6 = new AsteriskVersion(160, "Asterisk 1.6"); - - /** - * Represents the Asterisk 1.8 series. - * - * @since 1.0.0 - */ - public static final AsteriskVersion ASTERISK_1_8 = new AsteriskVersion(180, "Asterisk 1.8"); - - /** - * Represents the Asterisk 10 series. - * - * @since 1.0.0 - */ - public static final AsteriskVersion ASTERISK_10 = new AsteriskVersion(1000, "Asterisk 10"); - - /** - * Represents the Asterisk 11 series. - * - * @since 1.0.0 - */ - public static final AsteriskVersion ASTERISK_11 = new AsteriskVersion(1100, "Asterisk 11"); - - /** - * Represents the Asterisk 12 series. - * - * @since 1.0.0 - */ - public static final AsteriskVersion ASTERISK_12 = new AsteriskVersion(1200, "Asterisk 12"); - - /** - * Represents the Asterisk 13 series. - * - * @since 1.0.0 - */ - public static final AsteriskVersion ASTERISK_13 = new AsteriskVersion(1300, "Asterisk 13"); - - /** - * Represents the Asterisk 14 series. - * - * @since 1.1.0 - */ - public static final AsteriskVersion ASTERISK_14 = new AsteriskVersion(1400, "Asterisk 14"); - - - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - private AsteriskVersion(int version, String versionString) - { - this.version = version; - this.versionString = versionString; - } - - /** - * Returns true if this version is equal to or higher than - * the given version. - * - * @param o the version to compare to - * @return true if this version is equal to or higher than - * the given version, false otherwise. - */ - public boolean isAtLeast(AsteriskVersion o) - { - return version >= o.version; - } - - public int compareTo(AsteriskVersion o) - { - return Integer.compare(version, o.version); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - AsteriskVersion that = (AsteriskVersion) o; - - return version == that.version; - } - - @Override - public int hashCode() - { - return version; - } - - @Override - public String toString() - { - return versionString; - } -} diff --git a/src/main/java/org/asteriskjava/Cli.java b/src/main/java/org/asteriskjava/Cli.java deleted file mode 100644 index 82e49fcbd..000000000 --- a/src/main/java/org/asteriskjava/Cli.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.asteriskjava; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.asteriskjava.fastagi.DefaultAgiServer; - -/** - * Simple command line interface for Asterisk-Java. This class is run when - * Asterisk-Java is started with {@code java -jar asterisk-java.jar}. It is - * configured as Main-Class in the manifest. - *

- * The command line interface supports the following options: - *

- *
{@code -a}, {@code -agi [port]} - *
- *
Starts a FastAGI server
- *
{@code -h}, {@code -help} - *
- *
Displays the available options
- *
{@code -v}, {@code -version}
- *
Displays the version of Asterisk-Java
- *
- * If no option is given a FastAGI server is started on the default port. - * - * @since 1.0.0 - */ -public class Cli -{ - private void parseOptions(String[] args) throws Exception - { - if (args.length == 0) - { - startAgiServer(); - return; - } - - final String arg = args[0]; - if ("-h".equals(arg) || "-help".equals(arg)) - { - showHelp(); - } - else if ("-v".equals(arg) || "-version".equals(arg)) - { - showVersion(); - } - else if ("-a".equals(arg) || "-agi".equals(arg)) - { - if (args.length >= 2) - { - Integer port = null; - try - { - port = new Integer(args[1]); - } - catch (NumberFormatException e) - { - System.err.println("Invalid port '" + args[1] + "'. Port must be a number."); - exit(1); - } - startAgiServer(port); - } - } - else - { - showHelp(); - } - } - - private void showHelp() - { - showVersion(); - System.err.println(); - System.err.println("-a, -agi [port]\n\tStarts a FastAGI server"); - System.err.println("-h, -help\n\tDisplays the available options\n"); - System.err.println("-v, -version\n\tDisplays the version of Asterisk-Java\n"); - } - - private void showVersion() - { - System.out.println("Asterisk-Java " + getVersion()); - } - - private String getVersion() - { - String version = ""; - final InputStream is; - final Properties properties; - - is = getClass().getResourceAsStream("/META-INF/maven/org.asteriskjava/asterisk-java/pom.properties"); - if (is == null) - { - return version; - } - - properties = new Properties(); - try - { - properties.load(is); // contains version, groupId and artifactId - } - catch (IOException e) - { - return version; - } - finally - { - try - { - is.close(); - } - catch (IOException e) - { - // ignore - } - } - - version = properties.getProperty("version", version); - return version; - } - - private void startAgiServer() throws IOException - { - startAgiServer(null); - } - - private void startAgiServer(Integer port) throws IOException - { - final DefaultAgiServer server; - - server = new DefaultAgiServer(); - if (port != null) - { - server.setPort(port); - } - server.startup(); - } - - private void exit(int code) - { - System.exit(code); - } - - public static void main(String[] args) throws Exception - { - new Cli().parseOptions(args); - } -} diff --git a/src/main/java/org/asteriskjava/config/.gitignore b/src/main/java/org/asteriskjava/config/.gitignore deleted file mode 100644 index 46cfb38ff..000000000 --- a/src/main/java/org/asteriskjava/config/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -/Category.class -/ConfigDirective.class -/ConfigElement.class -/ConfigFile.class -/ConfigFileImpl.class -/ConfigFileReader.class -/ConfigParseException.class -/ConfigVariable.class -/ExecDirective.class -/IncludeDirective.class -/MissingDirectiveParameterException.class -/MissingEqualSignException.class -/UnknownDirectiveException.class diff --git a/src/main/java/org/asteriskjava/config/Category.java b/src/main/java/org/asteriskjava/config/Category.java deleted file mode 100644 index 6c9532836..000000000 --- a/src/main/java/org/asteriskjava/config/Category.java +++ /dev/null @@ -1,140 +0,0 @@ -package org.asteriskjava.config; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * - */ -public class Category extends ConfigElement -{ - private String name; - private boolean template; - private final List baseCategories = new ArrayList<>(); - private final List elements = new ArrayList<>(); - - /** - * The last object in the list will get assigned any trailing comments when EOF is hit. - */ - //private String trailingComment; - - public Category(String name) - { - if (name == null) - { - throw new IllegalArgumentException("Name must not be null"); - } - this.name = name; - } - - public Category(String filename, int lineno, String name) - { - super(filename, lineno); - this.name = name; - } - - /** - * Returns the name of this category. - * - * @return the name of this category. - */ - public String getName() - { - return name; - } - - /** - * Checks if this category is a template. - * - * @return true if this category is a template, false otherwise. - */ - public boolean isTemplate() - { - return template; - } - - void markAsTemplate() - { - template = true; - } - - /** - * Returns a list of categories this category inherits from. - * - * @return a list of categories this category inherits from, never null. - */ - public List getBaseCategories() - { - return baseCategories; - } - - void addBaseCategory(Category baseCategory) - { - baseCategories.add(baseCategory); - } - - public List getElements() - { - return elements; - } - - public void addElement(ConfigElement element) - { - if (element instanceof Category) - { - throw new IllegalArgumentException("Nested categories are not allowed"); - } - - elements.add(element); - } - - public String format() - { - StringBuilder sb = new StringBuilder(); - - format(sb); - for (ConfigElement e : elements) - { - sb.append("\n"); - e.format(sb); - } - return sb.toString(); - } - - @Override - protected StringBuilder rawFormat(StringBuilder sb) - { - sb.append("[").append(name).append("]"); - if (isTemplate() || !getBaseCategories().isEmpty()) - { - sb.append("("); - if (isTemplate()) - { - sb.append("!"); - if (!getBaseCategories().isEmpty()) - { - sb.append(","); - } - } - Iterator inheritsFromIterator = getBaseCategories().iterator(); - while (inheritsFromIterator.hasNext()) - { - sb.append(inheritsFromIterator.next().getName()); - if (inheritsFromIterator.hasNext()) - { - sb.append(","); - } - } - sb.append(")"); - } - - return sb; - } - - @Override - public String toString() - { - return name; - } -} diff --git a/src/main/java/org/asteriskjava/config/ConfigDirective.java b/src/main/java/org/asteriskjava/config/ConfigDirective.java deleted file mode 100644 index 0950027a8..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigDirective.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.asteriskjava.config; - -public abstract class ConfigDirective extends ConfigElement -{ - protected ConfigDirective() - { - } - - protected ConfigDirective(String filename, int lineno) - { - super(filename, lineno); - } -} diff --git a/src/main/java/org/asteriskjava/config/ConfigElement.java b/src/main/java/org/asteriskjava/config/ConfigElement.java deleted file mode 100644 index f1ccb80cf..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigElement.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.asteriskjava.config; - -public abstract class ConfigElement -{ - /** - * Name of the file the category was read from. - */ - private String filename; - - /** - * Line number. - */ - private int lineno; - private String preComment; - private String samelineComment; - - protected ConfigElement() - { - } - - protected ConfigElement(String filename, int lineno) - { - this.filename = filename; - this.lineno = lineno; - } - - public String getFileName() - { - return filename; - } - - public void setFileName(String filename) - { - this.filename = filename; - } - - public int getLineNumber() - { - return lineno; - } - - void setLineNumber(int lineno) - { - this.lineno = lineno; - } - - public String getPreComment() - { - return preComment; - } - - public void setPreComment(String preComment) - { - this.preComment = preComment; - } - - public String getComment() - { - return samelineComment; - } - - public void setComment(String samelineComment) - { - this.samelineComment = samelineComment; - } - - protected StringBuilder format(StringBuilder sb) - { - if (preComment != null && preComment.length() != 0) - { - sb.append(preComment); - } - - rawFormat(sb); - - if (samelineComment != null && samelineComment.length() != 0) - { - sb.append(" ; ").append(samelineComment); - } - - return sb; - } - - protected abstract StringBuilder rawFormat(StringBuilder sb); -} diff --git a/src/main/java/org/asteriskjava/config/ConfigFile.java b/src/main/java/org/asteriskjava/config/ConfigFile.java deleted file mode 100644 index b8150688e..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigFile.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.config; - -import java.util.List; -import java.util.Map; - -/** - * An Asterisk configuration file. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public interface ConfigFile -{ - /** - * Returns the filename. - * - * @return the filename, for example "voicemail.conf". - */ - String getFilename(); - - /** - * Returns the lines per category. - * - * @return the lines per category. - */ - Map> getCategories(); - - String getValue(String category, String key); - - List getValues(String category, String key); -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/config/ConfigFileImpl.java b/src/main/java/org/asteriskjava/config/ConfigFileImpl.java deleted file mode 100644 index 2810f5e20..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigFileImpl.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.config; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * An Asterisk configuration file read from the filesystem. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class ConfigFileImpl implements ConfigFile -{ - private final String filename; - protected final Map categories; - - public ConfigFileImpl(String filename, Map categories) - { - this.filename = filename; - this.categories = categories; - } - - public String getFilename() - { - return filename; - } - - public Map> getCategories() - { - final Map> c; - - c = new TreeMap<>(); - - synchronized (categories) - { - for (Category category : categories.values()) - { - List lines; - - lines = new ArrayList<>(); - for (ConfigElement element : category.getElements()) - { - if (element instanceof ConfigVariable) - { - ConfigVariable cv = (ConfigVariable) element; - lines.add(cv.getName() + "=" + cv.getValue()); - } - } - c.put(category.getName(), lines); - } - } - - return c; - } - - public String getValue(String categoryName, String key) - { - final Category category; - - category = getCategory(categoryName); - if (category == null) - { - return null; - } - - for (ConfigElement element : category.getElements()) - { - if (element instanceof ConfigVariable) - { - ConfigVariable cv = (ConfigVariable) element; - - if (cv.getName().equals(key)) - { - return cv.getValue(); - } - } - } - return null; - } - - public List getValues(String categoryName, String key) - { - final Category category; - final List result; - - category = getCategory(categoryName); - result = new ArrayList<>(); - if (category == null) - { - return result; - } - - for (ConfigElement element : category.getElements()) - { - if (element instanceof ConfigVariable) - { - ConfigVariable cv = (ConfigVariable) element; - - if (cv.getName().equals(key)) - { - result.add(cv.getValue()); - } - } - } - return result; - } - - protected Category getCategory(String name) - { - synchronized (categories) - { - return categories.get(name); - } - } -} diff --git a/src/main/java/org/asteriskjava/config/ConfigFileReader.java b/src/main/java/org/asteriskjava/config/ConfigFileReader.java deleted file mode 100644 index ef0d912dc..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigFileReader.java +++ /dev/null @@ -1,489 +0,0 @@ -package org.asteriskjava.config; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.nio.CharBuffer; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * Reads and parses Asterisk configuration files.
- * See Asterisk's main/config.c.
- * Client code is not supposed to use this class. - * - * @author srt - * @version $Id$ - */ -public class ConfigFileReader -{ - private static final int MAX_LINE_LENGTH = 8192; - private static char COMMENT_META = ';'; - private static char COMMENT_TAG = '-'; - private static final Set> WARNING_CLASSES; - - static - { - WARNING_CLASSES = new HashSet<>(); - WARNING_CLASSES.add(MissingEqualSignException.class); - WARNING_CLASSES.add(UnknownDirectiveException.class); - WARNING_CLASSES.add(MissingDirectiveParameterException.class); - } - - private StringBuilder commentBlock; - protected final Map categories; - private final List warnings; - - protected Category currentCategory; - private int currentCommentLevel = 0; - - public ConfigFileReader() - { - this.commentBlock = new StringBuilder(); - this.categories = new LinkedHashMap<>(); - this.warnings = new ArrayList<>(); - } - - public ConfigFile readFile(String configfile) - { - final ConfigFile result; - - try (BufferedReader reader = new BufferedReader( - new InputStreamReader(new FileInputStream(configfile), StandardCharsets.UTF_8))) - { - readFile(configfile, reader); - } - catch (Exception e) - { - // ignored - } - - result = new ConfigFileImpl(configfile, new TreeMap(categories)); - - return result; - } - - void reset() - { - commentBlock = new StringBuilder(); - categories.clear(); - warnings.clear(); - currentCategory = null; - currentCommentLevel = 0; - } - - Collection getCategories() - { - return categories.values(); - } - - public Collection getWarnings() - { - return new ArrayList<>(warnings); - } - - void readFile(String configfile, BufferedReader reader) throws IOException, ConfigParseException - { - String line; - int lineno = 0; - CharBuffer buffer = CharBuffer.allocate(MAX_LINE_LENGTH); - - reset(); - while ((line = reader.readLine()) != null) - { - lineno++; - buffer.clear(); - buffer.put(line); - buffer.put("\n"); - buffer.flip(); - - processLine(configfile, lineno, buffer); - } - } - - ConfigElement processLine(String configfile, int lineno, CharBuffer buffer) throws ConfigParseException - { - char c; - final StringBuilder processLineBuilder; - final StringBuilder lineCommentBuilder; - - processLineBuilder = new StringBuilder(MAX_LINE_LENGTH); - lineCommentBuilder = new StringBuilder(MAX_LINE_LENGTH); - buffer.mark(); - - while (buffer.hasRemaining()) - { - final int position; - - position = buffer.position(); - c = buffer.get(); - // System.out.println(position + ": " + c); - - if (c == COMMENT_META) - { - if (position >= 1 && buffer.get(position - 1) == '\\') - { - /* Escaped semicolons aren't comments. */ - } // NOPMD - else if (buffer.remaining() >= 3 && buffer.get(position + 1) == COMMENT_TAG - && buffer.get(position + 2) == COMMENT_TAG && buffer.get(position + 3) != COMMENT_TAG) - { - /* Meta-Comment start detected ";--" */ - - currentCommentLevel++; - // System.out.println("Comment start, new level: " + - // currentCommentLevel); - - if (!inComment()) - { - commentBlock.append(";--"); - buffer.position(position + 3); - buffer.mark(); - continue; - } - } - else if (inComment() && position >= 2 && buffer.get(position - 1) == COMMENT_TAG - && buffer.get(position - 2) == COMMENT_TAG) - { - /* Meta-Comment end detected */ - - currentCommentLevel--; - - if (!inComment()) - { - buffer.reset(); - - // int commentLength = (position + 1) - - // buffer.position(); - - // buffer.reset(); - // for (int i = 0; i < commentLength; i++) - // { - // commentBlock.append(buffer.get()); - // } - - commentBlock.append(c); - // System.out.println("Comment end at " + position + ": - // '" + commentBlock.toString() + "'"); - - buffer.position(position + 1); - buffer.compact(); - buffer.flip(); - - // System.out.println("Buffer compacted"); - continue; - } - } - else - { - if (!inComment()) - { - /* - * If ; is found, and we are not nested in a comment, we - * immediately stop all comment processing - */ - // System.out.println("Found ; while not in comment"); - while (buffer.hasRemaining()) - { - lineCommentBuilder.append(buffer.get()); - } - break; - } - - /* Found ';' while in comment */ - // NOPMD - } - } - - if (inComment()) - { - commentBlock.append(c); - } - else - { - // System.out.println("Added '" + c + "' to processLine"); - processLineBuilder.append(c); - } - } - - String processLineString; - String lineCommentString; - ConfigElement configElement; - - processLineString = processLineBuilder.toString().trim(); - lineCommentString = lineCommentBuilder.toString().trim(); - - // System.out.println("process line: '" + processLineString + "'"); - if (processLineString.length() == 0) - { - if (lineCommentString.length() != 0) - { - commentBlock.append(";"); - commentBlock.append(lineCommentString); - } - if (!inComment()) - { - commentBlock.append("\n"); - } - return null; - } - - try - { - configElement = processTextLine(configfile, lineno, processLineString); - } - catch (ConfigParseException e) - { - // some parsing exceptions are treated as warnings by Asterisk, we - // mirror this behavior. - if (WARNING_CLASSES.contains(e.getClass())) - { - warnings.add(e); - return null; - } - throw e; - } - - if (lineCommentString.length() != 0) - { - configElement.setComment(lineCommentString); - } - - if (commentBlock.length() != 0) - { - configElement.setPreComment(commentBlock.toString()); - commentBlock.delete(0, commentBlock.length()); - } - - return configElement; - } - - boolean inComment() - { - return currentCommentLevel != 0; - } - - protected ConfigElement processTextLine(String configfile, int lineno, String line) throws ConfigParseException - { - ConfigElement configElement; - - if (line.charAt(0) == '[') // A category header - { - configElement = parseCategoryHeader(configfile, lineno, line); - } - else if (line.charAt(0) == '#') // a directive - #include or #exec - { - configElement = parseDirective(configfile, lineno, line); - } - else // just a line - { - if (currentCategory == null) - { - throw new ConfigParseException(configfile, lineno, "parse error: No category context for line %d of %s", - lineno, configfile); - } - - configElement = parseVariable(configfile, lineno, line); - currentCategory.addElement(configElement); - } - - return configElement; - } - - protected Category parseCategoryHeader(String configfile, int lineno, String line) throws ConfigParseException - { - final Category category; - final String name; - final int nameEndPos; - - /* - * format is one of the following: [foo] define a new category named - * 'foo' [foo](!) define a new template category named 'foo' [foo](+) - * append to category 'foo', error if foo does not exist. [foo](a) - * define a new category and inherit from template a. You can put a - * comma-separated list of templates and '!' and '+' between - * parentheses, with obvious meaning. - */ - - nameEndPos = line.indexOf(']'); - if (nameEndPos == -1) - { - throw new ConfigParseException(configfile, lineno, "parse error: no closing ']', line %d of %s", lineno, - configfile); - } - name = line.substring(1, nameEndPos); - category = new Category(configfile, lineno, name); - - /* Handle options or categories to inherit from if available */ - if (line.length() > nameEndPos + 1 && line.charAt(nameEndPos + 1) == '(') - { - final String[] options; - final String optionsString; - final int optionsEndPos; - - optionsString = line.substring(nameEndPos + 1); - optionsEndPos = optionsString.indexOf(')'); - if (optionsEndPos == -1) - { - throw new ConfigParseException(configfile, lineno, "parse error: no closing ')', line %d of %s", lineno, - configfile); - } - - options = optionsString.substring(1, optionsEndPos).split(","); - for (String cur : options) - { - if ("!".equals(cur)) // category template - { - category.markAsTemplate(); - } - else if ("+".equals(cur)) // category addition - { - final Category categoryToAddTo; - - categoryToAddTo = categories.get(name); - if (categoryToAddTo == null) - { - throw new ConfigParseException(configfile, lineno, - "Category addition requested, but category '%s' does not exist, line %d of %s", name, lineno, - configfile); - } - - // todo implement category addition - // category = categoryToAddTo; - } - else - { - final Category baseCategory; - - baseCategory = categories.get(cur); - if (baseCategory == null) - { - throw new ConfigParseException(configfile, lineno, - "Inheritance requested, but category '%s' does not exist, line %d of %s", cur, lineno, - configfile); - } - inheritCategory(category, baseCategory); - } - } - } - - appendCategory(category); - return category; - } - - ConfigDirective parseDirective(String configfile, int lineno, String line) throws ConfigParseException - { - ConfigDirective directive; - final StringBuilder nameBuilder; - final StringBuilder paramBuilder; - String name = null; - String param; - - nameBuilder = new StringBuilder(); - paramBuilder = new StringBuilder(); - for (int i = 1; i < line.length(); i++) - { - final char c; - - c = line.charAt(i); - if (name == null) - { - nameBuilder.append(c); - if (Character.isWhitespace(c) || i + 1 == line.length()) - { - name = nameBuilder.toString().trim(); - } - } - else - { - paramBuilder.append(c); - } - } - - param = paramBuilder.toString().trim(); - - if (param.length() != 0 && (param.charAt(0) == '"' || param.charAt(0) == '<' || param.charAt(0) == '>')) - { - param = param.substring(1); - } - - int endPos = param.length() - 1; - if (param.length() != 0 - && (param.charAt(endPos) == '"' || param.charAt(endPos) == '<' || param.charAt(endPos) == '>')) - { - param = param.substring(0, endPos); - } - - if ("exec".equalsIgnoreCase(name)) - { - directive = new ExecDirective(configfile, lineno, param); - } - else if ("include".equalsIgnoreCase(name)) - { - directive = new IncludeDirective(configfile, lineno, param); - } - else - { - throw new UnknownDirectiveException(configfile, lineno, "Unknown directive '%s' at line %d of %s", name, lineno, - configfile); - } - - if (param.length() == 0) - { - if (name == null) - { - name = ""; - } - throw new MissingDirectiveParameterException(configfile, lineno, - "Directive '#%s' needs an argument (%s) at line %d of %s", name.toLowerCase(Locale.US), - "include".equalsIgnoreCase(name) ? "filename" : "/path/to/executable", lineno, configfile); - } - - return directive; - } - - protected ConfigVariable parseVariable(String configfile, int lineno, String line) throws ConfigParseException - { - int pos; - String name; - String value; - - pos = line.indexOf('='); - if (pos == -1) - { - throw new MissingEqualSignException(configfile, lineno, "No '=' (equal sign) in line %d of %s", lineno, - configfile); - } - - name = line.substring(0, pos).trim(); - - // Ignore > in => - if (line.length() > pos + 1 && line.charAt(pos + 1) == '>') - { - pos++; - } - - value = (line.length() > pos + 1) ? line.substring(pos + 1).trim() : ""; - return new ConfigVariable(configfile, lineno, name, value); - } - - void inheritCategory(Category category, Category baseCategory) - { - category.addBaseCategory(baseCategory); - } - - void appendCategory(Category category) - { - categories.put(category.getName(), category); - currentCategory = category; - } -} diff --git a/src/main/java/org/asteriskjava/config/ConfigParseException.java b/src/main/java/org/asteriskjava/config/ConfigParseException.java deleted file mode 100644 index e872ca7ad..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigParseException.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.config; - -/** - * - */ -public class ConfigParseException extends Exception -{ - private static final long serialVersionUID = 4346366210261425734L; - private final String filename; - private final int lineno; - - public ConfigParseException(String filename, int lineno, String message) - { - super(message); - this.filename = filename; - this.lineno = lineno; - } - - public ConfigParseException(String filename, int lineno, String format, Object... params) - { - super(String.format(format, params)); - this.filename = filename; - this.lineno = lineno; - } - - public String getFileName() - { - return filename; - } - - public int getLineNumber() - { - return lineno; - } -} diff --git a/src/main/java/org/asteriskjava/config/ConfigVariable.java b/src/main/java/org/asteriskjava/config/ConfigVariable.java deleted file mode 100644 index 7f72567b6..000000000 --- a/src/main/java/org/asteriskjava/config/ConfigVariable.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.asteriskjava.config; - -/** - * - */ -public class ConfigVariable extends ConfigElement -{ - private String name; - private String value; - - public ConfigVariable(String name, String value) - { - setName(name); - setValue(value); - } - - public ConfigVariable(String filename, int lineno, String name, String value) - { - super(filename, lineno); - setName(name); - setValue(value); - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - if (name == null) - { - throw new IllegalArgumentException("Variable name must not be null"); - } - this.name = name; - } - - public String getValue() - { - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - @Override - protected StringBuilder rawFormat(StringBuilder sb) - { - sb.append(name).append(" = "); - if (value != null) - { - sb.append(value); - } - return sb; - } - - @Override - public String toString() - { - return name+"="+value; - } -} diff --git a/src/main/java/org/asteriskjava/config/ExecDirective.java b/src/main/java/org/asteriskjava/config/ExecDirective.java deleted file mode 100644 index 18c59800b..000000000 --- a/src/main/java/org/asteriskjava/config/ExecDirective.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.config; - -public class ExecDirective extends ConfigDirective -{ - /** - * file name of the executable. - */ - private final String execFile; - - public ExecDirective(String execFile) - { - super(); - this.execFile = execFile; - } - - public ExecDirective(String filename, int lineno, String execFile) - { - super(filename, lineno); - this.execFile = execFile; - } - - public String getExecFile() - { - return execFile; - } - - @Override - protected StringBuilder rawFormat(StringBuilder sb) - { - sb.append("#exec \"").append(execFile).append("\""); - return sb; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/config/IncludeDirective.java b/src/main/java/org/asteriskjava/config/IncludeDirective.java deleted file mode 100644 index 3d315b656..000000000 --- a/src/main/java/org/asteriskjava/config/IncludeDirective.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.config; - -public class IncludeDirective extends ConfigDirective -{ - /** - * file name included. - */ - private final String includeFile; - - public IncludeDirective(String includeFile) - { - super(); - this.includeFile = includeFile; - } - - public IncludeDirective(String filename, int lineno, String includeFile) - { - super(filename, lineno); - this.includeFile = includeFile; - } - - public String getIncludeFile() - { - return includeFile; - } - - @Override - protected StringBuilder rawFormat(StringBuilder sb) - { - sb.append("#include \"").append(includeFile).append("\""); - return sb; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/config/MissingDirectiveParameterException.java b/src/main/java/org/asteriskjava/config/MissingDirectiveParameterException.java deleted file mode 100644 index cd3adab03..000000000 --- a/src/main/java/org/asteriskjava/config/MissingDirectiveParameterException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.asteriskjava.config; - -/** - * A required parameter to a directive is missing.

- * The #include and #exec directives require a parameter (include file or command to execute). - */ -public class MissingDirectiveParameterException extends ConfigParseException -{ - private static final long serialVersionUID = -3802754628756681515L; - public MissingDirectiveParameterException(String filename, int lineno, String format, Object... params) - { - super(filename, lineno, format, params); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/config/MissingEqualSignException.java b/src/main/java/org/asteriskjava/config/MissingEqualSignException.java deleted file mode 100644 index 99a42f746..000000000 --- a/src/main/java/org/asteriskjava/config/MissingEqualSignException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.asteriskjava.config; - -/** - * The equal sign on a variable assignment line is missing.

- * A variable line must include an equal sign. - */ -public class MissingEqualSignException extends ConfigParseException -{ - private static final long serialVersionUID = 2694490330074765342L; - public MissingEqualSignException(String filename, int lineno, String format, Object... params) - { - super(filename, lineno, format, params); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/config/UnknownDirectiveException.java b/src/main/java/org/asteriskjava/config/UnknownDirectiveException.java deleted file mode 100644 index 54ae2a8cf..000000000 --- a/src/main/java/org/asteriskjava/config/UnknownDirectiveException.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.asteriskjava.config; - -/** - * An unknown directive has been encountered.

- * Asterisk only supports #include and #exec directives. - */ -public class UnknownDirectiveException extends ConfigParseException -{ - private static final long serialVersionUID = 4356355066633810196L; - public UnknownDirectiveException(String filename, int lineno, String format, Object... params) - { - super(filename, lineno, format, params); - } -} diff --git a/src/main/java/org/asteriskjava/config/dialplan/.gitignore b/src/main/java/org/asteriskjava/config/dialplan/.gitignore deleted file mode 100644 index 6b973a36c..000000000 --- a/src/main/java/org/asteriskjava/config/dialplan/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/ConfigExtension.class -/ConfigInclude.class -/ExtensionsConfigFile.class -/ExtensionsConfigFileReader.class diff --git a/src/main/java/org/asteriskjava/config/dialplan/ConfigExtension.java b/src/main/java/org/asteriskjava/config/dialplan/ConfigExtension.java deleted file mode 100644 index ad9843d65..000000000 --- a/src/main/java/org/asteriskjava/config/dialplan/ConfigExtension.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.asteriskjava.config.dialplan; - -import java.util.Arrays; - -import org.asteriskjava.config.ConfigElement; - -/** - * Represents the dial plan extension as a specific kind of configuration - * directive This class makes no interpretation of syntax checking of names, - * priorities, or application (for now). - * - * @author martins - */ -public class ConfigExtension extends ConfigElement -{ - String name, priority; - - /** - * Holds the application in the first element, and arguments in all subsequent elements. Similar to command line arguments array. - */ - String [] application; - - public ConfigExtension(String filename, int lineno, String name, String priority, String [] application) - { - super(filename,lineno); - this.name = name; - this.priority = priority; - this.application = application; - } - - @Override - protected StringBuilder rawFormat(StringBuilder sb) - { - return sb.append(toString()); - } - - @Override - public String toString() - { - return "exten => " + name + "," + priority + "," + Arrays.asList(application); - } - - public String getName() - { - return name; - } - - public String getPriority() - { - return priority; - } - - public String[] getApplication() - { - return application; - } - -} diff --git a/src/main/java/org/asteriskjava/config/dialplan/ConfigInclude.java b/src/main/java/org/asteriskjava/config/dialplan/ConfigInclude.java deleted file mode 100644 index 80ee07187..000000000 --- a/src/main/java/org/asteriskjava/config/dialplan/ConfigInclude.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.config.dialplan; - -import org.asteriskjava.config.ConfigElement; - -public class ConfigInclude extends ConfigElement -{ - String category; - - public ConfigInclude(String filename, int lineno, String category) - { - super(filename, lineno); - this.category = category; - } - - @Override - protected StringBuilder rawFormat(StringBuilder sb) - { - return sb.append(toString()); - } - - @Override - public String toString() - { - return "include => " + category; - } - - public String getName() - { - return category; - } - -} diff --git a/src/main/java/org/asteriskjava/config/dialplan/ExtensionsConfigFile.java b/src/main/java/org/asteriskjava/config/dialplan/ExtensionsConfigFile.java deleted file mode 100644 index cba0d75a8..000000000 --- a/src/main/java/org/asteriskjava/config/dialplan/ExtensionsConfigFile.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.asteriskjava.config.dialplan; - -import java.util.Collection; -import java.util.Map; - -import org.asteriskjava.config.Category; -import org.asteriskjava.config.ConfigFileImpl; - -public class ExtensionsConfigFile extends ConfigFileImpl -{ - public ExtensionsConfigFile(String filename, Map categories) - { - super(filename, categories); - } - - public Collection getContexts() - { - return categories.values(); - } -} diff --git a/src/main/java/org/asteriskjava/config/dialplan/ExtensionsConfigFileReader.java b/src/main/java/org/asteriskjava/config/dialplan/ExtensionsConfigFileReader.java deleted file mode 100644 index 9a875ff6b..000000000 --- a/src/main/java/org/asteriskjava/config/dialplan/ExtensionsConfigFileReader.java +++ /dev/null @@ -1,193 +0,0 @@ -package org.asteriskjava.config.dialplan; - -import java.util.ArrayList; -import java.util.List; - -import org.asteriskjava.config.ConfigElement; -import org.asteriskjava.config.ConfigFileReader; -import org.asteriskjava.config.ConfigParseException; -import org.asteriskjava.config.ConfigVariable; - -/* - * Interprets extensions.conf as a special kind of config file, the dialplan. - * - Line numbers correspond with pbx_config.c, tags/1.4.19 revision 96024 - */ -public class ExtensionsConfigFileReader extends ConfigFileReader -{ - /* - * This method corresponds to an iteration of the loop at line 2212 Notes: - * 1. [general] and [globals] are allowed to be a context here if they - * contain only configvariables 2. switch and ignorepat are treated like - * regular ConfigVariable. - */ - @Override - protected ConfigElement processTextLine(String configfile, int lineno, String line) throws ConfigParseException - { - ConfigElement configElement; - - if ((line.trim().startsWith("exten") || line.trim().startsWith("include")) && currentCategory != null - && (currentCategory.getName().equals("general") || currentCategory.getName().equals("globals"))) - throw new ConfigParseException(configfile, lineno, - "cannot have 'exten' or 'include' in global or general sections"); - - /* - * Goal here is to break out anything unique that we might want to look - * at and parse separately. For now, only exten and include fit that - * criteria. Eventually, I could see parsing sections for things from - * macros, contexts to differentiate them from categories, switch for - * realtime, and more. - */ - if (line.trim().startsWith("exten")) - { - configElement = parseExtension(configfile, lineno, line); - currentCategory.addElement(configElement); - return configElement; - } - else if (line.trim().startsWith("include")) - { - // use parseVariable since we have access to it - ConfigVariable configvar = parseVariable(configfile, lineno, line); - configElement = new ConfigInclude(configfile, lineno, configvar.getValue()); - currentCategory.addElement(configElement); - return configElement; - } - - // leave everything else the same - configElement = super.processTextLine(configfile, lineno, line); - - return configElement; - } - - /* Roughly corresponds to pbx_config.c:2222 */ - protected ConfigExtension parseExtension(String configfile, int lineno, String line) throws ConfigParseException - { - ConfigVariable initialVariable = parseVariable(configfile, lineno, line); - - if (!initialVariable.getName().equals("exten")) - throw new ConfigParseException(configfile, lineno, "missing 'exten' near " + line); - line = initialVariable.getValue().trim(); - - int nameIndex = line.indexOf(",", 0); - if (nameIndex == -1) - throw new ConfigParseException(configfile, lineno, "missing extension name near " + line); - String name = line.substring(0, nameIndex); - line = line.substring(name.length() + 1, line.length()).trim(); - - int priorityDelimiter = line.indexOf(",", 0); - if (priorityDelimiter == -1) - throw new ConfigParseException(configfile, lineno, "missing extension priority near " + line); - String priority = line.substring(0, priorityDelimiter); - line = line.substring(priority.length() + 1, line.length()).trim(); - - String[] application = harvestApplicationWithArguments(line); - - return new ConfigExtension(configfile, lineno, name, priority, application); - } - - /* Roughly corresponds to pbx_config.c:2276 */ - private static String[] harvestApplicationWithArguments(String arg) - { - List args = new ArrayList<>(); - - if (arg.trim().length() >= 0) - { - String appl = "", data = ""; - - /* Find the first occurrence of either '(' or ',' */ - int firstc = arg.indexOf(','); - int firstp = arg.indexOf('('); - - if (firstc != -1 && (firstp == -1 || firstc < firstp)) - { - /* comma found, no parenthesis */ - /* or both found, but comma found first */ - String[] split = arg.split(","); - appl = split[0]; - for (int i = 1; i < split.length; i++) - data += split[i] + (i + 1 < split.length ? "," : ""); - } - else if (firstc == -1 && firstp == -1) - { - /* Neither found */ - data = ""; - } - else - { - /* Final remaining case is parenthesis found first */ - String[] split = arg.split("\\("); - appl = split[0]; - for (int i = 1; i < split.length; i++) - data += split[i] + (i + 1 < split.length ? "(" : ""); - int end = data.lastIndexOf(')'); - if (end == -1) - { - // ast_log(LOG_WARNING, "No closing parenthesis found? - // '%s(%s'\n", appl, data); - } - else if (end == data.length() - 1) - { - data = data.substring(0, end); - } - data = processQuotesAndSlashes(data, ',', '|'); - } - - if (!appl.trim().equals("")) - { - args.add(appl.trim()); - if (!data.trim().equals("")) - { - String[] dataSplit = data.split("\\|"); - for (String aDataSplit : dataSplit) - { - args.add(aDataSplit.trim()); - } - } - } - } - - return args.toArray(new String[args.size()]); - } - - public ExtensionsConfigFile readExtensionsFile(String configfile) - { - super.readFile(configfile); - /* at some point, we may want to resolve back references */ - /* that include or goto from one context to another */ - return new ExtensionsConfigFile(configfile, categories); - } - - /* ast_process_quotes_and_slashes rewritten to be java friendly */ - private static String processQuotesAndSlashes(String start, char find, char replace_with) - { - String dataPut = ""; - int inEscape = 0; - int inQuotes = 0; - - char[] startChars = start.toCharArray(); - for (char startChar : startChars) - { - if (inEscape != 0) - { - dataPut += startChar; /* Always goes verbatim */ - inEscape = 0; - } - else - { - if (startChar == '\\') - { - inEscape = 1; /* Do not copy \ into the data */ - } - else if (startChar == '\'') - { - inQuotes = 1 - inQuotes; /* Do not copy ' into the data */ - } - else - { - /* Replace , with |, unless in quotes */ - dataPut += inQuotes != 0 ? startChar : ((startChar == find) ? replace_with : startChar); - } - } - } - return dataPut; - } -} diff --git a/src/main/java/org/asteriskjava/config/dialplan/package.html b/src/main/java/org/asteriskjava/config/dialplan/package.html deleted file mode 100644 index 7783de3c2..000000000 --- a/src/main/java/org/asteriskjava/config/dialplan/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

Provides classes to manage the dialplan of an Asterisk server.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/config/package.html b/src/main/java/org/asteriskjava/config/package.html deleted file mode 100644 index 0fca39daa..000000000 --- a/src/main/java/org/asteriskjava/config/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

Provides classes to manage the configuration of an Asterisk server.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/examples/activities/BlindTransfer.java b/src/main/java/org/asteriskjava/examples/activities/BlindTransfer.java deleted file mode 100644 index 8948437de..000000000 --- a/src/main/java/org/asteriskjava/examples/activities/BlindTransfer.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.asteriskjava.examples.activities; - -import java.io.IOException; - -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.ActivityStatusEnum; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.Call.OperandChannel; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.Trunk; -import org.asteriskjava.pbx.activities.BlindTransferActivity; -import org.asteriskjava.pbx.activities.DialActivity; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -/** - * dial somebody and then blind transfer the call to a third party. - * - * @author bsutton - */ -public class BlindTransfer -{ - - static public void main(String[] args) throws IOException, AuthenticationFailedException, TimeoutException - { - /** - * Initialise the PBX Factory. You need to implement your own AsteriskSettings class. - */ - PBXFactory.init(new ExamplesAsteriskSettings()); - - /** - * Activities utilise an agi entry point in your dial plan. - * You can create your own entry point in dialplan or have - * asterisk-java add it automatically - */ - AsteriskPBX asteriskPbx = (AsteriskPBX) PBXFactory.getActivePBX(); - asteriskPbx.createAgiEntryPoint(); - - // We are all configured lets try and do a blind transfer. - blindTransfer(); - } - - static private void blindTransfer() - { - PBX pbx = PBXFactory.getActivePBX(); - - // The trunk MUST match the section header (e.g. [default]) that appears - // in your /etc/asterisk/sip.d file (assuming you are using a SIP trunk). - // The trunk is used to select which SIP trunk to dial through. - Trunk trunk = pbx.buildTrunk("default"); - - // We are going to dial from extension 100 - EndPoint from = pbx.buildEndPoint(TechType.SIP, "100"); - // The caller ID to show on extension 100. - CallerID fromCallerID = pbx.buildCallerID("100", "My Phone"); - - // The caller ID to display on the called parties phone - CallerID toCallerID = pbx.buildCallerID("83208100", "Asterisk Java is calling"); - // The party we are going to call. - EndPoint to = pbx.buildEndPoint(TechType.SIP, trunk, "5551234"); - - // Start the dial and return immediately. - // progress is provided via the ActivityCallback. - pbx.dial(from, fromCallerID, to, toCallerID, new ActivityCallback() - { - - @Override - public void progress(DialActivity activity, ActivityStatusEnum status, String message) - { - if (status == ActivityStatusEnum.SUCCESS) - { - System.out.println("Dial all good so lets do a blind transfer"); - PBX pbx = PBXFactory.getActivePBX(); - // Call is up - Call call = activity.getNewCall(); - CallerID toCallerID = pbx.buildCallerID("101", "I'm calling you"); - EndPoint transferTarget = pbx.buildEndPoint(TechType.SIP, "101"); - pbx.blindTransfer(call, OperandChannel.REMOTE_PARTY, transferTarget, toCallerID, false, 30L, - new ActivityCallback() - { - - @Override - public void progress(BlindTransferActivity activity, ActivityStatusEnum status, String message) - { - // if success the blind transfer completed. - } - }); - } - if (status == ActivityStatusEnum.FAILURE) - System.out.println("Oops something bad happened when we dialed."); - } - }); - - } - -} diff --git a/src/main/java/org/asteriskjava/examples/activities/Dial.java b/src/main/java/org/asteriskjava/examples/activities/Dial.java deleted file mode 100644 index db3c6e636..000000000 --- a/src/main/java/org/asteriskjava/examples/activities/Dial.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.asteriskjava.examples.activities; - -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.ActivityStatusEnum; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.Trunk; -import org.asteriskjava.pbx.activities.DialActivity; - -public class Dial -{ - static public void main(String[] args) - { - syncDial(); - asyncDial(); - - } - - /** - * Simple synchronous dial. The dial method won't return until the dial - * starts. Using this method will lockup your UI until the dial starts. For - * better control use the async Dial method below. - */ - static private void syncDial() - { - try - { - PBX pbx = PBXFactory.getActivePBX(); - - // The trunk MUST match the section header (e.g. [default]) that appears - // in your /etc/asterisk/sip.d file (assuming you are using a SIP trunk). - // The trunk is used to select which SIP trunk to dial through. - Trunk trunk = pbx.buildTrunk("default"); - - // We are going to dial from extension 100 - EndPoint from = pbx.buildEndPoint(TechType.SIP, "100"); - // The caller ID to show on extension 100. - CallerID fromCallerID = pbx.buildCallerID("100", "My Phone"); - - // The caller ID to display on the called parties phone - CallerID toCallerID = pbx.buildCallerID("83208100", "Asterisk Java is calling"); - // The party we are going to call. - EndPoint to = pbx.buildEndPoint(TechType.SIP, trunk, "5551234"); - - // Trunk is currently ignored so set to null - // The call is dialed and only returns when the call comes up (it - // doesn't wait for the remote end to answer). - DialActivity dial = pbx.dial(from, fromCallerID, to, toCallerID); - - Call call = dial.getNewCall(); - - Thread.sleep(20000); - - pbx.hangup(call); - } - catch (PBXException | InterruptedException e) - { - System.out.println(e); - } - } - - static private void asyncDial() - { - PBX pbx = PBXFactory.getActivePBX(); - - // We are going to dial from extension 100 - EndPoint from = pbx.buildEndPoint(TechType.SIP, "100"); - // The caller ID to show on extension 100. - CallerID fromCallerID = pbx.buildCallerID("100", "My Phone"); - - // The caller ID to display on the called parties phone - CallerID toCallerID = pbx.buildCallerID("83208100", "Asterisk Java is calling"); - // The party we are going to call. - EndPoint to = pbx.buildEndPoint(TechType.SIP, pbx.buildTrunk("default"), "5551234"); - - // Start the dial and return immediately. - // progress is provided via the ActivityCallback. - pbx.dial(from, fromCallerID, to, toCallerID, new ActivityCallback() - { - - @Override - public void progress(DialActivity activity, ActivityStatusEnum status, String message) - { - if (status == ActivityStatusEnum.SUCCESS) - { - System.out.println("Dial all good"); - try - { - // Call is up - Call call = activity.getNewCall(); - // So lets just hangup the call - PBXFactory.getActivePBX().hangup(call.getOriginatingParty()); - } - catch (PBXException e) - { - System.out.println(e); - } - } - if (status == ActivityStatusEnum.FAILURE) - System.out.println("Oops something bad happened when we dialed."); - } - }); - - } - -} diff --git a/src/main/java/org/asteriskjava/examples/activities/ExamplesAsteriskSettings.java b/src/main/java/org/asteriskjava/examples/activities/ExamplesAsteriskSettings.java deleted file mode 100644 index 30c9d0b5f..000000000 --- a/src/main/java/org/asteriskjava/examples/activities/ExamplesAsteriskSettings.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.asteriskjava.examples.activities; - -import org.asteriskjava.pbx.AsteriskSettings; - -public class ExamplesAsteriskSettings implements AsteriskSettings -{ - - @Override - public int getManagerPortNo() - { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String getManagerPassword() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getManagerUsername() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getAsteriskIP() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public Integer getMeetmeBaseAddress() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean getDisableBridge() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public String getManagementContext() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getExtensionPark() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public int getDialTimeout() - { - // TODO Auto-generated method stub - return 0; - } - - @Override - public String getAutoAnswer() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getAgiExtension() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean getCanDetectHangup() - { - // TODO Auto-generated method stub - return false; - } - -} diff --git a/src/main/java/org/asteriskjava/examples/activities/Hold.java b/src/main/java/org/asteriskjava/examples/activities/Hold.java deleted file mode 100644 index bf37a9640..000000000 --- a/src/main/java/org/asteriskjava/examples/activities/Hold.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.asteriskjava.examples.activities; - -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.ActivityStatusEnum; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.activities.DialActivity; -import org.asteriskjava.pbx.activities.HoldActivity; - -/** - * dial somebody and then put them on hold. - * - * @author bsutton - */ -public class Hold -{ - - static public void main(String[] args) - { - hold(); - } - - static private void hold() - { - PBX pbx = PBXFactory.getActivePBX(); - - // We are going to dial from extension 100 - EndPoint from = pbx.buildEndPoint(TechType.SIP, "100"); - // The caller ID to show on extension 100. - CallerID fromCallerID = pbx.buildCallerID("100", "My Phone"); - - // The caller ID to display on the called parties phone - CallerID toCallerID = pbx.buildCallerID("83208100", "Asterisk Java is calling"); - // The party we are going to call. - EndPoint to = pbx.buildEndPoint("SIP/default/5551234"); - - // Start the dial and return immediately. - // progress is provided via the ActivityCallback. - pbx.dial(from, fromCallerID, to, toCallerID, new ActivityCallback() - { - - @Override - public void progress(DialActivity activity, ActivityStatusEnum status, String message) - { - if (status == ActivityStatusEnum.SUCCESS) - { - System.out.println("Dial all good so lets place them on hold"); - PBX pbx = PBXFactory.getActivePBX(); - // Call is up - Call call = activity.getNewCall(); - - // Place the remote party on hold. - HoldActivity hold = pbx.hold(call.getRemoteParty()); - - Channel heldChannel = hold.getChannel(); - } - if (status == ActivityStatusEnum.FAILURE) - System.out.println("Oops something bad happened when we dialed."); - } - }); - - } - -} diff --git a/src/main/java/org/asteriskjava/examples/fastagi/ExampleCallIn.java b/src/main/java/org/asteriskjava/examples/fastagi/ExampleCallIn.java deleted file mode 100644 index debdd01ae..000000000 --- a/src/main/java/org/asteriskjava/examples/fastagi/ExampleCallIn.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.examples.fastagi; - -/* Cloudvox - answer and control a phone call with Java -Place and receive phone calls via open API: http://cloudvox.com/ -Learn about call scripting, Asterisk/AGI, voice apps: http://help.cloudvox.com/ -Added to the project and modified by Tropo: http://tropo.com */ - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.BaseAgiScript; - -/* Example incoming call handler -Answer call, speak message */ -public class ExampleCallIn extends BaseAgiScript { - public void service(AgiRequest request, AgiChannel channel) throws AgiException { - answer(); - - exec("Playback", "tt-monkeys"); - - hangup(); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/examples/fastagi/fastagi.properties b/src/main/java/org/asteriskjava/examples/fastagi/fastagi.properties deleted file mode 100644 index 916b40c85..000000000 --- a/src/main/java/org/asteriskjava/examples/fastagi/fastagi.properties +++ /dev/null @@ -1 +0,0 @@ -callin.agi = ExampleCallIn \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/.gitignore b/src/main/java/org/asteriskjava/fastagi/.gitignore deleted file mode 100644 index 98a4ac9ad..000000000 --- a/src/main/java/org/asteriskjava/fastagi/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -/AbstractAgiServer.class -/AbstractMappingStrategy.class -/AgiChannel.class -/AgiException.class -/AgiHangupException.class -/AgiNetworkException.class -/AgiOperations.class -/AgiRequest.class -/AgiScript.class -/AgiServer.class -/AgiServerThread$1.class -/AgiServerThread$AgiThreadUncaughtExceptionHanlder.class -/AgiServerThread.class -/AgiSpeechException.class -/AsyncAgiServer.class -/BaseAgiScript.class -/ClassNameMappingStrategy.class -/CompositeMappingStrategy.class -/DefaultAgiServer.class -/InvalidCommandSyntaxException.class -/InvalidOrUnknownCommandException.class -/MappingStrategy.class -/NamedAgiScript.class -/ResourceBundleMappingStrategy.class -/ScriptEngineMappingStrategy$1.class -/ScriptEngineMappingStrategy$ScriptEngineAgiScript.class -/ScriptEngineMappingStrategy.class -/SimpleMappingStrategy.class -/SpeechRecognitionResult$SpeechResult.class -/SpeechRecognitionResult.class -/StaticMappingStrategy.class diff --git a/src/main/java/org/asteriskjava/fastagi/AbstractAgiServer.java b/src/main/java/org/asteriskjava/fastagi/AbstractAgiServer.java deleted file mode 100644 index 76bedea20..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AbstractAgiServer.java +++ /dev/null @@ -1,298 +0,0 @@ -package org.asteriskjava.fastagi; - -import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.asteriskjava.fastagi.internal.DefaultAgiChannelFactory; -import org.asteriskjava.util.DaemonThreadFactory; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Abstract base class for FastAGI and AsyncAGI servers. - * - * @since 1.0.0 - */ -public abstract class AbstractAgiServer -{ - private final Log logger = LogFactory.getLog(getClass()); - - /** - * The default thread pool size. - */ - private static final int DEFAULT_POOL_SIZE = 10; - - /** - * The default thread pool size. - */ - private static final int DEFAULT_MAXIMUM_POOL_SIZE = 100; - - /** - * The minimum number of worker threads in the thread pool. - */ - private int poolSize = DEFAULT_POOL_SIZE; - - /** - * The maximum number of worker threads in the thread pool. This equals the - * maximum number of concurrent requests this AgiServer can serve. - */ - private int maximumPoolSize = DEFAULT_MAXIMUM_POOL_SIZE; - - /** - * The thread pool that contains the worker threads to process incoming - * requests. - */ - private ThreadPoolExecutor pool; - - /** - * The strategy to use for mapping AgiRequests to AgiScripts that serve - * them. - */ - private MappingStrategy mappingStrategy; - - /** - * The factory to use for creating new AgiChannel instances. - */ - private final AgiChannelFactory agiChannelFactory; - - private volatile boolean die = false; - - public AbstractAgiServer() - { - this(new DefaultAgiChannelFactory()); - } - - /** - * Creates a new AbstractAgiServer with the given channel factory. - * - * @param agiChannelFactory the AgiChannelFactory to use for creating new - * AgiChannel instances. - * @since 1.0.0 - */ - public AbstractAgiServer(AgiChannelFactory agiChannelFactory) - { - if (agiChannelFactory == null) - { - throw new IllegalArgumentException("AgiChannelFactory must not be null"); - } - - logger.debug("Using channelFactory " + agiChannelFactory.getClass().getCanonicalName()); - this.agiChannelFactory = agiChannelFactory; - } - - /** - * Returns the AgiChannelFactory to use for creating new AgiChannel - * instances. - * - * @return the AgiChannelFactory to use for creating new AgiChannel - * instances. - */ - protected AgiChannelFactory getAgiChannelFactory() - { - return this.agiChannelFactory; - } - - /** - * Returns the default number of worker threads in the thread pool. - * - * @return the default number of worker threads in the thread pool. - * @since 1.0.0 - */ - public synchronized int getPoolSize() - { - return poolSize; - } - - /** - * Sets the default number of worker threads in the thread pool.
- * This is the number of threads that are available even if they are idle. - *
- * The default pool size is 10. - * - * @param poolSize the size of the worker thread pool. - * @throws IllegalArgumentException if the new pool size is negative - * @see java.util.concurrent.ThreadPoolExecutor#setCorePoolSize(int) - */ - public synchronized void setPoolSize(int poolSize) - { - if (poolSize < 0) - { - throw new IllegalArgumentException("New poolSize (" + poolSize + ") is must not be negative"); - } - - if (pool != null) - { - pool.setCorePoolSize(poolSize); - } - this.poolSize = poolSize; - } - - /** - * Returns the maximum number of worker threads in the thread pool. - * - * @return the maximum number of worker threads in the thread pool. - * @since 1.0.0 - */ - public synchronized int getMaximumPoolSize() - { - return maximumPoolSize; - } - - /** - * Sets the maximum number of worker threads in the thread pool.
- * This equals the maximum number of concurrent requests this AgiServer can - * serve.
- * The default maximum pool size is 100. - * - * @param maximumPoolSize the maximum size of the worker thread pool. - * @throws IllegalArgumentException if maximumPoolSize is less than current - * pool size or less than or equal to 0. - * @see java.util.concurrent.ThreadPoolExecutor#setMaximumPoolSize(int) - */ - public synchronized void setMaximumPoolSize(int maximumPoolSize) - { - if (maximumPoolSize <= 0) - { - throw new IllegalArgumentException("New maximumPoolSize (" + maximumPoolSize + ") is must be positive"); - } - - if (maximumPoolSize < poolSize) - { - throw new IllegalArgumentException( - "New maximumPoolSize (" + maximumPoolSize + ") is less than current pool size (" + poolSize + ")"); - } - - if (pool != null) - { - pool.setMaximumPoolSize(maximumPoolSize); - } - this.maximumPoolSize = maximumPoolSize; - } - - /** - * Sets the strategy to use for mapping AgiRequests to AgiScripts that serve - * them. - * - * @param mappingStrategy the mapping strategy to use. - */ - public void setMappingStrategy(MappingStrategy mappingStrategy) - { - this.mappingStrategy = mappingStrategy; - } - - protected MappingStrategy getMappingStrategy() - { - return mappingStrategy; - } - - protected boolean isDie() - { - return die; - } - - protected synchronized void shutdown() - { - this.die = true; - if (pool != null) - { - pool.shutdown(); - } - } - - @Override - protected void finalize() throws Throwable - { - this.die = true; - if (pool != null) - { - pool.shutdown(); - } - - super.finalize(); - } - - /** - * Execute the runnable using the configured ThreadPoolExecutor obtained - * from {@link #getPool()}. - * - * @param command the command to run. - * @throws RejectedExecutionException if the runnable can't be executed - */ - protected void execute(Runnable command) throws RejectedExecutionException - { - if (isDie()) - { - logger.warn("AgiServer is shutting down: Refused to execute AgiScript"); - return; - } - - getPool().execute(command); - } - - protected void handleException(String message, Exception e) - { - logger.warn(message, e); - } - - private synchronized ThreadPoolExecutor getPool() - { - if (pool == null) - { - pool = createPool(); - logger.info("Thread pool started."); - } - - return pool; - } - - /** - * Returns the approximate number of AgiConnectionHandler threads that are - * actively executing tasks. - * - * @see ThreadPoolExecutor#getActiveCount() - * @see #getPoolActiveThreadCount() - * @see org.asteriskjava.fastagi.internal.AgiConnectionHandler#AGI_CONNECTION_HANDLERS - */ - public int getPoolActiveTaskCount() - { - if (pool != null) - { - return pool.getActiveCount(); - } - return -1; - }// getPoolActiveCount - - public int getPoolActiveThreadCount() - { - if (pool != null) - { - return pool.getPoolSize(); - } - return -1; - }// getPoolActiveThreadCount - - /** - * Creates a new ThreadPoolExecutor to serve the AGI requests. The nature of - * this pool defines how many concurrent requests can be handled. The - * default implementation returns a dynamic thread pool defined by the - * poolSize and maximumPoolSize properties. - *

- * You can override this method to change this behavior. For example you can - * use a cached pool with - * - *

-     * return Executors.newCachedThreadPool(new DaemonThreadFactory());
-     * 
- * - * @return the ThreadPoolExecutor to use for serving AGI requests. - * @see #setPoolSize(int) - * @see #setMaximumPoolSize(int) - */ - protected ThreadPoolExecutor createPool() - { - return new ThreadPoolExecutor(poolSize, (maximumPoolSize < poolSize) ? poolSize : maximumPoolSize, 50000L, - TimeUnit.MILLISECONDS, new SynchronousQueue(), new DaemonThreadFactory()); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AbstractMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/AbstractMappingStrategy.java deleted file mode 100644 index b78607c7a..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AbstractMappingStrategy.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.List; - -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Abstract base class for common mapping strategies. - *
- * If you implement your own mapping strategy you can derive from this class. - * - * @author srt - * @since 0.3 - */ -public abstract class AbstractMappingStrategy implements MappingStrategy -{ - /** - * Reference to Asterisk-Java's logging subsystem. - */ - protected Log logger = LogFactory.getLog(getClass()); - private static final String[] DEFAULT_SCRIPT_PATH = new String[]{"agi"}; - - private ClassLoader defaultClassLoader = null; - - @Override - public AgiScript determineScript(AgiRequest request, AgiChannel channel) - { - return determineScript(request); - } - - public abstract AgiScript determineScript(AgiRequest request); - - /** - * Returns the ClassLoader to use for loading AgiScript classes and load - * other resources like the mapping properties file.

- * By default this method returns a class loader that searches for classes in the - * "agi" subdirectory (if it exists) and uses the context class loader of the - * current thread as the parent class loader.

- * You can override this method if you prefer using a different class loader. - * - * @return the ClassLoader to use for loading AgiScript classes and load - * other resources like the mapping properties file. - * @since 1.0.0 - */ - protected synchronized ClassLoader getClassLoader() - { - if (defaultClassLoader == null) - { - final ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader(); - final List dirUrls = new ArrayList<>(); - - for (String scriptPathEntry : DEFAULT_SCRIPT_PATH) - { - final File scriptDir = new File(scriptPathEntry); - if (! scriptDir.isDirectory()) - { - continue; - } - - try - { - dirUrls.add(scriptDir.toURI().toURL()); - } - catch (MalformedURLException e) - { - // should not happen - } - } - - if (dirUrls.isEmpty()) - { - return parentClassLoader; - } - - defaultClassLoader = new URLClassLoader(dirUrls.toArray(new URL[dirUrls.size()]), parentClassLoader); - } - - return defaultClassLoader; - } - - /** - * Creates a new instance of an AGI script. - * - * @param className Class name of the AGI script. The class must implement - * {@link AgiScript}. - * @return the created instance of the AGI script class. If the instance - * can't be created an error is logged and null is - * returned. - */ - @SuppressWarnings("unchecked") - protected AgiScript createAgiScriptInstance(String className) - { - Class tmpClass; - Class agiScriptClass; - Constructor constructor; - AgiScript agiScript; - - agiScript = null; - - try - { - tmpClass = getClassLoader().loadClass(className); - } - catch (ClassNotFoundException e1) - { - logger.debug("Unable to create AgiScript instance of type " + className - + ": Class not found, make sure the class exists and is available on the CLASSPATH"); - return null; - } - - if (!AgiScript.class.isAssignableFrom(tmpClass)) - { - logger.warn("Unable to create AgiScript instance of type " + className - + ": Class does not implement the AgiScript interface"); - return null; - } - - agiScriptClass = (Class) tmpClass; - try - { - constructor = agiScriptClass.getConstructor(); - agiScript = constructor.newInstance(); - } - catch (Exception e) - { - logger.warn("Unable to create AgiScript instance of type " + className, e); - } - - return agiScript; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiChannel.java b/src/main/java/org/asteriskjava/fastagi/AgiChannel.java deleted file mode 100644 index f9082c703..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiChannel.java +++ /dev/null @@ -1,882 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import org.asteriskjava.fastagi.command.AgiCommand; -import org.asteriskjava.fastagi.reply.AgiReply; - -/** - * Provides the functionality to send AgiCommands to Asterisk while handling an - * AgiRequest.
- * This interface is supposed to be used by AgiScripts for interaction with the - * Asterisk server. - * - * @author srt - * @version $Id$ - */ -public interface AgiChannel -{ - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - String getName(); - - /** - * Returns the unqiue id of the channel. - * - * @return the unqiue id of the channel. - */ - String getUniqueId(); - - /** - * Returns the reply received in response to the last command sent to - * Asterisk. - * - * @return the reply received in response to the last command sent to - * Asterisk or null if none has yet been received. - * @since 1.0.0 - */ - AgiReply getLastReply(); - - /** - * Sends a command to asterisk and returns the corresponding reply. The - * reply is also available through {@link #getLastReply()}. - * - * @param command the command to send. - * @return the reply of the asterisk server containing the return value. - * @throws AgiException if the command can't be sent to Asterisk (for - * example because the channel has been hung up) - */ - AgiReply sendCommand(AgiCommand command) throws AgiException; - - /** - * Answers the channel. - * - * @since 0.2 - */ - void answer() throws AgiException; - - /** - * Hangs the channel up. - * - * @since 0.2 - */ - void hangup() throws AgiException; - - /** - * Cause the channel to automatically hangup at the given number of seconds - * in the future. - * - * @param time the number of seconds before this channel is automatically - * hung up. - *

- * 0 disables the autohangup feature. - * @since 0.2 - */ - void setAutoHangup(int time) throws AgiException; - - /** - * Sets the caller id on the current channel. - * - * @param callerId the raw caller id to set, for example - * "John Doe<1234>". - * @since 0.2 - */ - void setCallerId(String callerId) throws AgiException; - - /** - * Plays music on hold from the default music on hold class. - * - * @since 0.2 - */ - void playMusicOnHold() throws AgiException; - - /** - * Plays music on hold from the given music on hold class. - * - * @param musicOnHoldClass the music on hold class to play music from as - * configures in Asterisk's musiconhold.conf. - * @since 0.2 - */ - void playMusicOnHold(String musicOnHoldClass) throws AgiException; - - /** - * Stops playing music on hold. - * - * @since 0.2 - */ - void stopMusicOnHold() throws AgiException; - - /** - * Returns the status of the channel. - *

- * Return values: - *

    - *
  • 0 Channel is down and available - *
  • 1 Channel is down, but reserved - *
  • 2 Channel is off hook - *
  • 3 Digits (or equivalent) have been dialed - *
  • 4 Line is ringing - *
  • 5 Remote end is ringing - *
  • 6 Line is up - *
  • 7 Line is busy - *
- * - * @return the status of the channel. - * @since 0.2 - */ - int getChannelStatus() throws AgiException; - - /** - * Plays the given file and waits for the user to enter DTMF digits until he - * presses '#'. The user may interrupt the streaming by starting to enter - * digits. - * - * @param file the name of the file to play - * @return a String containing the DTMF the user entered - * @since 0.2 - */ - String getData(String file) throws AgiException; - - /** - * Plays the given file and waits for the user to enter DTMF digits until he - * presses '#' or the timeout occurs. The user may interrupt the streaming - * by starting to enter digits. - * - * @param file the name of the file to play - * @param timeout the timeout in milliseconds to wait for user input. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - * @return a String containing the DTMF the user entered - * @since 0.2 - */ - String getData(String file, long timeout) throws AgiException; - - /** - * Plays the given file and waits for the user to enter DTMF digits until he - * presses '#' or the timeout occurs or the maximum number of digits has - * been entered. The user may interrupt the streaming by starting to enter - * digits. - * - * @param file the name of the file to play - * @param timeout the timeout in milliseconds to wait for user input. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - * @param maxDigits the maximum number of digits the user is allowed to - * enter - * @return a String containing the DTMF the user entered - * @since 0.2 - */ - String getData(String file, long timeout, int maxDigits) throws AgiException; - - /** - * Plays the given file, and waits for the user to press one of the given - * digits. If none of the escape digits is pressed while streaming the file - * it waits for the default timeout of 5 seconds still waiting for the user - * to press a digit. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that the user is expected to - * press. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char getOption(String file, String escapeDigits) throws AgiException; - - /** - * Plays the given file, and waits for the user to press one of the given - * digits. If none of the escape digits is pressed while streaming the file - * it waits for the specified timeout still waiting for the user to press a - * digit. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that the user is expected to - * press. - * @param timeout the timeout in milliseconds to wait if none of the defined - * esacpe digits was presses while streaming. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char getOption(String file, String escapeDigits, long timeout) throws AgiException; - - /** - * since at least asterisk 13 - * - * @param room - * @param profile - * @throws AgiException - */ - void confbridge(String room, String profile) throws AgiException; - - /** - * since at least asterisk 1.4 - * - * @param room - * @param options - * @throws AgiException - */ - void meetme(String room, String options) throws AgiException; - - /** - * Executes the given command. - * - * @param application the name of the application to execute, for example - * "Dial". - * @return the return code of the application of -2 if the application was - * not found. - * @since 0.2 - */ - int exec(String application) throws AgiException; - - /** - * Executes the given command. - * - * @param application the name of the application to execute, for example - * "Dial". - * @param options the parameters to pass to the application, for example - * "SIP/123". - * @return the return code of the application of -2 if the application was - * not found. - * @since 0.2 - */ - int exec(String application, String... options) throws AgiException; - - /** - * Sets the context for continuation upon exiting the application. - * - * @param context the context for continuation upon exiting the application. - * @since 0.2 - */ - void setContext(String context) throws AgiException; - - /** - * Sets the extension for continuation upon exiting the application. - * - * @param extension the extension for continuation upon exiting the - * application. - * @since 0.2 - */ - void setExtension(String extension) throws AgiException; - - /** - * Sets the priority or label for continuation upon exiting the application. - * - * @param priority the priority or label for continuation upon exiting the - * application. - * @since 0.2 - */ - void setPriority(String priority) throws AgiException; - - /** - * Plays the given file. - * - * @param file name of the file to play. - * @since 0.2 - */ - void streamFile(String file) throws AgiException; - - /** - * Plays the given file and allows the user to escape by pressing one of the - * given digit. - * - * @param file name of the file to play. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char streamFile(String file, String escapeDigits) throws AgiException; - - /** - * Plays the given file starting at the specified offset and allows the user - * to escape by pressing one of the given digit. - * - * @param file name of the file to play. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @param offset the offset samples to skip before streaming. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 1.0.0 - */ - char streamFile(String file, String escapeDigits, int offset) throws AgiException; - - /** - * Says the given digit string. - * - * @param digits the digit string to say. - * @since 0.2 - */ - void sayDigits(String digits) throws AgiException; - - /** - * Says the given number, returning early if any of the given DTMF number - * are received on the channel. - * - * @param digits the digit string to say. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayDigits(String digits, String escapeDigits) throws AgiException; - - /** - * Says the given number. - * - * @param number the number to say. - * @since 0.2 - */ - void sayNumber(String number) throws AgiException; - - /** - * Says the given number, returning early if any of the given DTMF number - * are received on the channel. - * - * @param number the number to say. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayNumber(String number, String escapeDigits) throws AgiException; - - /** - * Says the given character string with phonetics. - * - * @param text the text to say. - * @since 0.2 - */ - void sayPhonetic(String text) throws AgiException; - - /** - * Says the given character string with phonetics, returning early if any of - * the given DTMF number are received on the channel. - * - * @param text the text to say. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayPhonetic(String text, String escapeDigits) throws AgiException; - - /** - * Says the given character string. - * - * @param text the text to say. - * @since 0.2 - */ - void sayAlpha(String text) throws AgiException; - - /** - * Says the given character string, returning early if any of the given DTMF - * number are received on the channel. - * - * @param text the text to say. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayAlpha(String text, String escapeDigits) throws AgiException; - - /** - * Says the given time. - * - * @param time the time to say in seconds since 00:00:00 on January 1, 1970. - * @since 0.2 - */ - void sayTime(long time) throws AgiException; - - /** - * Says the given time, returning early if any of the given DTMF number are - * received on the channel. - * - * @param time the time to say in seconds since 00:00:00 on January 1, 1970. - * @param escapeDigits a String containing the DTMF digits that allow the - * user to escape. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayTime(long time, String escapeDigits) throws AgiException; - - /** - * Returns the value of the current channel or global variable.
- * Supports functions and builtin variables. To retrieve the caller id you - * can use getVariable("CALLERID(name)");
- * Does not support expression parsing, use {@link #getFullVariable(String)} - * in those cases. - * - * @param name the name of the variable (or function call) to retrieve. - * @return the value of the given variable or null if not set. - * @since 0.2 - */ - String getVariable(String name) throws AgiException; - - /** - * Sets the value of the current channel or global variable to a new value. - *
- * Supports functions and builtin variables. To set the caller id you can - * use setVariable("CALLERID(name)", "John Doe"); - * - * @param name the name of the variable (or function call) to set. - * @param value the new value to set. - * @since 0.2 - */ - void setVariable(String name, String value) throws AgiException; - - /** - * Waits up to 'timeout' milliseconds to receive a DTMF digit. - * - * @param timeout timeout the milliseconds to wait for the channel to - * receive a DTMF digit, -1 will wait forever. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char waitForDigit(int timeout) throws AgiException; - - /** - * Evaluates a channel expression for the current channel. To extract the - * caller id use getFullVariable("${CALLERID(name)}");. - *

- * Available since Asterisk 1.2. - * - * @param expr the expression to evaluate. - * @return the value of the given expression or null if not - * set. - * @see #getVariable(String) - * @since 0.2 - */ - String getFullVariable(String expr) throws AgiException; - - /** - * Evaluates a channel expression for the given channel.To extract the - * caller id of channel use - * getFullVariable("${CALLERID(name)}", "SIP/john-0085d860");. - *

- * Available since Asterisk 1.2. - * - * @param expr the the expression to evaluate. - * @param channel the name of the channel. - * @return the value of the given expression or null if not - * set. - * @since 0.2 - */ - String getFullVariable(String expr, String channel) throws AgiException; - - /** - * Says the given time. - *

- * Available since Asterisk 1.2. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @since 0.2 - */ - void sayDateTime(long time) throws AgiException; - - /** - * Says the given time and allows interruption by one of the given escape - * digits. - *

- * Available since Asterisk 1.2. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayDateTime(long time, String escapeDigits) throws AgiException; - - /** - * Says the given time in the given format and allows interruption by one of - * the given escape digits. - *

- * Available since Asterisk 1.2. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - * @param format the format the time should be said in - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayDateTime(long time, String escapeDigits, String format) throws AgiException; - - /** - * Says the given time in the given format and timezone and allows - * interruption by one of the given escape digits. - *

- * Available since Asterisk 1.2. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - * @param format the format the time should be said in - * @param timezone the timezone to use when saying the time, for example - * "UTC" or "Europe/Berlin". - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.2 - */ - char sayDateTime(long time, String escapeDigits, String format, String timezone) throws AgiException; - - /** - * Retrieves an entry in the Asterisk database for a given family and key. - * - * @param family the family of the entry to retrieve. - * @param key the key of the entry to retrieve. - * @return the value of the given family and key or null if - * there is no such value. - * @since 0.3 - */ - String databaseGet(String family, String key) throws AgiException; - - /** - * Adds or updates an entry in the Asterisk database for a given family, - * key, and value. - * - * @param family the family of the entry to add or update. - * @param key the key of the entry to add or update. - * @param value the new value of the entry. - * @since 0.3 - */ - void databasePut(String family, String key, String value) throws AgiException; - - /** - * Deletes an entry in the Asterisk database for a given family and key. - * - * @param family the family of the entry to delete. - * @param key the key of the entry to delete. - * @since 0.3 - */ - void databaseDel(String family, String key) throws AgiException; - - /** - * Deletes a whole family of entries in the Asterisk database. - * - * @param family the family to delete. - * @since 0.3 - */ - void databaseDelTree(String family) throws AgiException; - - /** - * Deletes all entries of a given family in the Asterisk database that have - * a key that starts with a given prefix. - * - * @param family the family of the entries to delete. - * @param keytree the prefix of the keys of the entries to delete. - * @since 0.3 - */ - void databaseDelTree(String family, String keytree) throws AgiException; - - /** - * Sends a message to the Asterisk console via the verbose message system. - * - * @param message the message to send. - * @param level the verbosity level to use. Must be in [1..4]. - * @since 0.3 - */ - void verbose(String message, int level) throws AgiException; - - /** - * Record to a file until a given dtmf digit in the sequence is received. - * - * @param file the name of the file to stream, must not include extension. - * @param format the format of the file to be recorded, for example "wav". - * @param escapeDigits contains the digits that allow the user to end - * recording. - * @param timeout the maximum record time in milliseconds, or -1 for no - * timeout. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.3 - */ - char recordFile(String file, String format, String escapeDigits, int timeout) throws AgiException; - - /** - * Record to a file until a given dtmf digit in the sequence is received. - * - * @param file the name of the file to stream, must not include extension. - * @param format the format of the file to be recorded, for example "wav". - * @param escapeDigits contains the digits that allow the user to end - * recording. - * @param timeout the maximum record time in milliseconds, or -1 for no - * timeout. - * @param offset the offset samples to skip. - * @param beep true if a beep should be played before - * recording. - * @param maxSilence The amount of silence (in seconds) to allow before - * returning despite the lack of dtmf digits or reaching timeout. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.3 - */ - char recordFile(String file, String format, String escapeDigits, int timeout, int offset, boolean beep, int maxSilence) - throws AgiException; - - /** - * Plays the given file allowing the user to control the streaming by using - * "#" for forward and "*" for rewind. - * - * @param file the name of the file to stream, must not include extension. - * @since 0.3 - */ - void controlStreamFile(String file) throws AgiException; - - /** - * Plays the given file allowing the user to control the streaming by using - * "#" for forward and "*" for rewind. Pressing one of the escape digits - * stops streaming. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.3 - */ - char controlStreamFile(String file, String escapeDigits) throws AgiException; - - /** - * Plays the given file allowing the user to control the streaming by using - * "#" for forward and "*" for rewind. Pressing one of the escape digits - * stops streaming. The file is played starting at the indicated offset. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. May be null if you don't want the - * user to interrupt. - * @param offset the offset samples to skip before streaming. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.3 - */ - char controlStreamFile(String file, String escapeDigits, int offset) throws AgiException; - - /** - * Plays the given file allowing the user to control the streaming by using - * forwardDigit for forward, rewindDigit for rewind and pauseDigit for - * pause. Pressing one of the escape digits stops streaming. The file is - * played starting at the indicated offset, use 0 to start at the beginning. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. May be null if you don't want the - * user to interrupt. - * @param offset the offset samples to skip before streaming, use 0 to start - * at the beginning. - * @param forwardDigit the digit for fast forward. - * @param rewindDigit the digit for rewind. - * @param pauseDigit the digit for pause and unpause. - * @return the DTMF digit pressed or 0x0 if none was pressed. - * @since 0.3 - */ - char controlStreamFile(String file, String escapeDigits, int offset, String forwardDigit, String rewindDigit, - String pauseDigit) throws AgiException; - - /** - * Creates a speech object that uses the default speech engine. The speech - * object is used by the other speech methods and must be created before - * they are called. - * - * @throws AgiSpeechException if the speech object cannot be created. - * @see #speechDestroy() - * @since 1.0.0 - */ - void speechCreate() throws AgiException; - - /** - * Creates a speech object that uses the given speech engine. The speech - * object is used by the other speech methods and must be created before - * they are called. - * - * @param engine the name of the speech engine. For example "lumenvox". - * @throws AgiSpeechException if the speech object cannot be created. - * @see #speechDestroy() - * @since 1.0.0 - */ - void speechCreate(String engine) throws AgiException; - - /** - * Sets the speech engine setting indicated by name to the given value. - * - * @param name the name of the setting to set. - * @param value the value to set. - * @throws AgiSpeechException if the setting cannot be set. - * @since 1.0.0 - */ - void speechSet(String name, String value) throws AgiException; - - /** - * Destroys the current speech object. - * - * @throws AgiSpeechException if the speech engine cannot be destroyed. - * @see #speechCreate(String) - * @since 1.0.0 - */ - void speechDestroy() throws AgiException; - - /** - * Loads the specified grammar. The grammer is then available for calls to - * {@link #speechActivateGrammar(String)} under the given name. Eplicitly - * loading a grammer is only required if the grammer has not been defined in - * the speech engine configuration, e.g. the [grammars] section - * of lumenvox.conf. - * - * @param label the name of the grammar, used for subsequent calls to - * {@link #speechActivateGrammar(String)}, - * {@link #speechDeactivateGrammar(String)} and - * {@link #speechUnloadGrammar(String)}. - * @param path the path to the grammar to load. - * @throws AgiSpeechException if the grammar cannot be loaded. - * @see #speechUnloadGrammar(String) - * @see #speechActivateGrammar(String) - * @since 1.0.0 - */ - void speechLoadGrammar(String label, String path) throws AgiException; - - /** - * Unloads the specified grammar. - * - * @param label the name of the grammar to unload. - * @throws AgiSpeechException if the grammar cannot be unloaded. - * @see #speechLoadGrammar(String, String) - * @since 1.0.0 - */ - void speechUnloadGrammar(String label) throws AgiException; - - /** - * Activates the specified grammar. - * - * @param label the name of the grammar to activate. - * @throws AgiSpeechException if the grammar cannot be activated. - * @see #speechDeactivateGrammar(String) - * @see #speechLoadGrammar(String, String) - * @since 1.0.0 - */ - void speechActivateGrammar(String label) throws AgiException; - - /** - * Deactivates the specified grammar. - * - * @param label the name to the grammar to deactivate. - * @throws AgiSpeechException if the grammar cannot be deactivated. - * @see #speechActivateGrammar(String) - * @since 1.0.0 - */ - void speechDeactivateGrammar(String label) throws AgiException; - - /** - * Plays the given prompt while listening for speech and DTMF. - * - * @param prompt the name of the file to stream, must not include extension. - * @param timeout the timeout in milliseconds to wait for user input. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - * @return the recognition result - * @since 1.0.0 - */ - SpeechRecognitionResult speechRecognize(String prompt, int timeout) throws AgiException; - - /** - * Plays the given prompt while listening for speech and DTMF. - * - * @param prompt the name of the file to stream, must not include extension. - * @param timeout the timeout in milliseconds to wait for user input. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - * @param offset the offset samples to skip before streaming, use 0 to start - * at the beginning. - * @return the recognition result - * @since 1.0.0 - */ - SpeechRecognitionResult speechRecognize(String prompt, int timeout, int offset) throws AgiException, AgiSpeechException; - - /** - * Defines the point in the dialplan where the call will continue when the - * AGI script returns. - *

- * This is a shortcut for calling {@link #setContext(String)}, - * {@link #setExtension(String)} and {@link #setPriority(String)} in series. - * - * @param context the context for continuation upon exiting the application. - * @param extension the extension for continuation upon exiting the - * application. - * @param priority the priority or label for continuation upon exiting the - * application. - * @see #setContext(String) - * @see #setExtension(String) - * @see #setPriority(String) - * @since 1.0.0 - */ - void continueAt(String context, String extension, String priority) throws AgiException; - - /** - * Calls a subroutine in the dialplan
- * This method is available since Asterisk 1.6. - * - * @param context the context of the called subroutine. - * @param extension the extension in the called context. - * @param priority the priority of the called extension. - * @since 1.0.0 - */ - public void gosub(String context, String extension, String priority) throws AgiException; - - /** - * Calls a subroutine in the dialplan - *

- *
- * This method is available since Asterisk 1.6. - * - * @param context the context of the called subroutine. - * @param extension the extension in the called context. - * @param priority the priority of the called extension. - * @param arguments optional arguments to be passed to the subroutine. They - * should be separated by comma. They will accessible in the form - * of ${ARG1}, ${ARG2}, etc in the subroutine body. - * @since 1.0.0 - */ - public void gosub(String context, String extension, String priority, String... arguments) throws AgiException; - - /** - * invoke the dial command - * - * @param target - * @param timeout - * @param options - * @throws AgiException - */ - public void dial(String target, int timeout, String options) throws AgiException; - - /** - * invoke the bridge command - * - * @param channelName - * @param options - * @throws AgiException - */ - void bridge(String channelName, String options) throws AgiException; - - void queue(String queue) throws AgiException; - -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiChannelFactory.java b/src/main/java/org/asteriskjava/fastagi/AgiChannelFactory.java deleted file mode 100644 index 100eca517..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiChannelFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.fastagi; - -/** - * An AgiChannelFactory creates instances of AgiChannels, - * that are passed to agi scripts. - *

- * An instance of the AgiChannelFactory can be passed to the - * DefaultAgiServer's constructor. - * - * @since 1.0.0 - */ -public interface AgiChannelFactory -{ - /** - * Creates a new AgiChannel. - * - * @param request the request to build the channel for. - * @param agiWriter the writer. - * @param agiReader the reader. - * @return the created channel. - */ - AgiChannel createAgiChannel(AgiRequest request, AgiWriter agiWriter, AgiReader agiReader); -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiException.java b/src/main/java/org/asteriskjava/fastagi/AgiException.java deleted file mode 100644 index 5aa33eb30..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * Base class for all AGI specific exceptions. - * - * @author srt - * @version $Id$ - */ -public class AgiException extends Exception -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1215836054948768757L; - - /** - * Creates a new AgiException with the given message. - * - * @param message a message describing the AgiException. - */ - public AgiException(String message) - { - super(message); - } - - /** - * Creates a new AgiException with the given message and cause. - * - * @param message a message describing the AgiException. - * @param cause the throwable that caused this exception. - */ - public AgiException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiHangupException.java b/src/main/java/org/asteriskjava/fastagi/AgiHangupException.java deleted file mode 100644 index f9a37b831..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiHangupException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * The AgiHangupException is thrown if the channel is hung up while - * processing the {@link org.asteriskjava.fastagi.AgiRequest}.

- * Up to Asterisk 1.4 hanging up the channel also closes the TCP connection, - * since Asterisk 1.6 the connection is kept alive but commands that - * require an active channel return status code - * {@link org.asteriskjava.fastagi.reply.AgiReply#SC_DEAD_CHANNEL}. Both events - * are translated to an AgiHangupException. - * - * @author srt - * @version $Id$ - */ -public class AgiHangupException extends AgiException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256444698691252274L; - - /** - * Creates a new AgiHangupException. - */ - public AgiHangupException() - { - super("Channel was hung up."); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiNetworkException.java b/src/main/java/org/asteriskjava/fastagi/AgiNetworkException.java deleted file mode 100644 index b6d566009..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiNetworkException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * The AgiNetworkException usally wraps an IOException denoting a network - * problem while talking to the Asterisk server. - * - * @author srt - * @version $Id$ - */ -public class AgiNetworkException extends AgiException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256445789629723703L; - - /** - * Creates a new AgiNetworkException with the given message and cause. - * - * @param message a message describing the AgiException. - * @param cause the throwable that caused this exception. - */ - public AgiNetworkException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiOperations.java b/src/main/java/org/asteriskjava/fastagi/AgiOperations.java deleted file mode 100644 index ea3846a11..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiOperations.java +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import org.asteriskjava.fastagi.command.AgiCommand; -import org.asteriskjava.fastagi.internal.AgiConnectionHandler; -import org.asteriskjava.fastagi.reply.AgiReply; - -/** - * AgiOperations provides some convinience methods that wrap the various - * {@link AgiCommand AgiCommands}. - * - * @since 0.3 - * @author srt - * @version $Id$ - */ -public class AgiOperations implements AgiChannel -{ - private final AgiChannel channel; - - /** - * Creates a new instance that operates on the channel attached to the - * current thread. - */ - public AgiOperations() - { - this.channel = null; - } - - /** - * Creates a new instance that operates on the given channel. - * - * @param channel the channel to operate on. - */ - public AgiOperations(AgiChannel channel) - { - this.channel = channel; - } - - /** - * Returns the channel to operate on. - * - * @return the channel to operate on. - * @throws IllegalStateException if no {@link AgiChannel} is bound to the - * current channel and no channel has been passed to the - * constructor. - */ - protected AgiChannel getChannel() - { - AgiChannel threadBoundChannel; - - if (channel != null) - { - return channel; - } - - threadBoundChannel = AgiConnectionHandler.getChannel(); - if (threadBoundChannel == null) - { - throw new IllegalStateException("Trying to send command from an invalid thread"); - } - - return threadBoundChannel; - } - - /* The following methods simply delegate to #getChannel() */ - - public String getName() - { - return getChannel().getName(); - } - - public String getUniqueId() - { - return getChannel().getUniqueId(); - } - - public AgiReply getLastReply() - { - return getChannel().getLastReply(); - } - - public AgiReply sendCommand(AgiCommand command) throws AgiException - { - return getChannel().sendCommand(command); - } - - public void answer() throws AgiException - { - getChannel().answer(); - } - - public void hangup() throws AgiException - { - getChannel().hangup(); - } - - public void setAutoHangup(int time) throws AgiException - { - getChannel().setAutoHangup(time); - } - - public void setCallerId(String callerId) throws AgiException - { - getChannel().setCallerId(callerId); - } - - public void playMusicOnHold() throws AgiException - { - getChannel().playMusicOnHold(); - } - - public void playMusicOnHold(String musicOnHoldClass) throws AgiException - { - getChannel().playMusicOnHold(musicOnHoldClass); - } - - public void stopMusicOnHold() throws AgiException - { - getChannel().stopMusicOnHold(); - } - - public int getChannelStatus() throws AgiException - { - return getChannel().getChannelStatus(); - } - - public String getData(String file) throws AgiException - { - return getChannel().getData(file); - } - - public String getData(String file, long timeout) throws AgiException - { - return getChannel().getData(file, timeout); - } - - public String getData(String file, long timeout, int maxDigits) throws AgiException - { - return getChannel().getData(file, timeout, maxDigits); - } - - public char getOption(String file, String escapeDigits) throws AgiException - { - return getChannel().getOption(file, escapeDigits); - } - - public char getOption(String file, String escapeDigits, long timeout) throws AgiException - { - return getChannel().getOption(file, escapeDigits, timeout); - } - - public int exec(String application) throws AgiException - { - return getChannel().exec(application); - } - - public int exec(String application, String... options) throws AgiException - { - return getChannel().exec(application, options); - } - - public void setContext(String context) throws AgiException - { - getChannel().setContext(context); - } - - public void setExtension(String extension) throws AgiException - { - getChannel().setExtension(extension); - } - - public void setPriority(String priority) throws AgiException - { - getChannel().setPriority(priority); - } - - public void streamFile(String file) throws AgiException - { - getChannel().streamFile(file); - } - - public char streamFile(String file, String escapeDigits) throws AgiException - { - return getChannel().streamFile(file, escapeDigits); - } - - public char streamFile(String file, String escapeDigits, int offset) throws AgiException - { - return getChannel().streamFile(file, escapeDigits, offset); - } - - public void sayDigits(String digits) throws AgiException - { - getChannel().sayDigits(digits); - } - - public char sayDigits(String digits, String escapeDigits) throws AgiException - { - return getChannel().sayDigits(digits, escapeDigits); - } - - public void sayNumber(String number) throws AgiException - { - getChannel().sayNumber(number); - } - - public char sayNumber(String number, String escapeDigits) throws AgiException - { - return getChannel().sayNumber(number, escapeDigits); - } - - public void sayPhonetic(String text) throws AgiException - { - getChannel().sayPhonetic(text); - } - - public char sayPhonetic(String text, String escapeDigits) throws AgiException - { - return getChannel().sayPhonetic(text, escapeDigits); - } - - public void sayAlpha(String text) throws AgiException - { - getChannel().sayAlpha(text); - } - - public char sayAlpha(String text, String escapeDigits) throws AgiException - { - return getChannel().sayAlpha(text, escapeDigits); - } - - public void sayTime(long time) throws AgiException - { - getChannel().sayTime(time); - } - - public char sayTime(long time, String escapeDigits) throws AgiException - { - return getChannel().sayTime(time, escapeDigits); - } - - public String getVariable(String name) throws AgiException - { - return getChannel().getVariable(name); - } - - public void setVariable(String name, String value) throws AgiException - { - getChannel().setVariable(name, value); - } - - public char waitForDigit(int timeout) throws AgiException - { - return getChannel().waitForDigit(timeout); - } - - public String getFullVariable(String name) throws AgiException - { - return getChannel().getFullVariable(name); - } - - public String getFullVariable(String name, String channel) throws AgiException - { - return getChannel().getFullVariable(name, channel); - } - - public void sayDateTime(long time) throws AgiException - { - getChannel().sayDateTime(time); - } - - public char sayDateTime(long time, String escapeDigits) throws AgiException - { - return getChannel().sayDateTime(time, escapeDigits); - } - - public char sayDateTime(long time, String escapeDigits, String format) throws AgiException - { - return getChannel().sayDateTime(time, escapeDigits, format); - } - - public char sayDateTime(long time, String escapeDigits, String format, String timezone) throws AgiException - { - return getChannel().sayDateTime(time, escapeDigits, format, timezone); - } - - public String databaseGet(String family, String key) throws AgiException - { - return getChannel().databaseGet(family, key); - } - - public void databasePut(String family, String key, String value) throws AgiException - { - getChannel().databasePut(family, key, value); - } - - public void databaseDel(String family, String key) throws AgiException - { - getChannel().databaseDel(family, key); - } - - public void databaseDelTree(String family) throws AgiException - { - getChannel().databaseDelTree(family); - } - - public void databaseDelTree(String family, String keytree) throws AgiException - { - getChannel().databaseDelTree(family, keytree); - } - - public void verbose(String message, int level) throws AgiException - { - getChannel().verbose(message, level); - } - - public char recordFile(String file, String format, String escapeDigits, int timeout) throws AgiException - { - return getChannel().recordFile(file, format, escapeDigits, timeout); - } - - public char recordFile(String file, String format, String escapeDigits, int timeout, int offset, boolean beep, - int maxSilence) throws AgiException - { - return getChannel().recordFile(file, format, escapeDigits, timeout, offset, beep, maxSilence); - } - - public void controlStreamFile(String file) throws AgiException - { - getChannel().controlStreamFile(file); - } - - public char controlStreamFile(String file, String escapeDigits) throws AgiException - { - return getChannel().controlStreamFile(file, escapeDigits); - } - - public char controlStreamFile(String file, String escapeDigits, int offset) throws AgiException - { - return getChannel().controlStreamFile(file, escapeDigits, offset); - } - - public char controlStreamFile(String file, String escapeDigits, int offset, String forwardDigit, String rewindDigit, - String pauseDigit) throws AgiException - { - return getChannel().controlStreamFile(file, escapeDigits, offset, forwardDigit, rewindDigit, pauseDigit); - } - - public void speechCreate() throws AgiException - { - getChannel().speechCreate(); - } - - public void speechCreate(String engine) throws AgiException - { - getChannel().speechCreate(engine); - } - - public void speechSet(String name, String value) throws AgiException - { - getChannel().speechSet(name, value); - } - - public void speechDestroy() throws AgiException - { - getChannel().speechDestroy(); - } - - public void speechLoadGrammar(String name, String path) throws AgiException - { - getChannel().speechLoadGrammar(name, path); - } - - public void speechUnloadGrammar(String name) throws AgiException - { - getChannel().speechUnloadGrammar(name); - } - - public void speechActivateGrammar(String name) throws AgiException - { - getChannel().speechActivateGrammar(name); - } - - public void speechDeactivateGrammar(String name) throws AgiException - { - getChannel().speechDeactivateGrammar(name); - } - - public SpeechRecognitionResult speechRecognize(String prompt, int timeout) throws AgiException - { - return getChannel().speechRecognize(prompt, timeout); - } - - public SpeechRecognitionResult speechRecognize(String prompt, int timeout, int offset) throws AgiException - { - return getChannel().speechRecognize(prompt, timeout, offset); - } - - public void continueAt(String context, String extension, String priority) throws AgiException - { - getChannel().continueAt(context, extension, priority); - } - - public void gosub(String context, String extension, String priority) throws AgiException - { - getChannel().gosub(context, extension, priority); - } - - public void gosub(String context, String extension, String priority, String... arguments) throws AgiException - { - getChannel().gosub(context, extension, priority, arguments); - } - - @Override - public void confbridge(String room, String profile) throws AgiException - { - getChannel().confbridge(room, profile); - - } - - @Override - public void meetme(String room, String options) throws AgiException - { - getChannel().meetme(room, options); - - } - - @Override - public void dial(String target, int timeout, String options) throws AgiException - { - getChannel().dial(target, timeout, options); - - } - - @Override - public void bridge(String channelName, String options) throws AgiException - { - getChannel().bridge(channelName, options); - - } - - @Override - public void queue(String queue) throws AgiException - { - getChannel().queue(queue); - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiReader.java b/src/main/java/org/asteriskjava/fastagi/AgiReader.java deleted file mode 100644 index 68850f90e..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiReader.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import org.asteriskjava.fastagi.reply.AgiReply; - -/** - * The AgiReader reads the replies from the network and parses them using a - * ReplyBuilder. - * - * @author srt - * @version $Id$ - */ -public interface AgiReader -{ - /** - * Reads the initial request data from Asterisk. - * - * @return the request read. - * @throws AgiException if the request can't be read. - */ - AgiRequest readRequest() throws AgiException; - - /** - * Reads one reply to an AgiCommand from Asterisk. - * - * @return the reply read. - * @throws AgiException if the reply can't be read. - */ - AgiReply readReply() throws AgiException; -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiRequest.java b/src/main/java/org/asteriskjava/fastagi/AgiRequest.java deleted file mode 100644 index 45086a621..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiRequest.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.net.InetAddress; -import java.util.Map; - -/** - * Provides client request information to an {@link org.asteriskjava.fastagi.AgiScript}.

- * This includes information about the channel the script is invoked on and - * parameters passed from the dialplan. - * - * @author srt - * @version $Id$ - */ -public interface AgiRequest -{ - /** - * Returns a Map containing the raw request name/value pairs. - * - * @return Map contain raw request name/value pairs. - */ - Map getRequest(); - - /** - * Returns the name of the script to execute including its full path.

- * This corresponds to the request url with protocol, host, port and - * parameters stripped off.

- * As Async AGI does not yet pass a script parameter this property will - * be null for requests received through Async AGI. - * - * @return the name of the script to execute. - */ - String getScript(); - - /** - * Returns the full URL of the requestURL in the form - * agi://host[:port][/script][?param1=value1&param2=value2]. - * - * @return the full URL of the requestURL in the form - * agi://host[:port][/script][?param1=value1&param2=value2]. - */ - String getRequestURL(); - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - String getChannel(); - - /** - * Returns the unqiue id of the channel. - * - * @return the unqiue id of the channel. - */ - String getUniqueId(); - - /** - * Returns the type of the channel, for example "SIP". - * - * @return the type of the channel, for example "SIP". - */ - String getType(); - - /** - * Returns the language set for the current channel, for example "en". - * - * @return the language set for the current channel, for example "en". - */ - String getLanguage(); - - /** - * Returns the Caller*ID number, for example "1234".

- * Note: even with Asterisk 1.0 is contains only the numerical part - * of the Caller ID. - * - * @return the Caller*ID number, for example "1234", if no Caller*ID is set or it - * is "unknown" null is returned. - * @deprecated as of 0.3, use {@link #getCallerIdNumber()} instead. - */ - @Deprecated String getCallerId(); - - /** - * Returns the Caller*ID number, for example "1234".

- * Note: even with Asterisk 1.0 is contains only the numerical part - * of the Caller ID. - * - * @return the Caller*ID number, for example "1234", if no Caller*ID is set or it - * is "unknown" null is returned. - */ - String getCallerIdNumber(); - - /** - * Returns the the Caller*ID Name, for example "John Doe". - * - * @return the the Caller*ID Name, for example "John Doe", if no Caller*ID - * Name is set or it is "unknown" null is returned. - */ - String getCallerIdName(); - - /** - * Returns the number, that has been dialed by the user. - * - * @return the dialed number, if no DNID is available or it is "unknown" - * null is returned. - */ - String getDnid(); - - /** - * If this call has been forwared, the number of the person doing the - * redirect is returned (Redirected dialed number identification service).

- * This is usally only only available on PRI. - * - * @return the number of the person doing the redirect, , if no RDNIS is - * available or it is "unknown" null is returned. - */ - String getRdnis(); - - /** - * Returns the context in the dial plan from which the AGI script was - * called. - * - * @return the context in the dial plan from which the AGI script was - * called. - */ - String getContext(); - - /** - * Returns the extension in the dial plan from which the AGI script was - * called. - * - * @return the extension in the dial plan from which the AGI script was - * called. - */ - String getExtension(); - - /** - * Returns the priority of the dial plan entry the AGI script was - * called from. - * - * @return the priority of the dial plan entry the AGI script was - * called from. - */ - Integer getPriority(); - - /** - * Returns wheather this agi is passed audio (EAGI - Enhanced AGI).

- * Enhanced AGI is currently not supported on FastAGI. - * - * @return Boolean.TRUE if this agi is passed audio, Boolean.FALSE - * otherwise. - */ - Boolean getEnhanced(); - - /** - * Returns the account code set for the call. - * - * @return the account code set for the call. - */ - String getAccountCode(); - - /** - * Returns the Callerid presentation/screening.

- * Available since Asterisk 1.2. - * - * @return the Callerid presentation/screening. - * @since 0.2 - */ - Integer getCallingPres(); - - /** - * Returns the Callerid ANI 2 (Info digits).

- * Available since Asterisk 1.2. - * - * @return the Callerid ANI 2 (Info digits). - * @since 0.2 - */ - Integer getCallingAni2(); - - /** - * Returns the Callerid Type of Number.

- * Available since Asterisk 1.2. - * - * @return the Callerid Type of Number. - * @since 0.2 - */ - Integer getCallingTon(); - - /** - * Returns the Callerid Transit Network Select.

- * Available since Asterisk 1.2. - * - * @return the Callerid Transit Network Select. - * @since 0.2 - */ - Integer getCallingTns(); - - /** - * Returns the value of a request parameter as a String, or - * null if the parameter does not exist. You should only use - * this method when you are sure the parameter has only one value.

- * If the parameter might have more than one value, use - * {@link #getParameterValues(String)}.

- * If you use this method with a multivalued parameter, the value returned - * is equal to the first value in the array returned by - * getParameterValues. - * - * @param name a String containing the name of the parameter whose value is - * requested. - * @return a String representing the single value of the parameter. - * @see #getParameterValues(String) - */ - String getParameter(String name); - - /** - * Returns an array of String objects containing all of the values the given - * request parameter has, or - * an empty array if the parameter does not exist.

- * If the parameter has a single value, the array has a length of 1. - * - * @param name a String containing the name of the parameter whose value is requested. - * @return an array of String objects containing the parameter's values. - */ - String[] getParameterValues(String name); - - /** - * Returns a Map of the parameters of this request. - * - * @return a java.util.Map containing parameter names as keys and parameter - * values as map values. The keys in the parameter map are of type - * String. The values in the parameter map are of type String array. - */ - Map getParameterMap(); - - /** - * Returns the array of arguments passed from the AGI dialplan command.

- * Example: {@code AGI(agi://localhost/HelloWorld,value1,,value2)} results in - * {@code getArguments()[0] = "value1"}, {@code getArguments()[1] = null} - * and {@code getArguments()[2] = "value2"}.

- * Available since Asterisk 1.6 - * - * @return the array of arguments passed from the AGI command, never null. - * @since 1.0.0 - */ - String[] getArguments(); - - /** - * Returns the local address this channel, that is the IP address of the AGI - * server. - * - * @return the local address this channel. - * @since 0.2 - */ - InetAddress getLocalAddress(); - - /** - * Returns the local port of this channel, that is the port the AGI server - * is listening on. - * - * @return the local port of this socket channel. - * @since 0.2 - */ - int getLocalPort(); - - /** - * Returns the remote address of this channel, that is the IP address of the - * Asterisk server. - * - * @return the remote address of this channel. - * @since 0.2 - */ - InetAddress getRemoteAddress(); - - /** - * Returns the remote port of this channel, that is the client port the - * Asterisk server is using for the AGI connection. - * - * @return the remote port of this channel. - * @since 0.2 - */ - int getRemotePort(); -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiScript.java b/src/main/java/org/asteriskjava/fastagi/AgiScript.java deleted file mode 100644 index ee72d12a5..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiScript.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * AgiScripts are used by the AsteriskServer to handle AgiRequests received from - * the Asterisk server.

- * To implement functionality using this framework you have to implement this - * interface.

- * Note: The implementation of AgiScript must be threadsafe as only one instance - * is used by AsteriskServer to handle all requests to a resource. - * - * @author srt - * @version $Id$ - */ -public interface AgiScript -{ - /** - * The service method is called by the AsteriskServer whenever this - * AgiScript should handle an incoming AgiRequest. - * - * @param request the initial data received from Asterisk when requesting - * this script. - * @param channel a handle to communicate with Asterisk such as sending - * commands to the channel sending the request. - * - * @throws AgiException any exception thrown by your script will be logged. - */ - void service(final AgiRequest request, final AgiChannel channel) throws AgiException; -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiServer.java b/src/main/java/org/asteriskjava/fastagi/AgiServer.java deleted file mode 100644 index c5a0261bb..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiServer.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.io.IOException; - -/** - * Listens for incoming FastAGI connections, reads the inital data and builds an - * {@link AgiRequest} that is then handed over to the appropriate - * {@link org.asteriskjava.fastagi.AgiScript} for processing.

- * To pass a call from Asterisk to the AGI server add an extension to your - * dialplan that makes use of the AGI() application. For example: - *

- * exten => 5551212,1,AGI(agi://192.168.0.2/GetCallerRecord)
- * 
- * Before Asterisk-Java returns control to the dialplan it sets the - * channel variable AJ_AGISTATUS to one of the following - * values: - *
    - *
  • NOT_FOUND if no AGI script had been configured to - * handle the request. - *
  • SUCCESS if the AGI script was executed successfully. - *
  • FAILED if the AGI script terminated abnormally by - * throwing an exception or there was an internal error processing it. - *
- * If Asterisk-Java was not able to process the request because its thread - * pool was exhausted the AJ_AGISTATUS variable is not set. - *

- * The AJ_AGISTATUS variable complements the AGISTATUS - * variable that is set by Asterisk to SUCCESS, FAILURE - * or HANGUP and is available since Asterisk 1.4. - * - * @see org.asteriskjava.fastagi.AgiServerThread - * @author srt - * @version $Id$ - */ -public interface AgiServer -{ - /** - * Starts this AgiServer.

- * After calling startup() this AgiServer is ready to receive requests from - * Asterisk servers and process them.

- * Note that this method will not return until the AgiServer has been shut down. - * If you want to run the AgiServer in the background use wrap it with an - * {@link AgiServerThread}. - * - * @throws IOException if the server socket cannot be bound. - * @throws IllegalStateException if this AgiServer is already running. - */ - void startup() throws IOException, IllegalStateException; - - /** - * Stops this AgiServer.

- * The server socket is closed, new connections are refused and resources - * are freed. Any running {@link AgiScript}s are finish before shutdown - * completes. - * - * @throws IllegalStateException if this AgiServer is already shut down or - * has not yet been started. - */ - void shutdown() throws IllegalStateException; -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiServerThread.java b/src/main/java/org/asteriskjava/fastagi/AgiServerThread.java deleted file mode 100644 index 77a226cfe..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiServerThread.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.lang.Thread.UncaughtExceptionHandler; -import java.util.concurrent.atomic.AtomicLong; - -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Runs an AgiServer in a separate Thread. - *

- * You can use this class to run an AgiServer in the background of your - * application or run it in your servlet container or application server. - *

- * By default the thread used by this class is marked as daemon thread, that - * means it will be destroyed when the last user thread has finished. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgiServerThread -{ - private final Log logger = LogFactory.getLog(getClass()); - private static AtomicLong idCounter = new AtomicLong(); - private AgiServer agiServer; - private Thread thread; - private boolean daemon = true; - - /** - * Creates a new AgiServerThread. - *

- * Before you can run this thread you must set an {@link AgiServer} using - * {@link #setAgiServer(AgiServer)}. - *

- * This constructor is mainly intended for use with setter based dependency - * injection. - */ - public AgiServerThread() - { - super(); - } - - /** - * Creates a new AgiServerThread that runs the given {@link AgiServer}. - * - * @param agiServer the AgiServer to run. - */ - public AgiServerThread(AgiServer agiServer) - { - super(); - this.agiServer = agiServer; - } - - /** - * Sets the AgiServer to run. - *

- * This property must be set before starting the AgiServerThread by calling - * startup. - * - * @param agiServer the AgiServer to run. - */ - public synchronized void setAgiServer(AgiServer agiServer) - { - this.agiServer = agiServer; - } - - /** - * Marks the thread as either a daemon thread or a user thread. - *

- * Default is true. - * - * @param daemon if false, marks the thread as a user - * thread. - * @see Thread#setDaemon(boolean) - * @since 0.3 - */ - public void setDaemon(boolean daemon) - { - this.daemon = daemon; - } - - /** - * Starts the AgiServer in its own thread. - *

- * Note: The AgiServerThread is designed to handle one AgiServer instance at - * a time so calling this method twice without stopping the AgiServer in - * between will result in a RuntimeException. - * - * @throws IllegalStateException if the mandatory property agiServer has not - * been set or the AgiServer had already been started. - * @throws RuntimeException if the AgiServer can't be started due to IO - * problems, for example because the socket has already been - * bound by another process. - */ - public synchronized void startup() throws IllegalStateException, RuntimeException - { - if (agiServer == null) - { - throw new IllegalStateException("Mandatory property agiServer is not set."); - } - - if (thread != null) - { - throw new IllegalStateException("AgiServer is already started"); - } - - thread = createThread(); - thread.start(); - } - - protected Thread createThread() - { - Thread t; - - t = new Thread(new Runnable() - { - public void run() - { - try - { - agiServer.startup(); - } - catch (Throwable e) - { - throw new RuntimeException("Exception running AgiServer.", e); - } - } - }); - t.setName("Asterisk-Java AgiServer-" + idCounter.getAndIncrement()); - t.setDaemon(daemon); - t.setUncaughtExceptionHandler(new AgiThreadUncaughtExceptionHanlder()); - - return t; - } - - /** - * Stops the {@link AgiServer}. - *

- * The AgiServer must have been started by calling {@link #startup()} before - * you can stop it. - * - * @see AgiServer#shutdown() - * @throws IllegalStateException if the mandatory property agiServer has not - * been set or the AgiServer had already been shut down. - */ - public synchronized void shutdown() throws IllegalStateException - { - if (agiServer == null) - { - throw new IllegalStateException("Mandatory property agiServer is not set."); - } - - agiServer.shutdown(); - - if (thread != null) - { - try - { - thread.join(); - } - catch (InterruptedException e) - { - logger.warn("Interrupted while waiting for AgiServer to shutdown."); - Thread.currentThread().interrupt(); - } - thread = null; // NOPMD by srt on 7/5/06 11:23 PM - } - } - - class AgiThreadUncaughtExceptionHanlder implements UncaughtExceptionHandler - { - public void uncaughtException(Thread t, Throwable e) - { - logger.error("Uncaught exception in AgiServerThread", e); - } - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/AgiSpeechException.java b/src/main/java/org/asteriskjava/fastagi/AgiSpeechException.java deleted file mode 100644 index 9eb711cce..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiSpeechException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * The AgiSpeechException is thrown if a speech command can not be executed - * successfully. The Asterisk Speech API is not very verbose about the reasons for - * a failure so this exception is thrown for all failures of the speech - * recognition engine. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class AgiSpeechException extends AgiException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * Creates a new AgiSpeechException with the given message. - * - * @param message the message - */ - public AgiSpeechException(String message) - { - super(message); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/AgiWriter.java b/src/main/java/org/asteriskjava/fastagi/AgiWriter.java deleted file mode 100644 index 0b4527f5a..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AgiWriter.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.command.AgiCommand; - -/** - * The AgiWriter sends commands to Asterisk. - * - * @author srt - * @version $Id$ - */ -public interface AgiWriter -{ - /** - * Sends the given command to the Asterisk server. - * - * @param command the command to send. - * @throws AgiException if the command can't be sent. - */ - void sendCommand(AgiCommand command) throws AgiException; -} diff --git a/src/main/java/org/asteriskjava/fastagi/AsyncAgiServer.java b/src/main/java/org/asteriskjava/fastagi/AsyncAgiServer.java deleted file mode 100644 index 335ad2c42..000000000 --- a/src/main/java/org/asteriskjava/fastagi/AsyncAgiServer.java +++ /dev/null @@ -1,217 +0,0 @@ -package org.asteriskjava.fastagi; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.RejectedExecutionException; - -import org.asteriskjava.fastagi.internal.AsyncAgiConnectionHandler; -import org.asteriskjava.fastagi.internal.DefaultAgiChannelFactory; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.event.AsyncAgiEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.RenameEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * AGI server for AGI over the Manager API (AsyncAGI).

- * AsyncAGI is available since Asterisk 1.6. - * - * @since 1.0.0 - */ -public class AsyncAgiServer extends AbstractAgiServer implements ManagerEventListener -{ - private final Log logger = LogFactory.getLog(getClass()); - private final Map connectionHandlers; - - /** - * Creates a new AsyncAgiServer with a {@link DefaultAgiChannelFactory}.

- * Note that you must set a {@link org.asteriskjava.fastagi.MappingStrategy} before using it. - * - * @see #setMappingStrategy(MappingStrategy) - */ - public AsyncAgiServer() - { - this(new DefaultAgiChannelFactory()); - } - - /** - * Creates a new AsyncAgiServer with a custom {@link AgiChannelFactory}.

- * Note that you must set a {@link org.asteriskjava.fastagi.MappingStrategy} before using it. - * - * @param agiChannelFactory The factory to use for creating new AgiChannel instances. - * @see #setMappingStrategy(MappingStrategy) - * @since 1.0.0 - */ - public AsyncAgiServer(AgiChannelFactory agiChannelFactory) - { - super(agiChannelFactory); - this.connectionHandlers = new HashMap<>(); - } - - /** - * Creates a new AsyncAgiServer with the given MappingStrategy.

- * Please note that Async AGI does not currently support passing a script name, so your - * MappingStrategy must be aware that the {@link org.asteriskjava.fastagi.AgiRequest#getScript() script} - * property of the AgiRequests will likely be null. - * - * @param mappingStrategy the MappingStrategy to use to determine which AGI script to run - * for a certain request. - */ - public AsyncAgiServer(MappingStrategy mappingStrategy) - { - this(mappingStrategy, new DefaultAgiChannelFactory()); - logger.debug("use default AgiChannelFactory"); - } - - /** - * Creates a new AsyncAgiServer with the given MappingStrategy.

- * Please note that Async AGI does not currently support passing a script name, so your - * MappingStrategy must be aware that the {@link org.asteriskjava.fastagi.AgiRequest#getScript() script} - * property of the AgiRequests will likely be null. - * - * @param mappingStrategy the MappingStrategy to use to determine which AGI script to run - * for a certain request. - * @param agiChannelFactory The factory to use for creating new AgiChannel instances. - */ - public AsyncAgiServer(MappingStrategy mappingStrategy, AgiChannelFactory agiChannelFactory) - { - this(agiChannelFactory); - setMappingStrategy(mappingStrategy); - } - - /** - * Creates a new AsyncAgiServer that will execute the given AGI script for every - * request.

- * Internally this constructor uses a {@link org.asteriskjava.fastagi.StaticMappingStrategy}. - * - * @param agiScript the AGI script to execute. - * @param agiChannelFactory The factory to use for creating new AgiChannel instances. - */ - public AsyncAgiServer(AgiScript agiScript, AgiChannelFactory agiChannelFactory) - { - this(agiChannelFactory); - setMappingStrategy(new StaticMappingStrategy(agiScript)); - } - - /** - * Creates a new AsyncAgiServer that will execute the given AGI script for every - * request.

- * Internally this constructor uses a {@link org.asteriskjava.fastagi.StaticMappingStrategy}. - * - * @param agiScript the AGI script to execute. - */ - public AsyncAgiServer(AgiScript agiScript) - { - this(agiScript, new DefaultAgiChannelFactory()); - logger.debug("use default AgiChannelFactory"); - } - - - public void onManagerEvent(ManagerEvent event) - { - if (event instanceof AsyncAgiEvent) - { - handleAsyncAgiEvent((AsyncAgiEvent) event); - } - else if (event instanceof RenameEvent) - { - handleRenameEvent((RenameEvent) event); - } - } - - private void handleAsyncAgiEvent(AsyncAgiEvent asyncAgiEvent) - { - final ManagerConnection connection; - final String channelName; - final AsyncAgiConnectionHandler connectionHandler; - - connection = (ManagerConnection) asyncAgiEvent.getSource(); - channelName = asyncAgiEvent.getChannel(); - - if (asyncAgiEvent.isStart()) - { - connectionHandler = new AsyncAgiConnectionHandler(getMappingStrategy(), asyncAgiEvent, this.getAgiChannelFactory()); - setConnectionHandler(connection, channelName, connectionHandler); - try - { - execute(connectionHandler); - } - catch (RejectedExecutionException e) - { - logger.warn("Execution was rejected by pool. Try to increase the pool size."); - // release resources if execution was rejected due to the pool size - connectionHandler.release(); - } - } - else - { - connectionHandler = getConnectionHandler(connection, channelName); - if (connectionHandler == null) - { - logger.info("No AsyncAgiConnectionHandler registered for channel " + channelName + ": Ignoring AsyncAgiEvent"); - return; - } - - if (asyncAgiEvent.isExec()) - { - connectionHandler.onAsyncAgiExecEvent(asyncAgiEvent); - } - else if (asyncAgiEvent.isEnd()) - { - connectionHandler.onAsyncAgiEndEvent(asyncAgiEvent); - removeConnectionHandler(connection, channelName); - } - else - { - logger.warn("Ignored unknown AsyncAgiEvent of sub type '" + asyncAgiEvent.getSubEvent() + "'"); - } - } - } - - private void handleRenameEvent(RenameEvent renameEvent) - { - final ManagerConnection connection = (ManagerConnection) renameEvent.getSource(); - final AsyncAgiConnectionHandler connectionHandler = getConnectionHandler(connection, renameEvent.getChannel()); - - if (connectionHandler == null) - { - return; - } - - removeConnectionHandler(connection, renameEvent.getChannel()); - setConnectionHandler(connection, renameEvent.getNewname(), connectionHandler); - - connectionHandler.updateChannelName(renameEvent.getNewname()); - } - - private AsyncAgiConnectionHandler getConnectionHandler(ManagerConnection connection, String channelName) - { - synchronized (connectionHandlers) - { - return connectionHandlers.get(calculateHashKey(connection, channelName)); - } - } - - private void setConnectionHandler(ManagerConnection connection, String channelName, AsyncAgiConnectionHandler connectionHandler) - { - synchronized (connectionHandlers) - { - connectionHandlers.put(calculateHashKey(connection, channelName), connectionHandler); - } - } - - private void removeConnectionHandler(ManagerConnection connection, String channelName) - { - synchronized (connectionHandlers) - { - connectionHandlers.remove(calculateHashKey(connection, channelName)); - } - } - - private Integer calculateHashKey(ManagerConnection connection, String channelName) - { - return connection.hashCode() * 31 + channelName.hashCode(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/BaseAgiScript.java b/src/main/java/org/asteriskjava/fastagi/BaseAgiScript.java deleted file mode 100644 index 417adbe3a..000000000 --- a/src/main/java/org/asteriskjava/fastagi/BaseAgiScript.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * The BaseAgiScript provides some convinience methods to make it easier to - * write custom {@link org.asteriskjava.fastagi.AgiScript}s. - *

- * Just extend it by your own script classes. - * - * @since 0.2 - * @author srt - * @version $Id$ - */ -public abstract class BaseAgiScript extends AgiOperations implements AgiScript -{ - public BaseAgiScript() - { - super(); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/ClassNameMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/ClassNameMappingStrategy.java deleted file mode 100644 index 38806e56d..000000000 --- a/src/main/java/org/asteriskjava/fastagi/ClassNameMappingStrategy.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.util.HashMap; -import java.util.Map; - -/** - * A MappingStrategy that determines the AGIScript based on the fully - * qualified class name given in the AGI URL.

- * To use this ClassNameMappingStrategy the calls to your - * {@link org.asteriskjava.fastagi.AgiScript} in - * your dialplan should look like this: - *

- * exten => 123,1,AGI(agi://your.server.com/com.example.agi.MyScript)
- * 
- * Where com.example.agi.MyScript is the fully qualified name of your - * AgiScript. - * - * @author srt - * @version $Id$ - */ -public class ClassNameMappingStrategy extends AbstractMappingStrategy -{ - private Map instances; - private boolean shareInstances; - - /** - * Creates a new ClassNameMappingStrategy using shared instances. - */ - public ClassNameMappingStrategy() - { - this(true); - } - - /** - * Creates a new ClassNameMappingStrategy indicating whether to use shared - * instances or not. - * - * @param shareInstances true to use shared instances, - * false to create a new instance for - * each request. - * @since 0.3 - */ - public ClassNameMappingStrategy(boolean shareInstances) - { - super(); - this.instances = new HashMap<>(); - this.shareInstances = shareInstances; - } - - /** - * Sets whether to use shared instances or not. If set to true - * all AGIRequests are served by the same instance of an - * AGIScript, if set to false a new instance is created for - * each request.

- * Default is true. - * - * @param shareInstances true to use shared instances, - * false to create a new instance for - * each request. - * @since 0.3 - */ - public synchronized void setShareInstances(boolean shareInstances) - { - this.shareInstances = shareInstances; - } - - public synchronized AgiScript determineScript(AgiRequest request) - { - AgiScript script; - - if (shareInstances) - { - script = instances.get(request.getScript()); - if (script != null) - { - return script; - } - } - - script = createAgiScriptInstance(request.getScript()); - if (script == null) - { - return null; - } - - if (shareInstances) - { - instances.put(request.getScript(), script); - } - - return script; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/CompositeMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/CompositeMappingStrategy.java deleted file mode 100644 index e3ec008ad..000000000 --- a/src/main/java/org/asteriskjava/fastagi/CompositeMappingStrategy.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * A mapping strategy that tries a sequence of other mapping strategies to find - * an AgiScript matching the request. The first strategy that returns a result wins, - * so the order of the mapping strategies passed to the CompositeMappingStrategy - * matters.

- * Example: - *

- * new CompositeMappingStrategy(
- *       new ResourceBundleMappingStrategy(),
- *       new ClassNameMappingStrategy());
- * 
- * This creates a new mapping strategy that first tries to look up the script - * in fastagi-mapping.properties and - if the properties file is - * not present on the classpath or contains no mapping for the request - uses - * a {@link ClassNameMappingStrategy} to get the script. - * - * @see ResourceBundleMappingStrategy - * @see ClassNameMappingStrategy - * @author srt - * @since 0.3 - * @version $Id$ - */ -public class CompositeMappingStrategy implements MappingStrategy -{ - private List strategies; - - /** - * Creates a new empty CompositeMappingStrategy. - */ - public CompositeMappingStrategy() - { - super(); - } - - /** - * Creates a new CompositeMappingStrategy. - * - * @param strategies the strategies to use. - */ - public CompositeMappingStrategy(MappingStrategy... strategies) - { - super(); - this.strategies = new ArrayList<>(Arrays.asList(strategies)); - } - - /** - * Creates a new CompositeMappingStrategy. - * - * @param strategies the strategies to use. - */ - public CompositeMappingStrategy(List strategies) - { - super(); - this.strategies = new ArrayList<>(strategies); - } - - /** - * Adds a strategy (at the end of the list). - * - * @param strategy the strategy to add. - */ - public void addStrategy(MappingStrategy strategy) - { - if (strategies == null) - { - strategies = new ArrayList<>(); - } - strategies.add(strategy); - } - - /** - * Sets the strategies to use. - * - * @param strategies the strategies to use. - */ - public void setStrategies(List strategies) - { - this.strategies = new ArrayList<>(strategies); - } - - @Override - public AgiScript determineScript(AgiRequest request, AgiChannel channel) - { - AgiScript script = null; - - if (strategies == null) - { - return null; - } - - for (MappingStrategy strategy : strategies) - { - script = strategy.determineScript(request, channel); - if (script != null) - { - break; - } - } - - return script; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/DefaultAgiServer.java b/src/main/java/org/asteriskjava/fastagi/DefaultAgiServer.java deleted file mode 100644 index 82dd06ef5..000000000 --- a/src/main/java/org/asteriskjava/fastagi/DefaultAgiServer.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.io.IOException; -import java.net.InetAddress; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.concurrent.RejectedExecutionException; - -import org.asteriskjava.fastagi.internal.AgiConnectionHandler; -import org.asteriskjava.fastagi.internal.DefaultAgiChannelFactory; -import org.asteriskjava.fastagi.internal.FastAgiConnectionHandler; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; -import org.asteriskjava.util.ReflectionUtil; -import org.asteriskjava.util.ServerSocketFacade; -import org.asteriskjava.util.SocketConnectionFacade; -import org.asteriskjava.util.internal.ServerSocketFacadeImpl; - -/** - * Default implementation of the {@link org.asteriskjava.fastagi.AgiServer} - * interface for FastAGI. - * - * @author srt - * @version $Id$ - */ -public class DefaultAgiServer extends AbstractAgiServer implements AgiServer -{ - private final Log logger = LogFactory.getLog(getClass()); - - /** - * The default name of the resource bundle that contains the config. - */ - private static final String DEFAULT_CONFIG_RESOURCE_BUNDLE_NAME = "fastagi"; - - /** - * The default bind port. - */ - private static final int DEFAULT_BIND_PORT = 4573; - - /** Default 50? Windows server max 200? */ - private static final int BACKLOG = 200; - - private ServerSocketFacade serverSocket; - - private String configResourceBundleName = DEFAULT_CONFIG_RESOURCE_BUNDLE_NAME; - private int port = DEFAULT_BIND_PORT; - private InetAddress address = null; - - /** - * Creates a new DefaultAgiServer. - */ - public DefaultAgiServer() - { - this(null, null); - - } - - /** - * Creates a new DefaultAgiServer and set a custom factory for creating - * AgiChannels - * - * @param agiChannelFactory The factory to use for creating new AgiChannel - * instances. - */ - public DefaultAgiServer(AgiChannelFactory agiChannelFactory) - { - this(null, null, agiChannelFactory); - } - - /** - * Creates a new DefaultAgiServer and loads its configuration from an - * alternative resource bundle. - * - * @param configResourceBundleName the name of the conifiguration resource - * bundle (default is "fastagi"). - */ - public DefaultAgiServer(String configResourceBundleName) - { - this(configResourceBundleName, null); - } - - /** - * Creates a new DefaultAgiServer that uses the given - * {@link MappingStrategy}. - * - * @param mappingStrategy the MappingStrategy to use to determine the - * AgiScript to run. - * @since 1.0.0 - */ - public DefaultAgiServer(MappingStrategy mappingStrategy) - { - this(null, mappingStrategy); - } - - /** - * Creates a new DefaultAgiServer that runs the given {@link AgiScript} for - * all requests. - * - * @param agiScript the AgiScript to run. - * @since 1.0.0 - */ - public DefaultAgiServer(AgiScript agiScript) - { - this(null, new StaticMappingStrategy(agiScript)); - } - - /** - * Creates a new DefaultAgiServer and loads its configuration from an - * alternative resource bundle and uses the given {@link MappingStrategy}. - * - * @param configResourceBundleName the name of the conifiguration resource - * bundle (default is "fastagi"). - * @param mappingStrategy the MappingStrategy to use to determine the - * AgiScript to run. - * @since 1.0.0 - */ - public DefaultAgiServer(String configResourceBundleName, MappingStrategy mappingStrategy) - { - this(configResourceBundleName, mappingStrategy, new DefaultAgiChannelFactory()); - } - - /** - * Creates a new DefaultAgiServer and loads its configuration from an - * alternative resource bundle and uses the given {@link MappingStrategy}. - * - * @param configResourceBundleName the name of the conifiguration resource - * bundle (default is "fastagi"). - * @param mappingStrategy the MappingStrategy to use to determine the - * AgiScript to run. - * @param agiChannelFactory The factory to use for creating new AgiChannel - * instances. - * @since 1.0.0 - */ - public DefaultAgiServer(String configResourceBundleName, MappingStrategy mappingStrategy, - AgiChannelFactory agiChannelFactory) - { - super(agiChannelFactory); - - if (mappingStrategy == null) - { - final CompositeMappingStrategy compositeMappingStrategy = new CompositeMappingStrategy(); - - compositeMappingStrategy.addStrategy(new ResourceBundleMappingStrategy()); - compositeMappingStrategy.addStrategy(new ClassNameMappingStrategy()); - if (ReflectionUtil.isClassAvailable("javax.script.ScriptEngineManager")) - { - MappingStrategy scriptEngineMappingStrategy = (MappingStrategy) ReflectionUtil - .newInstance("org.asteriskjava.fastagi.ScriptEngineMappingStrategy"); - if (scriptEngineMappingStrategy != null) - { - compositeMappingStrategy.addStrategy(scriptEngineMappingStrategy); - } - } - else - { - logger.warn("ScriptEngine support disabled: It is only availble when running at least Java 6"); - } - - setMappingStrategy(compositeMappingStrategy); - } - else - { - setMappingStrategy(mappingStrategy); - } - - if (configResourceBundleName != null) - { - this.configResourceBundleName = configResourceBundleName; - } - - loadConfig(); - } - - /** - * Sets the TCP port to listen on for new connections.
- * The default port is 4573. - * - * @param bindPort the port to bind to. - * @deprecated use {@link #setPort(int)} instead - */ - @Deprecated - public void setBindPort(int bindPort) - { - this.port = bindPort; - } - - /** - * Sets the TCP port to listen on for new connections.
- * The default port is 4573. - * - * @param port the port to bind to. - * @since 0.2 - */ - public void setPort(int port) - { - this.port = port; - } - - /** - * Returns the TCP port this server is configured to bind to. - * - * @return the TCP port this server is configured to bind to. - * @since 1.0.0 - */ - public int getPort() - { - return port; - } - - /** - * Returns the address this server is configured to bind to. - * - * @return the address this server is configured to bind to. - */ - public InetAddress getAddress() - { - return address; - } - - /** - * Sets the address to bind server. - * - * @param address the address to bind to. - */ - public void setAddress(InetAddress address) - { - this.address = address; - } - - private void loadConfig() - { - final ResourceBundle resourceBundle; - - try - { - resourceBundle = ResourceBundle.getBundle(configResourceBundleName); - } - catch (MissingResourceException e) - { - return; - } - - try - { - String portString; - - try - { - portString = resourceBundle.getString("port"); - } - catch (MissingResourceException e) - { - // for backward compatibility only - portString = resourceBundle.getString("bindPort"); - } - port = Integer.parseInt(portString); - } - catch (Exception e) // NOPMD - { - // swallow - } - - try - { - setPoolSize(Integer.parseInt(resourceBundle.getString("poolSize"))); - } - catch (Exception e) // NOPMD - { - // swallow - } - - try - { - setMaximumPoolSize(Integer.parseInt(resourceBundle.getString("maximumPoolSize"))); - } - catch (Exception e) // NOPMD - { - // swallow - } - } - - protected ServerSocketFacade createServerSocket() throws IOException - { - return new ServerSocketFacadeImpl(port, BACKLOG, address); - } - - public void startup() throws IOException, IllegalStateException - { - try - { - serverSocket = createServerSocket(); - } - catch (IOException e) - { - logger.error("Unable start AgiServer: cannot to bind to *:" + port + ".", e); - throw e; - } - - logger.info("Listening on *:" + port + "."); - - // loop will be terminated by accept() throwing an IOException when the - // ServerSocket is closed. - while (true) - { - final SocketConnectionFacade socket; - - // accept connection - try - { - socket = serverSocket.accept(); - } - catch (IOException e) - { - // swallow only if shutdown - if (isDie()) - { - break; - } - // handle exception but continue to run - handleException("IOException while waiting for connections.", e); - continue; - } - - logger.debug("Received connection from " + socket.getRemoteAddress()); - - // execute connection handler - final AgiConnectionHandler connectionHandler = new FastAgiConnectionHandler(getMappingStrategy(), socket, - this.getAgiChannelFactory()); - try - { - execute(connectionHandler); - } - catch (RejectedExecutionException e) - { - logger.warn("Execution was rejected by pool. Try to increase the pool size."); - // release resources like closing the socket if execution was - // rejected due to the pool size - connectionHandler.release(); - } - } - logger.info("AgiServer shut down."); - } - - /** - * @deprecated use {@link #startup()} instead. - */ - @Deprecated - public void run() - { - try - { - startup(); - } - catch (IOException e) // NOPMD - { - // nothing we can do about that and exceptions have already been - // logged - // by startup(). - } - } - - @Override - public synchronized void shutdown() throws IllegalStateException - { - // setting the death flag causes the accept() loop to exit when a - // SocketException occurs. - super.shutdown(); - - if (serverSocket != null) - { - try - { - // closes the server socket and throws a SocketException on - // Threads waiting in accept() - serverSocket.close(); - } - catch (IOException e) - { - logger.warn("IOException while closing server socket.", e); - } - } - } - - @Override - protected void finalize() throws Throwable - { - - if (serverSocket != null) - { - try - { - serverSocket.close(); - } - catch (IOException e) // NOPMD - { - // swallow - } - } - - super.finalize(); - } - - /** - * Creates a new DefaultAgiServer and starts it. - * - * @param args not used - * @throws Exception if the server can't be started - * @deprecated since 1.0.0 use {@link org.asteriskjava.Cli} instead. - */ - @Deprecated - public static void main(String[] args) throws Exception - { - final AgiServer server; - - server = new DefaultAgiServer(); - server.startup(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/InvalidCommandSyntaxException.java b/src/main/java/org/asteriskjava/fastagi/InvalidCommandSyntaxException.java deleted file mode 100644 index adde6786a..000000000 --- a/src/main/java/org/asteriskjava/fastagi/InvalidCommandSyntaxException.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * An InvalidCommandSyntaxException is thrown when the reader receives a reply - * with status code 520. - * - * @author srt - * @version $Id$ - */ -public class InvalidCommandSyntaxException extends AgiException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3257002168165807929L; - - private final String synopsis; - private final String usage; - - /** - * Creates a new InvalidCommandSyntaxException with the given synopsis and - * usage. - * - * @param synopsis the synopsis of the command. - * @param usage the usage of the command. - */ - public InvalidCommandSyntaxException(String synopsis, String usage) - { - super("Invalid command syntax: " + synopsis); - this.synopsis = synopsis; - this.usage = usage; - } - - /** - * Returns the synopsis of the command that was called with invalid syntax. - * - * @return the synopsis of the command that was called with invalid syntax. - */ - public String getSynopsis() - { - return synopsis; - } - - /** - * Returns a description of the command that was called with invalid syntax. - * - * @return a description of the command that was called with invalid syntax. - */ - public String getUsage() - { - return usage; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/InvalidOrUnknownCommandException.java b/src/main/java/org/asteriskjava/fastagi/InvalidOrUnknownCommandException.java deleted file mode 100644 index ca03069b0..000000000 --- a/src/main/java/org/asteriskjava/fastagi/InvalidOrUnknownCommandException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * An InvalidOrUnknownCommandException is thrown when the reader receives a reply - * with status code 510. - * - * @author srt - * @version $Id$ - */ -public class InvalidOrUnknownCommandException extends AgiException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3257002168165807929L; - - /** - * Creates a new InvalidOrUnknownCommandException. - * - * @param command the invalid or unknown command. - */ - public InvalidOrUnknownCommandException(String command) - { - super("Invalid or unknown command: " + command); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/MappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/MappingStrategy.java deleted file mode 100644 index e1d7c3a09..000000000 --- a/src/main/java/org/asteriskjava/fastagi/MappingStrategy.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * A MappingStrategy determines which {@link org.asteriskjava.fastagi.AgiScript} - * is called to service a given {@link org.asteriskjava.fastagi.AgiRequest}.

- * A MappingStrategy can use any of the properties - * of an AgiRequest to do this. However most MappingStrategies will just use - * the script property, that is the name of the invoked AGI script as passed - * from Asterisk's dialplan.

- * Asterisk-Java ships with several mapping strategies that are available out - * of the box. If you have some special requirements that are not satisfied by - * any of the available strategies feel free to implement this interface and - * use your own strategy. - * - * @author srt - * @version $Id$ - */ -public interface MappingStrategy -{ - /** - * Returns the AgiScript instance that is responsible to handle - * the given request. - * - * @param request the request to lookup. - * @param channel the channel. - * @return the AgiScript instance to handle this request - * or null if none could be determined by this strategy. - */ - AgiScript determineScript(AgiRequest request, AgiChannel channel); -} diff --git a/src/main/java/org/asteriskjava/fastagi/NamedAgiScript.java b/src/main/java/org/asteriskjava/fastagi/NamedAgiScript.java deleted file mode 100644 index 6995d2550..000000000 --- a/src/main/java/org/asteriskjava/fastagi/NamedAgiScript.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * Interface for an AgiScript that provides a name for logging and management. - * - * @since 1.0.0 - */ -public interface NamedAgiScript extends AgiScript -{ - /** - * Returns the name of the script. - * - * @return the name of the script - */ - String getName(); -} diff --git a/src/main/java/org/asteriskjava/fastagi/ResourceBundleMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/ResourceBundleMappingStrategy.java deleted file mode 100644 index ac387c9a1..000000000 --- a/src/main/java/org/asteriskjava/fastagi/ResourceBundleMappingStrategy.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * A MappingStrategy that is configured via a resource bundle. - *

- * The resource bundle contains the script part of the url as key and the fully - * qualified class name of the corresponding AgiScript as value. - *

- * Example: - * - *

- * leastcostdial.agi = com.example.fastagi.LeastCostDialAgiScript
- * hello.agi = com.example.fastagi.HelloAgiScript
- * 
- * - * LeastCostDialAgiScript and HelloAgiScript must both implement the AgiScript - * interface and have a default constructor with no parameters. - *

- * The resource bundle (properties) file is called - * fastagi-mapping.properties by default and must be available on - * the classpath. - * - * @author srt - * @version $Id$ - */ -public class ResourceBundleMappingStrategy extends AbstractMappingStrategy -{ - private static final String DEFAULT_RESOURCE_BUNDLE_NAME = "fastagi-mapping"; - private String resourceBundleName; - private Map mappings; - private Map instances; - private boolean shareInstances; - - /** - * Creates a new ResourceBundleMappingStrategy using shared instances.. - */ - public ResourceBundleMappingStrategy() - { - this(DEFAULT_RESOURCE_BUNDLE_NAME); - } - - /** - * Creates a new ResourceBundleMappingStrategy with the given basename of - * the resource bundle to use. - * - * @param resourceBundleName basename of the resource bundle to use - */ - public ResourceBundleMappingStrategy(String resourceBundleName) - { - this(resourceBundleName, true); - } - - /** - * Creates a new ResourceBundleMappingStrategy indicating whether to use - * shared instances or not. - * - * @param shareInstances true to use shared instances, - * false to create a new instance for each request. - * @since 0.3 - */ - public ResourceBundleMappingStrategy(boolean shareInstances) - { - this(DEFAULT_RESOURCE_BUNDLE_NAME, shareInstances); - } - - /** - * Creates a new ResourceBundleMappingStrategy with the given basename of - * the resource bundle to use and indicating whether to use shared instances - * or not. - * - * @param resourceBundleName basename of the resource bundle to use - * @param shareInstances true to use shared instances, - * false to create a new instance for each request. - * @since 0.3 - */ - public ResourceBundleMappingStrategy(String resourceBundleName, boolean shareInstances) - { - super(); - this.resourceBundleName = resourceBundleName; - this.shareInstances = shareInstances; - } - - /** - * Sets the basename of the resource bundle to use. - *

- * Default is "fastagi-mapping". - * - * @param resourceBundleName basename of the resource bundle to use - */ - public void setResourceBundleName(String resourceBundleName) - { - this.resourceBundleName = resourceBundleName; - synchronized (this) - { - this.mappings = null; - this.instances = null; - } - } - - /** - * Sets whether to use shared instances or not. If set to true - * all AgiRequests are served by the same instance of an AgiScript, if set - * to false a new instance is created for each request. - *

- * Default is true. - * - * @param shareInstances true to use shared instances, - * false to create a new instance for each request. - * @since 0.3 - */ - public synchronized void setShareInstances(boolean shareInstances) - { - this.shareInstances = shareInstances; - } - - private synchronized void loadResourceBundle() - { - ResourceBundle resourceBundle; - Enumeration< ? > keys; - - mappings = new HashMap<>(); - if (shareInstances) - { - instances = new HashMap<>(); - } - - try - { - resourceBundle = ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), getClassLoader()); - } - catch (MissingResourceException e) - { - logger.info("Resource bundle '" + resourceBundleName + "' not found."); - return; - } - - keys = resourceBundle.getKeys(); - - while (keys.hasMoreElements()) - { - String scriptName; - String className; - AgiScript agiScript; - - scriptName = (String) keys.nextElement(); - className = resourceBundle.getString(scriptName); - - mappings.put(scriptName, className); - - if (shareInstances) - { - agiScript = createAgiScriptInstance(className); - if (agiScript == null) - { - continue; - } - instances.put(scriptName, agiScript); - } - - logger.info("Added mapping for '" + scriptName + "' to class " + className); - } - } - - public synchronized AgiScript determineScript(AgiRequest request) - { - if (mappings == null || (shareInstances && instances == null)) - { - loadResourceBundle(); - } - - if (shareInstances) - { - return instances.get(request.getScript()); - } - return createAgiScriptInstance(mappings.get(request.getScript())); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/ScriptEngineMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/ScriptEngineMappingStrategy.java deleted file mode 100644 index 13b74dc2f..000000000 --- a/src/main/java/org/asteriskjava/fastagi/ScriptEngineMappingStrategy.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Matcher; - -import javax.script.Bindings; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; - -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * A MappingStrategy that uses {@link javax.script.ScriptEngine} to run - * AgiScripts. This MappingStrategy can be used to run JavaScript, Groovy, - * JRuby, etc. scripts. - * - * @since 1.0.0 - */ -public class ScriptEngineMappingStrategy implements MappingStrategy -{ - protected final Log logger = LogFactory.getLog(getClass()); - - /** - * The binding under which the AGI request is made available to scripts. - */ - public static final String REQUEST = "request"; - - /** - * The binding under which the AGI channel is made available to scripts. - */ - public static final String CHANNEL = "channel"; - - private static final String[] DEFAULT_SCRIPT_PATH = new String[]{"agi"}; - private static final String[] DEFAULT_LIB_PATH = new String[]{"lib"}; - - protected String[] scriptPath; - protected String[] libPath; - protected ScriptEngineManager scriptEngineManager = null; - - /** - * Creates a new ScriptEngineMappingStrategy that searches for scripts in - * the current directory. - */ - public ScriptEngineMappingStrategy() - { - this(DEFAULT_SCRIPT_PATH, DEFAULT_LIB_PATH); - } - - /** - * Creates a new ScriptEngineMappingStrategy that searches for scripts on - * the given path. - * - * @param scriptPath array of directory names to search for script files. - * @param libPath array of directory names to search for additional - * libraries (jar files). - */ - public ScriptEngineMappingStrategy(String[] scriptPath, String[] libPath) - { - setScriptPath(scriptPath); - setLibPath(libPath); - } - - /** - * Sets the path to search for script files. - *

- * Default is "agi". - * - * @param scriptPath array of directory names to search for script files. - */ - public void setScriptPath(String[] scriptPath) - { - this.scriptPath = Arrays.copyOf(scriptPath, scriptPath.length); - } - - /** - * Sets the path to search for additional libraries (jar files). - *

- * Default is "lib". - * - * @param libPath array of directory names to search for additional - * libraries (jar files). - */ - public void setLibPath(String[] libPath) - { - this.libPath = Arrays.copyOf(libPath, libPath.length); - } - - @Override - public AgiScript determineScript(AgiRequest request, AgiChannel channel) - { - // check is a file corresponding to the AGI request is found on the - // scriptPath - final File file = searchFile(request.getScript(), scriptPath); - if (file == null) - { - return null; - } - - // check if there is a ScriptEngine that can handle the file - final ScriptEngine scriptEngine = getScriptEngine(file); - if (scriptEngine == null) - { - logger.debug("No ScriptEngine found that can handle '" + file.getPath() + "'"); - return null; - } - - return new ScriptEngineAgiScript(file, scriptEngine); - } - - /** - * Searches for a ScriptEngine that can handle the given file. - * - * @param file the file to search a ScriptEngine for. - * @return the ScriptEngine or null if none is found. - */ - protected ScriptEngine getScriptEngine(File file) - { - final String extension = getExtension(file.getName()); - if (extension == null) - { - return null; - } - - return getScriptEngineManager().getEngineByExtension(extension); - } - - /** - * Returns the ScriptEngineManager to use for loading the ScriptEngine. The - * ScriptEngineManager is only created once and reused for subsequent - * requests. Override this method to provide your own implementation. - * - * @return the ScriptEngineManager to use for loading the ScriptEngine. - * @see javax.script.ScriptEngineManager#ScriptEngineManager() - */ - protected synchronized ScriptEngineManager getScriptEngineManager() - { - if (scriptEngineManager == null) - { - this.scriptEngineManager = new ScriptEngineManager(getClassLoader()); - } - return scriptEngineManager; - } - - /** - * Returns the ClassLoader to use for the ScriptEngineManager. Adds all jar - * files in the "lib" subdirectory of the current directory to the class - * path. Override this method to provide your own ClassLoader. - * - * @return the ClassLoader to use for the ScriptEngineManager. - * @see #getScriptEngineManager() - */ - protected ClassLoader getClassLoader() - { - final ClassLoader parentClassLoader = Thread.currentThread().getContextClassLoader(); - final List jarFileUrls = new ArrayList<>(); - - if (libPath == null || libPath.length == 0) - { - return parentClassLoader; - } - - for (String libPathEntry : libPath) - { - final File libDir = new File(libPathEntry); - if (!libDir.isDirectory()) - { - continue; - } - - final File[] jarFiles = libDir.listFiles(new FilenameFilter() - { - public boolean accept(File dir, String name) - { - return name.endsWith(".jar"); - } - }); - if (jarFiles != null) - { - - for (File jarFile : jarFiles) - { - try - { - jarFileUrls.add(jarFile.toURI().toURL()); - } - catch (MalformedURLException e) - { - // should not happen - } - } - } - else - { - logger.error("Didn't find any jar files at " + libDir.getAbsolutePath()); - } - } - - if (jarFileUrls.isEmpty()) - { - return parentClassLoader; - } - - return new URLClassLoader(jarFileUrls.toArray(new URL[jarFileUrls.size()]), parentClassLoader); - } - - /** - * Searches for the file with the given name on the path. - * - * @param scriptName the name of the file to search for. - * @param path an array of directories to search for the file in order of - * preference. - * @return the canonical file if found on the path or null if - * not found. - */ - protected File searchFile(String scriptName, String[] path) - { - if (scriptName == null || path == null) - { - return null; - } - - for (String pathElement : path) - { - final File pathElementDir = new File(pathElement); - // skip if pathElement is not a directory - if (!pathElementDir.isDirectory()) - { - continue; - } - - final File file = new File(pathElementDir, scriptName.replaceAll("/", Matcher.quoteReplacement(File.separator))); - if (!file.exists()) - { - continue; - } - - try - { - // prevent attacks with scripts using ".." in their name. - if (!isInside(file, pathElementDir)) - { - return null; - } - } - catch (IOException e) - { - logger.warn("Unable to check whether '" + file.getPath() + "' is below '" + pathElementDir.getPath() + "'"); - continue; - } - - try - { - return file.getCanonicalFile(); - } - catch (IOException e) - { - logger.error("Unable to get canonical file for '" + file.getPath() + "'", e); - } - } - return null; - } - - /** - * Checks whether a file is contained within a given directory (or a sub - * directory) or not. - * - * @param file the file to check. - * @param dir the directory to check. - * @return true if file is below directory, false - * otherwise. - * @throws IOException if the canonical path of file or dir cannot be - * determined. - */ - protected final boolean isInside(File file, File dir) throws IOException - { - return file.getCanonicalPath().startsWith(dir.getCanonicalPath()); - } - - /** - * Returns the extension (the part after the last ".") of the given script. - * - * @param scriptName the name of the script to return the extension of. - * @return the extension of the script or null if there is no - * extension. - */ - protected static String getExtension(String scriptName) - { - if (scriptName == null) - { - return null; - } - - int filePosition = scriptName.lastIndexOf("/"); - String fileName; - - if (scriptName.lastIndexOf("\\") > filePosition) - { - filePosition = scriptName.lastIndexOf("\\"); - } - - if (filePosition >= 0) - { - fileName = scriptName.substring(filePosition + 1); - } - else - { - fileName = scriptName; - } - - final int extensionPosition = fileName.lastIndexOf("."); - if (extensionPosition >= 0) - { - return fileName.substring(extensionPosition + 1); - } - - return null; - } - - protected static Reader getReader(File file) throws FileNotFoundException - { - final InputStream is = new FileInputStream(file); - return new InputStreamReader(is, StandardCharsets.UTF_8); - } - - protected class ScriptEngineAgiScript implements NamedAgiScript - { - final File file; - final ScriptEngine scriptEngine; - - /** - * Creates a new ScriptEngineAgiScript. - * - * @param file the file that contains the script to execute. - * @param scriptEngine the ScriptEngine to use for executing the script. - */ - public ScriptEngineAgiScript(File file, ScriptEngine scriptEngine) - { - this.file = file; - this.scriptEngine = scriptEngine; - } - - public String getName() - { - return file == null ? null : file.getName(); - } - - public void service(AgiRequest request, AgiChannel channel) throws AgiException - { - final Bindings bindings = scriptEngine.createBindings(); - - bindings.put(ScriptEngine.FILENAME, file.getPath()); - bindings.put(REQUEST, request); - bindings.put(CHANNEL, channel); - - // support for custom bindings - populateBindings(file, request, channel, bindings); - - try - { - scriptEngine.eval(getReader(file), bindings); - } - catch (ScriptException e) - { - throw new AgiException("Execution of script '" + file.getPath() + "' with ScriptEngine failed", e); - } - catch (FileNotFoundException e) - { - throw new AgiException("Script '" + file.getPath() + "' not found", e); - } - } - } - - /** - * Override this method if you want to add additional bindings before the - * script is run. By default the AGI request, AGI channel and the filename - * are available to scripts under the bindings "request", "channel" and - * "javax.script.filename". - * - * @param file the script file. - * @param request the AGI request. - * @param channel the AGI channel. - * @param bindings the bindings to populate. - */ - protected void populateBindings(File file, AgiRequest request, AgiChannel channel, Bindings bindings) - { - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/SimpleMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/SimpleMappingStrategy.java deleted file mode 100644 index 864439c60..000000000 --- a/src/main/java/org/asteriskjava/fastagi/SimpleMappingStrategy.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.util.Map; - -/** - * A MappingStrategy that is configured via a fixed set of properties.

- * This mapping strategy is most useful when used with the Spring framework.

- * Example (using Spring): - * - *

- * <beans>
- *    <bean id="mapping"
- *          class="org.asteriskjava.fastagi.SimpleMappingStrategy">
- *        <property name="mappings">
- *            <map>
- *                <entry>
- *                    <key><value>hello.agi</value></key>
- *                    <ref local="hello"/>
- *                </entry>
- *                <entry>
- *                    <key><value>leastcostdial.agi</value></key>
- *                    <ref local="leastCostDial"/>
- *                </entry>
- *            </map>
- *        </property>
- *    </bean>
- *
- *    <bean id="hello"
- *          class="com.example.fastagi.HelloAgiScript"/>
- *
- *    <bean id="leastCostDial"
- *          class="com.example.fastagi.LeastCostDialAgiScript">
- *        <property name="rates"><value>rates.txt</value></property>
- *    </bean>
- * <beans>
- * 
- * - * LeastCostDialAgiScript and HelloAgiScript must both implement the AgiScript.

- * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class SimpleMappingStrategy implements MappingStrategy -{ - private Map mappings; - - /** - * Set the "path to AgiScript" mapping.

- * Use the path (for example hello.agi) as key and your - * AgiScript (for example new HelloAgiScript()) as value of - * this map. - * - * @param mappings the path to AgiScript mapping. - */ - public void setMappings(Map mappings) - { - this.mappings = mappings; - } - - @Override - public AgiScript determineScript(AgiRequest request, AgiChannel channel) - { - if (mappings == null) - { - return null; - } - - return mappings.get(request.getScript()); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/SpeechRecognitionResult.java b/src/main/java/org/asteriskjava/fastagi/SpeechRecognitionResult.java deleted file mode 100644 index 353e8d542..000000000 --- a/src/main/java/org/asteriskjava/fastagi/SpeechRecognitionResult.java +++ /dev/null @@ -1,238 +0,0 @@ -package org.asteriskjava.fastagi; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.asteriskjava.fastagi.reply.AgiReply; - -/** - * Contains the results of a speech recognition command. - * - * @see org.asteriskjava.fastagi.AgiChannel#speechRecognize(String, int) - * @see org.asteriskjava.fastagi.AgiChannel#speechRecognize(String, int, int) - * @see org.asteriskjava.fastagi.command.SpeechRecognizeCommand - * @since 1.0.0 - */ -public class SpeechRecognitionResult implements Serializable -{ - private static final long serialVersionUID = 0L; - private final AgiReply agiReply; - - public SpeechRecognitionResult(AgiReply agiReply) - { - this.agiReply = agiReply; - } - - /** - * Checks whether a DTMF digit was recieved. - * - * @return true if a DTMF digit was received, false otherwise. - * @see #getDigit() - */ - public boolean isDtmf() - { - return "digit".equals(agiReply.getExtra()); - } - - /** - * Checks whether speech was recognized. - * - * @return true if speech was recognized, false otherwise. - * @see #getText() - * @see #getScore() - * @see #getGrammar() - */ - public boolean isSpeech() - { - return "speech".equals(agiReply.getExtra()); - } - - /** - * Checks whether a timeout was encountered and neither a DTMF digit was received nor speech was recognized. - * - * @return true a timeout was encountered, false otherwise. - */ - public boolean isTimeout() - { - return "timeout".equals(agiReply.getExtra()); - } - - /** - * Returns the DTMF digit that was received. - * - * @return the DTMF digit that was received or 0x0 if none was received. - */ - public char getDigit() - { - final String digit = agiReply.getAttribute("digit"); - if (digit == null || digit.length() == 0) - { - return 0x0; - } - return digit.charAt(0); - } - - /** - * Returns the position where the prompt stopped playing because a DTMF digit was received or speech was - * recognized (barge in). - * - * @return the position where the prompt stopped playing, 0 if it was played completely. - */ - public int getEndpos() - { - return Integer.parseInt(agiReply.getAttribute("endpos")); - } - - /** - * Returns the confidence score for the first recognition result. This is an integer between 0 (lowest confidence) - * and 1000 (highest confidence). - * - * @return the confidence score for the first recognition result or 0 if no speech was recognized. - */ - public int getScore() - { - final String score0 = agiReply.getAttribute("score0"); - return score0 == null ? 0 : Integer.parseInt(score0); - } - - /** - * Returns the text for the first recognition result. This is the text that was recognized by the speech engine. - * - * @return the text for the first recognition result or null if no speech was recognized. - */ - public String getText() - { - return agiReply.getAttribute("text0"); - } - - /** - * Returns the grammar for the first recognition result. This is the grammar that was used by the speech engine. - * - * @return the grammar for the first recognition result or null if no speech was recognized. - */ - public String getGrammar() - { - return agiReply.getAttribute("grammar0"); - } - - /** - * Returns how many results have been recoginized. Usually there is only one result but if multiple rules in - * the grammar match multiple results may be returned. - * - * @return the number of results recognized. - */ - public int getNumberOfResults() - { - final String numberOfResults = agiReply.getAttribute("results"); - return numberOfResults == null ? 0 : Integer.parseInt(numberOfResults); - } - - public List getAllResults() - { - final int numberOfResults = getNumberOfResults(); - final List results = new ArrayList<>(numberOfResults); - - for (int i = 0; i < numberOfResults; i++) - { - SpeechResult result = new SpeechResult( - Integer.parseInt(agiReply.getAttribute("score" + i)), - agiReply.getAttribute("text" + i), - agiReply.getAttribute("grammar" + i) - ); - results.add(result); - } - - return results; - } - - public String toString() - { - final StringBuilder sb = new StringBuilder("SpeechRecognitionResult["); - if (isDtmf()) - { - sb.append("dtmf=true,"); - sb.append("digit=").append(getDigit()).append(","); - } - if (isSpeech()) - { - sb.append("speech=true,"); - sb.append("score=").append(getScore()).append(","); - sb.append("text='").append(getText()).append("',"); - sb.append("grammar='").append(getGrammar()).append("',"); - } - if (isTimeout()) - { - sb.append("timeout=true,"); - } - - if (getNumberOfResults() > 1) - { - sb.append("numberOfResults=").append(getNumberOfResults()).append(","); - sb.append("allResults=").append(getAllResults()).append(","); - } - - sb.append("endpos=").append(getEndpos()).append("]"); - return sb.toString(); - } - - /** - * Container class for recognized speech. - * - * @see SpeechRecognitionResult#getAllResults() - */ - public static class SpeechResult implements Serializable - { - private static final long serialVersionUID = 0L; - private final int score; - private final String text; - private final String grammar; - - private SpeechResult(int score, String text, String grammar) - { - this.score = score; - this.text = text; - this.grammar = grammar; - } - - /** - * Returns the confidence score. This is an integer between 0 (lowest confidence) - * and 1000 (highest confidence). - * - * @return the confidence score. - */ - public int getScore() - { - return score; - } - - /** - * Returns the text. This is the text that was recognized by the speech engine. - * - * @return the text - */ - public String getText() - { - return text; - } - - /** - * Returns the grammar. This is the grammar that was used by the speech engine. - * - * @return the grammar - */ - public String getGrammar() - { - return grammar; - } - - public String toString() - { - final StringBuilder sb = new StringBuilder("["); - sb.append("score=").append(score).append(","); - sb.append("text='").append(text).append("',"); - sb.append("grammar='").append(grammar).append("']"); - return sb.toString(); - } - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/StaticMappingStrategy.java b/src/main/java/org/asteriskjava/fastagi/StaticMappingStrategy.java deleted file mode 100644 index dfa0274a4..000000000 --- a/src/main/java/org/asteriskjava/fastagi/StaticMappingStrategy.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.asteriskjava.fastagi; - -/** - * Mapping strategy that maps all requests to the same script instance. - * - * @since 1.0.0 - */ -public class StaticMappingStrategy implements MappingStrategy -{ - private AgiScript agiScript; - - public StaticMappingStrategy() - { - } - - /** - * Creates a new StaticMappingStrategy that maps all requests to the given script. - * - * @param agiScript the script to map to. - */ - public StaticMappingStrategy(AgiScript agiScript) - { - this.agiScript = agiScript; - } - - /** - * Sets the AgiScript to map to. - * - * @param agiScript the AgiScript to map to. - */ - public void setAgiScript(AgiScript agiScript) - { - this.agiScript = agiScript; - } - - @Override - public AgiScript determineScript(AgiRequest request, AgiChannel channel) - { - return agiScript; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/.gitignore b/src/main/java/org/asteriskjava/fastagi/command/.gitignore deleted file mode 100644 index c436b7ecf..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/.gitignore +++ /dev/null @@ -1,49 +0,0 @@ -/AbstractAgiCommand.class -/AgiCommand.class -/AnswerCommand.class -/AsyncAgiBreakCommand.class -/ChannelStatusCommand.class -/ControlStreamFileCommand.class -/DatabaseDelCommand.class -/DatabaseDelTreeCommand.class -/DatabaseGetCommand.class -/DatabasePutCommand.class -/ExecCommand.class -/GetDataCommand.class -/GetFullVariableCommand.class -/GetOptionCommand.class -/GetVariableCommand.class -/GosubCommand.class -/HangupCommand.class -/NoopCommand.class -/ReceiveCharCommand.class -/ReceiveTextCommand.class -/RecordFileCommand.class -/SayAlphaCommand.class -/SayDateTimeCommand.class -/SayDigitsCommand.class -/SayNumberCommand.class -/SayPhoneticCommand.class -/SayTimeCommand.class -/SendImageCommand.class -/SendTextCommand.class -/SetAutoHangupCommand.class -/SetCallerIdCommand.class -/SetContextCommand.class -/SetExtensionCommand.class -/SetMusicOffCommand.class -/SetMusicOnCommand.class -/SetPriorityCommand.class -/SetVariableCommand.class -/SpeechActivateGrammarCommand.class -/SpeechCreateCommand.class -/SpeechDeactivateGrammarCommand.class -/SpeechDestroyCommand.class -/SpeechLoadGrammarCommand.class -/SpeechRecognizeCommand.class -/SpeechSetCommand.class -/SpeechUnloadGrammarCommand.class -/StreamFileCommand.class -/TddModeCommand.class -/VerboseCommand.class -/WaitForDigitCommand.class diff --git a/src/main/java/org/asteriskjava/fastagi/command/AbstractAgiCommand.java b/src/main/java/org/asteriskjava/fastagi/command/AbstractAgiCommand.java deleted file mode 100644 index 949277a05..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/AbstractAgiCommand.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -import java.io.Serializable; - -/** - * Abstract base class that provides some convenience methods for - * implementing AgiCommand classes. - * - * @author srt - * @version $Id$ - */ -public abstract class AbstractAgiCommand implements Serializable, AgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3257849874518456633L; - - public abstract String buildCommand(); - - /** - * Escapes and quotes a given String according to the rules set by - * Asterisk's AGI. - * - * @param s the String to escape and quote - * @return the transformed String - */ - protected String escapeAndQuote(String s) - { - String tmp; - - if (s == null) - { - return "\"\""; - } - - tmp = s; - tmp = tmp.replaceAll("\\\\", "\\\\\\\\"); - tmp = tmp.replaceAll("\\\"", "\\\\\""); - tmp = tmp.replaceAll("\\\n", ""); // filter newline - return "\"" + tmp + "\""; // add quotes - } - - protected String escapeAndQuote(String[] options) - { - if (options == null) - { - return escapeAndQuote((String) null); - } - - final StringBuilder sb = new StringBuilder(); - for (int i = 0; i < options.length; i++) - { - if (i > 0) - { - sb.append(","); - } - sb.append(options[i]); - } - - return escapeAndQuote(sb.toString()); - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder(getClass().getName()).append("["); - sb.append("command='").append(buildCommand()).append("', "); - sb.append("systemHashcode=").append(System.identityHashCode(this)).append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/AgiCommand.java b/src/main/java/org/asteriskjava/fastagi/command/AgiCommand.java deleted file mode 100644 index 4d77554af..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/AgiCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * AgiCommand that can be sent to Asterisk via the Asterisk Gateway Interface.

- * This interface contains only one method that transforms the command to a - * String representation understood by Asterisk. - * - * @author srt - * @version $Id$ - */ -public interface AgiCommand -{ - - /** - * Returns a string suitable to be sent to asterisk.

- * - * @return a string suitable to be sent to asterisk. - */ - String buildCommand(); -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/AnswerCommand.java b/src/main/java/org/asteriskjava/fastagi/command/AnswerCommand.java deleted file mode 100644 index 666bfb6e9..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/AnswerCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Answers channel if not already in answer state.

- * Returns -1 on channel failure, or 0 if successful. - * - * @author srt - * @version $Id$ - */ -public class AnswerCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - - /** - * Creates a new AnswerCommand. - */ - public AnswerCommand() - { - super(); - } - - @Override - public String buildCommand() - { - return "ANSWER"; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/AsyncAgiBreakCommand.java b/src/main/java/org/asteriskjava/fastagi/command/AsyncAgiBreakCommand.java deleted file mode 100644 index 0ec6810e3..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/AsyncAgiBreakCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Breaks the Async AGI loop. - * - * @author srt - * @version $Id$ - */ -public class AsyncAgiBreakCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - /** - * Creates a new AsyncAgiBreakCommand. - */ - public AsyncAgiBreakCommand() - { - super(); - } - - @Override - public String buildCommand() - { - return "ASYNCAGI BREAK"; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/BridgeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/BridgeCommand.java deleted file mode 100644 index 390b66db1..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/BridgeCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.asteriskjava.fastagi.command; - -public class BridgeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - private String options; - private String channel; - - /** - * Creates a new AnswerCommand. - */ - public BridgeCommand(String channel, String options) - { - super(); - this.channel = channel; - this.options = options; - } - - @Override - public String buildCommand() - { - String command = "EXEC " + escapeAndQuote("bridge") + " " + escapeAndQuote(channel); - if (options != null && options.length() > 0) - { - command += " " + escapeAndQuote(options); - } - - return command; - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/ChannelStatusCommand.java b/src/main/java/org/asteriskjava/fastagi/command/ChannelStatusCommand.java deleted file mode 100644 index 4bd075b88..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/ChannelStatusCommand.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Returns the status of the specified channel. If no channel name is given the - * returns the status of the current channel.

- * Return values: - *

    - *
  • 0 Channel is down and available - *
  • 1 Channel is down, but reserved - *
  • 2 Channel is off hook - *
  • 3 Digits (or equivalent) have been dialed - *
  • 4 Line is ringing - *
  • 5 Remote end is ringing - *
  • 6 Line is up - *
  • 7 Line is busy - *
- * - * @author srt - * @version $Id$ - */ -public class ChannelStatusCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3904959746380281145L; - - /** - * The name of the channel to query or null for the current - * channel. - */ - private String channel; - - /** - * Creates a new ChannelStatusCommand that queries the current channel. - */ - public ChannelStatusCommand() - { - super(); - } - - /** - * Creates a new ChannelStatusCommand that queries the given channel. - * - * @param channel the name of the channel to query. - */ - public ChannelStatusCommand(String channel) - { - super(); - this.channel = channel; - } - - /** - * Returns the name of the channel to query. - * - * @return the name of the channel to query or null for the - * current channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to query. - * - * @param channel the name of the channel to query or null - * for the current channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - @Override - public String buildCommand() - { - return "CHANNEL STATUS" - + (channel == null ? "" : " " + escapeAndQuote(channel)); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/ConfbridgeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/ConfbridgeCommand.java deleted file mode 100644 index 378eee5e0..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/ConfbridgeCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.asteriskjava.fastagi.command; - -public class ConfbridgeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - private String room; - private String profile; - - /** - * Creates a new AnswerCommand. - */ - public ConfbridgeCommand(String room, String profile) - { - super(); - this.room = room; - this.profile = profile; - } - - @Override - public String buildCommand() - { - String command = "EXEC " + escapeAndQuote("confbridge") + " " + escapeAndQuote(room); - if (profile != null && profile.length() > 0) - { - command += " " + escapeAndQuote(profile); - } - - return command; - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/ControlStreamFileCommand.java b/src/main/java/org/asteriskjava/fastagi/command/ControlStreamFileCommand.java deleted file mode 100644 index c7e30e4d2..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/ControlStreamFileCommand.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Plays the given file, allowing playback to be interrupted by the given - * digits, if any, and allows the listner to control the stream.

- * If offset is provided then the audio will seek to sample offset before play - * starts.

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed, or -1 on error or if the - * channel was disconnected.

- * Remember, the file extension must not be included in the filename.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class ControlStreamFileCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3978141041352128820L; - - /** - * The name of the file to stream. - */ - private String file; - - /** - * When one of these digits is pressed while streaming the command returns. - */ - private String escapeDigits; - - /** - * The offset samples to skip before streaming. - */ - private int offset; - - private String forwardDigit; - - private String rewindDigit; - - private String pauseDigit; - - /** - * Creates a new ControlStreamFileCommand, streaming from the beginning. It - * uses the default digit "#" for forward and "*" for rewind and does not - * support pausing. - * - * @param file the name of the file to stream, must not include extension. - */ - public ControlStreamFileCommand(String file) - { - super(); - this.file = file; - this.offset = -1; - } - - /** - * Creates a new ControlStreamFileCommand, streaming from the beginning. It - * uses the default digit "#" for forward and "*" for rewind and does not - * support pausing. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. - */ - public ControlStreamFileCommand(String file, String escapeDigits) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.offset = -1; - } - - /** - * Creates a new ControlStreamFileCommand, streaming from the given offset. - * It uses the default digit "#" for forward and "*" for rewind and does not - * support pausing. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. May be null if you don't want the - * user to interrupt. - * @param offset the offset samples to skip before streaming. - */ - public ControlStreamFileCommand(String file, String escapeDigits, int offset) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.offset = offset; - } - - /** - * Creates a new ControlStreamFileCommand, streaming from the given offset. - * It allows the user to pause streaming by pressing the pauseDigit. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. May be null if you don't want the - * user to interrupt. - * @param offset the offset samples to skip before streaming. - * @param forwardDigit the digit for fast forward. - * @param rewindDigit the digit for rewind. - * @param pauseDigit the digit for pause and unpause. - */ - public ControlStreamFileCommand(String file, String escapeDigits, - int offset, String forwardDigit, String rewindDigit, - String pauseDigit) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.offset = offset; - this.forwardDigit = forwardDigit; - this.rewindDigit = rewindDigit; - this.pauseDigit = pauseDigit; - } - - /** - * Returns the name of the file to stream. - * - * @return the name of the file to stream. - */ - public String getFile() - { - return file; - } - - /** - * Sets the name of the file to stream. - * - * @param file the name of the file to stream, must not include extension. - */ - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - /** - * Returns the offset samples to skip before streaming. - * - * @return the offset samples to skip before streaming. - */ - public int getOffset() - { - return offset; - } - - /** - * Sets the offset samples to skip before streaming. - * - * @param offset the offset samples to skip before streaming. - */ - public void setOffset(int offset) - { - this.offset = offset; - } - - /** - * Returns the digit for fast forward. - * - * @return the digit for fast forward. - */ - public String getForwardDigit() - { - return forwardDigit; - } - - /** - * Returns the digit for rewind. - * - * @return the digit for rewind. - */ - public String getRewindDigit() - { - return rewindDigit; - } - - /** - * Retruns the digit for pause and unpause. - * - * @return the digit for pause and unpause. - */ - public String getPauseDigit() - { - return pauseDigit; - } - - /** - * Sets the control digits for fast forward and rewind. - * - * @param forwardDigit the digit for fast forward. - * @param rewindDigit the digit for rewind. - */ - public void setControlDigits(String forwardDigit, String rewindDigit) - { - this.forwardDigit = forwardDigit; - this.rewindDigit = rewindDigit; - } - - /** - * Sets the control digits for fast forward, rewind and pause. - * - * @param forwardDigit the digit for fast forward. - * @param rewindDigit the digit for rewind. - * @param pauseDigit the digit for pause and unpause. - */ - public void setControlDigits(String forwardDigit, String rewindDigit, - String pauseDigit) - { - this.forwardDigit = forwardDigit; - this.rewindDigit = rewindDigit; - this.pauseDigit = pauseDigit; - } - - @Override - public String buildCommand() - { - StringBuilder sb; - - sb = new StringBuilder("CONTROL STREAM FILE "); - sb.append(escapeAndQuote(file)); - sb.append(" "); - sb.append(escapeAndQuote(escapeDigits)); - if (offset >= 0) - { - sb.append(" "); - sb.append(offset); - } - else if (forwardDigit != null || rewindDigit != null - || pauseDigit != null) - { - sb.append(" 0"); - } - - if (forwardDigit != null || rewindDigit != null || pauseDigit != null) - { - sb.append(" "); - sb.append(forwardDigit); - } - if (rewindDigit != null || pauseDigit != null) - { - sb.append(" "); - sb.append(rewindDigit); - } - if (pauseDigit != null) - { - sb.append(" "); - sb.append(pauseDigit); - } - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/DatabaseDelCommand.java b/src/main/java/org/asteriskjava/fastagi/command/DatabaseDelCommand.java deleted file mode 100644 index 2c27d2fe4..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/DatabaseDelCommand.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Deletes a family or specific keytree within a family in the Asterisk - * database.

- * Returns 1 if successful, 0 otherwise. - * - * @author srt - * @version $Id$ - */ -public class DatabaseDelCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The family (or family of the keytree) to delete. - */ - private String family; - - /** - * The keyTree to delete. - */ - private String keyTree; - - /** - * Creates a new DatabaseDelCommand to delete a family. - * - * @param family the family to delete. - */ - public DatabaseDelCommand(String family) - { - super(); - this.family = family; - } - - /** - * Creates a new DatabaseDelCommand to delete a keytree. - * - * @param family the family of the keytree to delete. - * @param keyTree the keytree to delete. - */ - public DatabaseDelCommand(String family, String keyTree) - { - super(); - this.family = family; - this.keyTree = keyTree; - } - - /** - * Returns the family (or family of the keytree) to delete. - * - * @return the family (or family of the keytree) to delete. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family (or family of the keytree) to delete. - * - * @param family the family (or family of the keytree) to delete. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the keytree to delete. - * - * @return the keytree to delete. - */ - public String getKeyTree() - { - return keyTree; - } - - /** - * Sets the keytree to delete. - * - * @param keyTree the keytree to delete. - */ - public void setKeyTree(String keyTree) - { - this.keyTree = keyTree; - } - - @Override - public String buildCommand() - { - return "DATABASE DELTREE " + escapeAndQuote(family) - + (keyTree == null ? "" : " " + escapeAndQuote(keyTree)); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/DatabaseDelTreeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/DatabaseDelTreeCommand.java deleted file mode 100644 index 383a8241c..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/DatabaseDelTreeCommand.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Deletes a family or specific keytree within a family in the Asterisk - * database. - *

- * Returns 1 if successful, 0 otherwise. - * - * @author srt - * @version $Id$ - */ -public class DatabaseDelTreeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The family of the key to delete. - */ - private String family; - - /** - * The keytree to delete. - */ - private String keyTree; - - /** - * Creates a new DatabaseDelCommand to delete a whole family. - * - * @param family the family to delete. - */ - public DatabaseDelTreeCommand(String family) - { - super(); - this.family = family; - } - - /** - * Creates a new DatabaseDelCommand to delete a keytree within a given - * family. - * - * @param family the family of the keytree to delete. - * @param keyTree the keytree to delete. - */ - public DatabaseDelTreeCommand(String family, String keyTree) - { - super(); - this.family = family; - this.keyTree = keyTree; - } - - /** - * Returns the family of the key to delete. - * - * @return the family of the key to delete. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key to delete. - * - * @param family the family of the key to delete. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the keytree to delete. - * - * @return the keytree to delete. - */ - public String getKeyTree() - { - return keyTree; - } - - /** - * Sets the keytree to delete. - * - * @param keyTree the keytree to delete, null to delete the - * whole family. - */ - public void setKeyTree(String keyTree) - { - this.keyTree = keyTree; - } - - @Override - public String buildCommand() - { - if (keyTree != null) - { - return "DATABASE DELTREE " + escapeAndQuote(family) + " " + escapeAndQuote(keyTree); - } - return "DATABASE DELTREE " + escapeAndQuote(family); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/DatabaseGetCommand.java b/src/main/java/org/asteriskjava/fastagi/command/DatabaseGetCommand.java deleted file mode 100644 index c3732893a..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/DatabaseGetCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Retrieves an entry in the Asterisk database for a given family and key.

- * Returns 0 if is not set. Returns 1 if the variable is set and returns the - * value in parenthesis.

- * Example return code: 200 result=1 (testvariable) - * - * @author srt - * @version $Id$ - */ -public class DatabaseGetCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The family of the key to retrieve. - */ - private String family; - - /** - * The key to retrieve. - */ - private String key; - - /** - * Creates a new DatabaseGetCommand. - * - * @param family the family of the key to retrieve. - * @param key the key to retrieve. - */ - public DatabaseGetCommand(String family, String key) - { - super(); - this.family = family; - this.key = key; - } - - /** - * Returns the family of the key to retrieve. - * - * @return the family of the key to retrieve. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key to retrieve. - * - * @param family the family of the key to retrieve. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the key to retrieve. - * - * @return the key to retrieve. - */ - public String getKey() - { - return key; - } - - /** - * Sets the key to retrieve. - * - * @param key the key to retrieve. - */ - public void setKey(String key) - { - this.key = key; - } - - @Override - public String buildCommand() - { - return "DATABASE GET " + escapeAndQuote(family) + " " - + escapeAndQuote(key); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/DatabasePutCommand.java b/src/main/java/org/asteriskjava/fastagi/command/DatabasePutCommand.java deleted file mode 100644 index 93a3ba9de..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/DatabasePutCommand.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Adds or updates an entry in the Asterisk database for a given family, key, - * and value.

- * Returns 1 if successful, 0 otherwise. - * - * @author srt - * @version $Id$ - */ -public class DatabasePutCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The family of the key to set. - */ - private String family; - - /** - * The key to set. - */ - private String key; - - /** - * The value to set. - */ - private String value; - - /** - * Creates a new DatabasePutCommand. - * - * @param family the family of the key to set. - * @param key the key to set. - * @param value the value to set. - */ - public DatabasePutCommand(String family, String key, String value) - { - super(); - this.family = family; - this.key = key; - this.value = value; - } - - /** - * Returns the family of the key to set. - * - * @return the family of the key to set. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key to set. - * - * @param family the family of the key to set. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the key to set. - * - * @return the key to set. - */ - public String getKey() - { - return key; - } - - /** - * Sets the key to set. - * - * @param key the key to set. - */ - public void setKey(String key) - { - this.key = key; - } - - /** - * Returns the value to set. - * - * @return the value to set. - */ - public String getValue() - { - return value; - } - - /** - * Sets the value to set. - * - * @param value the value to set. - */ - public void setValue(String value) - { - this.value = value; - } - - @Override - public String buildCommand() - { - return "DATABASE PUT " + escapeAndQuote(family) + " " - + escapeAndQuote(key) + " " + escapeAndQuote(value); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/DialCommand.java b/src/main/java/org/asteriskjava/fastagi/command/DialCommand.java deleted file mode 100644 index 7c0885851..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/DialCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.asteriskjava.fastagi.command; - -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class DialCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - private String options; - private String target; - private int timeout; - private final Log logger = LogFactory.getLog(getClass()); - - /** - * Creates a new AnswerCommand. - */ - public DialCommand(String target, int timeout, String options) - { - super(); - this.target = target; - this.timeout = timeout; - this.options = options; - } - - @Override - public String buildCommand() - { - - String command = "EXEC " + escapeAndQuote("dial") + " " + escapeAndQuote(target) + "|" - + escapeAndQuote("" + timeout); - if (options != null && options.length() > 0) - { - command += "|" + escapeAndQuote(options); - } - - logger.info(command); - - return command; - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/ExecCommand.java b/src/main/java/org/asteriskjava/fastagi/command/ExecCommand.java deleted file mode 100644 index b65be09b3..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/ExecCommand.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Executes an application with the given options.

- * Returns whatever the application returns, or -2 if the application was not - * found. - * - * @author srt - * @version $Id$ - */ -public class ExecCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3904959746380281145L; - - /** - * The name of the application to execute. - */ - private String application; - - /** - * The options to pass to the application. - */ - private String[] options; - - /** - * Creates a new ExecCommand. - * - * @param application the name of the application to execute. - */ - public ExecCommand(String application) - { - super(); - this.application = application; - } - - /** - * Creates a new ExecCommand. - * - * @param application the name of the application to execute. - * @param options the options to pass to the application. - */ - public ExecCommand(String application, String... options) - { - super(); - this.application = application; - this.options = options; - } - - /** - * Returns the name of the application to execute. - * - * @return the name of the application to execute. - */ - public String getApplication() - { - return application; - } - - /** - * Sets the name of the application to execute. - * - * @param application the name of the application to execute. - */ - public void setApplication(String application) - { - this.application = application; - } - - /** - * Returns the options to pass to the application. - * - * @return the options to pass to the application. - */ - public String[] getOptions() - { - return options; - } - - /** - * Sets the options to pass to the application. - * - * @param options the options to pass to the application. - */ - public void setOptions(String... options) - { - this.options = options; - } - - @Override - public String buildCommand() - { - return "EXEC " + escapeAndQuote(application) + " " - + escapeAndQuote(options); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/GetDataCommand.java b/src/main/java/org/asteriskjava/fastagi/command/GetDataCommand.java deleted file mode 100644 index d93a0b5e7..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/GetDataCommand.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Stream the given file, and recieve DTMF data. The user may interrupt the - * streaming by starting to enter digits. - *

- * Returns the digits recieved from the channel at the other end. - *

- * Input ends when the timeout is reached, the maximum number of digits is read - * or the user presses #. - * - * @author srt - * @version $Id$ - */ -public class GetDataCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3978141041352128820L; - - private static final int DEFAULT_MAX_DIGITS = 1024; - private static final int DEFAULT_TIMEOUT = 0; - - /** - * The name of the file to stream. - */ - private String file; - - /** - * The timeout in milliseconds to wait for data. - *

- * 0 means standard timeout value, -1 means "ludicrous time" (essentially - * never times out). - */ - private long timeout; - - /** - * The maximum number of digits to read. - *

- * Must be in [1..1024]. - */ - private int maxDigits; - - /** - * Creates a new GetDataCommand with default timeout and maxDigits set to - * 1024. - * - * @param file the name of the file to stream, must not include extension. - */ - public GetDataCommand(String file) - { - super(); - this.file = file; - this.timeout = DEFAULT_TIMEOUT; - this.maxDigits = DEFAULT_MAX_DIGITS; - } - - /** - * Creates a new GetDataCommand with the given timeout and maxDigits set to - * 1024. - * - * @param file the name of the file to stream, must not include extension. - * @param timeout the timeout in milliseconds to wait for data. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - */ - public GetDataCommand(String file, long timeout) - { - super(); - this.file = file; - this.timeout = timeout; - this.maxDigits = DEFAULT_MAX_DIGITS; - } - - /** - * Creates a new GetDataCommand with the given timeout and maxDigits. - * - * @param file the name of the file to stream, must not include extension. - * @param timeout the timeout in milliseconds to wait for data. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - * @param maxDigits the maximum number of digits to read. - *

- * Must be in [1..1024]. - * @throws IllegalArgumentException if maxDigits is not in [1..1024] - */ - public GetDataCommand(String file, long timeout, int maxDigits) throws IllegalArgumentException - { - super(); - if (maxDigits < 1 || maxDigits > 1024) - { - throw new IllegalArgumentException("maxDigits must be in [1..1024]"); - } - - this.file = file; - this.timeout = timeout; - this.maxDigits = maxDigits; - } - - /** - * Returns the name of the file to stream. - * - * @return the name of the file to stream. - */ - public String getFile() - { - return file; - } - - /** - * Sets the name of the file to stream. - *

- * This attribute is mandatory. - * - * @param file the name of the file to stream, must not include extension. - */ - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the timeout to wait for data. - * - * @return the timeout in milliseconds to wait for data. - */ - public long getTimeout() - { - return timeout; - } - - /** - * Sets the timeout to wait for data. - * - * @param timeout the timeout in milliseconds to wait for data. - *

- * 0 means standard timeout value, -1 means "ludicrous time" - * (essentially never times out). - */ - public void setTimeout(long timeout) - { - this.timeout = timeout; - } - - /** - * Returns the maximum number of digits to read. - * - * @return the maximum number of digits to read. - */ - public int getMaxDigits() - { - return maxDigits; - } - - /** - * Sets the maximum number of digits to read. - * - * @param maxDigits the maximum number of digits to read. - *

- * Must be in [1..1024]. - * @throws IllegalArgumentException if maxDigits is not in [1..1024] - */ - public void setMaxDigits(int maxDigits) throws IllegalArgumentException - { - if (maxDigits < 1 || maxDigits > 1024) - { - throw new IllegalArgumentException("maxDigits must be in [1..1024]"); - } - - this.maxDigits = maxDigits; - } - - @Override - public String buildCommand() - { - if (maxDigits == DEFAULT_MAX_DIGITS) - { - if (timeout == DEFAULT_TIMEOUT) - { - return "GET DATA " + escapeAndQuote(file); - } - return "GET DATA " + escapeAndQuote(file) + " " + timeout; - } - return "GET DATA " + escapeAndQuote(file) + " " + timeout + " " + maxDigits; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/GetFullVariableCommand.java b/src/main/java/org/asteriskjava/fastagi/command/GetFullVariableCommand.java deleted file mode 100644 index ff94d205c..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/GetFullVariableCommand.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Returns the value of the given channel varible and understands complex - * variable names and builtin variables, unlike the GetVariableCommand.

- * You can also use this command to use custom Asterisk functions. Syntax is - * "func(args)".

- * Returns 0 if the variable is not set or channel does not exist. Returns 1 if - * the variable is set and returns the variable in parenthesis.

- * Available since Asterisk 1.2

- * Example return code: 200 result=1 (testvariable) - * - * @since 0.2 - * @author srt - * @version $Id$ - * @see org.asteriskjava.fastagi.command.GetVariableCommand - */ -public class GetFullVariableCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The name of the variable to retrieve. - */ - private String variable; - - private String channel; - - /** - * Creates a new GetFullVariableCommand. - * - * @param variable the name of the variable to retrieve. - */ - public GetFullVariableCommand(String variable) - { - super(); - this.variable = variable; - } - - /** - * Creates a new GetFullVariableCommand. - * - * @param variable the name of the variable to retrieve. - * @param channel the name of the channel. - */ - public GetFullVariableCommand(String variable, String channel) - { - super(); - this.variable = variable; - this.channel = channel; - } - - /** - * Returns the name of the variable to retrieve. - * - * @return the the name of the variable to retrieve. - */ - public String getVariable() - { - return variable; - } - - /** - * Sets the name of the variable to retrieve.

- * You can also use custom dialplan functions (like "func(args)") as - * variable. - * - * @param variable the name of the variable to retrieve. - */ - public void setVariable(String variable) - { - this.variable = variable; - } - - /** - * Returns the the name of the channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - * - * @param channel the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - @Override - public String buildCommand() - { - StringBuilder sb; - - sb = new StringBuilder("GET FULL VARIABLE "); - sb.append(escapeAndQuote(variable)); - - if (channel != null) - { - sb.append(" "); - sb.append(escapeAndQuote(channel)); - } - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/GetOptionCommand.java b/src/main/java/org/asteriskjava/fastagi/command/GetOptionCommand.java deleted file mode 100644 index dd6bc5532..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/GetOptionCommand.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Plays the given file, and waits for the user to press one of the given - * digits. If none of the esacpe digits is pressed while streaming the file this - * command waits for the specified timeout still waiting for the user to press a - * digit. Streaming always begins at the beginning.

- * Returns 0 if no digit being pressed, or the ASCII numerical value of the - * digit if one was pressed, or -1 on error or if the channel was disconnected. - *
- * Remember, the file extension must not be included in the filename. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.fastagi.command.StreamFileCommand - */ -public class GetOptionCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3978141041352128820L; - - /** - * The name of the file to stream. - */ - private String file; - - /** - * When one of these digits is pressed while streaming the command returns. - */ - private String escapeDigits; - - /** - * The timeout in milliseconds. - */ - private long timeout; - - /** - * Creates a new GetOptionCommand with a default timeout of 5 seconds. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that the user is expected to - * press. - */ - public GetOptionCommand(String file, String escapeDigits) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.timeout = -1; - } - - /** - * Creates a new GetOptionCommand with the given timeout. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that the user is expected to - * press. - * @param timeout the timeout in milliseconds to wait if none of the defined - * esacpe digits was presses while streaming. - */ - public GetOptionCommand(String file, String escapeDigits, long timeout) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.timeout = timeout; - } - - /** - * Returns the name of the file to stream. - * - * @return the name of the file to stream. - */ - public String getFile() - { - return file; - } - - /** - * Sets the name of the file to stream. - * - * @param file the name of the file to stream, must not include extension. - */ - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the digits that the user is expected to press. - * - * @return the digits that the user is expected to press. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that the user is expected to press. - * - * @param escapeDigits the digits that the user is expected to press. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - /** - * Returns the timeout to wait if none of the defined esacpe digits was - * presses while streaming. - * - * @return the timeout in milliseconds. - */ - public long getTimeout() - { - return timeout; - } - - /** - * Sets the timeout to wait if none of the defined esacpe digits was presses - * while streaming. - * - * @param timeout the timeout in milliks,seconds. - */ - public void setTimeout(long timeout) - { - this.timeout = timeout; - } - - @Override - public String buildCommand() - { - return "GET OPTION " + escapeAndQuote(file) + " " - + escapeAndQuote(escapeDigits) - + (timeout < 0 ? "" : " " + timeout); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/GetVariableCommand.java b/src/main/java/org/asteriskjava/fastagi/command/GetVariableCommand.java deleted file mode 100644 index 471f28f8e..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/GetVariableCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Returns the value of the given channel varible.

- * Since Asterisk 1.2 you can also use this command to use custom Asterisk - * functions. Syntax is "func(args)".

- * Returns 0 if the variable is not set. Returns 1 if the variable is set and - * returns the variable in parenthesis.

- * Example return code: 200 result=1 (testvariable) - * - * @author srt - * @version $Id$ - */ -public class GetVariableCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The name of the variable to retrieve. - */ - private String variable; - - /** - * Creates a new GetVariableCommand. - * - * @param variable the name of the variable to retrieve. - */ - public GetVariableCommand(String variable) - { - super(); - this.variable = variable; - } - - /** - * Returns the name of the variable to retrieve. - * - * @return the the name of the variable to retrieve. - */ - public String getVariable() - { - return variable; - } - - /** - * Sets the name of the variable to retrieve.

- * Since Asterisk 1.2 you can also use custom dialplan functions (like - * "func(args)") as variable. - * - * @param variable the name of the variable to retrieve. - */ - public void setVariable(String variable) - { - this.variable = variable; - } - - @Override - public String buildCommand() - { - return "GET VARIABLE " + escapeAndQuote(variable); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/GosubCommand.java b/src/main/java/org/asteriskjava/fastagi/command/GosubCommand.java deleted file mode 100644 index 3c6826795..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/GosubCommand.java +++ /dev/null @@ -1,165 +0,0 @@ -package org.asteriskjava.fastagi.command; - -/** - * Calls a subroutine from dialplan. - *
- * Example return code: 200 result=0 Gosub complete - *
- * This command is available since Asterisk 1.6. - * - * @author fadishei - * @since 1.0.0 - */ -public class GosubCommand extends AbstractAgiCommand -{ - private static final long serialVersionUID = 1L; - - /** - * the context of the called subroutine. - */ - private String context; - - /** - * the extension in the called context. - */ - private String extension; - - /** - * the priority of the called extension. - */ - private String priority; - - /** - * an optional list of arguments to be passed to the subroutine. - * They will accessible in the form of ${ARG1}, ${ARG2}, etc in the subroutine body. - */ - private String[] arguments; - - /** - * Creates a new GosubCommand. - * - * @param context context of the called subroutine. - * @param extension the extension in the called context. - * @param priority of the called extension. - */ - public GosubCommand(String context, String extension, String priority) - { - super(); - this.context = context; - this.extension = extension; - this.priority = priority; - } - - /** - * Creates a new GosubCommand. - * - * @param context context of the called subroutine. - * @param extension the extension in the called context. - * @param priority the priority of the called extension. - * @param arguments the arguments to be passed to the called subroutine. - */ - public GosubCommand(String context, String extension, String priority, String... arguments) - { - super(); - this.context = context; - this.extension = extension; - this.priority = priority; - this.arguments = arguments; - } - - /** - * Returns the context of the subroutine to call. - * - * @return the context of the subroutine to call. - */ - public String getContext() - { - return context; - } - - /** - * Sets the context of the subroutine to call. - * - * @param context the context of the subroutine to call. - */ - public void setContext(String context) - { - this.context = context; - } - - /** - * Returns the extension within the called context. - * - * @return the extension within the called context. - */ - public String getExtension() - { - return extension; - } - - /** - * Sets the extension within the called context. - * - * @param extension the extension within the called context. - */ - public void setExtension(String extension) - { - this.extension = extension; - } - - /** - * Returns the priority of the called extension. - * - * @return the priority of the called extension. - */ - public String getPriority() - { - return priority; - } - - /** - * Sets the priority of the called extension. - * - * @param priority the priority of the called extension. - */ - public void setPriority(String priority) - { - this.priority = priority; - } - - /** - * Returns the arguments to be passed to the subroutine. - * - * @return the arguments to be passed to the subroutine. - */ - public String[] getArguments() - { - return arguments; - } - - /** - * Sets the arguments to be passed to the subroutine. - * - * @param arguments the arguments to be passed to the subroutine. - */ - public void setArguments(String[] arguments) - { - this.arguments = arguments; - } - - @Override - public String buildCommand() - { - final StringBuilder sb = new StringBuilder("GOSUB "); - sb.append(escapeAndQuote(context)).append(" "); - sb.append(escapeAndQuote(extension)).append(" "); - sb.append(escapeAndQuote(priority)); - - if (arguments != null) - { - sb.append(" ").append(escapeAndQuote(arguments)); - } - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/HangupCommand.java b/src/main/java/org/asteriskjava/fastagi/command/HangupCommand.java deleted file mode 100644 index 22859e0df..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/HangupCommand.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Hangs up the specified channel. If no channel name is given, hangs up the - * current channel. - * - * @author srt - * @version $Id$ - */ -public class HangupCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3904959746380281145L; - - /** - * The name of the channel to hangup or null for the current - * channel. - */ - private String channel; - - /** - * Creates a new HangupCommand that hangs up the current channel. - */ - public HangupCommand() - { - super(); - } - - /** - * Creates a new HangupCommand that hangs up the given channel. - * - * @param channel the name of the channel to hangup. - */ - public HangupCommand(String channel) - { - super(); - this.channel = channel; - } - - /** - * Returns the name of the channel to hangup. - * - * @return the name of the channel to hangup or null for the - * current channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to hangup. - * - * @param channel the name of the channel to hangup or null - * for the current channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - @Override - public String buildCommand() - { - return "HANGUP" - + (channel == null ? "" : " " + escapeAndQuote(channel)); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/MeetmeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/MeetmeCommand.java deleted file mode 100644 index 04024a28e..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/MeetmeCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.asteriskjava.fastagi.command; - -public class MeetmeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - private String room; - private String options; - - /** - * Creates a new AnswerCommand. - */ - public MeetmeCommand(String room, String options) - { - super(); - this.room = room; - this.options = options; - } - - @Override - public String buildCommand() - { - String command = "EXEC " + escapeAndQuote("meetme") + " " + escapeAndQuote(room); - if (options != null && options.length() > 0) - { - command += "|" + escapeAndQuote(options); - } - - return command; - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/NoopCommand.java b/src/main/java/org/asteriskjava/fastagi/command/NoopCommand.java deleted file mode 100644 index c6f0f9fb4..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/NoopCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Does nothing. - * - * @author srt - * @version $Id$ - */ -public class NoopCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - - /** - * Creates a new NoopCommand. - */ - public NoopCommand() - { - super(); - } - - @Override - public String buildCommand() - { - return "NOOP"; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/QueueCommand.java b/src/main/java/org/asteriskjava/fastagi/command/QueueCommand.java deleted file mode 100644 index 86f3420fb..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/QueueCommand.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.fastagi.command; - -public class QueueCommand extends AbstractAgiCommand -{ - - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - - private String queue; - - /** - * Creates a new AnswerCommand. - */ - public QueueCommand(String queue) - { - super(); - this.queue = queue; - - } - - @Override - public String buildCommand() - { - String command = "EXEC " + escapeAndQuote("queue") + " " + escapeAndQuote(queue); - // if (options != null && options.length() > 0) - // { - // command += " " + escapeAndQuote(options); - // } - - return command; - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/ReceiveCharCommand.java b/src/main/java/org/asteriskjava/fastagi/command/ReceiveCharCommand.java deleted file mode 100644 index d1c062c44..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/ReceiveCharCommand.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Receives a character of text on a channel.

- * Specify timeout to be the maximum time to wait for input in milliseconds, or - * 0 for infinite.

- * Most channels do not support the reception of text.

- * Returns the decimal value of the character if one is received, or 0 if the - * channel does not support text reception. Returns -1 only on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class ReceiveCharCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The milliseconds to wait for the channel to receive a character. - */ - private int timeout; - - /** - * Creates a new ReceiveCharCommand with a default timeout of 0 meaning to - * wait for ever. - */ - public ReceiveCharCommand() - { - super(); - this.timeout = 0; - } - - /** - * Creates a new ReceiveCharCommand. - * - * @param timeout the milliseconds to wait for the channel to receive a - * character. - */ - public ReceiveCharCommand(int timeout) - { - super(); - this.timeout = timeout; - } - - /** - * Returns the milliseconds to wait for the channel to receive a character. - * - * @return the milliseconds to wait for the channel to receive a character. - */ - public int getTimeout() - { - return timeout; - } - - /** - * Sets the milliseconds to wait for the channel to receive a character. - * - * @param timeout the milliseconds to wait for the channel to receive a - * character. - */ - public void setTimeout(int timeout) - { - this.timeout = timeout; - } - - @Override - public String buildCommand() - { - return "RECEIVE CHAR " + timeout; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/ReceiveTextCommand.java b/src/main/java/org/asteriskjava/fastagi/command/ReceiveTextCommand.java deleted file mode 100644 index 564d5f11c..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/ReceiveTextCommand.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Receives a string of text on a channel.

- * Specify timeout to be the maximum time to wait for input in milliseconds, or - * 0 for infinite.

- * Most channels do not support the reception of text.

- * Returns -1 for failure or 1 for success, and the string in parentheses.

- * Available since Asterisk 1.2. - * - * @since 0.2 - * @author srt - * @version $Id$ - */ -public class ReceiveTextCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The milliseconds to wait for the channel to receive a character. - */ - private int timeout; - - /** - * Creates a new ReceiveTextCommand with a default timeout of 0 meaning to - * wait for ever. - */ - public ReceiveTextCommand() - { - super(); - this.timeout = 0; - } - - /** - * Creates a new ReceiveTextCommand. - * - * @param timeout the milliseconds to wait for the channel to receive the - * text. - */ - public ReceiveTextCommand(int timeout) - { - super(); - this.timeout = timeout; - } - - /** - * Returns the milliseconds to wait for the channel to receive the text. - * - * @return the milliseconds to wait for the channel to receive the text. - */ - public int getTimeout() - { - return timeout; - } - - /** - * Sets the milliseconds to wait for the channel to receive the text. - * - * @param timeout the milliseconds to wait for the channel to receive the - * text. - */ - public void setTimeout(int timeout) - { - this.timeout = timeout; - } - - @Override - public String buildCommand() - { - return "RECEIVE TEXT " + timeout; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/RecordFileCommand.java b/src/main/java/org/asteriskjava/fastagi/command/RecordFileCommand.java deleted file mode 100644 index abea85e7d..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/RecordFileCommand.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Record to a file until a given dtmf digit in the sequence is received. - *

- * Returns -1 on hangup or error. - *

- * The format will specify what kind of file will be recorded. The timeout is - * the maximum record time in milliseconds, or -1 for no timeout. Offset samples - * is optional, and if provided will seek to the offset without exceeding the - * end of the file. "maxSilence" is the number of seconds of maxSilence allowed - * before the function returns despite the lack of dtmf digits or reaching - * timeout. - * - * @author srt - * @version $Id$ - */ -public class RecordFileCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3978141041352128820L; - - /** - * The name of the file to record. - */ - private String file; - - /** - * The format of the file to be recorded, for example "wav". - */ - private String format; - - /** - * The these digits a user can press to end the recording. - */ - private String escapeDigits; - - /** - * The maximum record time in milliseconds, or -1 for no timeout. - */ - private int timeout; - - /** - * The offset samples to skip. - */ - private int offset; - - /** - * Wheather a beep should be played before recording. - */ - private boolean beep; - - /** - * The amount of silence (in seconds) to allow before returning despite the - * lack of dtmf digits or reaching timeout. - */ - private int maxSilence; - - /** - * Creates a new RecordFileCommand. - * - * @param file the name of the file to stream, must not include extension. - * @param format the format of the file to be recorded, for example "wav". - * @param escapeDigits contains the digits that allow the user to end - * recording. - * @param timeout the maximum record time in milliseconds, or -1 for no - * timeout. - */ - public RecordFileCommand(String file, String format, String escapeDigits, int timeout) - { - super(); - this.file = file; - this.format = format; - this.escapeDigits = escapeDigits; - this.timeout = timeout; - this.offset = 0; - this.beep = false; - this.maxSilence = 0; - } - - /** - * Creates a new RecordFileCommand. - * - * @param file the name of the file to stream, must not include extension. - * @param format the format of the file to be recorded, for example "wav". - * @param escapeDigits contains the digits that allow the user to end - * recording. - * @param timeout the maximum record time in milliseconds, or -1 for no - * timeout. - * @param offset the offset samples to skip. - * @param beep true if a beep should be played before - * recording. - * @param maxSilence The amount of silence (in seconds) to allow before - * returning despite the lack of dtmf digits or reaching timeout. - */ - public RecordFileCommand(String file, String format, String escapeDigits, int timeout, int offset, boolean beep, - int maxSilence) - { - super(); - this.file = file; - this.format = format; - this.escapeDigits = escapeDigits; - this.timeout = timeout; - this.offset = offset; - this.beep = beep; - this.maxSilence = maxSilence; - } - - /** - * Returns the name of the file to stream. - * - * @return the name of the file to stream. - */ - public String getFile() - { - return file; - } - - /** - * Sets the name of the file to stream. - * - * @param file the name of the file to stream, must not include extension. - */ - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the format of the file to be recorded, for example "wav". - * - * @return the format of the file to be recorded, for example "wav". - */ - public String getFormat() - { - return format; - } - - /** - * Sets the format of the file to be recorded, for example "wav". - * - * @param format the format of the file to be recorded, for example "wav". - */ - public void setFormat(String format) - { - this.format = format; - } - - /** - * Returns the digits that allow the user to end recording. - * - * @return the digits that allow the user to end recording. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to end recording. - * - * @param escapeDigits the digits that allow the user to end recording or - * null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - /** - * Returns the maximum record time in milliseconds. - * - * @return the maximum record time in milliseconds. - */ - public int getTimeout() - { - return timeout; - } - - /** - * Sets the maximum record time in milliseconds. - * - * @param timeout the maximum record time in milliseconds, or -1 for no - * timeout. - */ - public void setTimeout(int timeout) - { - this.timeout = timeout; - } - - /** - * Returns the offset samples to skip. - * - * @return the offset samples to skip. - */ - public int getOffset() - { - return offset; - } - - /** - * Sets the offset samples to skip. - * - * @param offset the offset samples to skip. - */ - public void setOffset(int offset) - { - this.offset = offset; - } - - /** - * Returns true if a beep should be played before recording. - * - * @return true if a beep should be played before recording, - * false if not. - */ - public boolean getBeep() - { - return beep; - } - - /** - * Set to true to play a beep before recording. - * - * @param beep true if a beep should be played before - * recording, false if not. - */ - public void setBeep(boolean beep) - { - this.beep = beep; - } - - /** - * Returns the amount of silence (in seconds) to allow before returning - * despite the lack of dtmf digits or reaching timeout. - * - * @return the amount of silence (in seconds) to allow before returning - * despite the lack of dtmf digits or reaching timeout. - */ - int getMaxSilence() - { - return maxSilence; - } - - /** - * Sets the amount of silence (in seconds) to allow before returning despite - * the lack of dtmf digits or reaching timeout. - * - * @param maxSilence the amount of silence (in seconds) to allow before - * returning despite the lack of dtmf digits or reaching timeout. - */ - void setMaxSilence(int maxSilence) - { - this.maxSilence = maxSilence; - } - - @Override - public String buildCommand() - { - return "RECORD FILE " + escapeAndQuote(file) + " " + escapeAndQuote(format) + " " + escapeAndQuote(escapeDigits) - + " " + timeout + " " + offset + (beep ? " BEEP" : "") + " s=" + maxSilence; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SayAlphaCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SayAlphaCommand.java deleted file mode 100644 index 75e771ffa..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SayAlphaCommand.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this text except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Say a given character string, returning early if any of the - * given DTMF digits are received on the channel.

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed or -1 on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class SayAlphaCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256721797012404276L; - - /** - * The text to say. - */ - private String text; - - /** - * When one of these digits is pressed the command returns. - */ - private String escapeDigits; - - /** - * Creates a new SayAlphaCommand. - * - * @param text the text to say. - */ - public SayAlphaCommand(String text) - { - super(); - this.text = text; - } - - /** - * Creates a new SayAlphaCommand. - * - * @param text the text to say. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. - */ - public SayAlphaCommand(String text, String escapeDigits) - { - super(); - this.text = text; - this.escapeDigits = escapeDigits; - } - - /** - * Returns the text to say. - * - * @return the text to say. - */ - public String getText() - { - return text; - } - - /** - * Sets the text to say. - * - * @param text the text to say. - */ - public void setText(String text) - { - this.text = text; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the text that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - @Override - public String buildCommand() - { - return "SAY ALPHA " + escapeAndQuote(text) + " " - + escapeAndQuote(escapeDigits); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SayDateTimeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SayDateTimeCommand.java deleted file mode 100644 index b90a52506..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SayDateTimeCommand.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Say a given time, returning early if any of the given DTMF digits are - * pressed.

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed or -1 on error/hangup.

- * Available since Asterisk 1.2. - * - * @since 0.2 - * @author srt - * @version $Id$ - */ -public class SayDateTimeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -976344744239948036L; - - private static final String DEFAULT_FORMAT = "ABdY 'digits/at' IMp"; - - private long time; - private String escapeDigits; - private String format; - private String timezone; - - /** - * Creates a new SayDateTimeCommand that says the given time. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - */ - public SayDateTimeCommand(long time) - { - super(); - this.time = time; - } - - /** - * Creates a new SayDateTimeCommand that says the given time and allows - * interruption by one of the given escape digits. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - */ - public SayDateTimeCommand(long time, String escapeDigits) - { - super(); - this.time = time; - this.escapeDigits = escapeDigits; - } - - /** - * Creates a new SayDateTimeCommand that says the given time in the given - * format and allows interruption by one of the given escape digits. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - * @param format the format the time should be said in - */ - public SayDateTimeCommand(long time, String escapeDigits, String format) - { - super(); - this.time = time; - this.escapeDigits = escapeDigits; - this.format = format; - } - - /** - * Creates a new SayDateTimeCommand that says the given time in the given - * format and timezone and allows interruption by one of the given escape - * digits. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - * @param format the format the time should be said in - * @param timezone the timezone to use when saying the time, for example - * "UTC" or "Europe/Berlin". - */ - public SayDateTimeCommand(long time, String escapeDigits, String format, - String timezone) - { - super(); - this.time = time; - this.escapeDigits = escapeDigits; - this.format = format; - this.timezone = timezone; - } - - /** - * Returns the time to say in seconds elapsed since 00:00:00 on January 1, - * 1970, Coordinated Universal Time (UTC). - * - * @return the time to say in seconds elapsed since 00:00:00 on January 1, - * 1970, Coordinated Universal Time (UTC) - */ - public long getTime() - { - return time; - } - - /** - * Returns the time to say in seconds elapsed since 00:00:00 on January 1, - * 1970, Coordinated Universal Time (UTC).

- * This property is mandatory. - * - * @param time the time to say in seconds elapsed since 00:00:00 on January - * 1, 1970, Coordinated Universal Time (UTC) - */ - public void setTime(long time) - { - this.time = time; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - /** - * Returns the format the time should be said in. - * - * @return the format the time should be said in - */ - public String getFormat() - { - return format; - } - - /** - * Sets the format the time should be said in.

- * See voicemail.conf.

- * Defaults to "ABdY 'digits/at' IMp". - * - * @param format the format the time should be said in - */ - public void setFormat(String format) - { - this.format = format; - } - - /** - * Returns the timezone to use when saying the time. - * - * @return the timezone to use when saying the time. - */ - public String getTimezone() - { - return timezone; - } - - /** - * Sets the timezone to use when saying the time.

- * A list of available timezones is available in - * /usr/share/zoneinfo on your Asterisk server.

- * Defaults to machine default. - * - * @param timezone the timezone to use when saying the time, for example - * "UTC" or "Europe/Berlin". - */ - public void setTimezone(String timezone) - { - this.timezone = timezone; - } - - @Override - public String buildCommand() - { - StringBuilder sb; - - sb = new StringBuilder("SAY DATETIME "); - sb.append(time); - sb.append(" "); - sb.append(escapeAndQuote(escapeDigits)); - - if (format == null && timezone != null) - { - sb.append(" "); - sb.append(escapeAndQuote(DEFAULT_FORMAT)); - } - if (format != null) - { - sb.append(" "); - sb.append(escapeAndQuote(format)); - } - - if (timezone != null) - { - sb.append(" "); - sb.append(escapeAndQuote(timezone)); - } - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SayDigitsCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SayDigitsCommand.java deleted file mode 100644 index e5b13c687..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SayDigitsCommand.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this digits except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Say a given digit string, returning early if any of the given DTMF digits are - * received on the channel.

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed or -1 on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class SayDigitsCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3907207173934101552L; - - /** - * The digits string to say. - */ - private String digits; - - /** - * When one of these digits is pressed while saying the digits the command - * returns. - */ - private String escapeDigits; - - /** - * Creates a new SayDigitsCommand. - * - * @param digits the digits to say. - */ - public SayDigitsCommand(String digits) - { - super(); - this.digits = digits; - } - - /** - * Creates a new SayDigitsCommand. - * - * @param digits the digits to say. - * @param escapeDigits the digits that allow the user to interrupt this - * command. - */ - public SayDigitsCommand(String digits, String escapeDigits) - { - super(); - this.digits = digits; - this.escapeDigits = escapeDigits; - } - - /** - * Returns the digits string to say. - * - * @return the digits string to say. - */ - public String getDigits() - { - return digits; - } - - /** - * Sets the digits to say. - * - * @param digits the digits string to say. - */ - public void setDigits(String digits) - { - this.digits = digits; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - @Override - public String buildCommand() - { - return "SAY DIGITS " + escapeAndQuote(digits) + " " - + escapeAndQuote(escapeDigits); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SayNumberCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SayNumberCommand.java deleted file mode 100644 index 37933303e..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SayNumberCommand.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this number except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Say a given number, returning early if any of the given DTMF number are - * received on the channel.

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed or -1 on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class SayNumberCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3833744404153644087L; - - /** - * The number to say. - */ - private String number; - - /** - * When one of these number is pressed while streaming the command returns. - */ - private String escapeDigits; - - /** - * Creates a new SayNumberCommand. - * - * @param number the number to say. - */ - public SayNumberCommand(String number) - { - super(); - this.number = number; - } - - /** - * Creates a new SayNumberCommand. - * - * @param number the number to say. - * @param escapeDigits contains the number that allow the user to - * interrupt this command. - */ - public SayNumberCommand(String number, String escapeDigits) - { - super(); - this.number = number; - this.escapeDigits = escapeDigits; - } - - /** - * Returns the number to say. - * - * @return the number to say. - */ - public String getNumber() - { - return number; - } - - /** - * Sets the number to say. - * - * @param number the number to say. - */ - public void setNumber(String number) - { - this.number = number; - } - - /** - * Returns the number that allow the user to interrupt this command. - * - * @return the number that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the number that allow the user to interrupt this command. - * - * @param escapeDigits the number that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - @Override - public String buildCommand() - { - return "SAY NUMBER " + escapeAndQuote(number) + " " - + escapeAndQuote(escapeDigits); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SayPhoneticCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SayPhoneticCommand.java deleted file mode 100644 index 933b834d1..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SayPhoneticCommand.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this text except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Say a given character string with phonetics, returning early if any of the - * given DTMF digits are received on the channel.

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed or -1 on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class SayPhoneticCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256721797012404276L; - - /** - * The text to say. - */ - private String text; - - /** - * When one of these digits is pressed the command returns. - */ - private String escapeDigits; - - /** - * Creates a new SayPhonticCommand. - * - * @param text the text to say. - */ - public SayPhoneticCommand(String text) - { - super(); - this.text = text; - } - - /** - * Creates a new SayPhoneticCommand. - * - * @param text the text to say. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. - */ - public SayPhoneticCommand(String text, String escapeDigits) - { - super(); - this.text = text; - this.escapeDigits = escapeDigits; - } - - /** - * Returns the text to say. - * - * @return the text to say. - */ - public String getText() - { - return text; - } - - /** - * Sets the text to say. - * - * @param text the text to say. - */ - public void setText(String text) - { - this.text = text; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the text that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - @Override - public String buildCommand() - { - return "SAY PHONETIC " + escapeAndQuote(text) + " " - + escapeAndQuote(escapeDigits); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SayTimeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SayTimeCommand.java deleted file mode 100644 index 9285e2f0b..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SayTimeCommand.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this time except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Say a given time, returning early if any of the given DTMF digits are - * received on the channel.

- * Time is the number of seconds elapsed since 00:00:00 on January 1, 1970, - * Coordinated Universal Time (UTC).

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed or -1 on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class SayTimeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256721797012404276L; - - /** - * The time to say in seconds since 00:00:00 on January 1, 1970. - */ - private long time; - - /** - * When one of these digits is pressed the command returns. - */ - private String escapeDigits; - - /** - * Creates a new SayTimeCommand. - * - * @param time the time to say in seconds since 00:00:00 on January 1, 1970. - */ - public SayTimeCommand(long time) - { - super(); - this.time = time; - } - - /** - * Creates a new SayTimeCommand. - * - * @param time the time to say in seconds since 00:00:00 on January 1, 1970. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. - */ - public SayTimeCommand(long time, String escapeDigits) - { - super(); - this.time = time; - this.escapeDigits = escapeDigits; - } - - /** - * Returns the time to say in seconds since 00:00:00 on January 1, 1970. - * - * @return the time to say in seconds since 00:00:00 on January 1, 1970. - */ - public long getTime() - { - return time; - } - - /** - * Sets the time to say in seconds since 00:00:00 on January 1, 1970. - * - * @param time the time to say in seconds since 00:00:00 on January 1, 1970. - */ - public void setTime(long time) - { - this.time = time; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the time that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - @Override - public String buildCommand() - { - return "SAY TIME " + time + " " + escapeAndQuote(escapeDigits); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SendImageCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SendImageCommand.java deleted file mode 100644 index 0cc5c2949..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SendImageCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sends the given image on a channel.

- * Most channels do not support the transmission of images.

- * Returns 0 if image is sent, or if the channel does not support image - * transmission. Returns -1 only on error/hangup.

- * Image names should not include extensions. - * - * @author srt - * @version $Id$ - */ -public class SendImageCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3904959746380281145L; - - /** - * The name of the image to send. - */ - private String image; - - /** - * Creates a new SendImageCommand. - * - * @param image the image to send, should not include extension. - */ - public SendImageCommand(String image) - { - super(); - this.image = image; - } - - /** - * Returns the image to send. - * - * @return the image to send. - */ - public String getImage() - { - return image; - } - - /** - * Sets the image to send. - * - * @param image the image to send, should not include extension. - */ - public void setImage(String image) - { - this.image = image; - } - - @Override - public String buildCommand() - { - return "SEND IMAGE " + escapeAndQuote(image); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SendTextCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SendTextCommand.java deleted file mode 100644 index 237cd445e..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SendTextCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sends the given text on a channel.

- * Most channels do not support the transmission of text.

- * Returns 0 if text is sent, or if the channel does not support text - * transmission. Returns -1 only on error/hangup. - * - * @author srt - * @version $Id$ - */ -public class SendTextCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3904959746380281145L; - - /** - * The text to send. - */ - private String text; - - /** - * Creates a new SendTextCommand. - * - * @param text the text to send. - */ - public SendTextCommand(String text) - { - super(); - this.text = text; - } - - /** - * Returns the text to send. - * - * @return the text to send. - */ - public String getText() - { - return text; - } - - /** - * Sets the text to send. - * - * @param text the text to send. - */ - public void setText(String text) - { - this.text = text; - } - - @Override - public String buildCommand() - { - return "SEND TEXT " + escapeAndQuote(text); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetAutoHangupCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetAutoHangupCommand.java deleted file mode 100644 index e1e806340..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetAutoHangupCommand.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Cause the channel to automatically hangup at the given number of seconds in - * the future.

- * Of course it can be hungup before then as well. Setting to 0 will cause the - * autohangup feature to be disabled on this channel. - * - * @author srt - * @version $Id$ - */ -public class SetAutoHangupCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3257562923458443314L; - - /** - * The number of seconds before this channel is automatically hung up. - */ - private int time; - - /** - * Creates a new SetAutoHangupCommand. - * - * @param time the number of seconds before this channel is automatically - * hung up.

- * 0 disables the autohangup feature. - */ - public SetAutoHangupCommand(int time) - { - super(); - this.time = time; - } - - /** - * Returns the number of seconds before this channel is automatically hung - * up. - * - * @return the number of seconds before this channel is automatically hung - * up. - */ - public int getTime() - { - return time; - } - - /** - * Sets the number of seconds before this channel is automatically hung up. - * - * @param time the number of seconds before this channel is automatically - * hung up.

- * 0 disables the autohangup feature. - */ - public void setTime(int time) - { - this.time = time; - } - - @Override - public String buildCommand() - { - return "SET AUTOHANGUP " + time; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetCallerIdCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetCallerIdCommand.java deleted file mode 100644 index a78f087d1..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetCallerIdCommand.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this time except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Changes the callerid of the current channel. - * - * @author srt - * @version $Id$ - */ -public class SetCallerIdCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256721797012404276L; - - /** - * The new callerId. - */ - private String callerId; - - /** - * Creates a new SetCallerIdCommand. - * - * @param callerId the new callerId. - */ - public SetCallerIdCommand(String callerId) - { - super(); - this.callerId = callerId; - } - - /** - * Returns the new callerId. - * - * @return the new callerId. - */ - public String getCallerId() - { - return callerId; - } - - /** - * Sets the new callerId. - * - * @param callerId the new callerId. - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - @Override - public String buildCommand() - { - return "SET CALLERID " + escapeAndQuote(callerId); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetContextCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetContextCommand.java deleted file mode 100644 index e2fc923b7..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetContextCommand.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sets the context for continuation upon exiting the application. - * - * @author srt - * @version $Id$ - */ -public class SetContextCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The context for continuation upon exiting the application. - */ - private String context; - - /** - * Creates a new SetPriorityCommand. - * - * @param context the context for continuation upon exiting the application. - */ - public SetContextCommand(String context) - { - super(); - this.context = context; - } - - /** - * Returns the context for continuation upon exiting the application. - * - * @return the context for continuation upon exiting the application. - */ - public String getContext() - { - return context; - } - - /** - * Sets the context for continuation upon exiting the application. - * - * @param context the context for continuation upon exiting the application. - */ - public void setContext(String context) - { - this.context = context; - } - - @Override - public String buildCommand() - { - return "SET CONTEXT " + escapeAndQuote(context); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetExtensionCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetExtensionCommand.java deleted file mode 100644 index ef6ec34ae..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetExtensionCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sets the extension for continuation upon exiting the application. - * - * @author srt - * @version $Id$ - */ -public class SetExtensionCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The extension for continuation upon exiting the application. - */ - private String extension; - - /** - * Creates a new SetPriorityCommand. - * - * @param extension the extension for continuation upon exiting the - * application. - */ - public SetExtensionCommand(String extension) - { - super(); - this.extension = extension; - } - - /** - * Returns the extension for continuation upon exiting the application. - * - * @return the extension for continuation upon exiting the application. - */ - public String getExtension() - { - return extension; - } - - /** - * Sets the extension for continuation upon exiting the application. - * - * @param extension the extension for continuation upon exiting the - * application. - */ - public void setExtension(String extension) - { - this.extension = extension; - } - - @Override - public String buildCommand() - { - return "SET EXTENSION " + escapeAndQuote(extension); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetMusicOffCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetMusicOffCommand.java deleted file mode 100644 index e4770aee1..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetMusicOffCommand.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Turns off music on hold on the current channel.

- * Always returns 0. - * - * @author srt - * @version $Id$ - */ -public class SetMusicOffCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - - /** - * Creates a new SetMusicOffCommand. - */ - public SetMusicOffCommand() - { - super(); - } - - @Override - public String buildCommand() - { - return "SET MUSIC OFF"; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetMusicOnCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetMusicOnCommand.java deleted file mode 100644 index 0c38dac41..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetMusicOnCommand.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Turns on music on hold on the current channel.

- * Always returns 0. - * - * @author srt - * @version $Id$ - */ -public class SetMusicOnCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3762248656229053753L; - - /** - * The music on hold class to play music from. - */ - private String musicOnHoldClass; - - /** - * Creates a new SetMusicOnCommand playing music from the default music on - * hold class. - */ - public SetMusicOnCommand() - { - super(); - } - - /** - * Creates a new SetMusicOnCommand playing music from the default music on - * hold class. - * - * @param musicOnHoldClass the music on hold class to play music from. - */ - public SetMusicOnCommand(String musicOnHoldClass) - { - this.musicOnHoldClass = musicOnHoldClass; - } - - /** - * Returns the music on hold class to play music from. - * - * @return the music on hold class to play music from or null - * for the default class. - */ - public String getMusicOnHoldClass() - { - return musicOnHoldClass; - } - - /** - * Sets the music on hold class to play music from. - * - * @param musicOnHoldClass the music on hold class to play music from or - * null for the default class. - */ - public void setMusicOnHoldClass(String musicOnHoldClass) - { - this.musicOnHoldClass = musicOnHoldClass; - } - - @Override - public String buildCommand() - { - return "SET MUSIC ON" - + (musicOnHoldClass == null ? "" : " " - + escapeAndQuote(musicOnHoldClass)); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetPriorityCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetPriorityCommand.java deleted file mode 100644 index 402124425..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetPriorityCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sets the priority for continuation upon exiting the application.

- * Since Asterisk 1.2 SetPriorityCommand also supports labels. - * - * @author srt - * @version $Id$ - */ -public class SetPriorityCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The priority or label for continuation upon exiting the application. - */ - private String priority; - - /** - * Creates a new SetPriorityCommand. - * - * @param priority the priority or label for continuation upon exiting the - * application. - */ - public SetPriorityCommand(String priority) - { - super(); - this.priority = priority; - } - - /** - * Returns the priority or label for continuation upon exiting the application. - * - * @return the priority or label for continuation upon exiting the application. - */ - public String getPriority() - { - return priority; - } - - /** - * Sets the priority or label for continuation upon exiting the application. - * - * @param priority the priority or label for continuation upon exiting the - * application. - */ - public void setPriority(String priority) - { - this.priority = priority; - } - - @Override - public String buildCommand() - { - return "SET PRIORITY " + escapeAndQuote(priority); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SetVariableCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SetVariableCommand.java deleted file mode 100644 index 5c93d97e8..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SetVariableCommand.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sets the given channel varible to the given value. - * - * @author srt - * @version $Id$ - */ -public class SetVariableCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The name of the variable to set. - */ - private String variable; - - /** - * The value to set. - */ - private String value; - - /** - * Creates a new GetVariableCommand. - * - * @param variable the name of the variable to set. - * @param value the value to set. - */ - public SetVariableCommand(String variable, String value) - { - super(); - this.variable = variable; - this.value = value; - } - - /** - * Returns the name of the variable to set. - * - * @return the the name of the variable to set. - */ - public String getVariable() - { - return variable; - } - - /** - * Sets the name of the variable to set. - * - * @param variable the name of the variable to set. - */ - public void setVariable(String variable) - { - this.variable = variable; - } - - /** - * Returns the value to set. - * - * @return the value to set. - */ - public String getValue() - { - return value; - } - - /** - * Sets the value to set. - * - * @param value the value to set. - */ - public void setValue(String value) - { - this.value = value; - } - - @Override - public String buildCommand() - { - return "SET VARIABLE " + escapeAndQuote(variable) + " " - + escapeAndQuote(value); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechActivateGrammarCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechActivateGrammarCommand.java deleted file mode 100644 index be3cffccf..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechActivateGrammarCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Activates the specified grammar.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.fastagi.command.SpeechLoadGrammarCommand - * @see org.asteriskjava.fastagi.command.SpeechDeactivateGrammarCommand - * @since 1.0.0 - */ -public class SpeechActivateGrammarCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String name; - - /** - * Creates a new SpeechActivateGrammarCommand that acitvates the given grammer. - * - * @param name the name of the grammar. - */ - public SpeechActivateGrammarCommand(String name) - { - this.name = name; - } - - /** - * Returns the name of the grammar. - * - * @return the name of the grammar. - */ - public String getName() - { - return name; - } - - /** - * Sets the name of the grammar. - * - * @param name the name of the grammar. - */ - public void setName(String name) - { - this.name = name; - } - - @Override - public String buildCommand() - { - return "SPEECH ACTIVATE GRAMMAR " + escapeAndQuote(name); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechCreateCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechCreateCommand.java deleted file mode 100644 index 5ce0f0064..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechCreateCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Creates a speech object to be used by the other Speech AGI commands.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - * @see org.asteriskjava.fastagi.command.SpeechDestroyCommand - * @see org.asteriskjava.fastagi.command.SpeechLoadGrammarCommand - */ -public class SpeechCreateCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String engine; - - /** - * Creates a new SpeechCreateCommand for the given engine. - * - * @param engine the name of the speech engine to use for subsequent Speech AGI commands. - */ - public SpeechCreateCommand(String engine) - { - this.engine = engine; - } - - /** - * Returns the name of the speech engine to use for subsequent Speech AGI commands. - * - * @return the name of the speech engine to use for subsequent Speech AGI commands. - */ - public String getEngine() - { - return engine; - } - - /** - * Sets the name of the speech engine to use for subsequent Speech AGI commands. - * - * @param engine the name of the speech engine to use for subsequent Speech AGI commands. - */ - public void setEngine(String engine) - { - this.engine = engine; - } - - @Override - public String buildCommand() - { - return "SPEECH CREATE " + escapeAndQuote(engine); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechDeactivateGrammarCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechDeactivateGrammarCommand.java deleted file mode 100644 index 48106db35..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechDeactivateGrammarCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Deactivates the specified grammar.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.fastagi.command.SpeechActivateGrammarCommand - * @since 1.0.0 - */ -public class SpeechDeactivateGrammarCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String name; - - /** - * Creates a new SpeechDeactivateGrammarCommand that deacitvates the given grammer. - * - * @param name the name of the grammar. - */ - public SpeechDeactivateGrammarCommand(String name) - { - this.name = name; - } - - /** - * Returns the name of the grammar. - * - * @return the name of the grammar. - */ - public String getName() - { - return name; - } - - /** - * Sets the name of the grammar. - * - * @param name the name of the grammar. - */ - public void setName(String name) - { - this.name = name; - } - - @Override - public String buildCommand() - { - return "SPEECH DEACTIVATE GRAMMAR " + escapeAndQuote(name); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechDestroyCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechDestroyCommand.java deleted file mode 100644 index 67ef745c7..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechDestroyCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Destroys a speech object previously created by a {@link SpeechCreateCommand}.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - * @see org.asteriskjava.fastagi.command.SpeechCreateCommand - */ -public class SpeechDestroyCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - /** - * Creates a new empty SpeechDestroyCommand. - */ - public SpeechDestroyCommand() - { - super(); - } - - @Override - public String buildCommand() - { - return "SPEECH DESTROY"; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechLoadGrammarCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechLoadGrammarCommand.java deleted file mode 100644 index 177020e8f..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechLoadGrammarCommand.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Loads the specified grammar as the specified name.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.fastagi.command.SpeechUnloadGrammarCommand - * @see org.asteriskjava.fastagi.command.SpeechActivateGrammarCommand - * @since 1.0.0 - */ -public class SpeechLoadGrammarCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String name; - private String path; - - /** - * Creates a new SpeechLoadGrammarCommand that loads the grammer from the given path and - * makes it available under the given name. - * - * @param name the name of the grammar, used to activate the gammer later. - * @param path the path to the grammar. - */ - public SpeechLoadGrammarCommand(String name, String path) - { - this.name = name; - this.path = path; - } - - /** - * Returns the name of the grammar. - * - * @return the name of the grammar. - */ - public String getName() - { - return name; - } - - /** - * Sets the name of the grammar, used to activate the gammer later. - * - * @param name the name of the grammar. - */ - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the path to the grammar. - * - * @return the path to the grammar. - */ - public String getPath() - { - return path; - } - - /** - * Sets the path to the grammar. - * - * @param path the path to the grammar. - */ - public void setPath(String path) - { - this.path = path; - } - - @Override - public String buildCommand() - { - return "SPEECH LOAD GRAMMAR " + escapeAndQuote(name) + " " + escapeAndQuote(path); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechRecognizeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechRecognizeCommand.java deleted file mode 100644 index ffb1b2dd5..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechRecognizeCommand.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Plays back given prompt while listening for speech and dtmf.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class SpeechRecognizeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - private String prompt; - private int timeout; - private int offset; - - /** - * Creates a new SpeechRecognizeCommand that plays the given prompt and listens for for speech and dtmf. - * - * @param prompt the prompt to play. - * @param timeout the maximum recognition time in milliseconds. - */ - public SpeechRecognizeCommand(String prompt, int timeout) - { - this.prompt = prompt; - this.timeout = timeout; - this.offset = 0; - } - - /** - * Creates a new SpeechRecognizeCommand that plays the given prompt and listens for for speech and dtmf. - * - * @param prompt the prompt to play. - * @param timeout the maximum recognition time in milliseconds. - * @param offset the offset samples to skip when playing the prompt. - */ - public SpeechRecognizeCommand(String prompt, int timeout, int offset) - { - this.prompt = prompt; - this.timeout = timeout; - this.offset = offset; - } - - /** - * Returns the prompt to play. - * - * @return the prompt to play. - */ - public String getPrompt() - { - return prompt; - } - - /** - * Sets the prompt to play. - * - * @param prompt the prompt to play. - */ - public void setPrompt(String prompt) - { - this.prompt = prompt; - } - - /** - * Returns the maximum recognition time in milliseconds. - * - * @return the maximum recognition time in milliseconds. - */ - public int getTimeout() - { - return timeout; - } - - /** - * Sets the maximum recognition time in milliseconds. - * - * @param timeout the maximum recognition time in milliseconds, or -1 for no timeout. - */ - public void setTimeout(int timeout) - { - this.timeout = timeout; - } - - /** - * Returns the offset samples to skip when playing the prompt. - * - * @return the offset samples to skip when playing the prompt. - */ - public int getOffset() - { - return offset; - } - - /** - * Sets the offset samples to skip when playing the prompt. - * - * @param offset the offset samples to skip when playing the prompt. - */ - public void setOffset(int offset) - { - this.offset = offset; - } - - @Override - public String buildCommand() - { - return "SPEECH RECOGNIZE " + escapeAndQuote(prompt) + " " + timeout + " " + offset; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechSetCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechSetCommand.java deleted file mode 100644 index 0f300747a..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechSetCommand.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sets a speech engine specific setting.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class SpeechSetCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String name; - private String value; - - /** - * Creates a new SpeechSetCommand that sets the setting indicated by name to the given value. - * - * @param name the name of the setting to set. - * @param value the value to set. - */ - public SpeechSetCommand(String name, String value) - { - this.name = name; - this.value = value; - } - - /** - * Returns the name of the setting to set. - * - * @return the name of the setting to set. - */ - public String getName() - { - return name; - } - - /** - * Sets the name of the setting to set. - * - * @param name the name of the setting to set. - */ - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the value to set. - * - * @return the value to set. - */ - public String getValue() - { - return value; - } - - /** - * Sets the value to set. - * - * @param value the value to set. - */ - public void setValue(String value) - { - this.value = value; - } - - @Override - public String buildCommand() - { - return "SPEECH SET " + escapeAndQuote(name) + " " + escapeAndQuote(value); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/SpeechUnloadGrammarCommand.java b/src/main/java/org/asteriskjava/fastagi/command/SpeechUnloadGrammarCommand.java deleted file mode 100644 index 1d1ca0bc6..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/SpeechUnloadGrammarCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Unloads the specified grammar.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @see SpeechLoadGrammarCommand - * @since 1.0.0 - */ -public class SpeechUnloadGrammarCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String name; - - /** - * Creates a new SpeechUnloadGrammarCommand that unloads the given grammer. - * - * @param name the name of the grammar. - */ - public SpeechUnloadGrammarCommand(String name) - { - this.name = name; - } - - /** - * Returns the name of the grammar. - * - * @return the name of the grammar. - */ - public String getName() - { - return name; - } - - /** - * Sets the name of the grammar. - * - * @param name the name of the grammar. - */ - public void setName(String name) - { - this.name = name; - } - - @Override - public String buildCommand() - { - return "SPEECH UNLOAD GRAMMAR " + escapeAndQuote(name); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/command/StreamFileCommand.java b/src/main/java/org/asteriskjava/fastagi/command/StreamFileCommand.java deleted file mode 100644 index 6bef5f529..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/StreamFileCommand.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Plays the given file, allowing playback to be interrupted by the given - * digits, if any. - *

- * If offset is provided then the audio will seek to sample offset before play - * starts. - *

- * Returns 0 if playback completes without a digit being pressed, or the ASCII - * numerical value of the digit if one was pressed, or -1 on error or if the - * channel was disconnected. - *

- * Remember, filename follows the same conventions and uses the same file path - * as dialplan applications like Playback or Background. The file extension must - * not be included in the filename. - * - * @author srt - * @version $Id$ - */ -public class StreamFileCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3978141041352128820L; - - /** - * The name of the file to stream. - */ - private String file; - - /** - * When one of these digits is pressed while streaming the command returns. - */ - private String escapeDigits; - - /** - * The offset samples to skip before streaming. - */ - private int offset; - - /** - * Creates a new StreamFileCommand, streaming from the beginning. - * - * @param file the name of the file to stream, must not include extension. - */ - public StreamFileCommand(String file) - { - super(); - this.file = file; - this.offset = -1; - } - - /** - * Creates a new StreamFileCommand, streaming from the beginning. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. - */ - public StreamFileCommand(String file, String escapeDigits) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.offset = -1; - } - - /** - * Creates a new StreamFileCommand, streaming from the given offset. - * - * @param file the name of the file to stream, must not include extension. - * @param escapeDigits contains the digits that allow the user to interrupt - * this command. Maybe null if you don't want the - * user to interrupt. - * @param offset the offset samples to skip before streaming. - */ - public StreamFileCommand(String file, String escapeDigits, int offset) - { - super(); - this.file = file; - this.escapeDigits = escapeDigits; - this.offset = offset; - } - - /** - * Returns the name of the file to stream. - * - * @return the name of the file to stream. - */ - public String getFile() - { - return file; - } - - /** - * Sets the name of the file to stream. - * - * @param file the name of the file to stream, must not include extension. - */ - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the digits that allow the user to interrupt this command. - * - * @return the digits that allow the user to interrupt this command. - */ - public String getEscapeDigits() - { - return escapeDigits; - } - - /** - * Sets the digits that allow the user to interrupt this command. - * - * @param escapeDigits the digits that allow the user to interrupt this - * command or null for none. - */ - public void setEscapeDigits(String escapeDigits) - { - this.escapeDigits = escapeDigits; - } - - /** - * Returns the offset samples to skip before streaming. - * - * @return the offset samples to skip before streaming. - */ - public int getOffset() - { - return offset; - } - - /** - * Sets the offset samples to skip before streaming. - * - * @param offset the offset samples to skip before streaming. - */ - public void setOffset(int offset) - { - this.offset = offset; - } - - @Override - public String buildCommand() - { - return "STREAM FILE " + escapeAndQuote(file) + " " - + escapeAndQuote(escapeDigits) - + (offset < 0 ? "" : " " + offset); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/TddModeCommand.java b/src/main/java/org/asteriskjava/fastagi/command/TddModeCommand.java deleted file mode 100644 index 6bdfe6435..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/TddModeCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Enable/Disable TDD transmission/reception on a channel.

- * Returns 1 if successful, or 0 if channel is not TDD-capable. - * - * @author srt - * @version $Id$ - */ -public class TddModeCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3258411746401268532L; - - /** - * The mode to set. - */ - private String mode; - - /** - * Creates a new TDDModeCommand. - * - * @param mode the mode to set, this can be one of "on", "off", "mate" or - * "tdd". - */ - public TddModeCommand(String mode) - { - super(); - this.mode = mode; - } - - /** - * Returns the mode to set. - * - * @return the mode to set. - */ - public String getMode() - { - return mode; - } - - /** - * Sets the mode to set. - * - * @param mode the mode to set, this can be one of "on", "off", "mate" or - * "tdd". - */ - public void setMode(String mode) - { - this.mode = mode; - } - - @Override - public String buildCommand() - { - return "TDD MODE " + escapeAndQuote(mode); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/VerboseCommand.java b/src/main/java/org/asteriskjava/fastagi/command/VerboseCommand.java deleted file mode 100644 index 2fdd1fd08..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/VerboseCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Sends a message to the Asterisk console via the verbose message system.

- * Always returns 1. - * - * @author srt - * @version $Id$ - */ -public class VerboseCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256719598056387384L; - - /** - * The message to send. - */ - private String message; - - /** - * The verbosity level to use.

- * Must be in [1..4] - */ - private int level; - - /** - * Creates a new VerboseCommand. - * - * @param message the message to send. - * @param level the verbosity level to use.

- * Must be in [1..4] - */ - public VerboseCommand(String message, int level) - { - super(); - this.message = message; - this.level = level; - } - - /** - * Returns the message to send. - * - * @return the message to send. - */ - public String getMessage() - { - return message; - } - - /** - * Sets the message to send. - * - * @param message the message to send. - */ - public void setMessage(String message) - { - this.message = message; - } - - /** - * Returns the level to use. - * - * @return the level to use. - */ - public int getLevel() - { - return level; - } - - /** - * Sets the level to use.

- * Must be in in [1..4]. - * - * @param level the level to use. - */ - public void setLevel(int level) - { - this.level = level; - } - - @Override - public String buildCommand() - { - return "VERBOSE " + escapeAndQuote(message) + " " + level; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/WaitForDigitCommand.java b/src/main/java/org/asteriskjava/fastagi/command/WaitForDigitCommand.java deleted file mode 100644 index ce9971986..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/WaitForDigitCommand.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -/** - * Waits up to 'timeout' milliseconds for channel to receive a DTMF digit.

- * Returns -1 on channel failure, 0 if no digit is received in the timeout, or - * the numerical value of the ascii of the digit if one is received. Use -1 for - * the timeout value if you desire the call to block indefinitely. - * - * @author srt - * @version $Id$ - */ -public class WaitForDigitCommand extends AbstractAgiCommand -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3257562923458443314L; - - /** - * The milliseconds to wait for the channel to receive a DTMF digit. - */ - private long timeout; - - /** - * Creates a new WaitForDigitCommand with a default timeout of -1 which - * blocks the channel indefinitely. - */ - public WaitForDigitCommand() - { - super(); - this.timeout = -1; - } - - /** - * Creates a new WaitForDigitCommand. - * - * @param timeout the milliseconds to wait for the channel to receive a DTMF - * digit. - */ - public WaitForDigitCommand(long timeout) - { - super(); - this.timeout = timeout; - } - - /** - * Returns the milliseconds to wait for the channel to receive a DTMF digit. - * - * @return the milliseconds to wait for the channel to receive a DTMF digit. - */ - public long getTimeout() - { - return timeout; - } - - /** - * Sets the milliseconds to wait for the channel to receive a DTMF digit. - * - * @param timeout the milliseconds to wait for the channel to receive a DTMF - * digit. - */ - public void setTimeout(long timeout) - { - this.timeout = timeout; - } - - @Override - public String buildCommand() - { - return "WAIT FOR DIGIT " + timeout; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/command/package.html b/src/main/java/org/asteriskjava/fastagi/command/package.html deleted file mode 100644 index 391c66946..000000000 --- a/src/main/java/org/asteriskjava/fastagi/command/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides classes that represent the standard commands that can be sent - to an Asterisk server via the FastAGI.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/internal/.gitignore b/src/main/java/org/asteriskjava/fastagi/internal/.gitignore deleted file mode 100644 index df400e5e4..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -/AgiChannelFactory.class -/AgiChannelImpl.class -/AgiConnectionHandler.class -/AgiReader.class -/AgiReplyImpl.class -/AgiRequestImpl.class -/AgiWriter.class -/AsyncAgiConnectionHandler.class -/AsyncAgiReader.class -/AsyncAgiWriter.class -/DefaultAgiChannelFactory.class -/FastAgiConnectionHandler.class -/FastAgiReader.class -/FastAgiWriter.class diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AgiChannelImpl.java b/src/main/java/org/asteriskjava/fastagi/internal/AgiChannelImpl.java deleted file mode 100644 index ba0171f83..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AgiChannelImpl.java +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.AgiSpeechException; -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.InvalidCommandSyntaxException; -import org.asteriskjava.fastagi.InvalidOrUnknownCommandException; -import org.asteriskjava.fastagi.SpeechRecognitionResult; -import org.asteriskjava.fastagi.command.AgiCommand; -import org.asteriskjava.fastagi.command.AnswerCommand; -import org.asteriskjava.fastagi.command.BridgeCommand; -import org.asteriskjava.fastagi.command.ChannelStatusCommand; -import org.asteriskjava.fastagi.command.ConfbridgeCommand; -import org.asteriskjava.fastagi.command.ControlStreamFileCommand; -import org.asteriskjava.fastagi.command.DatabaseDelCommand; -import org.asteriskjava.fastagi.command.DatabaseDelTreeCommand; -import org.asteriskjava.fastagi.command.DatabaseGetCommand; -import org.asteriskjava.fastagi.command.DatabasePutCommand; -import org.asteriskjava.fastagi.command.DialCommand; -import org.asteriskjava.fastagi.command.ExecCommand; -import org.asteriskjava.fastagi.command.GetDataCommand; -import org.asteriskjava.fastagi.command.GetFullVariableCommand; -import org.asteriskjava.fastagi.command.GetOptionCommand; -import org.asteriskjava.fastagi.command.GetVariableCommand; -import org.asteriskjava.fastagi.command.GosubCommand; -import org.asteriskjava.fastagi.command.HangupCommand; -import org.asteriskjava.fastagi.command.MeetmeCommand; -import org.asteriskjava.fastagi.command.QueueCommand; -import org.asteriskjava.fastagi.command.RecordFileCommand; -import org.asteriskjava.fastagi.command.SayAlphaCommand; -import org.asteriskjava.fastagi.command.SayDateTimeCommand; -import org.asteriskjava.fastagi.command.SayDigitsCommand; -import org.asteriskjava.fastagi.command.SayNumberCommand; -import org.asteriskjava.fastagi.command.SayPhoneticCommand; -import org.asteriskjava.fastagi.command.SayTimeCommand; -import org.asteriskjava.fastagi.command.SetAutoHangupCommand; -import org.asteriskjava.fastagi.command.SetCallerIdCommand; -import org.asteriskjava.fastagi.command.SetContextCommand; -import org.asteriskjava.fastagi.command.SetExtensionCommand; -import org.asteriskjava.fastagi.command.SetMusicOffCommand; -import org.asteriskjava.fastagi.command.SetMusicOnCommand; -import org.asteriskjava.fastagi.command.SetPriorityCommand; -import org.asteriskjava.fastagi.command.SetVariableCommand; -import org.asteriskjava.fastagi.command.SpeechActivateGrammarCommand; -import org.asteriskjava.fastagi.command.SpeechCreateCommand; -import org.asteriskjava.fastagi.command.SpeechDeactivateGrammarCommand; -import org.asteriskjava.fastagi.command.SpeechDestroyCommand; -import org.asteriskjava.fastagi.command.SpeechLoadGrammarCommand; -import org.asteriskjava.fastagi.command.SpeechRecognizeCommand; -import org.asteriskjava.fastagi.command.SpeechSetCommand; -import org.asteriskjava.fastagi.command.SpeechUnloadGrammarCommand; -import org.asteriskjava.fastagi.command.StreamFileCommand; -import org.asteriskjava.fastagi.command.VerboseCommand; -import org.asteriskjava.fastagi.command.WaitForDigitCommand; -import org.asteriskjava.fastagi.reply.AgiReply; - -/** - * Default implementation of the AgiChannel interface. - * - * @author srt - * @version $Id$ - */ -public class AgiChannelImpl implements AgiChannel -{ - private final AgiRequest request; - private final AgiWriter agiWriter; - private final AgiReader agiReader; - - private AgiReply lastReply; - - protected AgiChannelImpl(AgiRequest request, AgiWriter agiWriter, AgiReader agiReader) - { - this.request = request; - this.agiWriter = agiWriter; - this.agiReader = agiReader; - this.lastReply = null; - } - - public String getName() - { - return request.getChannel(); - } - - public String getUniqueId() - { - return request.getUniqueId(); - } - - public AgiReply getLastReply() - { - return lastReply; - } - - public synchronized AgiReply sendCommand(AgiCommand command) throws AgiException - { - agiWriter.sendCommand(command); - lastReply = agiReader.readReply(); - - if (lastReply.getStatus() == AgiReply.SC_INVALID_OR_UNKNOWN_COMMAND) - { - throw new InvalidOrUnknownCommandException(command.buildCommand()); - } - if (lastReply.getStatus() == AgiReply.SC_DEAD_CHANNEL) - { - throw new AgiHangupException(); - } - if (lastReply.getStatus() == AgiReply.SC_INVALID_COMMAND_SYNTAX) - { - throw new InvalidCommandSyntaxException(lastReply.getSynopsis(), lastReply.getUsage()); - } - - return lastReply; - } - - public void answer() throws AgiException - { - sendCommand(new AnswerCommand()); - } - - public void hangup() throws AgiException - { - sendCommand(new HangupCommand()); - } - - public void setAutoHangup(int time) throws AgiException - { - sendCommand(new SetAutoHangupCommand(time)); - } - - public void setCallerId(String callerId) throws AgiException - { - sendCommand(new SetCallerIdCommand(callerId)); - } - - public void playMusicOnHold() throws AgiException - { - sendCommand(new SetMusicOnCommand()); - } - - public void playMusicOnHold(String musicOnHoldClass) throws AgiException - { - sendCommand(new SetMusicOnCommand(musicOnHoldClass)); - } - - public void stopMusicOnHold() throws AgiException - { - sendCommand(new SetMusicOffCommand()); - } - - public int getChannelStatus() throws AgiException - { - sendCommand(new ChannelStatusCommand()); - return lastReply.getResultCode(); - } - - public String getData(String file) throws AgiException - { - sendCommand(new GetDataCommand(file)); - return lastReply.getResult(); - } - - public String getData(String file, long timeout) throws AgiException - { - sendCommand(new GetDataCommand(file, timeout)); - return lastReply.getResult(); - } - - public String getData(String file, long timeout, int maxDigits) throws AgiException - { - sendCommand(new GetDataCommand(file, timeout, maxDigits)); - return lastReply.getResult(); - } - - public char getOption(String file, String escapeDigits) throws AgiException - { - sendCommand(new GetOptionCommand(file, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public char getOption(String file, String escapeDigits, long timeout) throws AgiException - { - sendCommand(new GetOptionCommand(file, escapeDigits, timeout)); - return lastReply.getResultCodeAsChar(); - } - - public int exec(String application) throws AgiException - { - sendCommand(new ExecCommand(application)); - return lastReply.getResultCode(); - } - - public int exec(String application, String... options) throws AgiException - { - sendCommand(new ExecCommand(application, options)); - return lastReply.getResultCode(); - } - - public void setContext(String context) throws AgiException - { - sendCommand(new SetContextCommand(context)); - } - - public void setExtension(String extension) throws AgiException - { - sendCommand(new SetExtensionCommand(extension)); - } - - public void setPriority(String priority) throws AgiException - { - sendCommand(new SetPriorityCommand(priority)); - } - - public void streamFile(String file) throws AgiException - { - sendCommand(new StreamFileCommand(file)); - } - - public char streamFile(String file, String escapeDigits) throws AgiException - { - sendCommand(new StreamFileCommand(file, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public char streamFile(String file, String escapeDigits, int offset) throws AgiException - { - sendCommand(new StreamFileCommand(file, escapeDigits, offset)); - return lastReply.getResultCodeAsChar(); - } - - public void sayDigits(String digits) throws AgiException - { - sendCommand(new SayDigitsCommand(digits)); - } - - public char sayDigits(String digits, String escapeDigits) throws AgiException - { - sendCommand(new SayDigitsCommand(digits, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public void sayNumber(String number) throws AgiException - { - sendCommand(new SayNumberCommand(number)); - } - - public char sayNumber(String number, String escapeDigits) throws AgiException - { - sendCommand(new SayNumberCommand(number, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public void sayPhonetic(String text) throws AgiException - { - sendCommand(new SayPhoneticCommand(text)); - } - - public char sayPhonetic(String text, String escapeDigits) throws AgiException - { - sendCommand(new SayPhoneticCommand(text, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public void sayAlpha(String text) throws AgiException - { - sendCommand(new SayAlphaCommand(text)); - } - - public char sayAlpha(String text, String escapeDigits) throws AgiException - { - sendCommand(new SayAlphaCommand(text, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public void sayTime(long time) throws AgiException - { - sendCommand(new SayTimeCommand(time)); - } - - public char sayTime(long time, String escapeDigits) throws AgiException - { - sendCommand(new SayTimeCommand(time, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public String getVariable(String name) throws AgiException - { - sendCommand(new GetVariableCommand(name)); - if (lastReply.getResultCode() != 1) - { - return null; - } - return lastReply.getExtra(); - } - - public void setVariable(String name, String value) throws AgiException - { - sendCommand(new SetVariableCommand(name, value)); - } - - public char waitForDigit(int timeout) throws AgiException - { - sendCommand(new WaitForDigitCommand(timeout)); - return lastReply.getResultCodeAsChar(); - } - - public String getFullVariable(String name) throws AgiException - { - sendCommand(new GetFullVariableCommand(name)); - if (lastReply.getResultCode() != 1) - { - return null; - } - return lastReply.getExtra(); - } - - public String getFullVariable(String name, String channel) throws AgiException - { - sendCommand(new GetFullVariableCommand(name, channel)); - if (lastReply.getResultCode() != 1) - { - return null; - } - return lastReply.getExtra(); - } - - public char sayDateTime(long time, String escapeDigits, String format, String timezone) throws AgiException - { - sendCommand(new SayDateTimeCommand(time, escapeDigits, format, timezone)); - return lastReply.getResultCodeAsChar(); - } - - public char sayDateTime(long time, String escapeDigits, String format) throws AgiException - { - sendCommand(new SayDateTimeCommand(time, escapeDigits, format)); - return lastReply.getResultCodeAsChar(); - } - - public char sayDateTime(long time, String escapeDigits) throws AgiException - { - sendCommand(new SayDateTimeCommand(time, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public void sayDateTime(long time) throws AgiException - { - sendCommand(new SayDateTimeCommand(time)); - } - - public String databaseGet(String family, String key) throws AgiException - { - sendCommand(new DatabaseGetCommand(family, key)); - if (lastReply.getResultCode() != 1) - { - return null; - } - return lastReply.getExtra(); - } - - public void databasePut(String family, String key, String value) throws AgiException - { - sendCommand(new DatabasePutCommand(family, key, value)); - } - - public void databaseDel(String family, String key) throws AgiException - { - sendCommand(new DatabaseDelCommand(family, key)); - } - - public void databaseDelTree(String family) throws AgiException - { - sendCommand(new DatabaseDelTreeCommand(family)); - } - - public void databaseDelTree(String family, String keytree) throws AgiException - { - sendCommand(new DatabaseDelTreeCommand(family, keytree)); - } - - public void verbose(String message, int level) throws AgiException - { - sendCommand(new VerboseCommand(message, level)); - } - - public char recordFile(String file, String format, String escapeDigits, int timeout) throws AgiException - { - sendCommand(new RecordFileCommand(file, format, escapeDigits, timeout)); - return lastReply.getResultCodeAsChar(); - } - - public char recordFile(String file, String format, String escapeDigits, int timeout, int offset, boolean beep, - int maxSilence) throws AgiException - { - sendCommand(new RecordFileCommand(file, format, escapeDigits, timeout, offset, beep, maxSilence)); - return lastReply.getResultCodeAsChar(); - } - - public void controlStreamFile(String file) throws AgiException - { - sendCommand(new ControlStreamFileCommand(file)); - } - - public char controlStreamFile(String file, String escapeDigits) throws AgiException - { - sendCommand(new ControlStreamFileCommand(file, escapeDigits)); - return lastReply.getResultCodeAsChar(); - } - - public char controlStreamFile(String file, String escapeDigits, int offset) throws AgiException - { - sendCommand(new ControlStreamFileCommand(file, escapeDigits, offset)); - return lastReply.getResultCodeAsChar(); - } - - public char controlStreamFile(String file, String escapeDigits, int offset, String forwardDigit, String rewindDigit, - String pauseDigit) throws AgiException - { - sendCommand(new ControlStreamFileCommand(file, escapeDigits, offset, forwardDigit, rewindDigit, pauseDigit)); - return lastReply.getResultCodeAsChar(); - } - - public void speechCreate() throws AgiException - { - speechCreate(""); - } - - public void speechCreate(String engine) throws AgiException - { - sendCommand(new SpeechCreateCommand(engine)); - if (lastReply.getResultCode() != 1) - { - if (engine == null || "".equals(engine)) - { - throw new AgiSpeechException("Speech object for default engine cannot be created"); - } - throw new AgiSpeechException("Speech object for engine '" + engine + "' cannot be created"); - } - } - - public void speechSet(String name, String value) throws AgiException - { - sendCommand(new SpeechSetCommand(name, value)); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Setting '" + name + "' cannot be set to '" + value + "'"); - } - } - - public void speechDestroy() throws AgiException - { - sendCommand(new SpeechDestroyCommand()); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Speech object cannot be destroyed"); - } - } - - public void speechLoadGrammar(String name, String path) throws AgiException - { - sendCommand(new SpeechLoadGrammarCommand(name, path)); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Grammar '" + name + "' cannot be loaded from '" + path + "'"); - } - } - - public void speechUnloadGrammar(String name) throws AgiException - { - sendCommand(new SpeechUnloadGrammarCommand(name)); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Grammar '" + name + "' cannot be unloaded"); - } - } - - public void speechActivateGrammar(String name) throws AgiException - { - sendCommand(new SpeechActivateGrammarCommand(name)); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Grammar '" + name + "' cannot be activated"); - } - } - - public void speechDeactivateGrammar(String name) throws AgiException - { - sendCommand(new SpeechDeactivateGrammarCommand(name)); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Grammar '" + name + "' cannot be deactivated"); - } - } - - public SpeechRecognitionResult speechRecognize(String prompt, int timeout) throws AgiException - { - return speechRecognize(new SpeechRecognizeCommand(prompt, timeout)); - } - - public SpeechRecognitionResult speechRecognize(String prompt, int timeout, int offset) throws AgiException - { - return speechRecognize(new SpeechRecognizeCommand(prompt, timeout, offset)); - } - - private SpeechRecognitionResult speechRecognize(SpeechRecognizeCommand command) throws AgiException - { - sendCommand(command); - if (lastReply.getResultCode() != 1) - { - throw new AgiSpeechException("Cannot recognize speech"); - } - - if ("hangup".equals(lastReply.getExtra())) - { - throw new AgiHangupException(); - } - final AgiReply speechRecognizeReply = lastReply; - return new SpeechRecognitionResult(speechRecognizeReply); - } - - public void continueAt(String context, String extension, String priority) throws AgiException - { - setContext(context); - setExtension(extension); - setPriority(priority); - } - - public void gosub(String context, String extension, String priority) throws AgiException - { - sendCommand(new GosubCommand(context, extension, priority)); - } - - public void gosub(String context, String extension, String priority, String... arguments) throws AgiException - { - sendCommand(new GosubCommand(context, extension, priority, arguments)); - } - - public AgiRequest getInternalAgiRequest() - { - return request; - } - - @Override - public void confbridge(String room, String profile) throws AgiException - { - sendCommand(new ConfbridgeCommand(room, profile)); - - } - - @Override - public void meetme(String room, String options) throws AgiException - { - sendCommand(new MeetmeCommand(room, options)); - - } - - @Override - public void dial(String target, int timeout, String options) throws AgiException - { - sendCommand(new DialCommand(target, timeout, options)); - - } - - @Override - public void bridge(String channelName, String options) throws AgiException - { - sendCommand(new BridgeCommand(channelName, options)); - - } - - @Override - public void queue(String queue) throws AgiException - { - sendCommand(new QueueCommand(queue)); - - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AgiConnectionHandler.java b/src/main/java/org/asteriskjava/fastagi/internal/AgiConnectionHandler.java deleted file mode 100644 index 3d20b8626..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AgiConnectionHandler.java +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiChannelFactory; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.AgiScript; -import org.asteriskjava.fastagi.MappingStrategy; -import org.asteriskjava.fastagi.NamedAgiScript; -import org.asteriskjava.fastagi.command.VerboseCommand; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * An AgiConnectionHandler is created and run by the AgiServer whenever a new - * AGI connection from an Asterisk Server is received. - *
- * It reads the request using an AgiReader and runs the AgiScript configured to - * handle this type of request. Finally it closes the AGI connection. - * - * @author srt - * @version $Id$ - */ -public abstract class AgiConnectionHandler implements Runnable -{ - private static final String AJ_AGISTATUS_VARIABLE = "AJ_AGISTATUS"; - private static final String AJ_AGISTATUS_NOT_FOUND = "NOT_FOUND"; - private static final String AJ_AGISTATUS_SUCCESS = "SUCCESS"; - private static final String AJ_AGISTATUS_FAILED = "FAILED"; - private static final ThreadLocal channel = new ThreadLocal<>(); - private final Log logger = LogFactory.getLog(getClass()); - private boolean ignoreMissingScripts = false; - private AgiScript script = null; - private AgiChannelFactory agiChannelFactory; - - - public static final ConcurrentMap AGI_CONNECTION_HANDLERS = - new ConcurrentHashMap<>(32); - - /** - * The strategy to use to determine which script to run. - */ - private final MappingStrategy mappingStrategy; - - /** - * Creates a new AGIConnectionHandler to handle the given socket connection. - * - * @param mappingStrategy the strategy to use to determine which script to run. - * @param agiChannelFactory the AgiFactory, that is used to create new AgiChannel objects. - */ - protected AgiConnectionHandler(MappingStrategy mappingStrategy, AgiChannelFactory agiChannelFactory) - { - if (mappingStrategy == null) - { - throw new IllegalArgumentException("MappingStrategy must not be null"); - } - if (agiChannelFactory == null) - { - throw new IllegalArgumentException("AgiChannelFactory must not be null"); - } - - this.agiChannelFactory = agiChannelFactory; - this.mappingStrategy = mappingStrategy; - } - - protected boolean isIgnoreMissingScripts() - { - return ignoreMissingScripts; - } - - protected void setIgnoreMissingScripts(boolean ignoreMissingScripts) - { - this.ignoreMissingScripts = ignoreMissingScripts; - } - - protected AgiScript getScript() - { - return script; - } - - protected abstract AgiReader createReader(); - - protected abstract AgiWriter createWriter(); - - /** - * Release any open resources like closing a socket. - */ - public abstract void release(); - - @Override public void run() { - AgiChannel channel = null; - - try - { - AgiReader reader; - AgiWriter writer; - AgiRequest request; - - reader = createReader(); - writer = createWriter(); - - request = reader.readRequest(); - channel = this.agiChannelFactory.createAgiChannel(request, writer, reader); - - AgiConnectionHandler.channel.set(channel); - - if (mappingStrategy != null) - { - script = mappingStrategy.determineScript(request, channel); - } - - if (script == null && !ignoreMissingScripts) - { - final String errorMessage; - - errorMessage = "No script configured for URL '" + request.getRequestURL() + "' (script '" + request.getScript() + "')"; - logger.error(errorMessage); - - setStatusVariable(channel, AJ_AGISTATUS_NOT_FOUND); - logToAsterisk(channel, errorMessage); - } - else if (script != null) { - AGI_CONNECTION_HANDLERS.put(this, channel); - runScript(script, request, channel); - } - } - catch (AgiException e) - { - setStatusVariable(channel, AJ_AGISTATUS_FAILED); - logger.error("AgiException while handling request", e); - } - catch (Exception e) - { - setStatusVariable(channel, AJ_AGISTATUS_FAILED); - logger.error("Unexpected Exception while handling request", e); - } - finally { - AGI_CONNECTION_HANDLERS.remove(this); - AgiConnectionHandler.channel.set(null); - release(); - } - }//run - - private void runScript(AgiScript script, AgiRequest request, AgiChannel channel) - { - String threadName; - threadName = Thread.currentThread().getName(); - - logger.info("Begin AgiScript " + getScriptName(script) + " on " + threadName); - try - { - script.service(request, channel); - setStatusVariable(channel, AJ_AGISTATUS_SUCCESS); - } - catch (AgiException e) - { - logger.error("AgiException running AgiScript " + getScriptName(script) + " on " + threadName, e); - setStatusVariable(channel, AJ_AGISTATUS_FAILED); - } - catch (Exception e) - { - logger.error("Exception running AgiScript " + getScriptName(script) + " on " + threadName, e); - setStatusVariable(channel, AJ_AGISTATUS_FAILED); - } - logger.info("End AgiScript " + getScriptName(script) + " on " + threadName); - } - - protected String getScriptName(AgiScript script) - { - if (script == null) - { - return null; - } - - if (script instanceof NamedAgiScript) - { - return ((NamedAgiScript) script).getName(); - } - return script.getClass().getName(); - } - - private void setStatusVariable(AgiChannel channel, String value) - { - if (channel == null) - { - return; - } - - try - { - channel.setVariable(AJ_AGISTATUS_VARIABLE, value); - } - catch (Exception e) // NOPMD - { - // swallow - } - } - - private void logToAsterisk(AgiChannel channel, String message) - { - if (channel == null) - { - return; - } - - try - { - channel.sendCommand(new VerboseCommand(message, 1)); - } - catch (Exception e) // NOPMD - { - // swallow - } - } - - /** - * Returns the AgiChannel associated with the current thread. - * - * @return the AgiChannel associated with the current thread or - * null if none is associated. - */ - public static AgiChannel getChannel() - { - return AgiConnectionHandler.channel.get(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AgiReplyImpl.java b/src/main/java/org/asteriskjava/fastagi/internal/AgiReplyImpl.java deleted file mode 100644 index 68fd13d06..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AgiReplyImpl.java +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.asteriskjava.fastagi.reply.AgiReply; - -/** - * Default implementation of the AgiReply interface. - * - * @author srt - * @version $Id$ - */ -public class AgiReplyImpl implements AgiReply -{ - private static final Pattern STATUS_PATTERN = Pattern.compile("^(\\d{3})[ -]"); - private static final Pattern RESULT_PATTERN = Pattern.compile("^200 result=(\\S+)"); - private static final Pattern PARENTHESIS_PATTERN = Pattern.compile("^200 result=\\S* +\\((.*)\\)"); - private static final Pattern ADDITIONAL_ATTRIBUTES_PATTERN = Pattern.compile("^200 result=\\S* +(\\(.*\\) )?(.+)$"); - private static final Pattern SYNOPSIS_PATTERN = Pattern.compile("^\\s*Usage:\\s*(.*)\\s*$"); - private static final String END_OF_PROPER_USAGE = "520 End of proper usage."; - - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 3256727294671337012L; - - private List lines; - private String firstLine; - - /** - * The result, that is the part directly following the "result=" string. - */ - private String result; - - /** - * The status code. - */ - private Integer status; - - /** - * Additional attributes contained in this reply, for example endpos. - */ - private Map attributes; - - /** - * The contents of the parenthesis. - */ - private String extra; - - /** - * In case of status == 520 (invalid command syntax) this attribute contains - * the synopsis of the command. - */ - private String synopsis; - - /** - * In case of status == 520 (invalid command syntax) this attribute contains - * the usage of the command. - */ - private String usage; - - AgiReplyImpl() - { - super(); - this.status = null; - } - - AgiReplyImpl(List lines) - { - this(); - if (lines != null) - { - this.lines = new ArrayList<>(lines); - if (!lines.isEmpty()) - { - firstLine = lines.get(0); - } - } - } - - public String getFirstLine() - { - return firstLine; - } - - public List getLines() - { - return lines; - } - - public int getResultCode() - { - String result; - - result = getResult(); - if (result == null) - { - return -1; - } - - try - { - return Integer.parseInt(result); - } - catch (NumberFormatException e) - { - return -1; - } - } - - public char getResultCodeAsChar() - { - int resultCode; - - resultCode = getResultCode(); - if (resultCode < 0) - { - return 0x0; - } - - return (char) resultCode; - } - - public String getResult() - { - if (result != null) - { - return result; - } - - final Matcher matcher = RESULT_PATTERN.matcher(firstLine); - if (matcher.find()) - { - result = matcher.group(1); - } - else - result = ""; - return result; - } - - public int getStatus() - { - if (status != null) - { - return status; - } - - if (firstLine == null) - { - return -1; - } - - final Matcher matcher = STATUS_PATTERN.matcher(firstLine); - if (matcher.find()) - { - status = Integer.parseInt(matcher.group(1)); - return status; - } - return -1; - } - - public String getAttribute(String name) - { - if (getStatus() != SC_SUCCESS) - { - return null; - } - - if ("result".equalsIgnoreCase(name)) - { - return getResult(); - } - - return getAttributes().get(name.toLowerCase(Locale.ENGLISH)); - } - - protected Map getAttributes() - { - if (attributes != null) - { - return attributes; - } - - attributes = new HashMap<>(); - - final Matcher matcher = ADDITIONAL_ATTRIBUTES_PATTERN.matcher(firstLine); - if (matcher.find()) - { - attributes.putAll(parseAttributes(matcher.group(2))); - } - return attributes; - } - - Map parseAttributes(String s) - { - StringBuilder keyBuilder = new StringBuilder(); - StringBuilder valueBuilder = new StringBuilder(); - Map map = new HashMap<>(); - - boolean inKey = true; - boolean inQuotes = false; - char previousChar = 0x0; - for (int i = 0; i < s.length(); i++) - { - char c = s.charAt(i); - if (c == '=' && inKey) - { - inKey = false; - inQuotes = false; - } - else if (c == ' ' && !inKey && !inQuotes) - { - map.put(keyBuilder.toString().toLowerCase(Locale.ENGLISH), valueBuilder.toString()); - keyBuilder.delete(0, keyBuilder.length()); - valueBuilder.delete(0, valueBuilder.length()); - inKey = true; - } - else if (c == '"' && !inKey) - { - if (previousChar == '\\') - { - valueBuilder.deleteCharAt(valueBuilder.length() - 1); - valueBuilder.append(c); - } - else - { - inQuotes = !inQuotes; - } - } - else - { - if (inKey) - { - keyBuilder.append(c); - } - else - { - valueBuilder.append(c); - } - } - - previousChar = c; - } - - if (keyBuilder.length() > 0) - { - map.put(keyBuilder.toString().toLowerCase(Locale.ENGLISH), valueBuilder.toString()); - } - return map; - } - - private boolean extraCreated; - - public String getExtra() - { - if (getStatus() != SC_SUCCESS) - { - return null; - } - - if (extraCreated) - { - return extra; - } - - final Matcher matcher = PARENTHESIS_PATTERN.matcher(firstLine); - if (matcher.find()) - { - extra = matcher.group(1); - } - extraCreated = true; - return extra; - } - - public String getSynopsis() - { - if (getStatus() != SC_INVALID_COMMAND_SYNTAX) - { - return null; - } - - if (synopsis == null && lines.size() > 1) - { - final String secondLine; - final Matcher synopsisMatcher; - - secondLine = lines.get(1); - synopsisMatcher = SYNOPSIS_PATTERN.matcher(secondLine); - if (synopsisMatcher.find()) - { - synopsis = synopsisMatcher.group(1); - } - } - return synopsis; - } - - /** - * Returns the usage of the command sent if Asterisk expected a different - * syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). - * - * @return the usage of the command sent, null if there were no - * syntax errors. - */ - public String getUsage() - { - if (usage == null) - { - StringBuilder usageSB; - - usageSB = new StringBuilder(); - for (int i = 2; i < lines.size(); i++) - { - String line; - - line = lines.get(i); - if (END_OF_PROPER_USAGE.equals(line)) - { - break; - } - - usageSB.append(line.trim()); - usageSB.append(" "); - } - usage = usageSB.toString().trim(); - } - return usage; - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder("AgiReply["); - sb.append("status=").append(getStatus()).append(","); - if (status == SC_SUCCESS) - { - sb.append("result='").append(getResult()).append("',"); - sb.append("extra='").append(getExtra()).append("',"); - sb.append("attributes=").append(getAttributes()).append(","); - } - if (status == SC_INVALID_COMMAND_SYNTAX) - { - sb.append("synopsis='").append(getSynopsis()).append("',"); - } - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AgiRequestImpl.java b/src/main/java/org/asteriskjava/fastagi/internal/AgiRequestImpl.java deleted file mode 100644 index 219ba70fc..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AgiRequestImpl.java +++ /dev/null @@ -1,653 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import java.io.UnsupportedEncodingException; -import java.net.InetAddress; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.util.AstUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Default implementation of the AGIRequest interface. - * - * @author srt - * @version $Id$ - */ -public class AgiRequestImpl implements AgiRequest -{ - private final Log logger = LogFactory.getLog(getClass()); - private static final Pattern SCRIPT_PATTERN = Pattern.compile("^([^\\?]*)\\?(.*)$"); - private static final Pattern PARAMETER_PATTERN = Pattern.compile("^(.*)=(.*)$"); - - private String rawCallerId; - - private Map request; - - /** - * A map assigning the values of a parameter (an array of Strings) to the - * name of the parameter. - */ - private Map parameterMap; - - private String[] arguments; - - private String parameters; - private String script; - private boolean callerIdCreated; - private InetAddress localAddress; - private int localPort; - private InetAddress remoteAddress; - private int remotePort; - - /** - * Creates a new AGIRequestImpl. - * - * @param environment the first lines as received from Asterisk containing - * the environment. - */ - AgiRequestImpl(final List environment) - { - this(buildMap(environment)); - } - - /** - * Creates a new AgiRequestImpl based on a preparsed map of parameters. - * - * @param request a map representing the AGI request. Keys must not contain - * the "agi_" or "ogi_" prefix. - * @since 1.0.0 - */ - private AgiRequestImpl(final Map request) - { - this.request = request; - - script = request.get("network_script"); - if (script != null) - { - Matcher scriptMatcher = SCRIPT_PATTERN.matcher(script); - if (scriptMatcher.matches()) - { - script = scriptMatcher.group(1); - parameters = scriptMatcher.group(2); - } - } - } - - /** - * Builds a map containing variable names as key (with the "agi_" or "ogi_" - * prefix stripped) and the corresponding values. - *

- * Syntactically invalid and empty variables are skipped. - * - * @param lines the environment to transform. - * @return a map with the variables set corresponding to the given - * environment. - * @throws IllegalArgumentException if lines is null - */ - private static Map buildMap(final Collection lines) throws IllegalArgumentException - { - final Map map; - - if (lines == null) - { - throw new IllegalArgumentException("Environment must not be null."); - } - - map = new HashMap<>(); - - for (String line : lines) - { - int colonPosition; - String key; - String value; - - colonPosition = line.indexOf(':'); - - // no colon on the line? - if (colonPosition < 0) - { - continue; - } - - // key doesn't start with agi_ or ogi_? - if (!line.startsWith("agi_") && !line.startsWith("ogi_")) - { - continue; - } - - // first colon in line is last character -> no value present? - if (line.length() < colonPosition + 2) - { - continue; - } - - key = line.substring(4, colonPosition).toLowerCase(Locale.ENGLISH); - value = line.substring(colonPosition + 2); - - if (value.length() != 0) - { - map.put(key, value); - } - } - - return map; - } - - public Map getRequest() - { - return request; - } - - /** - * Returns the name of the script to execute. - * - * @return the name of the script to execute. - */ - public synchronized String getScript() - { - return script; - } - - /** - * Returns the full URL of the request in the form - * agi://host[:port][/script]. - * - * @return the full URL of the request in the form - * agi://host[:port][/script]. - */ - public String getRequestURL() - { - return request.get("request"); - } - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return request.get("channel"); - } - - /** - * Returns the unqiue id of the channel. - * - * @return the unqiue id of the channel. - */ - public String getUniqueId() - { - return request.get("uniqueid"); - } - - public String getType() - { - return request.get("type"); - } - - public String getLanguage() - { - return request.get("language"); - } - - @Deprecated - public String getCallerId() - { - return getCallerIdNumber(); - } - - public String getCallerIdNumber() - { - String callerIdName; - String callerId; - - callerIdName = request.get("calleridname"); - callerId = request.get("callerid"); - if (callerIdName != null) - { - // Asterisk 1.2 - if (callerId == null || "unknown".equals(callerId)) - { - return null; - } - - return callerId; - } - // Asterisk 1.0 - return getCallerId10(); - } - - public String getCallerIdName() - { - String callerIdName; - - callerIdName = request.get("calleridname"); - if (callerIdName != null) - { - // Asterisk 1.2 - if ("unknown".equals(callerIdName)) - { - return null; - } - - return callerIdName; - } - // Asterisk 1.0 - return getCallerIdName10(); - } - - /** - * Returns the Caller*ID number using Asterisk 1.0 logic. - * - * @return the Caller*ID number - */ - private synchronized String getCallerId10() - { - final String[] parsedCallerId; - - if (!callerIdCreated) - { - rawCallerId = request.get("callerid"); - callerIdCreated = true; - } - - parsedCallerId = AstUtil.parseCallerId(rawCallerId); - if (parsedCallerId[1] == null) - { - return parsedCallerId[0]; - } - return parsedCallerId[1]; - } - - /** - * Returns the Caller*ID name using Asterisk 1.0 logic. - * - * @return the Caller*ID name - */ - private synchronized String getCallerIdName10() - { - if (!callerIdCreated) - { - rawCallerId = request.get("callerid"); - callerIdCreated = true; - } - - return AstUtil.parseCallerId(rawCallerId)[0]; - } - - public String getDnid() - { - String dnid; - - dnid = request.get("dnid"); - - if (dnid == null || "unknown".equals(dnid)) - { - return null; - } - - return dnid; - } - - public String getRdnis() - { - String rdnis; - - rdnis = request.get("rdnis"); - - if (rdnis == null || "unknown".equals(rdnis)) - { - return null; - } - - return rdnis; - } - - public String getContext() - { - return request.get("context"); - } - - public String getExtension() - { - return request.get("extension"); - } - - public Integer getPriority() - { - if (request.get("priority") != null) - { - return Integer.valueOf(request.get("priority")); - } - return null; - } - - public Boolean getEnhanced() - { - if (request.get("enhanced") != null) - { - if ("1.0".equals(request.get("enhanced"))) - { - return Boolean.TRUE; - } - return Boolean.FALSE; - } - return null; - } - - public String getAccountCode() - { - return request.get("accountcode"); - } - - public Integer getCallingAni2() - { - if (request.get("callingani2") == null) - { - return null; - } - - try - { - return Integer.valueOf(request.get("callingani2")); - } - catch (NumberFormatException e) - { - return null; - } - } - - public Integer getCallingPres() - { - if (request.get("callingpres") == null) - { - return null; - } - - try - { - return Integer.valueOf(request.get("callingpres")); - } - catch (NumberFormatException e) - { - return null; - } - } - - public Integer getCallingTns() - { - if (request.get("callingtns") == null) - { - return null; - } - - try - { - return Integer.valueOf(request.get("callingtns")); - } - catch (NumberFormatException e) - { - return null; - } - } - - public Integer getCallingTon() - { - if (request.get("callington") == null) - { - return null; - } - - try - { - return Integer.valueOf(request.get("callington")); - } - catch (NumberFormatException e) - { - return null; - } - } - - public String getParameter(String name) - { - String[] values; - - values = getParameterValues(name); - - if (values == null || values.length == 0) - { - return null; - } - - return values[0]; - } - - public synchronized String[] getParameterValues(String name) - { - if (getParameterMap().isEmpty()) - { - return new String[0]; - } - - final String[] values = parameterMap.get(name); - return values == null ? new String[0] : values; - } - - public synchronized Map getParameterMap() - { - if (parameterMap == null) - { - parameterMap = parseParameters(parameters); - } - return parameterMap; - } - - /** - * Parses the given parameter string and caches the result. - * - * @param s the parameter string to parse - * @return a Map made up of parameter names their values - */ - private synchronized Map parseParameters(String s) - { - Map> parameterMap; - Map result; - StringTokenizer st; - - parameterMap = new HashMap<>(); - result = new HashMap<>(); - - if (s == null) - { - return result; - } - - st = new StringTokenizer(s, "&"); - while (st.hasMoreTokens()) - { - String parameter; - Matcher parameterMatcher; - String name; - String value; - List values; - - parameter = st.nextToken(); - parameterMatcher = PARAMETER_PATTERN.matcher(parameter); - if (parameterMatcher.matches()) - { - try - { - name = URLDecoder.decode(parameterMatcher.group(1), "UTF-8"); - value = URLDecoder.decode(parameterMatcher.group(2), "UTF-8"); - } - catch (UnsupportedEncodingException e) - { - logger.error("Unable to decode parameter '" + parameter + "'", e); - continue; - } - } - else - { - try - { - name = URLDecoder.decode(parameter, "UTF-8"); - value = ""; - } - catch (UnsupportedEncodingException e) - { - logger.error("Unable to decode parameter '" + parameter + "'", e); - continue; - } - } - - if (parameterMap.get(name) == null) - { - values = new ArrayList<>(); - values.add(value); - parameterMap.put(name, values); - } - else - { - values = parameterMap.get(name); - values.add(value); - } - } - - for (Map.Entry> entry : parameterMap.entrySet()) - { - String[] valueArray; - - valueArray = new String[entry.getValue().size()]; - result.put(entry.getKey(), entry.getValue().toArray(valueArray)); - } - - return result; - } - - public synchronized String[] getArguments() - { - if (arguments != null) - { - return arguments.clone(); - } - - final Map map = new HashMap<>(); - int maxIndex = 0; - for (Map.Entry entry : request.entrySet()) - { - if (!entry.getKey().startsWith("arg_")) - { - continue; - } - - int index = Integer.parseInt(entry.getKey().substring(4)); - if (index > maxIndex) - { - maxIndex = index; - } - map.put(index, entry.getValue()); - } - - arguments = new String[maxIndex]; - for (int i = 0; i < maxIndex; i++) - { - arguments[i] = map.get(i + 1); - } - - return arguments.clone(); - } - - public InetAddress getLocalAddress() - { - return localAddress; - } - - void setLocalAddress(InetAddress localAddress) - { - this.localAddress = localAddress; - } - - public int getLocalPort() - { - return localPort; - } - - void setLocalPort(int localPort) - { - this.localPort = localPort; - } - - public InetAddress getRemoteAddress() - { - return remoteAddress; - } - - void setRemoteAddress(InetAddress remoteAddress) - { - this.remoteAddress = remoteAddress; - } - - public int getRemotePort() - { - return remotePort; - } - - void setRemotePort(int remotePort) - { - this.remotePort = remotePort; - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder("AgiRequest["); - sb.append("script='").append(getScript()).append("',"); - sb.append("requestURL='").append(getRequestURL()).append("',"); - sb.append("channel='").append(getChannel()).append("',"); - sb.append("uniqueId='").append(getUniqueId()).append("',"); - sb.append("type='").append(getType()).append("',"); - sb.append("language='").append(getLanguage()).append("',"); - sb.append("callerIdNumber='").append(getCallerIdNumber()).append("',"); - sb.append("callerIdName='").append(getCallerIdName()).append("',"); - sb.append("dnid='").append(getDnid()).append("',"); - sb.append("rdnis='").append(getRdnis()).append("',"); - sb.append("context='").append(getContext()).append("',"); - sb.append("extension='").append(getExtension()).append("',"); - sb.append("priority='").append(getPriority()).append("',"); - sb.append("enhanced='").append(getEnhanced()).append("',"); - sb.append("accountCode='").append(getAccountCode()).append("',"); - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiConnectionHandler.java b/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiConnectionHandler.java deleted file mode 100644 index 930c35c40..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiConnectionHandler.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import java.util.List; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; - -import org.asteriskjava.fastagi.AgiChannelFactory; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.MappingStrategy; -import org.asteriskjava.fastagi.command.AsyncAgiBreakCommand; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.event.AsyncAgiEvent; - -/** - * An AgiConnectionHandler for AsyncAGI. - *
- * It reads the request using a AsyncAgiReader and runs the AgiScript configured to - * handle this type of request. Finally it sends an {@link org.asteriskjava.fastagi.command.AsyncAgiBreakCommand}. - * - * @author srt - * @version $Id$ - */ -public class AsyncAgiConnectionHandler extends AgiConnectionHandler -{ - private final ManagerConnection connection; - private volatile String channelName; - private final List environment; - private final BlockingQueue asyncAgiEvents; - private AsyncAgiWriter writer; - - /** - * Creates a new FastAGIConnectionHandler to handle the given FastAGI socket connection. - * - * @param mappingStrategy the strategy to use to determine which script to run. - * @param asyncAgiStartEvent the AsyncAgiEvent that started this connection, must be a start sub event. - * @param agiChannelFactory The factory to use for creating new AgiChannel instances. - * @throws IllegalArgumentException if asyncAgiStartEvent is not a start sub type". - */ - public AsyncAgiConnectionHandler(MappingStrategy mappingStrategy, AsyncAgiEvent asyncAgiStartEvent, AgiChannelFactory agiChannelFactory) throws IllegalArgumentException - { - super(mappingStrategy, agiChannelFactory); - if (!asyncAgiStartEvent.isStart()) - { - throw new IllegalArgumentException("AsyncAgiEvent passed to AsyncAgiConnectionHandler is not a start sub event"); - } - connection = (ManagerConnection) asyncAgiStartEvent.getSource(); - channelName = asyncAgiStartEvent.getChannel(); - environment = asyncAgiStartEvent.decodeEnv(); - asyncAgiEvents = new LinkedBlockingQueue<>(); - setIgnoreMissingScripts(true); - } - - @Override - protected AgiReader createReader() - { - return new AsyncAgiReader(connection, environment, asyncAgiEvents); - } - - @Override - protected AgiWriter createWriter() - { - writer = new AsyncAgiWriter(connection, channelName); - return writer; - } - - @Override - public void release() - { - if (writer != null && (getScript() != null || ! isIgnoreMissingScripts())) - { - try - { - writer.sendCommand(new AsyncAgiBreakCommand()); - } - catch (AgiException e) // NOPMD - { - // ignore - } - } - } - - public void onAsyncAgiExecEvent(AsyncAgiEvent event) - { - asyncAgiEvents.offer(event); - } - - public void onAsyncAgiEndEvent(AsyncAgiEvent event) - { - asyncAgiEvents.offer(event); - } - - public void updateChannelName(String channelName) - { - this.channelName = channelName; - writer.updateChannelName(channelName); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiReader.java b/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiReader.java deleted file mode 100644 index dc5880ffc..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiReader.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.asteriskjava.fastagi.internal; - -import java.util.List; -import java.util.concurrent.BlockingQueue; - -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.reply.AgiReply; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.event.AsyncAgiEvent; - -public class AsyncAgiReader implements AgiReader -{ - private final AgiRequestImpl request; - private final BlockingQueue asyncAgiEvents; - - public AsyncAgiReader(ManagerConnection connection, List environment, BlockingQueue asyncAgiEvents) - { - this.request = new AgiRequestImpl(environment); - this.asyncAgiEvents = asyncAgiEvents; - - request.setLocalAddress(connection.getLocalAddress()); - request.setLocalPort(connection.getLocalPort()); - request.setRemoteAddress(connection.getRemoteAddress()); - request.setRemotePort(connection.getRemotePort()); - } - - public AgiRequest readRequest() throws AgiException - { - return request; - } - - public AgiReply readReply() throws AgiException - { - try - { - return new AgiReplyImpl(asyncAgiEvents.take().decodeResult()); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - throw new AgiException("Interrupted while waiting for AsyncAgiEvent", e); - } - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiWriter.java b/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiWriter.java deleted file mode 100644 index 4440bd60b..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/AsyncAgiWriter.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.asteriskjava.fastagi.internal; - -import java.io.IOException; - -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.command.AgiCommand; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.manager.action.AgiAction; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; - -/** - * Implementation of AgiWriter that uses a {@link org.asteriskjava.manager.ManagerConnection} to send - * {@link org.asteriskjava.fastagi.command.AgiCommand AgiCommands} as part of an AsyncAgi conversation. - * - * @see org.asteriskjava.manager.ManagerConnection - * @see org.asteriskjava.manager.action.AgiAction - * @since 1.0.0 - */ -public class AsyncAgiWriter implements AgiWriter -{ - private final ManagerConnection connection; - private volatile String channelName; - - public AsyncAgiWriter(ManagerConnection connection, String channelName) - { - this.connection = connection; - this.channelName = channelName; - } - - public void sendCommand(AgiCommand command) throws AgiException - { - final AgiAction agiAction; - final ManagerResponse response; - - agiAction = new AgiAction(channelName, command.buildCommand()); - - try - { - response = connection.sendAction(agiAction); - } - catch (IOException e) - { - throw new AgiException("Unable to send AsyncAGI command to " + connection.getHostname() + - " for channel " + channelName, e); - } - catch (TimeoutException e) - { - throw new AgiException("Timeout while sending AsyncAGI command to " + connection.getHostname() + - " for channel " + channelName , e); - } - - if (response instanceof ManagerError) - { - throw new AgiException("Unable to send AsyncAGI command to " + connection.getHostname() + - " for channel " + channelName + ": " + response.getMessage()); - } - } - - public void updateChannelName(String channelName) - { - this.channelName = channelName; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/DefaultAgiChannelFactory.java b/src/main/java/org/asteriskjava/fastagi/internal/DefaultAgiChannelFactory.java deleted file mode 100644 index 59bda0e1e..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/DefaultAgiChannelFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.asteriskjava.fastagi.internal; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiChannelFactory; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.AgiWriter; - -/** - * If no other factory is passed to DefaultAgiServer's constructor, - * an instance of this one will be used. The DefaultAgiChannelFactory - * creates AgiChannelImpl instances, that are passed to the agi scripts. - */ -public class DefaultAgiChannelFactory implements AgiChannelFactory -{ - @Override - public AgiChannel createAgiChannel(AgiRequest request, AgiWriter agiWriter, AgiReader agiReader) - { - return new AgiChannelImpl(request, agiWriter, agiReader); - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/FastAgiConnectionHandler.java b/src/main/java/org/asteriskjava/fastagi/internal/FastAgiConnectionHandler.java deleted file mode 100644 index edd32d8aa..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/FastAgiConnectionHandler.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import java.io.IOException; - -import org.asteriskjava.fastagi.AgiChannelFactory; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.MappingStrategy; -import org.asteriskjava.util.SocketConnectionFacade; - -/** - * An AgiConnectionHandler for FastAGI. - *
- * It reads the request using a FastAgiReader and runs the AgiScript configured to - * handle this type of request. Finally it closes the socket connection. - * - * @author srt - * @version $Id$ - */ -public class FastAgiConnectionHandler extends AgiConnectionHandler -{ - /** - * The socket connection. - */ - private final SocketConnectionFacade socket; - - /** - * Creates a new FastAGIConnectionHandler to handle the given FastAGI socket connection. - * - * @param mappingStrategy the strategy to use to determine which script to run. - * @param socket the socket connection to handle. - * @param agiChannelFactory The factory to use for creating new AgiChannel instances. - */ - public FastAgiConnectionHandler(MappingStrategy mappingStrategy, SocketConnectionFacade socket, AgiChannelFactory agiChannelFactory) - { - super(mappingStrategy, agiChannelFactory); - this.socket = socket; - } - - @Override - protected AgiReader createReader() - { - return new FastAgiReader(socket); - } - - @Override - protected AgiWriter createWriter() - { - return new FastAgiWriter(socket); - } - - @Override - public void release() - { - try - { - socket.close(); - } - catch (IOException e) // NOPMD - { - // swallow - } - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/internal/FastAgiReader.java b/src/main/java/org/asteriskjava/fastagi/internal/FastAgiReader.java deleted file mode 100644 index e337321ad..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/FastAgiReader.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.fastagi.AgiNetworkException; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.reply.AgiReply; -import org.asteriskjava.util.SocketConnectionFacade; - -/** - * Default implementation of the AgiReader implementation. - * - * @author srt - * @version $Id$ - */ -class FastAgiReader implements AgiReader -{ - private final SocketConnectionFacade socket; - - FastAgiReader(SocketConnectionFacade socket) - { - this.socket = socket; - } - - public AgiRequest readRequest() throws AgiException - { - AgiRequestImpl request; - String line; - List lines; - - lines = new ArrayList<>(); - - try - { - while ((line = socket.readLine()) != null) - { - if (line.length() == 0) - { - break; - } - - lines.add(line); - } - } - catch (IOException e) - { - throw new AgiNetworkException("Unable to read request from Asterisk: " + e.getMessage(), e); - } - - request = new AgiRequestImpl(lines); - request.setLocalAddress(socket.getLocalAddress()); - request.setLocalPort(socket.getLocalPort()); - request.setRemoteAddress(socket.getRemoteAddress()); - request.setRemotePort(socket.getRemotePort()); - - return request; - } - - public AgiReply readReply() throws AgiException - { - AgiReply reply; - List lines; - String line; - - lines = new ArrayList<>(); - - try - { - line = socket.readLine(); - } - catch (IOException e) - { - // readline throws IOException if the connection has been closed - throw new AgiHangupException(); - } - - if (line == null) - { - throw new AgiHangupException(); - } - - // TODO Asterisk 1.6 sends "HANGUP" when the channel is hung up. - // System.out.println(line); - if (line.startsWith("HANGUP")) - { - if (line.length() > 6) - { - line = line.substring(6); - } - else - { - return readReply(); - } - } - - lines.add(line); - - // read synopsis and usage if statuscode is 520 - if (line.startsWith(Integer.toString(AgiReply.SC_INVALID_COMMAND_SYNTAX))) - { - try - { - while ((line = socket.readLine()) != null) - { - lines.add(line); - if (line.startsWith(Integer.toString(AgiReply.SC_INVALID_COMMAND_SYNTAX))) - { - break; - } - } - } - catch (IOException e) - { - throw new AgiNetworkException("Unable to read reply from Asterisk: " + e.getMessage(), e); - } - } - - reply = new AgiReplyImpl(lines); - - // Special handling for gosub, see AJ-257 - if (reply.getStatus() == AgiReply.SC_TRYING) - { - return readReply(); - } - return reply; - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/FastAgiWriter.java b/src/main/java/org/asteriskjava/fastagi/internal/FastAgiWriter.java deleted file mode 100644 index f7656bc79..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/FastAgiWriter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import java.io.IOException; - -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiNetworkException; -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.command.AgiCommand; -import org.asteriskjava.util.SocketConnectionFacade; - - -/** - * Default implementation of the AGIWriter interface. - * - * @author srt - * @version $Id$ - */ -class FastAgiWriter implements AgiWriter -{ - private final SocketConnectionFacade socket; - - FastAgiWriter(SocketConnectionFacade socket) - { - this.socket = socket; - } - - public void sendCommand(AgiCommand command) throws AgiException - { - try - { - socket.write(command.buildCommand() + "\n"); - socket.flush(); - } - catch (IOException e) - { - throw new AgiNetworkException( - "Unable to send command to Asterisk: " + e.getMessage(), e); - } - } -} diff --git a/src/main/java/org/asteriskjava/fastagi/internal/package.html b/src/main/java/org/asteriskjava/fastagi/internal/package.html deleted file mode 100644 index e6959c54c..000000000 --- a/src/main/java/org/asteriskjava/fastagi/internal/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides private implementations for interfaces defined in the - org.asteriskjava.fastagi package.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/package.html b/src/main/java/org/asteriskjava/fastagi/package.html deleted file mode 100644 index 3dd3a37a2..000000000 --- a/src/main/java/org/asteriskjava/fastagi/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

Provides an implementaion of Asterisk's FastAGI.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/fastagi/reply/.gitignore b/src/main/java/org/asteriskjava/fastagi/reply/.gitignore deleted file mode 100644 index 56de7ec63..000000000 --- a/src/main/java/org/asteriskjava/fastagi/reply/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/AgiReply.class diff --git a/src/main/java/org/asteriskjava/fastagi/reply/AgiReply.java b/src/main/java/org/asteriskjava/fastagi/reply/AgiReply.java deleted file mode 100644 index bf7c70621..000000000 --- a/src/main/java/org/asteriskjava/fastagi/reply/AgiReply.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.reply; - -import java.io.Serializable; -import java.util.List; - -/** - * Reply received in response to an AgiCommand.

- * The AgiReply contains information about success or failure of the execution - * of an AgiCommand and - depending on the command sent - additional information - * returned, for example the value of a variable requested by a - * GetVariableCommand. - * - * @see org.asteriskjava.fastagi.command.AgiCommand - * @author srt - * @version $Id$ - */ -public interface AgiReply extends Serializable -{ - /** - * Status code (100) indicating Asterisk needs to process the - * AgiCommand and will report a final result code soon. - *

- * This code is only used by Asterisk-Java as an intermediate status and is - * never returned to the user. - */ - int SC_TRYING = 100; - - /** - * Status code (200) indicating Asterisk successfully processed the - * AgiCommand. - */ - int SC_SUCCESS = 200; - - /** - * Status code (510) indicating Asterisk was unable to process the - * AgiCommand because there is no command with the given name available. - */ - int SC_INVALID_OR_UNKNOWN_COMMAND = 510; - - /** - * Status code (511) indicating Asterisk was unable to execute the command - * because the channel has been hung up. Up to Asterisk 1.4 the TCP connection - * was closed on hangup, since Asterisk 1.6 the connection stays alive and - * commands that require a channel return a reply with this status code. - * - * @since 1.0.0 - */ - int SC_DEAD_CHANNEL = 511; - - /** - * Status code (520) indicating Asterisk was unable to process the - * AgiCommand because the syntax used was not correct. This is most likely - * due to missing required parameters or additional parameters sent that are - * not understood.

- * Ensure proper quoting of the parameters when you receive this status - * code. - */ - int SC_INVALID_COMMAND_SYNTAX = 520; - - /** - * Returns the first line of the raw reply. - * - * @return the first line of the raw reply. - */ - String getFirstLine(); - - /** - * Returns a List containing the lines of the raw reply. - * - * @return a List containing the lines of the raw reply. - */ - List getLines(); - - /** - * Returns the return code (the result as int). - * - * @return the return code or -1 if the result is not an int. - */ - int getResultCode(); - - /** - * Returns the return code as character. - * - * @return the return code as character. - */ - char getResultCodeAsChar(); - - /** - * Returns the result, that is the part directly following the "result=" - * string. - * - * @return the result. - */ - String getResult(); - - /** - * Returns the status code.

- * Supported status codes are: - *

    - *
  • 100 Trying - *
  • 200 Success - *
  • 510 Invalid or unknown command - *
  • 511 Command Not Permitted on a dead channel (since Asterisk 1.6) - *
  • 520 Invalid command syntax - *
- * - * @return the status code. - * @see #SC_TRYING - * @see #SC_SUCCESS - * @see #SC_INVALID_OR_UNKNOWN_COMMAND - * @see #SC_DEAD_CHANNEL - * @see #SC_INVALID_COMMAND_SYNTAX - */ - int getStatus(); - - /** - * Returns an additional attribute contained in the reply.

- * For example the reply to the StreamFileCommand contains an additional - * endpos attribute indicating the frame where the playback was stopped. - * This can be retrieved by calling getAttribute("endpos") on the - * corresponding reply. - * - * @param name the name of the attribute to retrieve. The name is case - * insensitive. - * @return the value of the attribute or null if it is not - * set. - */ - String getAttribute(String name); - - /** - * Returns the text in parenthesis contained in this reply.

- * The meaning of this property depends on the command sent. Sometimes it - * contains a flag like "timeout" or "hangup" or - in case of the - * GetVariableCommand - the value of the variable. - * - * @return the text in the parenthesis or null if not set. - */ - String getExtra(); - - /** - * Returns the synopsis of the command sent if Asterisk expected a different - * syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). - * - * @return the synopsis of the command sent, null if there - * were no syntax errors. - */ - String getSynopsis(); - - /** - * Returns the usage of the command sent if Asterisk expected a different - * syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). - * - * @return the usage of the command sent, null if there were - * no syntax errors. - */ - String getUsage(); -} diff --git a/src/main/java/org/asteriskjava/fastagi/reply/package.html b/src/main/java/org/asteriskjava/fastagi/reply/package.html deleted file mode 100644 index 738721be9..000000000 --- a/src/main/java/org/asteriskjava/fastagi/reply/package.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -

Provides a class that represents the reply that is received - from an Asterisk server in response to a command sent via - the FastAGI.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/live/.gitignore b/src/main/java/org/asteriskjava/live/.gitignore deleted file mode 100644 index 305344291..000000000 --- a/src/main/java/org/asteriskjava/live/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -/AbstractAsteriskServerListener.class -/AgentState.class -/AmaFlags.class -/AsteriskAgent.class -/AsteriskChannel.class -/AsteriskQueue.class -/AsteriskQueueEntry.class -/AsteriskQueueListener.class -/AsteriskQueueMember.class -/AsteriskServer.class -/AsteriskServerListener.class -/CallDetailRecord.class -/CallerId.class -/ChannelState.class -/ChannelStateHistoryEntry.class -/DefaultAsteriskServer.class -/DialedChannelHistoryEntry.class -/Disposition.class -/Extension.class -/ExtensionHistoryEntry.class -/HangupCause.class -/InvalidPenaltyException.class -/LinkedChannelHistoryEntry.class -/LiveException.class -/LiveObject.class -/ManagerCommunicationException.class -/MeetMeRoom.class -/MeetMeUser.class -/MeetMeUserState.class -/NoSuchChannelException.class -/NoSuchInterfaceException.class -/OriginateCallback.class -/QueueEntryState.class -/QueueMemberState.class -/SecureAsteriskServer.class -/Voicemailbox.class diff --git a/src/main/java/org/asteriskjava/live/AbstractAsteriskServerListener.java b/src/main/java/org/asteriskjava/live/AbstractAsteriskServerListener.java deleted file mode 100644 index 1caa62c67..000000000 --- a/src/main/java/org/asteriskjava/live/AbstractAsteriskServerListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Empty implementation of the {@link org.asteriskjava.live.AsteriskServerListener} - * interface. Use this class as a base class for your own listeners if you only want - * to implement a subset of the methods in {@link org.asteriskjava.live.AsteriskServerListener}. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public abstract class AbstractAsteriskServerListener implements AsteriskServerListener -{ - public void onNewAsteriskChannel(AsteriskChannel channel) - { - - } - - public void onNewMeetMeUser(MeetMeUser user) - { - - } -} diff --git a/src/main/java/org/asteriskjava/live/AgentState.java b/src/main/java/org/asteriskjava/live/AgentState.java deleted file mode 100644 index 3246a6fb4..000000000 --- a/src/main/java/org/asteriskjava/live/AgentState.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * The lifecycle status of an {@link org.asteriskjava.live.AsteriskAgent}. - * - * @since 0.3.1 - * @author Patrick Breucking - * @version $Id$ - */ -public enum AgentState -{ - /** - * Agent isn't logged in. - */ - AGENT_LOGGEDOFF, - - /** - * Agent is logged in and waiting for call. - */ - AGENT_IDLE, - - /** - * Agent is logged in and on a call. - */ - AGENT_ONCALL, - - /** - * Don't know anything about agent. Shouldn't ever get this. - */ - AGENT_UNKNOWN, - - /** - * Agent is logged in and a call is waiting for connect. - */ - AGENT_RINGING -} diff --git a/src/main/java/org/asteriskjava/live/AmaFlags.java b/src/main/java/org/asteriskjava/live/AmaFlags.java deleted file mode 100644 index eac1b5946..000000000 --- a/src/main/java/org/asteriskjava/live/AmaFlags.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -public enum AmaFlags -{ - BILLING, - DOCUMENTATION, - OMIT, - UNKNOWN -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskAgent.java b/src/main/java/org/asteriskjava/live/AsteriskAgent.java deleted file mode 100644 index f112c3912..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskAgent.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Represents an Asterisk agent - *

- * PropertyChangeEvents are fired for the following properties: - *

    - *
  • state
  • - *
- * - * @since 0.3.1 - * @author Patrick Breucking - * @version $Id$ - */ -public interface AsteriskAgent extends LiveObject -{ - String PROPERTY_STATE = "state"; - - /** - * @return the name - */ - public String getName(); - - /** - * @return the agentId - */ - public String getAgentId(); - - /** - * Returns the state of this agent. - * - * @return the state the state of this agent. - */ - public AgentState getState(); - -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskChannel.java b/src/main/java/org/asteriskjava/live/AsteriskChannel.java deleted file mode 100644 index a7fee808a..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskChannel.java +++ /dev/null @@ -1,656 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.util.MixMonitorDirection; - -/** - * Represents an Asterisk channel. - *

- * PropertyChangeEvents are fired for the following properties: - *

    - *
  • id - *
  • name - *
  • callerId - *
  • state - *
  • account - *
  • currentExtension - *
  • callDetailRecord - *
  • dialedChannel - *
  • dialingChannel - *
  • linkedChannel - *
  • meetMeUser - *
  • queueEntry - *
  • parkedAt - *
  • dtmfReceived - *
  • dtmfSent - *
- * - * @author srt - */ -public interface AsteriskChannel extends LiveObject -{ - String PROPERTY_ID = "id"; - String PROPERTY_NAME = "name"; - String PROPERTY_CALLER_ID = "callerId"; - String PROPERTY_STATE = "state"; - String PROPERTY_ACCOUNT = "account"; - String PROPERTY_CURRENT_EXTENSION = "currentExtension"; - String PROPERTY_CALL_DETAIL_RECORD = "callDetailRecord"; - String PROPERTY_DIALED_CHANNEL = "dialedChannel"; - String PROPERTY_DIALING_CHANNEL = "dialingChannel"; - String PROPERTY_LINKED_CHANNEL = "linkedChannel"; - String PROPERTY_MEET_ME_USER = "meetMeUser"; - String PROPERTY_QUEUE_ENTRY = "queueEntry"; - String PROPERTY_PARKED_AT = "parkedAt"; - String PROPERTY_DTMF_RECEIVED = "dtmfReceived"; - String PROPERTY_DTMF_SENT = "dtmfSent"; - String PROPERTY_MONITORED = "monitored"; - - String VARIABLE_MONITOR_EXEC = "MONITOR_EXEC"; - String VARIABLE_MONITOR_EXEC_ARGS = "MONITOR_EXEC_ARGS"; - - /** Pseudo-variable to store {@link org.asteriskjava.manager.event.DialEvent#getDialStatus()} */ - String VAR_AJ_DIAL_STATUS = "AJ_DIAL_STATUS"; - /** - * Returns the unique id of this channel, for example "1099015093.165". - * - * @return the unique id of this channel. - */ - String getId(); - - /** - * Returns the name of this channel, for example "SIP/1310-20da". - * - * @return the name of this channel. - */ - String getName(); - - /** - * Returns the caller id of this channel. - * - * @return the caller id of this channel. - */ - CallerId getCallerId(); - - /** - * Returns the state of this channel. - * - * @return the state of this channel. - */ - ChannelState getState(); - - /** - * Checks if this channel was at least once in the given state. - *

- * For example you can use this method the check if this channel had been - * answered: - * - *

-     * boolean answered = channel.wasInState(ChannelState.UP);
-     * 
- * - * @param state the state to look for. - * @return true if this channel was at least once in the - * given state; false otherwise. - * @since 0.3 - */ - boolean wasInState(ChannelState state); - - /** - * Checks if this channel was busy. - * - * @return true if this channel was busy; false - * otherwise. - * @since 0.3 - */ - boolean wasBusy(); - - /** - * Returns the account code used to bill this channel. - * - * @return the account code used to bill this channel. - */ - String getAccount(); - - /** - * Returns the last visited dialplan entry. - * - * @return the last visited dialplan entry. - * @since 0.2 - */ - Extension getCurrentExtension(); - - /** - * Returns the first visited dialplan entry. - * - * @return the first visited dialplan entry. - * @since 0.2 - */ - Extension getFirstExtension(); - - /** - * Returns a list of all visited dialplan entries. - * - * @return a list of all visited dialplan entries. - * @since 0.3 - */ - List getExtensionHistory(); - - /** - * Returns the date this channel has been created. - *

- * This property is immutable. - * - * @return the date this channel has been created. - */ - Date getDateOfCreation(); - - /** - * Returns the date this channel has left the Asterisk server for example by - * a hangup. - * - * @return the date this channel has left the Asterisk server or - * null if this channel is still active. - * @since 0.3 - */ - Date getDateOfRemoval(); - - /** - * Returns the reason for hangup. - * - * @return the reason for hangup or null if the channel has - * not yet been hung up or no hangup cause is available for this - * type of channel. - * @since 0.3 - */ - HangupCause getHangupCause(); - - /** - * Returns a textual representation of the reason for hangup. - * - * @return the textual representation of the reason for hangup or - * null if the channel has not yet been hung up or no - * hangup cause is available for this type of channel. If no hangup - * cause is available an empty String may be returned, too. - * @since 0.3 - */ - String getHangupCauseText(); - - /** - * Returns the call detail record for this channel. - * - * @return the call detail record for this channel or null if - * none has (yet) been received. - */ - CallDetailRecord getCallDetailRecord(); - - /** - * Returns the channel that has been dialed by this channel most recently, - * this is the destination channel that was created because this channel - * dialed it. - * - * @return the channel that has been dialed by this channel or - * null if none has been dialed. - */ - AsteriskChannel getDialedChannel(); - - /** - * Returns a list of all channels that have been dialed by this channel. - * - * @return a list of all channels that have been dialed by this channel. - */ - List getDialedChannelHistory(); - - /** - * Returns the channel that was dialing this channel, this is the source - * channel that created this channel by dialing it. - * - * @return the channel that was dialing this channel or null - * if none was dialing. - */ - AsteriskChannel getDialingChannel(); - - /** - * Returns the channel set that are dialing this channel, this is the source - * channel that created this channel by dialing it. - * - * @return the channel set that is dialing this channel or null - * if none was dialing. - */ - List getDialedChannels(); - - /** - * Returns the channel this channel is currently bridged with, if any. - * - * @return the channel this channel is bridged with, or null - * if this channel is currently not bridged to another channel. - */ - AsteriskChannel getLinkedChannel(); - - /** - * Returns a list of all channels this channel was briged with. - * - * @return a list of all channels this channel was briged with. - */ - List getLinkedChannelHistory(); - - /** - * Indicates if this channel was linked to another channel at least once. - * - * @return true if this channel was linked to another channel - * at least once, false otherwise. - * @since 0.2 - */ - boolean wasLinked(); - - /** - * Returns the MeetMeUser associated with this channel if this channel is - * currently taking part in a MeetMe conference. - * - * @return the MeetMeUser associated with this channel or null - * if this channel is currently not taking part in a MeetMe - * conference. - */ - MeetMeUser getMeetMeUser(); - - /** - * Returns the queue entry associated with this channel. - * - * @return the queue entry associated with this channel if any, null otherwise. - */ - AsteriskQueueEntry getQueueEntry(); - - /** - * Return the extension to dial to pickup he channel of the parking if the channel is - * currently parked. - * - * @return the Extension to dial, null if not currently parked. - */ - Extension getParkedAt(); - - /** - * Returns the channel variables as received by - * {@link org.asteriskjava.manager.event.VarSetEvent VarSetEvents}.

- * Available since Asterisk 1.6. - * - * @return the channel variables. - * @since 1.0.0 - */ - Map getVariables(); - - /** - * Returns the last DTMF digit received on this channels. - * - * @return the last DTMF digit received on this channels or null if none has yet been received. - * @since 1.0.0 - */ - Character getDtmfReceived(); - - /** - * Returns the last DTMF digit sent on this channels. - * - * @return the last DTMF digit sent on this channels or null if none has yet been sent. - * @since 1.0.0 - */ - Character getDtmfSent(); - - /** - * Return the actual MONITOR state. - * - * @return the actual Monitor state of this channel. - * @since 1.0.1 - */ - boolean isMonitored(); - - /* Actions */ - - /** - * Hangs up this channel. - * - * @throws ManagerCommunicationException if the hangup action cannot be sent - * to Asterisk. - * @throws NoSuchChannelException if this channel had already been hung up - * before the hangup was sent. - * @since 0.3 - */ - void hangup() throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Hangs up this channel using a given cause code. The cause code is mainly - * used for Zap PRI channels where it makes Asterisk send a PRI DISCONNECT - * message with the set CAUSE element to the switch. - * - * @param cause the cause code to send. - * @throws ManagerCommunicationException if the hangup action cannot be sent - * to Asterisk. - * @throws NoSuchChannelException if this channel had already been hung up - * before the hangup was sent. - * @since 0.3 - */ - void hangup(HangupCause cause) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Sets the absolute maximum amount of time permitted for a call on a given - * channel, it hangs up the channel after this time. - *

- * Time is counted from when you call setAbsoluteTimeout, not from the - * beginning of the call. - * - * @param seconds maximum duration of the call in seconds, 0 for unlimited - * call length. - * @throws ManagerCommunicationException if the absolute timeout action - * cannot be sent to Asterisk. - * @throws NoSuchChannelException if this channel had already been hung up - * before the absolute timeout was set. - * @since 0.3 - */ - //TODO exception when setting it to 0: NoSuchChannelException: Channel - // 'SIP/248-0a02fcd0' is not available: No timeout specified - void setAbsoluteTimeout(int seconds) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Redirects this channel to a new extension. - *

- * If this channel is linked to another channel, the linked channel is hung - * up. - * - * @param context the destination context. - * @param exten the destination extension. - * @param priority the destination priority. - * @throws ManagerCommunicationException if the redirect action cannot be - * sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * the redirect was sent. - * @since 0.3 - */ - void redirect(String context, String exten, int priority) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Redirects this channel and the channel this channel is linked to to a new - * extension. - *

- * If this channel is not linked to another channel only this channel is - * redirected. - * - * @param context the destination context. - * @param exten the destination extension. - * @param priority the destination priority. - * @throws ManagerCommunicationException if the redirect action cannot be - * sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * the redirect was sent. - * @since 0.3 - */ - void redirectBothLegs(String context, String exten, int priority) throws ManagerCommunicationException, - NoSuchChannelException; - - /** - * Returns the value of the given channel variable. - *

- * Currently Asterisk does not support the retrieval of built-in variables - * like EXTEN or CALLERIDNUM but only custom variables set via Asterisk's - * Set command or via {@link #setVariable(String, String)}. - * - * @param variable the name of the channel variable to return. - * @return the value of the channel variable or null if it is - * not set. - * @throws ManagerCommunicationException if the get variable action cannot - * be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * the variable was requested. - * @since 0.3 - */ - String getVariable(String variable) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Sets the value of the given channel variable. - * - * @param variable the name of the channel variable to set. - * @param value the value of the channel variable to set. - * @throws ManagerCommunicationException if the set variable action cannot - * be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * the variable was set. - * @since 0.3 - */ - void setVariable(String variable, String value) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Plays the given DTMF digit on this channel. - *

- * Available since Asterisk 1.2.8 - * - * @param digit the DTMF digit to play. - * @throws ManagerCommunicationException if the play DTMF action cannot be - * sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * the DTMF digit was set. - * @throws IllegalArgumentException if the digit is null. - * @since 0.3 - */ - void playDtmf(String digit) throws ManagerCommunicationException, NoSuchChannelException, IllegalArgumentException; - - /** - * Starts monitoring (recording) this channel. - *

- * The format of the files is "wav", they are not mixed. - *

- * The files are called filename-in.wav and filename-out.wav. - * - * @param filename the basename of the files created in the monitor spool - * directory. If null the channel name (with - * slashed replaced by dashes) is used. - * @throws ManagerCommunicationException if the monitor action cannot be - * sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * starting monitoring. - * @see #stopMonitoring() - * @see #pauseMonitoring() - * @since 0.3 - */ - void startMonitoring(String filename) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Starts monitoring (recording) this channel using the given audio format. - *

- * The files are not mixed. - *

- * The files are called filename-in.format and filename-out.format. - * - * @param filename the basename of the files created in the monitor spool - * directory. If null the channel name (with - * slashed replaced by dashes) is used. - * @param format the audio recording format. If null wav is - * used. - * @throws ManagerCommunicationException if the monitor action cannot be - * sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * starting monitoring. - * @see #stopMonitoring() - * @see #pauseMonitoring() - * @since 0.3 - */ - void startMonitoring(String filename, String format) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Starts monitoring (recording) this channel using the given audio format - * and optionally mixing input and output data after recording is finished. - *

- * Mixing is done by soxmix by default (which has to be installed on your - * Asterisk server). You can use your own script by setting the variable - * MONITOR_EXEC to your custom script before starting - * monitoring the channel. Your script is then called with 3 arguments, the - * two leg files and a target mixed file name which is the same as the leg - * file names without the in/out designator, i.e. filename.format.
- * The two leg files are only removed by Asterisk if - * MONITOR_EXEC is not set. If you use a custom script and - * want to remove them, just let your script do this.
- * To pass additional arguments to your script you can set the variable - * MONITOR_EXEC_ARGS to a list of arguments (separated by - * spaces). - *

- * Example: - * - *

-     *      AsteriskChannel c;
-     *      
-     *      [...]
-     *      c.setVariable(AsteriskChannel.VARIABLE_MONITOR_EXEC, "/usr/local/bin/2wav2mp3");
-     *      c.startMonitoring("my-recording", "wav", true);
-     * 
- * - * Side note: 2wav2mp3 is a nice script by Dietmar Zlabinger to mix the two - * legs to a stero mp3 file, for details see - * voip-info.org. - * - * @param filename the basename of the file(s) created in the monitor spool - * directory. If null the channel name (with - * slashed replaced by dashes) is used. - * @param format the audio recording format. If null wav is - * used. - * @param mix true to mix input and output data together - * after recording is finished, false to not mix - * them. - * @throws ManagerCommunicationException if the monitor action cannot be - * sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * starting monitoring. - * @see #VARIABLE_MONITOR_EXEC - * @see #VARIABLE_MONITOR_EXEC_ARGS - * @see #stopMonitoring() - * @see #pauseMonitoring() - * @since 0.3 - */ - void startMonitoring(String filename, String format, boolean mix) throws ManagerCommunicationException, - NoSuchChannelException; - - /** - * Changes the filename of a previously started monitoring. - *

- * If the channel exists but is not currently monitored your request is - * ignored and a warning message is written to Asterisk's CLI. - *

- * Use with care, this doesn't always seem to work. - * - * @param filename the basename of the file(s) created in the monitor spool - * directory. - * @throws ManagerCommunicationException if the change monitor action cannot - * be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * changing monitoring. - * @throws IllegalArgumentException if filename is null. - * @see #stopMonitoring() - * @see #pauseMonitoring() - * @since 0.3 - */ - void changeMonitoring(String filename) throws ManagerCommunicationException, NoSuchChannelException, - IllegalArgumentException; - - /** - * Stops monitoring this channel. - *

- * If the channel exists but is not currently monitored your request is - * ignored. - * - * @throws ManagerCommunicationException if the stop monitor action cannot - * be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * stopping monitoring. - * @see #startMonitoring(String) - * @see #startMonitoring(String, String) - * @see #startMonitoring(String, String, boolean) - * @since 0.3 - */ - void stopMonitoring() throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Temporarily stops monitoring this channel. - *

- * If the channel exists but is not currently monitored your request is - * ignored. - *

- * This method is available since Asterisk 1.4. - * - * @throws ManagerCommunicationException if the pause monitor action cannot - * be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * temporarily stopping monitoring. - * @see #unpauseMonitoring() - * @since 0.3 - */ - void pauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Re-enables monitoring this channel after calling - * {@link #pauseMonitoring()}. - *

- * If the channel exists but monitoring has not been paused your request is - * ignored. - *

- * This method is available since Asterisk 1.4. - * - * @throws ManagerCommunicationException if the unpause monitor action - * cannot be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * re-enabling monitoring. - * @see #pauseMonitoring() - * @since 0.3 - */ - void unpauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException; - - - /** - * Temporarily stops monitoring this channel if this is monitored with MixMonitor. - *

- * If the channel exists but is not currently monitored your request is - * ignored. - *

- * - * @throws ManagerCommunicationException if the pause monitor action cannot - * be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * temporarily stopping monitoring. - * @see #unPauseMixMonitor(org.asteriskjava.util.MixMonitorDirection) - * @since 1.0.0 - */ - void pauseMixMonitor(MixMonitorDirection direction) throws ManagerCommunicationException, NoSuchChannelException; - - - /** - * Re-enables monitoring this channel after calling - * {@link #pauseMixMonitor(org.asteriskjava.util.MixMonitorDirection)} ()} - * if this is monitored with MixMonitor - *

- * If the channel exists but monitoring has not been paused your request is - * ignored. - *

- * - * @throws ManagerCommunicationException if the unpause monitor action - * cannot be sent to Asterisk. - * @throws NoSuchChannelException if this channel had been hung up before - * re-enabling monitoring. - * @see #pauseMixMonitor(org.asteriskjava.util.MixMonitorDirection) - * @since 1.0.0 - */ - void unPauseMixMonitor(MixMonitorDirection direction) throws ManagerCommunicationException, NoSuchChannelException; - -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskQueue.java b/src/main/java/org/asteriskjava/live/AsteriskQueue.java deleted file mode 100644 index fe95a560b..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskQueue.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Collection; -import java.util.List; - -/** - * An Asterisk ACD queue. - * - * @author srt - * @author itaqua - * @version $Id$ - */ -public interface AsteriskQueue -{ - String STRATEGY_RINGALL = "ringall"; - String STRATEGY_ROUNDROBIN = "roundrobin"; - String STRATAGY_LEAST_RECENT = "leastrecent"; - String STRATEGY_FEWEST_CALLS = "fewestcalls"; - String STRATEGY_RANDOM = "random"; - String STRATEGY_RRMEMORY = "rrmemory"; - - /** - * Returns the name of this queue as defined in Asterisk's - * queues.conf. - * - * @return the name of this queue. - */ - String getName(); - - /** - * Returns the maximum number of people allowed to wait in this queue or 0 - * for unlimited. - *
- * Corresponds to the maxlen option in Asterisk's - * queues.conf. - * - * @return the maximum number of people allowed to wait in this queue. - */ - Integer getMax(); - - /** - * Returns the strategy used for this queue. - *
- * Possible values are: - *

    - *
  • ringall
  • - *
  • roundrobin
  • - *
  • leastrecent
  • - *
  • fewestcalls
  • - *
  • random
  • - *
  • rrmemory
  • - *
- * Available since Asterisk 1.6 - * - * @return the strategy used for this queue. - * @since 1.0.0 - */ - String getStrategy(); - - /** - * Returns the service level (in seconds) as defined by the - * servicelevel setting in queues.conf. - * - * @return the service level (in seconds). - */ - Integer getServiceLevel(); - - /** - * Returns the weight of this queue. - *
- * A queue can be assigned a 'weight' to ensure calls waiting in a higher - * priority queue will deliver its calls first. Only delays the lower weight - * queue's call if the member is also in the higher weight queue. - *
- * Available since Asterisk 1.2 - * - * @return the weight of this queue or null if not supported - * by your version of Asterisk. - */ - Integer getWeight(); - - /** - * Returns the list of entries currently waiting in this queue. - * - * @return the (ordered) list of entries currently waiting in this queue. - */ - List getEntries(); - - /** - * Returns the list of Asterisk members of this queue. - * - * @return the list of Asterisk members of this queue. - * @since 0.3.1 - */ - Collection getMembers(); - - /* - void addMember(String iface); - - void addMember(String iface, int penality); - - void addMember(String iface, String memberName); - - void addMember(String iface, String memberName, String stateInterface); - */ - - /** - * Registers a new queue listener. - * - * @param listener the listener to add. - * @since 0.3 - */ - void addAsteriskQueueListener(AsteriskQueueListener listener); - - /** - * Removes a previously registered queue listener. - * - * @param listener the listener to remove. - * @since 0.3 - */ - void removeAsteriskQueueListener(AsteriskQueueListener listener); - - /** - * Returns the number of abandoned calls. - * @author itaqua - * @return the number of abandoned calls. - */ - Integer getAbandoned(); - - /** - * Returns the ratio of calls answered within the specified service level per total completed - * calls (in percent). - * @author itaqua - * @return the ratio of calls answered within the specified service level per total completed - * calls (in percent). - */ - public Double getServiceLevelPerf(); - - /** - * Returns the number of completed calls. - * @author itaqua - * @return the number of completed calls. - */ - public Integer getCompleted(); - - /** - * Returns the current average talk time for this queue based on an exponential average. - * - * @return the current average talk time for this queue. - */ - public Integer getTalkTime(); - - /** - * Returns the current average holdtime for this queue (in seconds). - * @author itaqua - * @return the current average holdtime for this queue (in seconds). - */ - public Integer getHoldTime(); - - /** - * Returns the number of calls currently waiting in the queue. - * Is better to use get Waiting() - * @author itaqua - * @see getWaiting() - * @return the number of calls currently waiting in the queue. - */ - public Integer getCalls(); - - /** - * Returns the number of calls currently waiting in the queue. - * More verbose Method than getCalls() - * @author itaqua - * @return the number of calls currently waiting in the queue. - */ - public Integer getWaiting(); - - /** - * timestamp (miliseconds) of last update of this object - * @todo maybe change this to an immutable object - * @author itaqua - * @return - */ - long getLastUpdateMillis(); - -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskQueueEntry.java b/src/main/java/org/asteriskjava/live/AsteriskQueueEntry.java deleted file mode 100644 index b91688e7e..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskQueueEntry.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.asteriskjava.live; - -import java.util.Date; - -/** - * Represents a member of a queue.

- * PropertyChangeEvents are fired for the following properties: - *

    - *
  • state - *
  • position - *
  • reportedPosition - *
- * - * @author gmi - */ -public interface AsteriskQueueEntry extends LiveObject -{ - String PROPERTY_STATE = "state"; - String PROPERTY_POSITION = "position"; - String PROPERTY_REPORTED_POSITION = "reportedPosition"; - - int POSITION_UNDETERMINED = -1; - - /** - * Returns the date this member joined the Queue.

- * This property is immutable. - * - * @return the date this member joined the Queue - */ - Date getDateJoined(); - - /** - * Returns the date this member left the queue room.

- * This property is null as long as the user is - * in state {@link QueueEntryState#JOINED} and set to date the - * member left when entering {@link QueueEntryState#LEFT}. - * - * @return the date this member left the Queue or - * null if the user did not yet leave. - */ - Date getDateLeft(); - - /** - * Returns the lifecycle status of this AsteriskQueueEntry.

- * Initially the user is in state {@link org.asteriskjava.live.QueueEntryState#JOINED}. - * - * @return the lifecycle status of this AsteriskQueueEntry. - */ - QueueEntryState getState(); - - /** - * Returns the Queue this member joined.

- * This property is immutable. - * - * @return the Queue this entry joined. - */ - AsteriskQueue getQueue(); - - /** - * Returns the channel associated with this entry.

- * This property is immutable. - * - * @return the channel associated with this entry. - */ - AsteriskChannel getChannel(); - - /** - * Returns the name of the channel associated with this entry.

- * Comodity bridge, don't duplicate channel name as it can be renamed. - * - * @return the name of the channel associated with this entry. - */ - String getChannelName(); - - /** - * Returns the position of this queue entry in the queue.

- * - * @return the name of the channel associated with this entry. - */ - int getPosition(); -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskQueueListener.java b/src/main/java/org/asteriskjava/live/AsteriskQueueListener.java deleted file mode 100644 index 0cee29a1d..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskQueueListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.asteriskjava.live; - -/** - * You can register an AsteriskQueueListener with an - * {@link org.asteriskjava.live.AsteriskQueue} to be notified about new calls in - * and out of the queue, member state changes and exceeding service levels. - * - * @author gmi - * @since 0.3 - */ -public interface AsteriskQueueListener -{ - /** - * Called whenever an entry appears in the queue. - * - * @param entry the new entry. - */ - void onNewEntry(AsteriskQueueEntry entry); - - /** - * Called whenever an entry leaves the queue. - * - * @param entry the entry that leaves the queue. - */ - void onEntryLeave(AsteriskQueueEntry entry); - - /** - * Called whenever a member changes his state. - * - * @param member the member that changes his state. - * @since 0.3.1 - */ - void onMemberStateChange(AsteriskQueueMember member); - - /** - * @param entry - */ - void onEntryServiceLevelExceeded(AsteriskQueueEntry entry); - - /** - * Called whenever a new member is added to the queue. - * - * @param member the new member. - */ - void onMemberAdded(AsteriskQueueMember member); - - /** - * Called whenever a member is removed from this queue. - * - * @param member the member that has been removed from the queue. - */ - void onMemberRemoved(AsteriskQueueMember member); -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskQueueMember.java b/src/main/java/org/asteriskjava/live/AsteriskQueueMember.java deleted file mode 100644 index f3a4a3ceb..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskQueueMember.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * A queue member. Queue Member can be an agent or a direkt sip account, eg. a - * Phone.

- * PropertyChangeEvents are fired for the following properties: - *

    - *
  • state
  • - *
  • paused
  • - *
  • penalty (since Asterisk 1.6)
  • - *
- * - * @author Patrick Breucking - * @author itaqua - * @version $Id$ - * @since 0.3.1 - */ -public interface AsteriskQueueMember extends LiveObject -{ - String PROPERTY_STATE = "state"; - String PROPERTY_PENALTY = "penalty"; - String PROPERTY_PAUSED = "paused"; - String PROPERTY_CALLSTAKEN = "callsTaken"; - String PROPERTY_LASTCALL = "lastCall"; - - /** - * Returns the location of this member. - * - * @return the location of this member. - */ - String getLocation(); - - /** - * Returns the queue this member is registerd to. - * - * @return the queue this member is registerd to. - */ - AsteriskQueue getQueue(); - - /** - * Returns the state of this member. - * - * @return the state of this member. - */ - QueueMemberState getState(); - - /** - * Returns whether this member is currently paused.. - * - * @return paused true is this queue member is paused, false otherwise. - * @deprecated as of 1.0.0. Use {@link #isPaused()} instead. - */ - @Deprecated boolean getPaused(); - - /** - * Returns whether this member is currently paused.. - * - * @return paused true is this queue member is paused, false otherwise. - * @since 1.0.0 - */ - boolean isPaused(); - - /** - * Pauses or unpauses this member on this queue. - * - * @param paused true to pause this member, false to unpause. - * @throws ManagerCommunicationException if the QueuePauseAction could not be send to Asterisk. - * @throws NoSuchInterfaceException if the interface or the queue do not exist. - * @since 1.0.0 - */ - void setPaused(boolean paused) throws ManagerCommunicationException, NoSuchInterfaceException; - - /** - * Pauses or unpauses this member on all queues. - * - * @param paused true to pause this member, false to unpause. - * @throws ManagerCommunicationException if the QueuePauseAction could not be send to Asterisk. - * @throws NoSuchInterfaceException if the interface or the queue do not exist. - * @since 1.0.0 - */ - void setPausedAll(boolean paused) throws ManagerCommunicationException, NoSuchInterfaceException; - - /** - * Returns if this member has been dynamically added by the QueueAdd command - * (in the dialplan or via the Manager API) or if this member is has been - * statically defined in queues.conf. - * - * @return "dynamic" if the added member is a dynamic queue member, "static" - * if the added member is a static queue member. - * @since 1.0.0 - */ - public String getMembership(); - - /** - * Convenience method that checks whether this member has been statically - * defined in queues.conf. - * - * @return true if this member has been statically defined in - * queues.conf, false otherwise. - * @since 1.0.0 - */ - public boolean isStatic(); - - /** - * Convenience method that checks whether this member has been dynamically - * added by the QueueAdd command. - * - * @return true if this member has been dynamically added by - * the QueueAdd command, false otherwise. - * @since 1.0.0 - */ - public boolean isDynamic(); - - /** - * Returns the penalty of this member. - * - * @return the penalty of this member. - * @since 1.0.0 - */ - Integer getPenalty(); - - /** - * Assignes a new penalty to this queue member.

- * Available since Asterisk 1.6. - * - * @param penalty the new penalty value, must not be negative. - * @throws IllegalArgumentException if the penalty is negative. - * @throws ManagerCommunicationException if the QueuePenaltyAction could not be send to Asterisk. - * @throws InvalidPenaltyException if Asterisk refused to set the new penalty. - * @since 1.0.0 - */ - void setPenalty(int penalty) throws IllegalArgumentException, ManagerCommunicationException, InvalidPenaltyException; - - /** - * get the timestamp when the last call was terminated - * @author itaqua - * @return - */ - public abstract Long getLastCall(); - - /** - * total calls taken - * @author itaqua - * @return - */ - public abstract Integer getCallsTaken(); -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskServer.java b/src/main/java/org/asteriskjava/live/AsteriskServer.java deleted file mode 100644 index 64716bfb5..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskServer.java +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.config.ConfigFile; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.action.OriginateAction; - -/** - * The AsteriskServer is built on top of the - * {@link org.asteriskjava.manager.ManagerConnection} and is an attempt to - * simplify interaction with Asterisk by abstracting the interface.
- * You will certainly have less freedom using AsteriskServer but it will make - * life easier for easy things (like originating a call or getting a list of - * open channels).
- * AsteriskServer is still in an early state of development. So, when using - * AsteriskServer be aware that it might change in the future. - * - * @author srt - * @version $Id$ - */ -public interface AsteriskServer -{ - /** - * Returns the underlying ManagerConnection. - *

- * Unlike the methods operating on the manager connection this method does - * not implicitly initialize the connection. Thus you can use this method to - * add custom {@linkplain org.asteriskjava.manager.ManagerEventListener - * ManagerEventListeners} before the connection to the Asterisk server is - * established. If you want to ensure that the connection is established - * call {@link #initialize()}. - * - * @return the underlying ManagerConnection. - */ - ManagerConnection getManagerConnection(); - - /** - * Generates an outgoing channel. - * - * @param originateAction the action that contains parameters for the - * originate - * @return the generated channel - * @throws NoSuchChannelException if the channel is not available on the - * Asterisk server, for example because you used "SIP/1310" and - * 1310 is not a valid SIP user, the SIP channel module hasn't - * been loaded or the SIP or IAX peer is not registered - * currently. - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - public AsteriskChannel originate(OriginateAction originateAction) - throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Asynchronously generates an outgoing channel. - * - * @param originateAction the action that contains parameters for the - * originate - * @param cb callback to inform about the result - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - public void originateAsync(OriginateAction originateAction, OriginateCallback cb) throws ManagerCommunicationException; - - /** - * Generates an outgoing channel to a dialplan entry (extension, context, - * priority). - * - * @param channel channel name to call, for example "SIP/1310". - * @param context context to connect to - * @param exten extension to connect to - * @param priority priority to connect to - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @return the generated channel - * @throws NoSuchChannelException if the channel is not available on the - * Asterisk server, for example because you used "SIP/1310" and - * 1310 is not a valid SIP user, the SIP channel module hasn't - * been loaded or the SIP or IAX peer is not registered - * currently. - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - AsteriskChannel originateToExtension(String channel, String context, String exten, int priority, long timeout) - throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Generates an outgoing channel to a dialplan entry (extension, context, - * priority) and sets an optional map of channel variables. - * - * @param channel channel name to call, for example "SIP/1310". - * @param context context to connect to - * @param exten extension to connect to - * @param priority priority to connect to - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @param callerId callerId to use for the outgoing channel, may be - * null. - * @param variables channel variables to set, may be null. - * @return the generated channel - * @throws NoSuchChannelException if the channel is not available on the - * Asterisk server, for example because you used "SIP/1310" and - * 1310 is not a valid SIP user, the SIP channel module hasn't - * been loaded or the SIP or IAX peer is not registered - * currently. - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - AsteriskChannel originateToExtension(String channel, String context, String exten, int priority, long timeout, - CallerId callerId, Map variables) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Generates an outgoing channel to an application. - * - * @param channel channel name to call, for example "SIP/1310". - * @param application application to connect to, for example "MeetMe" - * @param data data to pass to the application, for example "1000|d", may be - * null. - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @return the generated channel - * @throws NoSuchChannelException if the channel is not available on the - * Asterisk server, for example because you used "SIP/1310" and - * 1310 is not a valid SIP user, the SIP channel module hasn't - * been loaded or the SIP or IAX peer is not registered - * currently. - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - AsteriskChannel originateToApplication(String channel, String application, String data, long timeout) - throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Generates an outgoing channel to an application and sets an optional map - * of channel variables. - * - * @param channel channel name to call, for example "SIP/1310". - * @param application application to connect to, for example "MeetMe" - * @param data data to pass to the application, for example "1000|d", may be - * null. - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @param callerId callerId to use for the outgoing channel, may be - * null. - * @param variables channel variables to set, may be null. - * @return the generated channel - * @throws NoSuchChannelException if the channel is not available on the - * Asterisk server, for example because you used "SIP/1310" and - * 1310 is not a valid SIP user, the SIP channel module hasn't - * been loaded or the SIP or IAX peer is not registered - * currently. - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - AsteriskChannel originateToApplication(String channel, String application, String data, long timeout, CallerId callerId, - Map variables) throws ManagerCommunicationException, NoSuchChannelException; - - /** - * Asynchronously generates an outgoing channel to a dialplan entry - * (extension, context, priority). - * - * @param channel channel name to call, for example "SIP/1310". - * @param context context to connect to - * @param exten extension to connect to - * @param priority priority to connect to - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @param callback callback to inform about the result - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - void originateToExtensionAsync(String channel, String context, String exten, int priority, long timeout, - OriginateCallback callback) throws ManagerCommunicationException; - - /** - * Asynchronously generates an outgoing channel to a dialplan entry - * (extension, context, priority) and sets an optional map of channel - * variables. - * - * @param channel channel name to call, for example "SIP/1310". - * @param context context to connect to - * @param exten extension to connect to - * @param priority priority to connect to - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @param callerId callerId to use for the outgoing channel, may be - * null. - * @param variables channel variables to set, may be null. - * @param callback callback to inform about the result - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - void originateToExtensionAsync(String channel, String context, String exten, int priority, long timeout, - CallerId callerId, Map variables, OriginateCallback callback) - throws ManagerCommunicationException; - - /** - * Asynchronously generates an outgoing channel to an application. - * - * @param channel channel name to call, for example "SIP/1310". - * @param application application to connect to, for example "MeetMe" - * @param data data to pass to the application, for example "1000|d", may be - * null. - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @param callback callback to inform about the result - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - void originateToApplicationAsync(String channel, String application, String data, long timeout, - OriginateCallback callback) throws ManagerCommunicationException; - - /** - * Asynchronously generates an outgoing channel to an application and sets - * an optional map of channel variables. - * - * @param channel channel name to call, for example "SIP/1310". - * @param application application to connect to, for example "MeetMe" - * @param data data to pass to the application, for example "1000|d", may be - * null. - * @param timeout how long to wait for the channel to be answered before its - * considered to have failed (in ms) - * @param callerId callerId to use for the outgoing channel, may be - * null. - * @param variables channel variables to set, may be null. - * @param callback callback to inform about the result - * @throws ManagerCommunicationException if the originate action cannot be - * sent to Asterisk - */ - void originateToApplicationAsync(String channel, String application, String data, long timeout, CallerId callerId, - Map variables, OriginateCallback callback) throws ManagerCommunicationException; - - /** - * Returns the active channels of the Asterisk server. - * - * @return a Collection of active channels. - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - Collection getChannels() throws ManagerCommunicationException; - - /** - * Returns a channel by its name. - * - * @param name name of the channel to return - * @return the channel with the given name or null if there is - * no such channel. - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - AsteriskChannel getChannelByName(String name) throws ManagerCommunicationException; - - /** - * Returns a channel by its unique id. - * - * @param id the unique id of the channel to return - * @return the channel with the given unique id or null if - * there is no such channel. - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - AsteriskChannel getChannelById(String id) throws ManagerCommunicationException; - - /** - * Returns the acitve MeetMe rooms on the Asterisk server. - * - * @return a Collection of MeetMeRooms - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - Collection getMeetMeRooms() throws ManagerCommunicationException; - - /** - * Returns the MeetMe room with the given number, if the room does not yet - * exist a new {@link MeetMeRoom} object is created. - * - * @param roomNumber the number of the room to return - * @return the MeetMe room with the given number. - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - MeetMeRoom getMeetMeRoom(String roomNumber) throws ManagerCommunicationException; - - /** - * Returns the queues served by the Asterisk server. - * - * @return a Collection of queues. - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - Collection getQueues() throws ManagerCommunicationException; - - /** - * Return the agents, registered at Asterisk server. (Consider remarks for - * {@link AsteriskAgent}) - * - * @return a Collection of agents - * @throws ManagerCommunicationException if there is a problem communication - * with Asterisk - */ - Collection getAgents() throws ManagerCommunicationException; - - /** - * Returns the exact version string of this Asterisk server.
- * This typically looks like "Asterisk 1.2.9.1-BRIstuffed-0.3.0-PRE-1q built - * by root @ pbx0 on a i686 running Linux on 2006-06-20 20:21:30 UTC". - * - * @return the version of this Asterisk server - * @throws ManagerCommunicationException if the version cannot be retrieved - * from Asterisk - * @since 0.2 - */ - String getVersion() throws ManagerCommunicationException; - - /** - * <<<<<<< HEAD Returns the CVS revision of a given source file of this - * Asterisk server.
- * ======= Returns the CVS revision of a given source file of this Asterisk - * server.
- * >>>>>>> refs/heads/release-1.1 For example getVersion("app_meetme.c") may - * return {1, 102} for CVS revision "1.102".
- * Note that this feature is not available with Asterisk 1.0.x.
- * You can use this feature if you need to write applications that behave - * different depending on specific modules being available in a specific - * version or not. - * - * @param file the file for which to get the version like "app_meetme.c" - * @return the CVS revision of the file, or null if that file - * is not part of the Asterisk instance you are connected to (maybe - * due to a module that provides it has not been loaded) or if you - * are connected to an Astersion 1.0.x - * @throws ManagerCommunicationException if the version cannot be retrieved - * from Asterisk - * @since 0.2 - */ - int[] getVersion(String file) throws ManagerCommunicationException; - - /** - * Returns the value of the given global variable. - * - * @param variable the name of the global variable to return. - * @return the value of the global variable or null if it is - * not set. - * @throws ManagerCommunicationException if the get variable action cannot - * be sent to Asterisk. - * @since 0.3 - */ - String getGlobalVariable(String variable) throws ManagerCommunicationException; - - /** - * Sets the value of the given global variable. - * - * @param variable the name of the global variable to set. - * @param value the value of the global variable to set. - * @throws ManagerCommunicationException if the set variable action cannot - * be sent to Asterisk. - * @since 0.3 - */ - void setGlobalVariable(String variable, String value) throws ManagerCommunicationException; - - /** - * Returns a collection of all voicemailboxes configured for this Asterisk - * server with the number of new and old messages they contain. - * - * @return a collection of all voicemailboxes configured for this Asterisk - * server - * @throws ManagerCommunicationException if the voicemailboxes can't be - * retrieved. - * @since 0.3 - */ - Collection getVoicemailboxes() throws ManagerCommunicationException; - - /** - * Executes a command line interface (CLI) command. - * - * @param command the command to execute, for example "sip show peers". - * @return a List containing strings representing the lines returned by the - * CLI command. - * @throws ManagerCommunicationException if the command can't be executed. - * @see org.asteriskjava.manager.action.CommandAction - * @since 0.3 - */ - List executeCliCommand(String command) throws ManagerCommunicationException; - - /** - * Checks whether a module is currently loaded. - *

- * Available since Asterisk 1.6 - * - * @param module name of the module to load (with out without the ".so" - * extension). - * @return true if the module is currently loaded, - * false otherwise. - * @throws ManagerCommunicationException if the module can't be checked. - */ - boolean isModuleLoaded(String module) throws ManagerCommunicationException; - - /** - * Loads a module or subsystem - *

- * Available since Asterisk 1.6 - * - * @param module name of the module to load (including ".so" extension) or - * subsystem name. - * @throws ManagerCommunicationException if the module cannot be loaded. - * @since 1.0.0 - */ - void loadModule(String module) throws ManagerCommunicationException; - - /** - * Unloads a module or subsystem. - *

- * Available since Asterisk 1.6 - * - * @param module name of the module to unload (including ".so" extension) or - * subsystem name. - * @throws ManagerCommunicationException if the module cannot be unloaded. - * @since 1.0.0 - */ - void unloadModule(String module) throws ManagerCommunicationException; - - /** - * Reloads a module or subsystem. - *

- * Available since Asterisk 1.6 - * - * @param module name of the module to reload (including ".so" extension) or - * subsystem name. - * @throws ManagerCommunicationException if the module cannot be reloaded. - * @since 1.0.0 - */ - void reloadModule(String module) throws ManagerCommunicationException; - - /** - * Reloads all currently loaded modules. - *

- * Available since Asterisk 1.6 - * - * @throws ManagerCommunicationException if the modules cannot be reloaded. - * @since 1.0.0 - */ - void reloadAllModules() throws ManagerCommunicationException; - - /** - * Reads the given Asterisk configuration file. - * - * @param filename the filename, for example "voicemail.conf". - * @return the configuration file. - * @throws ManagerCommunicationException if the command can't be executed. - */ - ConfigFile getConfig(String filename) throws ManagerCommunicationException; - - /** - * Adds a listener to this AsteriskServer.
- * If this server is not yet connected it will be implicitly connected. - * - * @param listener the listener to add. - * @throws ManagerCommunicationException if the server is not yet connected - * and the connection or initialization fails. - */ - void addAsteriskServerListener(AsteriskServerListener listener) throws ManagerCommunicationException; - - /** - * Removes a listener from this Asterisk server. - * - * @param listener the listener to remove. - */ - void removeAsteriskServerListener(AsteriskServerListener listener); - - /** - * Checks whether the listener is already registered with this Asterisk - * server - * - * @param listener the listener to check - * @return true, if the listener is already registered. - */ - boolean isAsteriskServerListening(AsteriskServerListener listener); - - /** - * The chainListener allows a listener to receive manager events after they - * have been processed by the AsteriskServer. If the AsteriskServer is - * handling messages using the asyncEventHandling then these messages will - * also be async. You would use the chainListener if you are processing raw - * events and using the AJ live ChannelManager. If you don't use the chain - * listener then you can't be certain that a channel name passed in a raw - * event will match the channel name held by the live Channel Manager. By - * chaining events you can be certain that events such as channel Rename - * events have been processed by the live ChannelManager before you receive - * an event and as such the names will always match. Whilst name matching is - * not always critical (as you should be matching by the channels unique id) - * the channel name does also contain state information (Zombie, Masq) in - * these cases it can be critical that you have the same name otherwise your - * state information will be out of date. - */ - public void addChainListener(ManagerEventListener chainListener); - - /** - * remove the chain listener. - * - * @param chainListener - */ - public void removeChainListener(ManagerEventListener chainListener); - - /** - * Closes the connection to this server. - */ - void shutdown(); - - /** - * Opens the connection to this server. - * - * @throws ManagerCommunicationException if login fails - */ - void initialize() throws ManagerCommunicationException; - - /** - * get Asterisk Queue by name - * - * @author itaqua - * @param queueName Name of the queue to retrieve - * @return - */ - public AsteriskQueue getQueueByName(String queueName); - - /** - * List of Queues Objects updated after certain date - * - * @author itaqua - * @param date - * @return - */ - public List getQueuesUpdatedAfter(Date date); - - /** - * every time we get an event of a queue we reload the information about it - * from the Asterisk Server - * - * @author itaqua - */ - public void forceQueuesMonitor(boolean force); - - /** - * Check if the Queue Information is forced - * - * @author itaqua - * @return - */ - public boolean isQueuesMonitorForced(); -} diff --git a/src/main/java/org/asteriskjava/live/AsteriskServerListener.java b/src/main/java/org/asteriskjava/live/AsteriskServerListener.java deleted file mode 100644 index 922369881..000000000 --- a/src/main/java/org/asteriskjava/live/AsteriskServerListener.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.asteriskjava.live; - -/** - * You can register an AsteriskServerListener with an - * {@link org.asteriskjava.live.AsteriskServer} to be notified about new - * channels and MeetMe users. - *

- * Usually it is better to extend {@link AbstractAsteriskServerListener} than to - * implement this interface directly as additonal methods will probably be added - * in future versions of Asterisk-Java. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public interface AsteriskServerListener -{ - /** - * Called whenever a new channel appears on the Asterisk server. - * - * @param channel the new channel. - */ - void onNewAsteriskChannel(AsteriskChannel channel); - - /** - * Called whenever a user joins a {@link MeetMeRoom}. - * - * @param user the user that joined. - */ - void onNewMeetMeUser(MeetMeUser user); - - /** - * Called whenever a new agent will be registered at Asterisk server. - * - * @param agent - */ - void onNewAgent(AsteriskAgent agent); - - /** - * Called whenever a queue entry ( ~ wapper over channel) joins a {@link org.asteriskjava.live.AsteriskQueue}. - * - * @param entry the queue entry that joined. - */ - void onNewQueueEntry(AsteriskQueueEntry entry); -} diff --git a/src/main/java/org/asteriskjava/live/CallDetailRecord.java b/src/main/java/org/asteriskjava/live/CallDetailRecord.java deleted file mode 100644 index 46caef42f..000000000 --- a/src/main/java/org/asteriskjava/live/CallDetailRecord.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Date; - -/** - * Represents an Asterisk Call Detail Record (CDR). - * - * @see org.asteriskjava.manager.event.CdrEvent - * @author srt - * @version $Id$ - * @since 0.3 - */ -public interface CallDetailRecord -{ - AsteriskChannel getChannel(); - - AsteriskChannel getDestinationChannel(); - - /** - * Returns the account number that is usually used to identify the party to bill for the call.

- * Corresponds to CDR field accountcode. - * - * @return the account number. - */ - String getAccountCode(); - - AmaFlags getAmaFlags(); - - /** - * Returns the destination context.

- * Corresponds to CDR field dcontext. - * - * @return the destination context. - */ - String getDestinationContext(); - - /** - * Returns the destination extension.

- * Corresponds to CDR field dst. - * - * @return the destination extension. - */ - String getDestinationExtension(); - - Disposition getDisposition(); - - Date getStartDate(); - - Date getAnswerDate(); - - Date getEndDate(); - - /** - * Returns the total time (in seconds) the caller spent in the system from dial to hangup.

- * Corresponds to CDR field duration. - * - * @return the total time in system in seconds. - */ - Integer getDuration(); - - /** - * Returns the total time (in seconds) the call was up from answer to hangup.

- * Corresponds to CDR field billsec. - * - * @return the total time in call in seconds. - */ - Integer getBillableSeconds(); - - /** - * Returns the last application if appropriate, for example "VoiceMail".

- * Corresponds to CDR field lastapp. - * - * @return the last application or null if not avaialble. - */ - String getLastApplication(); - - /** - * Returns the last application's data (arguments), for example "s1234".

- * Corresponds to CDR field lastdata. - * - * @return the last application's data or null if not avaialble. - */ - String getLastAppData(); - - /** - * Returns the user-defined field as set by Set(CDR(userfield)=Value).

- * Corresponds to CDR field userfield. - * - * @return the user-defined field. - */ - String getUserField(); -} diff --git a/src/main/java/org/asteriskjava/live/CallerId.java b/src/main/java/org/asteriskjava/live/CallerId.java deleted file mode 100644 index 592b5e1ca..000000000 --- a/src/main/java/org/asteriskjava/live/CallerId.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.io.Serializable; - -import org.asteriskjava.util.AstUtil; - -/** - * Represents a Caller*ID containing name and number. - *
- * Objects of this type are immutable. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class CallerId implements Serializable -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 6498024163374551005L; - private final String name; - private final String number; - - /** - * Creates a new CallerId. - * - * @param name the Caller*ID name. - * @param number the Caller*ID number. - */ - public CallerId(String name, String number) - { - this.name = (AstUtil.isNull(name)) ? null : name; - this.number = (AstUtil.isNull(number)) ? null : number; - } - - /** - * Returns the Caller*ID name. - * - * @return the Caller*ID name. - */ - public String getName() - { - return name; - } - - /** - * Returns the the Caller*ID number. - * - * @return the Caller*ID number. - */ - public String getNumber() - { - return number; - } - - /** - * Parses a caller id string in the form - * "Some Name" <1234> to a CallerId object. - * - * @param s the caller id string to parse. - * @return the corresponding CallerId object which is never null. - * @see AstUtil#parseCallerId(String) - */ - public static CallerId valueOf(String s) - { - final String[] parsedCallerId; - - parsedCallerId = AstUtil.parseCallerId(s); - return new CallerId(parsedCallerId[0], parsedCallerId[1]); - } - - /** - * Returns a string representation of this CallerId in the form - * "Some Name" <1234>. - */ - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder(); - if (name != null) - { - sb.append("\""); - sb.append(name); - sb.append("\""); - if (number != null) - { - sb.append(" "); - } - } - - if (number != null) - { - sb.append("<"); - sb.append(number); - sb.append(">"); - } - return sb.toString(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || getClass() != o.getClass()) - { - return false; - } - - CallerId callerId = (CallerId) o; - - if (name != null ? !name.equals(callerId.name) : callerId.name != null) - { - return false; - } - if (number != null ? !number.equals(callerId.number) : callerId.number != null) - { - return false; - } - - return true; - } - - @Override - public int hashCode() - { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (number != null ? number.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/org/asteriskjava/live/ChannelState.java b/src/main/java/org/asteriskjava/live/ChannelState.java deleted file mode 100644 index 0394a5cac..000000000 --- a/src/main/java/org/asteriskjava/live/ChannelState.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import org.asteriskjava.util.AstState; - -/** - * The lifecycle status of an {@link org.asteriskjava.live.AsteriskChannel}. - *
- * Defined in channel.c function ast_state2str. - * - * @author srt - * @version $Id$ - */ -public enum ChannelState -{ - /** - * Channel is down and available. - * This is the initial state of the channel when it is not yet in use. - */ - DOWN(AstState.AST_STATE_DOWN), - - /** - * Channel is down, but reserved. - */ - RSRVD(AstState.AST_STATE_RSRVD), - - /** - * Channel is off hook. - */ - OFFHOOK(AstState.AST_STATE_OFFHOOK), - - /** - * Digits (or equivalent) have been dialed. - */ - DIALING(AstState.AST_STATE_DIALING), - - /** - * Line is ringing. - */ - RING(AstState.AST_STATE_RING), - - /** - * Remote end is ringing. - */ - RINGING(AstState.AST_STATE_RINGING), - - /** - * Line is up. - */ - UP(AstState.AST_STATE_UP), - - /** - * Line is busy. - */ - BUSY(AstState.AST_STATE_BUSY), - - /** - * Digits (or equivalent) have been dialed while offhook. - */ - DIALING_OFFHOOK(AstState.AST_STATE_DIALING_OFFHOOK), - - /** - * Channel has detected an incoming call and is waiting for ring. - */ - PRERING(AstState.AST_STATE_PRERING), - - /** - * The channel has been hung up and is not longer available on the Asterisk server. - */ - HUNGUP(-1); - - private int status; - - /** - * Creates a new instance. - * - * @param status the numerical status code. - */ - ChannelState(int status) - { - this.status = status; - } - - /** - * Returns the numerical status code. - * - * @return the numerical status code. - */ - public int getStatus() - { - return status; - } - - /** - * Returns value specified by int. Use this to transform - * {@link org.asteriskjava.manager.event.AbstractChannelStateEvent#getChannelState()}. - * - * @param status integer representation of the status. - * @return corresponding ChannelState object or null if none matches. - */ - public static ChannelState valueOf(Integer status) - { - if (status == null) - { - return null; - } - - for (ChannelState tmp : ChannelState.values()) - { - if (tmp.getStatus() == status) - { - return tmp; - } - } - - return null; - } -} diff --git a/src/main/java/org/asteriskjava/live/ChannelStateHistoryEntry.java b/src/main/java/org/asteriskjava/live/ChannelStateHistoryEntry.java deleted file mode 100644 index f07a85327..000000000 --- a/src/main/java/org/asteriskjava/live/ChannelStateHistoryEntry.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.io.Serializable; -import java.util.Date; - -/** - * An entry in the channel state history of an {@link AsteriskChannel}. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class ChannelStateHistoryEntry implements Serializable -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 5437551192335452460L; - private final Date date; - private final ChannelState state; - - /** - * Creates a new instance. - * - * @param date the date the channel entered the state. - * @param state the state the channel entered. - */ - public ChannelStateHistoryEntry(Date date, ChannelState state) - { - this.date = date; - this.state = state; - } - - /** - * Returns the date the channel entered the state. - * - * @return the date the channel entered the state. - */ - public Date getDate() - { - return date; - } - - /** - * The state the channel entered. - * - * @return the state the channel entered. - */ - public ChannelState getState() - { - return state; - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder("ChannelStateHistoryEntry["); - sb.append("date=").append(date).append(","); - sb.append("state=").append(state).append("]"); - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/DefaultAsteriskServer.java b/src/main/java/org/asteriskjava/live/DefaultAsteriskServer.java deleted file mode 100644 index 88820d140..000000000 --- a/src/main/java/org/asteriskjava/live/DefaultAsteriskServer.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.config.ConfigFile; -import org.asteriskjava.live.internal.AsteriskServerImpl; -import org.asteriskjava.manager.DefaultManagerConnection; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.action.OriginateAction; - -/** - * Default implementation of the AsteriskServer interface. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.live.AsteriskServer - */ -public class DefaultAsteriskServer implements AsteriskServer -{ - private final AsteriskServerImpl impl; - - /** - * Creates a new instance without a {@link ManagerConnection}. The - * ManagerConnection must be set using - * {@link #setManagerConnection(ManagerConnection)} before you can use this - * AsteriskServer. - */ - public DefaultAsteriskServer() - { - this.impl = new AsteriskServerImpl(); - } - - /** - * Creates a new instance and a new {@link ManagerConnection} with the given - * connection data. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param username the username to use for login - * @param password the password to use for login - */ - public DefaultAsteriskServer(String hostname, String username, String password) - { - final ManagerConnection connection; - connection = createManagerConnection(hostname, 0, username, password); - this.impl = new AsteriskServerImpl(connection); - } - - /** - * Creates a new instance and a new {@link ManagerConnection} with the given - * connection data. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param port the port where Asterisk listens for incoming Manager API - * connections, usually 5038. - * @param username the username to use for login - * @param password the password to use for login - */ - public DefaultAsteriskServer(String hostname, int port, String username, String password) - { - final ManagerConnection connection; - connection = createManagerConnection(hostname, port, username, password); - this.impl = new AsteriskServerImpl(connection); - } - - protected DefaultManagerConnection createManagerConnection(String hostname, int port, String username, String password) - { - DefaultManagerConnection dmc; - dmc = new DefaultManagerConnection(hostname, port, username, password); - return dmc; - } - - /** - * Creates a new instance that uses the given {@link ManagerConnection}. - * - * @param eventConnection the ManagerConnection to use for receiving events - * from Asterisk. - */ - public DefaultAsteriskServer(ManagerConnection eventConnection) - { - this.impl = new AsteriskServerImpl(eventConnection); - } - - /** - * Determines if queue status is retrieved at startup. If you don't need - * queue information and still run Asterisk 1.0.x you can set this to - * true to circumvent the startup delay caused by the missing - * QueueStatusComplete event.
- * Default is false. - * - * @param skipQueues true to skip queue initialization, - * false to not skip. - * @since 0.2 - */ - public void setSkipQueues(boolean skipQueues) - { - this.impl.setSkipQueues(skipQueues); - } - - public void setManagerConnection(ManagerConnection eventConnection) - { - this.impl.setManagerConnection(eventConnection); - } - - public void initialize() throws ManagerCommunicationException - { - this.impl.initialize(); - } - - /* Implementation of the AsteriskServer interface */ - - public ManagerConnection getManagerConnection() - { - return this.impl.getManagerConnection(); - } - - public AsteriskChannel originate(OriginateAction originateAction) - throws ManagerCommunicationException, NoSuchChannelException - { - return this.impl.originate(originateAction); - } - - public AsteriskChannel originateToExtension(String channel, String context, String exten, int priority, long timeout) - throws ManagerCommunicationException, NoSuchChannelException - { - return this.impl.originateToExtension(channel, context, exten, priority, timeout); - } - - public AsteriskChannel originateToExtension(String channel, String context, String exten, int priority, long timeout, - CallerId callerId, Map variables) throws ManagerCommunicationException, NoSuchChannelException - { - return this.impl.originateToExtension(channel, context, exten, priority, timeout, callerId, variables); - } - - public AsteriskChannel originateToApplication(String channel, String application, String data, long timeout) - throws ManagerCommunicationException, NoSuchChannelException - { - return this.impl.originateToApplication(channel, application, data, timeout); - } - - public AsteriskChannel originateToApplication(String channel, String application, String data, long timeout, - CallerId callerId, Map variables) throws ManagerCommunicationException, NoSuchChannelException - { - return this.impl.originateToApplication(channel, application, data, timeout, callerId, variables); - } - - public void originateAsync(OriginateAction originateAction, OriginateCallback cb) throws ManagerCommunicationException - { - this.impl.originateAsync(originateAction, cb); - } - - public void originateToApplicationAsync(String channel, String application, String data, long timeout, CallerId callerId, - Map variables, OriginateCallback cb) throws ManagerCommunicationException - { - this.impl.originateToApplicationAsync(channel, application, data, timeout, callerId, variables, cb); - } - - public void originateToApplicationAsync(String channel, String application, String data, long timeout, - OriginateCallback cb) throws ManagerCommunicationException - { - this.impl.originateToApplicationAsync(channel, application, data, timeout, cb); - } - - public void originateToExtensionAsync(String channel, String context, String exten, int priority, long timeout, - CallerId callerId, Map variables, OriginateCallback cb) throws ManagerCommunicationException - { - this.impl.originateToExtensionAsync(channel, context, exten, priority, timeout, callerId, variables, cb); - } - - public void originateToExtensionAsync(String channel, String context, String exten, int priority, long timeout, - OriginateCallback cb) throws ManagerCommunicationException - { - this.impl.originateToExtensionAsync(channel, context, exten, priority, timeout, cb); - } - - public Collection getChannels() throws ManagerCommunicationException - { - return this.impl.getChannels(); - } - - public AsteriskChannel getChannelByName(String name) throws ManagerCommunicationException - { - return this.impl.getChannelByName(name); - } - - public AsteriskChannel getChannelById(String id) throws ManagerCommunicationException - { - return this.impl.getChannelById(id); - } - - public Collection getMeetMeRooms() throws ManagerCommunicationException - { - return this.impl.getMeetMeRooms(); - } - - public MeetMeRoom getMeetMeRoom(String name) throws ManagerCommunicationException - { - return this.impl.getMeetMeRoom(name); - } - - public Collection getQueues() throws ManagerCommunicationException - { - return this.impl.getQueues(); - } - - public String getVersion() throws ManagerCommunicationException - { - return this.impl.getVersion(); - } - - public int[] getVersion(String file) throws ManagerCommunicationException - { - return this.impl.getVersion(file); - } - - public String getGlobalVariable(String variable) throws ManagerCommunicationException - { - return this.impl.getGlobalVariable(variable); - } - - public void setGlobalVariable(String variable, String value) throws ManagerCommunicationException - { - this.impl.setGlobalVariable(variable, value); - } - - public Collection getVoicemailboxes() throws ManagerCommunicationException - { - return this.impl.getVoicemailboxes(); - } - - public List executeCliCommand(String command) throws ManagerCommunicationException - { - return this.impl.executeCliCommand(command); - } - - public boolean isModuleLoaded(String module) throws ManagerCommunicationException - { - return this.impl.isModuleLoaded(module); - } - - public ConfigFile getConfig(String filename) throws ManagerCommunicationException - { - return this.impl.getConfig(filename); - } - - public void reloadAllModules() throws ManagerCommunicationException - { - this.impl.reloadAllModules(); - } - - public void reloadModule(String module) throws ManagerCommunicationException - { - this.impl.reloadModule(module); - } - - public void unloadModule(String module) throws ManagerCommunicationException - { - this.impl.unloadModule(module); - } - - public void loadModule(String module) throws ManagerCommunicationException - { - this.impl.loadModule(module); - } - - public void addAsteriskServerListener(AsteriskServerListener listener) throws ManagerCommunicationException - { - this.impl.addAsteriskServerListener(listener); - } - - public void removeAsteriskServerListener(AsteriskServerListener listener) - { - this.impl.removeAsteriskServerListener(listener); - } - - public boolean isAsteriskServerListening(AsteriskServerListener listener) - { - return this.impl.isAsteriskServerListening(listener); - } - - public void shutdown() - { - this.impl.shutdown(); - } - - public Collection getAgents() throws ManagerCommunicationException - { - return this.impl.getAgents(); - } - - public AsteriskQueue getQueueByName(String queueName) - { - return impl.getQueueByName(queueName); - } - - @Override - public List getQueuesUpdatedAfter(Date date) - { - return impl.getQueuesUpdatedAfter(date); - } - - @Override - public void forceQueuesMonitor(boolean force) - { - impl.forceQueuesMonitor(force); - } - - @Override - public boolean isQueuesMonitorForced() - { - return impl.isQueuesMonitorForced(); - } - - @Override - public void addChainListener(ManagerEventListener chainListener) - { - this.impl.addChainListener(chainListener); - } - - @Override - public void removeChainListener(ManagerEventListener chainListener) - { - this.impl.removeChainListener(chainListener); - - } -} diff --git a/src/main/java/org/asteriskjava/live/DialedChannelHistoryEntry.java b/src/main/java/org/asteriskjava/live/DialedChannelHistoryEntry.java deleted file mode 100644 index a542e7598..000000000 --- a/src/main/java/org/asteriskjava/live/DialedChannelHistoryEntry.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Date; - -/** - * An entry in the dialed channels history of an {@link AsteriskChannel}. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class DialedChannelHistoryEntry -{ - private final Date date; - private final AsteriskChannel channel; - - /** - * Creates a new instance. - * - * @param date the date the channel was dialed. - * @param channel the channel that has been dialed. - */ - public DialedChannelHistoryEntry(Date date, AsteriskChannel channel) - { - this.date = date; - this.channel = channel; - } - - /** - * Returns the date the channel was dialed. - * - * @return the date the channel was dialed. - */ - public Date getDate() - { - return date; - } - - /** - * Returns the channel that has been dialed. - * - * @return the channel that has been dialed. - */ - public AsteriskChannel getChannel() - { - return channel; - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder("DialedChannelHistoryEntry["); - sb.append("date=").append(date).append(","); - sb.append("channel=").append(channel).append("]"); - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/Disposition.java b/src/main/java/org/asteriskjava/live/Disposition.java deleted file mode 100644 index 6823897c1..000000000 --- a/src/main/java/org/asteriskjava/live/Disposition.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -public enum Disposition -{ - NO_ANSWER, - FAILED, - BUSY, - ANSWERED, - UNKNOWN -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/live/Extension.java b/src/main/java/org/asteriskjava/live/Extension.java deleted file mode 100644 index f944001ee..000000000 --- a/src/main/java/org/asteriskjava/live/Extension.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.io.Serializable; - -public class Extension implements Serializable -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 768239042942945744L; - private final String context; - private final String extension; - private final Integer priority; - private final String application; - private final String appData; - - /** - * @param context - * @param extension - * @param priority - */ - public Extension(String context, String extension, Integer priority) - { - this(context, extension, priority, null, null); - } - - /** - * @param context - * @param extension - * @param priority - * @param application - * @param appData - */ - public Extension(String context, String extension, - Integer priority, String application, String appData) - { - this.context = context; - this.extension = extension; - this.priority = priority; - this.application = application; - this.appData = appData; - } - - public String getContext() - { - return context; - } - - public String getExtension() - { - return extension; - } - - public Integer getPriority() - { - return priority; - } - - public String getApplication() - { - return application; - } - - public String getAppData() - { - return appData; - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder("Extension["); - sb.append("context='").append(getContext()).append("',"); - sb.append("extension='").append(getExtension()).append("',"); - sb.append("priority='").append(getPriority()).append("',"); - sb.append("application='").append(getApplication()).append("',"); - sb.append("appData=").append(getAppData()).append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/ExtensionHistoryEntry.java b/src/main/java/org/asteriskjava/live/ExtensionHistoryEntry.java deleted file mode 100644 index 4f496c108..000000000 --- a/src/main/java/org/asteriskjava/live/ExtensionHistoryEntry.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.io.Serializable; -import java.util.Date; - -/** - * An entry in the extension history of an {@link AsteriskChannel}. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class ExtensionHistoryEntry implements Serializable -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 5437551192335452460L; - private final Date date; - private final Extension extension; - - /** - * Creates a new instance. - * - * @param date the date the extension has been visited. - * @param extension the extension that has been visited. - */ - public ExtensionHistoryEntry(Date date, Extension extension) - { - this.date = date; - this.extension = extension; - } - - /** - * Returns the date the extension has been visited. - * - * @return the date the extension has been visited. - */ - public Date getDate() - { - return date; - } - - /** - * Returns the extension that has been visited. - * - * @return the extension that has been visited. - */ - public Extension getExtension() - { - return extension; - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder(100); - sb.append("ExtensionHistoryEntry["); - sb.append("date=").append(date).append(","); - sb.append("extension=").append(extension).append("]"); - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/HangupCause.java b/src/main/java/org/asteriskjava/live/HangupCause.java deleted file mode 100644 index fcbe9ff6e..000000000 --- a/src/main/java/org/asteriskjava/live/HangupCause.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.HashMap; -import java.util.Map; - -/** - * Asterisk hangup cause.

- * Definitions from /include/asterisk/causes.h. - * - * @author srt - * @version $Id$ - */ -public enum HangupCause -{ - AST_CAUSE_UNALLOCATED(1), - AST_CAUSE_NO_ROUTE_TRANSIT_NET(2), - AST_CAUSE_NO_ROUTE_DESTINATION(3), - AST_CAUSE_MISDIALLED_TRUNK_PREFIX(5), - AST_CAUSE_CHANNEL_UNACCEPTABLE(6), - AST_CAUSE_CALL_AWARDED_DELIVERED(7), - AST_CAUSE_NUMBER_PORTED_NOT_HERE(14), - AST_CAUSE_NORMAL_CLEARING(16), - AST_CAUSE_USER_BUSY(17), - AST_CAUSE_NO_USER_RESPONSE(18), - AST_CAUSE_NO_ANSWER(19), - AST_CAUSE_SUBSCRIBER_ABSENT(20), - AST_CAUSE_CALL_REJECTED(21), - AST_CAUSE_NUMBER_CHANGED(22), - AST_CAUSE_REDIRECTED_TO_NEW_DESTINATION(23), - AST_CAUSE_ANSWERED_ELSEWHERE(26), - AST_CAUSE_DESTINATION_OUT_OF_ORDER(27), - AST_CAUSE_INVALID_NUMBER_FORMAT(28), - AST_CAUSE_FACILITY_REJECTED(29), - AST_CAUSE_RESPONSE_TO_STATUS_ENQUIRY(30), - AST_CAUSE_NORMAL_UNSPECIFIED(31), - AST_CAUSE_NORMAL_CIRCUIT_CONGESTION(34), - AST_CAUSE_NETWORK_OUT_OF_ORDER(38), - AST_CAUSE_NORMAL_TEMPORARY_FAILURE(41), - AST_CAUSE_SWITCH_CONGESTION(42), - AST_CAUSE_ACCESS_INFO_DISCARDED(43), - AST_CAUSE_REQUESTED_CHAN_UNAVAIL(44), - AST_CAUSE_PRE_EMPTED(45), - AST_CAUSE_FACILITY_NOT_SUBSCRIBED(50), - AST_CAUSE_OUTGOING_CALL_BARRED(52), - AST_CAUSE_INCOMING_CALL_BARRED(54), - AST_CAUSE_BEARERCAPABILITY_NOTAUTH(57), - AST_CAUSE_BEARERCAPABILITY_NOTAVAIL(58), - AST_CAUSE_BEARERCAPABILITY_NOTIMPL(65), - AST_CAUSE_CHAN_NOT_IMPLEMENTED(66), - AST_CAUSE_FACILITY_NOT_IMPLEMENTED(69), - AST_CAUSE_INVALID_CALL_REFERENCE(81), - AST_CAUSE_INCOMPATIBLE_DESTINATION(88), - AST_CAUSE_INVALID_MSG_UNSPECIFIED(95), - AST_CAUSE_MANDATORY_IE_MISSING(96), - AST_CAUSE_MESSAGE_TYPE_NONEXIST(97), - AST_CAUSE_WRONG_MESSAGE(98), - AST_CAUSE_IE_NONEXIST(99), - AST_CAUSE_INVALID_IE_CONTENTS(100), - AST_CAUSE_WRONG_CALL_STATE(101), - AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE(102), - AST_CAUSE_MANDATORY_IE_LENGTH_ERROR(103), - AST_CAUSE_PROTOCOL_ERROR(111), - AST_CAUSE_INTERWORKING(127), - - /* Special Asterisk aliases */ - AST_CAUSE_BUSY(AST_CAUSE_USER_BUSY), - AST_CAUSE_FAILURE(AST_CAUSE_NETWORK_OUT_OF_ORDER), - AST_CAUSE_NORMAL(AST_CAUSE_NORMAL_CLEARING), - AST_CAUSE_NOANSWER(AST_CAUSE_NO_ANSWER), - AST_CAUSE_CONGESTION(AST_CAUSE_NORMAL_CIRCUIT_CONGESTION), - AST_CAUSE_UNREGISTERED(AST_CAUSE_NO_ROUTE_DESTINATION), - AST_CAUSE_NOTDEFINED(0), - AST_CAUSE_NOSUCHDRIVER(AST_CAUSE_CHAN_NOT_IMPLEMENTED); - - private HangupCause(int code) - { - this.code = code; - } - - private HangupCause(HangupCause cause) - { - this.code = cause.code; - } - - /** - * Returns the numeric cause code.

- * Using this method in client code is discouraged. - * - * @return the numeric cause code. - */ - public int getCode() - { - return code; - } - - /** - * Returns the HangupCode by its numeric cause code.

- * Using this method in client code is discouraged. - * - * @param code the numeric cause code. - * @return the corresponding HangupCode enum or - * null if there is no such HangupCause. - */ - public static synchronized HangupCause getByCode(int code) - { - if (causes == null) - { - causes = new HashMap<>(); - for (HangupCause cause : values()) - { - causes.put(cause.code, cause); - } - } - - return causes.get(code); - } - - @Override - public String toString() - { - if (name().startsWith("AST_CAUSE_")) - { - return name().substring(10); - } - return name(); - } - - private int code; - private static Map causes; -} diff --git a/src/main/java/org/asteriskjava/live/InvalidPenaltyException.java b/src/main/java/org/asteriskjava/live/InvalidPenaltyException.java deleted file mode 100644 index 341b321ce..000000000 --- a/src/main/java/org/asteriskjava/live/InvalidPenaltyException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Indicates that the penalty could not be assigned to the queue member. - * - * @author srt - * @version $Id$ - */ -public class InvalidPenaltyException extends LiveException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * Creates a new instance with the given message. - * - * @param message the message - */ - public InvalidPenaltyException(String message) - { - super(message); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/live/LinkedChannelHistoryEntry.java b/src/main/java/org/asteriskjava/live/LinkedChannelHistoryEntry.java deleted file mode 100644 index 3b93cda86..000000000 --- a/src/main/java/org/asteriskjava/live/LinkedChannelHistoryEntry.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Date; - -/** - * An entry in the linked channels history of an {@link AsteriskChannel}. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class LinkedChannelHistoryEntry -{ - private final Date dateLinked; - private Date dateUnlinked; - private final AsteriskChannel channel; - - /** - * Creates a new instance. - * - * @param dateLinked the date the channel was linked. - * @param channel the channel that has been linked. - */ - public LinkedChannelHistoryEntry(Date dateLinked, AsteriskChannel channel) - { - this.dateLinked = dateLinked; - this.channel = channel; - } - - /** - * Returns the date the channel was linked. - * - * @return the date the channel was linked. - */ - public Date getDateLinked() - { - return dateLinked; - } - - /** - * Returns the date the channel was unlinked. - * - * @return the date the channel was unlinked. - */ - public Date getDateUnlinked() - { - return dateUnlinked; - } - - /** - * Sets the date the channel was unlinked. - * - * @param dateUnlinked the date the channel was unlinked. - */ - public void setDateUnlinked(Date dateUnlinked) - { - this.dateUnlinked = dateUnlinked; - } - - /** - * Returns the channel that has been linked. - * - * @return the channel that has been linked. - */ - public AsteriskChannel getChannel() - { - return channel; - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder(100); - sb.append("LinkedChannelHistoryEntry["); - sb.append("dateLinked=").append(dateLinked).append(","); - sb.append("dateUnlinked=").append(dateUnlinked).append(","); - sb.append("channel=").append(channel).append("]"); - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/LiveException.java b/src/main/java/org/asteriskjava/live/LiveException.java deleted file mode 100644 index 1f095eedd..000000000 --- a/src/main/java/org/asteriskjava/live/LiveException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Base class for exceptions thrown by the live package. - * - * @author srt - * @version $Id$ - */ -public abstract class LiveException extends RuntimeException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - /** - * Creates a new instance with the given message. - * - * @param message the message - */ - protected LiveException(String message) - { - super(message); - } - - /** - * Creates a new instance with the given message and cause. - * - * @param message the message - * @param cause the cause - */ - protected LiveException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/src/main/java/org/asteriskjava/live/LiveObject.java b/src/main/java/org/asteriskjava/live/LiveObject.java deleted file mode 100644 index 3186f4d34..000000000 --- a/src/main/java/org/asteriskjava/live/LiveObject.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.beans.PropertyChangeListener; - -/** - * Interface for all live objects. - *

- * Allows you to retrieve the {@link org.asteriskjava.live.AsteriskServer} this - * live object belongs to and provides support for - * {@link java.beans.PropertyChangeEvent}s. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public interface LiveObject -{ - /** - * Returns the AsteriskServer this live object belongs to. - * - * @return the AsteriskServer this live object belongs to. - */ - AsteriskServer getServer(); - - /** - * Adds a PropertyChangeListener that is notified whenever a property value - * changes. - * - * @param listener listener to notify - */ - void addPropertyChangeListener(PropertyChangeListener listener); - - /** - * Adds a PropertyChangeListener that is notified whenever a given property - * value changes. - * - * @param propertyName property to observe - * @param listener listener to notify - * @see #addPropertyChangeListener(PropertyChangeListener) - */ - void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); - - /** - * Removes the given PropertyChangeListener that was added by calling - * {@link #addPropertyChangeListener(PropertyChangeListener)}. - * - * @param listener listener to remove - */ - void removePropertyChangeListener(PropertyChangeListener listener); - - /** - * Removes the given PropertyChangeListener that was added by calling - * {@link #addPropertyChangeListener(String, PropertyChangeListener)}. - * - * @param propertyName property that is observed - * @param listener listener to remove - */ - void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); - - /** - * Timestamp of last update of the Object - * @return - */ - long getLastUpdateMillis(); -} diff --git a/src/main/java/org/asteriskjava/live/ManagerCommunicationException.java b/src/main/java/org/asteriskjava/live/ManagerCommunicationException.java deleted file mode 100644 index 395b543ef..000000000 --- a/src/main/java/org/asteriskjava/live/ManagerCommunicationException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - - -public class ManagerCommunicationException extends LiveException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1183197752451685927L; - - public ManagerCommunicationException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/src/main/java/org/asteriskjava/live/MeetMeRoom.java b/src/main/java/org/asteriskjava/live/MeetMeRoom.java deleted file mode 100644 index 4756f0bfd..000000000 --- a/src/main/java/org/asteriskjava/live/MeetMeRoom.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Collection; - -/** - * Represents an Asterisk MeetMe room.

- * MeetMe rooms bridge multiple channels. - * - * @author srt - * @since 0.3 - */ -public interface MeetMeRoom -{ - /** - * Returns the number of this MeetMe room.

- * This property is immutable. - * - * @return the number of this MeetMe room. - */ - String getRoomNumber(); - - /** - * Returns a collection of all active users in this MeetMe room. - * - * @return a collection of all active users in this MeetMe room. - */ - Collection getUsers(); - - /** - * Checks whether there are users in this room or not. - * - * @return true if this room is empty, false if there are users in it. - * @since 1.0.0 - */ - boolean isEmpty(); - - /** - * Locks this room so no addtional users can join. - * - * @throws ManagerCommunicationException if the room can't be locked. - */ - void lock() throws ManagerCommunicationException; - - /** - * Unlocks this room so additional users can join again. - * - * @throws ManagerCommunicationException if the room can't be locked. - */ - void unlock() throws ManagerCommunicationException; -} diff --git a/src/main/java/org/asteriskjava/live/MeetMeUser.java b/src/main/java/org/asteriskjava/live/MeetMeUser.java deleted file mode 100644 index dc883ee51..000000000 --- a/src/main/java/org/asteriskjava/live/MeetMeUser.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.util.Date; - -/** - * Represents a user of a MeetMe room.

- * PropertyChangeEvents are fired for the following properties: - *

    - *
  • talking - *
  • muted - *
  • state - *
- * - * @see org.asteriskjava.live.MeetMeRoom - * @author srt - * @since 0.3 - */ -public interface MeetMeUser extends LiveObject -{ - String PROPERTY_TALKING = "talking"; - String PROPERTY_MUTED = "muted"; - String PROPERTY_STATE = "state"; - - /** - * Returns whether this user is currently talking or not.

- * Asterisk supports talker detection since version 1.2. - * - * @return true if this user is currently talking and - * talker detection is supported, false otherwise. - */ - boolean isTalking(); - - /** - * Returns whether this user is muted or not.

- * Supported since Asterisk version 1.4. - * - * @return true if this user is muted and - * mute detection is supported, false otherwise. - */ - boolean isMuted(); - - /** - * Returns the date this user joined the MeetMe room.

- * This property is immutable. - * - * @return the date this user joined the MeetMe room. - */ - Date getDateJoined(); - - /** - * Returns the date this user left the MeetMe room.

- * This property is null as long as the user is - * in state {@link MeetMeUserState#JOINED} and set to date the - * user left when entering {@link MeetMeUserState#LEFT}. - * - * @return the date this user left the MeetMe room or - * null if the user did not yet leave. - */ - Date getDateLeft(); - - /** - * Returns the lifecycle status of this MeetMeUser.

- * Initially the user is in state {@link MeetMeUserState#JOINED}. - * - * @return the lifecycle status of this MeetMeUser. - */ - MeetMeUserState getState(); - - /** - * Returns the MeetMe room this user joined.

- * This property is immutable. - * - * @return the MeetMe room this user joined. - */ - MeetMeRoom getRoom(); - - /** - * Returns the user number assigned to this user in the room.

- * Usually you won't need to access this property directly.

- * This property is immutable. - * - * @return the user number assigned to this user in the room. - */ - Integer getUserNumber(); - - /** - * Returns the channel associated with this user.

- * This property is immutable. - * - * @return the channel associated with this user. - */ - AsteriskChannel getChannel(); - - /** - * Stops sending voice from this user to the MeetMe room. - * - * @throws ManagerCommunicationException if there is a problem talking to the Asterisk server. - */ - void mute() throws ManagerCommunicationException; - - /** - * (Re)starts sending voice from this user to the MeetMe room. - * - * @throws ManagerCommunicationException if there is a problem talking to the Asterisk server. - */ - void unmute() throws ManagerCommunicationException; - - /** - * Removes this user from the MeetMe room. - * - * @throws ManagerCommunicationException if there is a problem talking to the Asterisk server. - */ - void kick() throws ManagerCommunicationException; -} diff --git a/src/main/java/org/asteriskjava/live/MeetMeUserState.java b/src/main/java/org/asteriskjava/live/MeetMeUserState.java deleted file mode 100644 index 5a33f6221..000000000 --- a/src/main/java/org/asteriskjava/live/MeetMeUserState.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * The lifecycle status of a {@link org.asteriskjava.live.MeetMeUser}. - * - * @author srt - * @version $Id$ - */ -public enum MeetMeUserState -{ - /** - * The user joined the MeetMe room. - */ - JOINED, - - /** - * The user left the MeetMe room. - */ - LEFT -} diff --git a/src/main/java/org/asteriskjava/live/NoSuchChannelException.java b/src/main/java/org/asteriskjava/live/NoSuchChannelException.java deleted file mode 100644 index faa73050b..000000000 --- a/src/main/java/org/asteriskjava/live/NoSuchChannelException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Indicates that the channel is not available on the Asterisk server. - * - * @author srt - * @version $Id$ - */ -public class NoSuchChannelException extends LiveException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -6751088178882822091L; - - /** - * Creates a new instance with the given message. - * - * @param message the message - */ - public NoSuchChannelException(String message) - { - super(message); - } -} diff --git a/src/main/java/org/asteriskjava/live/NoSuchInterfaceException.java b/src/main/java/org/asteriskjava/live/NoSuchInterfaceException.java deleted file mode 100644 index a0c2714d2..000000000 --- a/src/main/java/org/asteriskjava/live/NoSuchInterfaceException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Indicates that the interface is not available on the Asterisk server. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class NoSuchInterfaceException extends LiveException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - /** - * Creates a new instance with the given message. - * - * @param message the message - */ - public NoSuchInterfaceException(String message) - { - super(message); - } -} diff --git a/src/main/java/org/asteriskjava/live/OriginateCallback.java b/src/main/java/org/asteriskjava/live/OriginateCallback.java deleted file mode 100644 index 32e94121e..000000000 --- a/src/main/java/org/asteriskjava/live/OriginateCallback.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Callback interface for asynchronous originates. - *

- * Contract:
- * {@link #onDialing(AsteriskChannel)} is called exactly once iif originate did not fail. - * It is called immediately after the channel has been created and before it is ringing.
- * In case of a failure {@link #onFailure(LiveException)} is the only method that is called - * and it is called exactly once.
- * Otherwise one of {@link #onSuccess(AsteriskChannel)} {@link #onBusy(AsteriskChannel)} or - * {@link #onNoAnswer(AsteriskChannel)} is called exactly once. - * - * @see AsteriskServer#originateToApplicationAsync(String, String, String, long, OriginateCallback) - * @see AsteriskServer#originateToApplicationAsync(String, String, String, long, CallerId, java.util.Map, OriginateCallback) - * @see AsteriskServer#originateToExtensionAsync(String, String, String, int, long, OriginateCallback) - * @see AsteriskServer#originateToExtensionAsync(String, String, String, int, long, CallerId, java.util.Map, OriginateCallback) - * @author srt - * @version $Id$ - * @since 0.3 - */ -public interface OriginateCallback -{ - /** - * Called when the channel has been created and before it starts ringing. - * - * @param channel the channel created. - */ - void onDialing(AsteriskChannel channel); - - /** - * Called if the originate was successful and the called party answered the - * call. - * - * @param channel the channel created. - */ - void onSuccess(AsteriskChannel channel); - - /** - * Called if the originate was unsuccessful because the called party did not - * answer the call. - * - * @param channel the channel created. - */ - void onNoAnswer(AsteriskChannel channel); - - /** - * Called if the originate was unsuccessful because the called party was - * busy. - * - * @param channel the channel created. - */ - void onBusy(AsteriskChannel channel); - - /** - * Called if the originate failed for example due to an invalid channel name - * or an originate to an unregistered SIP or IAX peer. - * - * @param cause the exception that caused the failure. - */ - void onFailure(LiveException cause); -} diff --git a/src/main/java/org/asteriskjava/live/QueueEntryState.java b/src/main/java/org/asteriskjava/live/QueueEntryState.java deleted file mode 100644 index 24e419263..000000000 --- a/src/main/java/org/asteriskjava/live/QueueEntryState.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.asteriskjava.live; - -/** - * The lifecycle status of a {@link org.asteriskjava.live.AsteriskQueueEntry}. - * - * @author gmi - */ -public enum QueueEntryState -{ - /** - * The user joined the queue. - */ - JOINED, - - /** - * The user left the queue. - */ - LEFT -} diff --git a/src/main/java/org/asteriskjava/live/QueueMemberState.java b/src/main/java/org/asteriskjava/live/QueueMemberState.java deleted file mode 100644 index 8a4ca11ed..000000000 --- a/src/main/java/org/asteriskjava/live/QueueMemberState.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import org.asteriskjava.manager.event.QueueMemberEvent; - -/** - * Represents the status of a Queue member. - * - *
- * Valid status codes are: - *

- *
AST_DEVICE_UNKNOWN (0)
- *
Queue member is available
- *
AST_DEVICE_NOT_INUSE (1)
- *
?
- *
AST_DEVICE_INUSE (2)
- *
?
- *
AST_DEVICE_BUSY (3)
- *
?
- *
AST_DEVICE_INVALID (4)
- *
?
- *
AST_DEVICE_UNAVAILABLE (5)
- *
?
- *
AST_DEVICE_RINGING (6)
- *
?
- *
AST_DEVICE_RINGINUSE (7)
- *
?
- *
AST_DEVICE_ONHOLD (8)
- *
?
- *
- * - * @author Patrick Breucking - * @author itaqua - * @version $Id$ - * @since 0.3.1 - * @see org.asteriskjava.manager.event.QueueMemberEvent - */ -public enum QueueMemberState -{ - DEVICE_UNKNOWN(QueueMemberEvent.AST_DEVICE_UNKNOWN), - - /** - * Queue member is available, eg. Agent is logged in but idle. - */ - DEVICE_NOT_INUSE(QueueMemberEvent.AST_DEVICE_NOT_INUSE), - - DEVICE_INUSE(QueueMemberEvent.AST_DEVICE_INUSE), - - /** - * Busy means, phone is in action, eg. is ringing, in call. - */ - DEVICE_BUSY(QueueMemberEvent.AST_DEVICE_BUSY), - - DEVICE_INVALID(QueueMemberEvent.AST_DEVICE_INVALID), - - /** - * Device is not available for call, eg. Agent is logged off. - */ - DEVICE_UNAVAILABLE(QueueMemberEvent.AST_DEVICE_UNAVAILABLE), - - /** - * Device is ringing. - */ - DEVICE_RINGING(QueueMemberEvent.AST_DEVICE_RINGING), - - /** - * Device is ringing *and* in use. - */ - DEVICE_RINGINUSE(QueueMemberEvent.AST_DEVICE_RINGINUSE), - - /** - * Device is on hold - */ - DEVICE_ONHOLD(QueueMemberEvent.AST_DEVICE_ONHOLD); - - - - - private final int status; - - /** - * Creates a new instance. - * - * @param status the numerical status code. - */ - QueueMemberState(int status) - { - this.status = status; - } - - /** - * Returns the numerical status code. - * - * @return the numerical status code. - * @see org.asteriskjava.manager.event.QueueMemberEvent#getStatus() - */ - public int getStatus() - { - return status; - } - - /** - * Returns value specified by int. Use this to transform - * {@link org.asteriskjava.manager.event.QueueMemberEvent#getStatus()}. - * - * @param status integer representation of the status. - * @return corresponding QueueMemberState object or null if none matches. - */ - public static QueueMemberState valueOf(Integer status) - { - if (status == null) - { - return null; - } - - for (QueueMemberState tmp : QueueMemberState.values()) - { - if (tmp.getStatus() == status) - { - return tmp; - } - } - - return null; - } -} diff --git a/src/main/java/org/asteriskjava/live/RecordingException.java b/src/main/java/org/asteriskjava/live/RecordingException.java deleted file mode 100644 index b54a7e05d..000000000 --- a/src/main/java/org/asteriskjava/live/RecordingException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -/** - * Indicates that a record operation related issue has occured, - * - * @author videanuadrian - * @version $Id$ - */ -public class RecordingException extends LiveException -{ - /** - * Serial version identifier. - */ - - private static final long serialVersionUID = 7804327171239361017L; - - /** - * Creates a new instance with the given message. - * - * @param message the message - */ - public RecordingException(String message) - { - super(message); - } -} diff --git a/src/main/java/org/asteriskjava/live/SecureAsteriskServer.java b/src/main/java/org/asteriskjava/live/SecureAsteriskServer.java deleted file mode 100644 index 0fde9ecc0..000000000 --- a/src/main/java/org/asteriskjava/live/SecureAsteriskServer.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asteriskjava.live; - -import org.asteriskjava.manager.DefaultManagerConnection; -import org.asteriskjava.manager.ManagerConnection; - -/** - * Secure implementation of the AsteriskServer interface.

- * Uses SSL for the connection to Asterisk. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.live.AsteriskServer - */ -public class SecureAsteriskServer extends DefaultAsteriskServer -{ - /** - * Creates a new instance and a new SSL secured {@link ManagerConnection} with the given - * connection data. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param port the port where Asterisk listens for incoming SSL secured Manager API connections, usually 5039. - * @param username the username to use for login - * @param password the password to use for login - */ - public SecureAsteriskServer(String hostname, int port, String username, String password) - { - super(hostname, port, username, password); - } - - @Override - protected DefaultManagerConnection createManagerConnection(String hostname, int port, String username, String password) - { - DefaultManagerConnection dmc; - dmc = super.createManagerConnection(hostname, port, username, password); - dmc.setSsl(true); - return dmc; - } -} diff --git a/src/main/java/org/asteriskjava/live/Voicemailbox.java b/src/main/java/org/asteriskjava/live/Voicemailbox.java deleted file mode 100644 index 15367b458..000000000 --- a/src/main/java/org/asteriskjava/live/Voicemailbox.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live; - -import java.io.Serializable; - -/** - * An Asterisk voicemailbox with status. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class Voicemailbox implements Serializable -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 2750652515961182547L; - private final String mailbox; - private final String context; - private final String user; - private int newMessages; - private int oldMessages; - - /** - * Creates a new instance. - * - * @param mailbox the name of this mailbox as defined in voicemail.conf. - * @param context the context of this mailbox as defined in voicemail.conf. - * @param user the user of this mailbox as defined in voicemail.conf. - */ - public Voicemailbox(String mailbox, String context, String user) - { - this.mailbox = mailbox; - this.context = context; - this.user = user; - } - - /** - * Returns the name of this mailbox as defined in voicemail.conf. - * - * @return the name of this mailbox as defined in voicemail.conf. - */ - public String getMailbox() - { - return mailbox; - } - - /** - * Returns the context of this mailbox as defined in voicemail.conf. - * - * @return the context of this mailbox as defined in voicemail.conf. - */ - public String getContext() - { - return context; - } - - /** - * Returns the user (usually the full name) of this mailbox as defined in voicemail.conf. - * - * @return the user of this mailbox as defined in voicemail.conf. - */ - public String getUser() - { - return user; - } - - /** - * Returns the number of new messages. - * - * @return the number of new messages. - */ - public int getNewMessages() - { - return newMessages; - } - - /** - * Sets the number of new messages. - * - * @param newMessages the number of new messages. - */ - public void setNewMessages(int newMessages) - { - this.newMessages = newMessages; - } - - /** - * Returns the number of old messages. - * - * @return the number of old messages. - */ - public int getOldMessages() - { - return oldMessages; - } - - /** - * Sets the number of old messages. - * - * @param oldMessages the number of old messages. - */ - public void setOldMessages(int oldMessages) - { - this.oldMessages = oldMessages; - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder(100); - sb.append("Voicemailbox["); - sb.append("mailbox='").append(getMailbox()).append("',"); - sb.append("context='").append(getContext()).append("',"); - sb.append("user='").append(getUser()).append("',"); - sb.append("newMessages=").append(getNewMessages()).append(","); - sb.append("oldMessages=").append(getOldMessages()).append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/.gitignore b/src/main/java/org/asteriskjava/live/internal/.gitignore deleted file mode 100644 index 9f05d58f2..000000000 --- a/src/main/java/org/asteriskjava/live/internal/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/ConfigFileImpl.class -/Constants.class -/ManagerCommunicationExceptionMapper.class -/ManagerConnectionPool.class -/MeetMeManager.class -/MeetMeRoomImpl.class -/MeetMeUserImpl.class -/OriginateCallbackData.class -/QueueManager.class -/AbstractLiveObject.class -/AgentManager.class -/AsteriskAgentImpl.class -/AsteriskChannelImpl.class -/AsteriskQueueEntryImpl.class -/AsteriskQueueImpl$ServiceLevelTimerTask.class -/AsteriskQueueImpl.class -/AsteriskQueueMemberImpl.class -/AsteriskServerImpl.class -/CallDetailRecordImpl.class -/ChannelManager.class diff --git a/src/main/java/org/asteriskjava/live/internal/AbstractLiveObject.java b/src/main/java/org/asteriskjava/live/internal/AbstractLiveObject.java deleted file mode 100644 index 0ae501c3c..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AbstractLiveObject.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; - -import org.asteriskjava.live.AsteriskServer; -import org.asteriskjava.live.LiveObject; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Abstract base class for all live objects. - * - * @author srt - * @since 0.3 - */ -abstract class AbstractLiveObject implements LiveObject -{ - private final Log logger = LogFactory.getLog(this.getClass()); - private final PropertyChangeSupport changes; - protected final AsteriskServerImpl server; - - // last time this object was updated - private long lastUpdate; - - AbstractLiveObject(AsteriskServerImpl server) - { - this.server = server; - this.changes = new PropertyChangeSupport(this); - stampLastUpdate(); - } - - public AsteriskServer getServer() - { - return server; - } - - public void addPropertyChangeListener(PropertyChangeListener listener) - { - changes.addPropertyChangeListener(listener); - } - - public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) - { - boolean haveToAdd = true; - for (PropertyChangeListener l : changes.getPropertyChangeListeners()) - { - if (l == listener) - { - haveToAdd = false; - break; - } - } - if (haveToAdd) - { - changes.addPropertyChangeListener(propertyName, listener); - } - } - - public void removePropertyChangeListener(PropertyChangeListener listener) - { - changes.removePropertyChangeListener(listener); - } - - public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) - { - changes.removePropertyChangeListener(propertyName, listener); - } - - protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) - { - if (oldValue != null || newValue != null) - { - stampLastUpdate(); - try - { - changes.firePropertyChange(propertyName, oldValue, newValue); - } - catch (Exception e) - { - logger.warn("Uncaught exception in PropertyChangeListener", e); - } - } - } - - @Override - public long getLastUpdateMillis() - { - return lastUpdate; - } - - public void stampLastUpdate() - { - lastUpdate = System.currentTimeMillis(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/AgentManager.java b/src/main/java/org/asteriskjava/live/internal/AgentManager.java deleted file mode 100644 index 51bc073f5..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AgentManager.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.asteriskjava.live.AgentState; -import org.asteriskjava.live.AsteriskAgent; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.manager.ResponseEvents; -import org.asteriskjava.manager.action.AgentsAction; -import org.asteriskjava.manager.event.AgentCallbackLoginEvent; -import org.asteriskjava.manager.event.AgentCallbackLogoffEvent; -import org.asteriskjava.manager.event.AgentCalledEvent; -import org.asteriskjava.manager.event.AgentCompleteEvent; -import org.asteriskjava.manager.event.AgentConnectEvent; -import org.asteriskjava.manager.event.AgentLoginEvent; -import org.asteriskjava.manager.event.AgentLogoffEvent; -import org.asteriskjava.manager.event.AgentsEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Manages all events related to agents on Asterisk server. For correct work - * ensure enabled AgentCalledEvents. You have to set - * eventwhencalled = yes in queues.conf. - * - * @author Patrick Breucking - * @version $Id$ - * @since 0.3.1 - */ -public class AgentManager -{ - - private final Log logger = LogFactory.getLog(this.getClass()); - - private final AsteriskServerImpl server; - - /** - * A Map of agents by thier agentId. - */ - private final Map agents; - - /** - * A Map of agent in state RINGING by the caller id. Needed to return agent - * into idle state, if call was not conneted. - */ - private final Map ringingAgents; - - AgentManager(AsteriskServerImpl asteriskServerImpl) - { - this.server = asteriskServerImpl; - agents = new HashMap<>(); - ringingAgents = new HashMap<>(); - } - - /** - * Retrieves all agents registered at Asterisk server by sending an - * AgentsAction. - * - * @throws ManagerCommunicationException if communication with Asterisk - * server fails. - */ - void initialize() throws ManagerCommunicationException - { - ResponseEvents re; - - re = server.sendEventGeneratingAction(new AgentsAction()); - - for (ManagerEvent event : re.getEvents()) - { - if (event instanceof AgentsEvent) - { - logger.info( event ); - handleAgentsEvent((AgentsEvent) event); - } - } - } - - void disconnected() - { - synchronized (agents) - { - agents.clear(); - } - } - - /** - * On AgentsEvent create a new Agent. - * - * @param event generated by Asterisk server. - */ - void handleAgentsEvent(AgentsEvent event) - { - AsteriskAgentImpl agent = new AsteriskAgentImpl(server, - event.getName(), "Agent/" + event.getAgent(), AgentState.valueOf(event.getStatus())); - logger.info("Adding agent " + agent.getName() + "(" + agent.getAgentId() + ")"); - - addAgent(agent); - } - - /** - * Add a new agent to the manager. - * - * @param agent agent to add. - */ - private void addAgent(AsteriskAgentImpl agent) - { - synchronized (agents) - { - agents.put(agent.getAgentId(), agent); - } - server.fireNewAgent(agent); - } - - /** - * Return the requested agent. - * - * @param agentId identifier for agent - * @return the requested agent - */ - AsteriskAgentImpl getAgentByAgentId(String agentId) - { - synchronized (agents) - { - return agents.get(agentId); - } - } - - /** - * Update state if agent was called. - * - * @param event - */ - void handleAgentCalledEvent(AgentCalledEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId(event.getAgentCalled()); - if (agent == null) - { - logger.error("Ignored AgentCalledEvent for unknown agent " + event.getAgentCalled()); - return; - } - updateRingingAgents(event.getChannelCalling(), agent); - updateAgentState(agent, AgentState.AGENT_RINGING); - } - - /** - * Set state of agent. - * - * @param agent - */ - private void updateAgentState(AsteriskAgentImpl agent, AgentState newState) - { - logger.info("Set state of agent " + agent.getAgentId() + " to " + newState); - synchronized (agent) - { - agent.updateState(newState); - } - } - - /** - * Updates state of agent, if the call in a queue was redirect to the next - * agent because the ringed agent doesn't answer the call. After reset - * state, put the next agent in charge. - * - * @param channelCalling - * @param agent - */ - private void updateRingingAgents(String channelCalling, AsteriskAgentImpl agent) - { - synchronized (ringingAgents) - { - if (ringingAgents.containsKey(channelCalling)) - { - updateAgentState(ringingAgents.get(channelCalling), AgentState.AGENT_IDLE); - } - ringingAgents.put(channelCalling, agent); - } - } - - /** - * Update state if agent was connected to channel. - * - * @param event - */ - void handleAgentConnectEvent(AgentConnectEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId(event.getChannel()); - if (agent == null) - { - logger.error("Ignored AgentConnectEvent for unknown agent " + event.getChannel()); - return; - } - agent.updateState(AgentState.AGENT_ONCALL); - } - - /** - * Change state if agent logs in. - * - * @param event - */ - void handleAgentLoginEvent(AgentLoginEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId("Agent/" + event.getAgent()); - if (agent == null) - { - synchronized (agents) - { - logger.error("Ignored AgentLoginEvent for unknown agent " - + event.getAgent() + ". Agents: " + agents.values().toString()); - - } - return; - } - agent.updateState(AgentState.AGENT_IDLE); - } - - /** - * Change state if agent logs out. - * - * @param event - */ - void handleAgentLogoffEvent(AgentLogoffEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId("Agent/" + event.getAgent()); - if (agent == null) - { - logger.error("Ignored AgentLogoffEvent for unknown agent " - + event.getAgent() + ". Agents: " - + agents.values().toString()); - return; - } - agent.updateState(AgentState.AGENT_LOGGEDOFF); - } - - /** - * Change state if agent logs in. - * - * @param event - */ - void handleAgentCallbackLoginEvent(AgentCallbackLoginEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId("Agent/" + event.getAgent()); - if (agent == null) - { - synchronized (agents) - { - logger.error("Ignored AgentCallbackLoginEvent for unknown agent " - + event.getAgent() + ". Agents: " + agents.values().toString()); - - } - return; - } - agent.updateState(AgentState.AGENT_IDLE); - } - - /** - * Change state if agent logs out. - * - * @param event - */ - void handleAgentCallbackLogoffEvent(AgentCallbackLogoffEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId("Agent/" + event.getAgent()); - if (agent == null) - { - logger.error("Ignored AgentCallbackLogoffEvent for unknown agent " - + event.getAgent() + ". Agents: " - + agents.values().toString()); - return; - } - agent.updateState(AgentState.AGENT_LOGGEDOFF); - - } - - /** - * Return all agents registered at Asterisk server. - * - * @return a collection of all agents. - */ - Collection getAgents() - { - Collection copy; - - synchronized (agents) - { - copy = new ArrayList(agents.values()); - } - return copy; - } - - /** - * Change state if connected call was terminated. - * - * @param event - */ - void handleAgentCompleteEvent(AgentCompleteEvent event) - { - AsteriskAgentImpl agent = getAgentByAgentId(event.getChannel()); - if (agent == null) - { - logger.error("Ignored AgentCompleteEvent for unknown agent " + event.getChannel()); - return; - } - agent.updateState(AgentState.AGENT_IDLE); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/AsteriskAgentImpl.java b/src/main/java/org/asteriskjava/live/internal/AsteriskAgentImpl.java deleted file mode 100644 index 1d38c3f67..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AsteriskAgentImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import org.asteriskjava.live.AgentState; -import org.asteriskjava.live.AsteriskAgent; - -/** - * Default implementation of the AsteriskAgent interface. - * - * @author Patrick Breucking - * @version $Id$ - */ -public class AsteriskAgentImpl extends AbstractLiveObject implements AsteriskAgent -{ - private String name; - private String agentId; - private AgentState state; - - AsteriskAgentImpl(AsteriskServerImpl server, String name, String agentId, AgentState state) - { - super(server); - if (server == null || name == null || agentId == null) - { - throw new IllegalArgumentException("Parameters passed to AsteriskAgentImpl() must not be null."); - } - this.name = name; - this.agentId = agentId; - this.state = state; - } - - public String getName() - { - return name; - } - - public String getAgentId() - { - return agentId; - } - - public AgentState getState() - { - return state; - } - - synchronized void updateState(AgentState state) - { - final AgentState oldState = this.state; - this.state = state; - firePropertyChange(PROPERTY_STATE, oldState, this.state); - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder("AsteriskAgent["); - sb.append("agentId='").append(getAgentId()).append("',"); - sb.append("name='").append(getName()).append("',"); - sb.append("state=").append(getState()).append(","); - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/live/internal/AsteriskChannelImpl.java b/src/main/java/org/asteriskjava/live/internal/AsteriskChannelImpl.java deleted file mode 100644 index 375d30d91..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AsteriskChannelImpl.java +++ /dev/null @@ -1,1066 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.AsteriskQueueEntry; -import org.asteriskjava.live.CallDetailRecord; -import org.asteriskjava.live.CallerId; -import org.asteriskjava.live.ChannelState; -import org.asteriskjava.live.ChannelStateHistoryEntry; -import org.asteriskjava.live.DialedChannelHistoryEntry; -import org.asteriskjava.live.Extension; -import org.asteriskjava.live.ExtensionHistoryEntry; -import org.asteriskjava.live.HangupCause; -import org.asteriskjava.live.LinkedChannelHistoryEntry; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.NoSuchChannelException; -import org.asteriskjava.live.RecordingException; -import org.asteriskjava.manager.action.AbsoluteTimeoutAction; -import org.asteriskjava.manager.action.ChangeMonitorAction; -import org.asteriskjava.manager.action.GetVarAction; -import org.asteriskjava.manager.action.HangupAction; -import org.asteriskjava.manager.action.MonitorAction; -import org.asteriskjava.manager.action.PauseMixMonitorAction; -import org.asteriskjava.manager.action.PauseMonitorAction; -import org.asteriskjava.manager.action.PlayDtmfAction; -import org.asteriskjava.manager.action.RedirectAction; -import org.asteriskjava.manager.action.SetVarAction; -import org.asteriskjava.manager.action.StopMonitorAction; -import org.asteriskjava.manager.action.UnpauseMonitorAction; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.MixMonitorDirection; - -/** - * Default implementation of the AsteriskChannel interface. - * - * @author srt - * @version $Id$ - */ -class AsteriskChannelImpl extends AbstractLiveObject implements AsteriskChannel -{ - private static final String CAUSE_VARIABLE_NAME = "PRI_CAUSE"; - /** - * Date this channel has been created. - */ - private final Date dateOfCreation; - private final List extensionHistory; - private final List stateHistory; - private final List linkedChannelHistory; - private final List dialedChannelHistory; - private final List dialedChannels; - private final List dialingChannels; - /** - * If this channel is bridged to another channel, the linkedChannels - * contains the channel this channel is bridged with. - */ - private final List linkedChannels; - private final Map variables; - /** - * Unique id of this channel. - */ - private String id; - /** - * The traceId is used to trace originated channels. - */ - private String traceId; - /** - * Date this channel has left the Asterisk server. - */ - private Date dateOfRemoval; - /** - * Name of this channel. - */ - private String name; - /** - * Caller*ID of this channel. - */ - private CallerId callerId; - /** - * State of this channel. - */ - private ChannelState state; - /** - * Account code used to bill this channel. - */ - private String account; - /** - * Indicates if this channel was linked to another channel at least once. - */ - private boolean wasLinked; - private HangupCause hangupCause; - private String hangupCauseText; - private CallDetailRecordImpl callDetailRecord; - /** - * MeetMe room user associated with this channel if any, null - * otherwise. - */ - private MeetMeUserImpl meetMeUserImpl; - /** - * Queue entry associated with this channel if any, null - * otherwise. - */ - private AsteriskQueueEntryImpl queueEntryImpl; - /** - * Extension where the call is parked if it is parked, null - * otherwise. - */ - private Extension parkedAt; - /** - * Last dtmf digit recieved on this channel if any, null - * otherwise. - */ - private Character dtmfReceived; - /** - * Last dtmf digit sent on this channel if any, null otherwise. - */ - private Character dtmfSent; - /** - * Actual monitor state - */ - private boolean isMonitored; - - /** - * Creates a new Channel. - * - * @param server server this channel belongs to. - * @param name name of this channel, for example "SIP/1310-20da". - * @param id unique id of this channel, for example "1099015093.165". - * @param dateOfCreation date this channel has been created. - * @throws IllegalArgumentException if any of the parameters are null. - */ - AsteriskChannelImpl(final AsteriskServerImpl server, final String name, final String id, final Date dateOfCreation) - throws IllegalArgumentException - { - super(server); - - if (server == null) - { - throw new IllegalArgumentException("Parameter 'server' passed to AsteriskChannelImpl() must not be null."); - } - if (name == null) - { - throw new IllegalArgumentException("Parameter 'name' passed to AsteriskChannelImpl() must not be null."); - } - if (id == null) - { - throw new IllegalArgumentException("Parameter 'id' passed to AsteriskChannelImpl() must not be null."); - } - if (dateOfCreation == null) - { - throw new IllegalArgumentException( - "Parameter 'dateOfCreation' passed to AsteriskChannelImpl() must not be null."); - } - - this.name = name; - this.id = id; - this.dateOfCreation = dateOfCreation; - this.extensionHistory = new ArrayList<>(); - this.stateHistory = new ArrayList<>(); - this.linkedChannelHistory = new ArrayList<>(); - this.dialedChannelHistory = new ArrayList<>(); - this.variables = new HashMap<>(); - this.dialedChannels = new ArrayList<>(); - this.dialingChannels = new ArrayList<>(); - this.linkedChannels = new ArrayList<>(); - } - - public String getId() - { - return id; - } - - /** - * Changes the id of this channel. - * - * @param date date of the name change. - * @param id the new unique id of this channel. - */ - void idChanged(Date date, String id) - { - final String oldId = this.id; - - if (oldId != null && oldId.equals(id)) - { - return; - } - - this.id = id; - firePropertyChange(PROPERTY_ID, oldId, id); - } - - String getTraceId() - { - return traceId; - } - - void setTraceId(String traceId) - { - this.traceId = traceId; - } - - public String getName() - { - return name; - } - - /** - * Changes the name of this channel. - * - * @param date date of the name change. - * @param name the new name of this channel. - */ - void nameChanged(Date date, String name) - { - final String oldName = this.name; - - if (oldName != null && oldName.equals(name)) - { - return; - } - - this.name = name; - firePropertyChange(PROPERTY_NAME, oldName, name); - } - - public CallerId getCallerId() - { - return callerId; - } - - /** - * Sets the caller id of this channel. - * - * @param callerId the caller id of this channel. - */ - void setCallerId(final CallerId callerId) - { - final CallerId oldCallerId = this.callerId; - - this.callerId = callerId; - firePropertyChange(PROPERTY_CALLER_ID, oldCallerId, callerId); - } - - public ChannelState getState() - { - return state; - } - - public boolean wasInState(ChannelState state) - { - synchronized (stateHistory) - { - for (ChannelStateHistoryEntry historyEntry : stateHistory) - { - if (historyEntry.getState() == state) - { - return true; - } - } - } - - return false; - } - - public boolean wasBusy() - { - return wasInState(ChannelState.BUSY) || hangupCause == HangupCause.AST_CAUSE_BUSY - || hangupCause == HangupCause.AST_CAUSE_USER_BUSY; - } - - /** - * Changes the state of this channel. - * - * @param date when the state change occurred. - * @param state the new state of this channel. - */ - synchronized void stateChanged(Date date, ChannelState state) - { - final ChannelStateHistoryEntry historyEntry; - final ChannelState oldState = this.state; - - if (oldState == state) - { - return; - } - - // System.err.println(id + " state change: " + oldState + " => " + state - // + " (" + name + ")"); - historyEntry = new ChannelStateHistoryEntry(date, state); - synchronized (stateHistory) - { - stateHistory.add(historyEntry); - } - - this.state = state; - firePropertyChange(PROPERTY_STATE, oldState, state); - } - - public String getAccount() - { - return account; - } - - /** - * Sets the account code used to bill this channel. - * - * @param account the account code used to bill this channel. - */ - void setAccount(String account) - { - final String oldAccount = this.account; - - this.account = account; - firePropertyChange(PROPERTY_ACCOUNT, oldAccount, account); - } - - public Extension getCurrentExtension() - { - final Extension extension; - - synchronized (extensionHistory) - { - if (extensionHistory.isEmpty()) - { - extension = null; - } - else - { - extension = extensionHistory.get(extensionHistory.size() - 1).getExtension(); - } - } - - return extension; - } - - public Extension getFirstExtension() - { - final Extension extension; - - synchronized (extensionHistory) - { - if (extensionHistory.isEmpty()) - { - extension = null; - } - else - { - extension = extensionHistory.get(0).getExtension(); - } - } - - return extension; - } - - public List getExtensionHistory() - { - final List copy; - - synchronized (extensionHistory) - { - copy = new ArrayList<>(extensionHistory); - } - - return copy; - } - - /** - * Adds a visted dialplan entry to the history. - * - * @param date the date the extension has been visited. - * @param extension the visted dialplan entry to add. - */ - void extensionVisited(Date date, Extension extension) - { - final Extension oldCurrentExtension = getCurrentExtension(); - final ExtensionHistoryEntry historyEntry; - - historyEntry = new ExtensionHistoryEntry(date, extension); - - synchronized (extensionHistory) - { - extensionHistory.add(historyEntry); - } - - firePropertyChange(PROPERTY_CURRENT_EXTENSION, oldCurrentExtension, extension); - } - - public Date getDateOfCreation() - { - return dateOfCreation; - } - - public Date getDateOfRemoval() - { - return dateOfRemoval; - } - - public HangupCause getHangupCause() - { - return hangupCause; - } - - public String getHangupCauseText() - { - return hangupCauseText; - } - - public CallDetailRecord getCallDetailRecord() - { - return callDetailRecord; - } - - void callDetailRecordReceived(Date date, CallDetailRecordImpl callDetailRecord) - { - final CallDetailRecordImpl oldCallDetailRecord = this.callDetailRecord; - - this.callDetailRecord = callDetailRecord; - firePropertyChange(PROPERTY_CALL_DETAIL_RECORD, oldCallDetailRecord, callDetailRecord); - } - - /** - * Sets dateOfRemoval, hangupCause and hangupCauseText and changes state to - * {@link ChannelState#HUNGUP}. Fires a PropertyChangeEvent for state. - * - * @param dateOfRemoval date the channel was hung up - * @param hangupCause cause for hangup - * @param hangupCauseText textual representation of hangup cause - */ - synchronized void hungup(Date dateOfRemoval, HangupCause hangupCause, String hangupCauseText) - { - this.dateOfRemoval = dateOfRemoval; - this.hangupCause = hangupCause; - this.hangupCauseText = hangupCauseText; - // update state and fire PropertyChangeEvent - stateChanged(dateOfRemoval, ChannelState.HUNGUP); - } - - /** - * Retrives the conplete List of all dialed channels associated to ths calls - * - * @return List of all dialed channels - */ - public List getDialedChannels() - { - final List copy; - - synchronized (dialedChannels) - { - copy = new ArrayList<>(dialedChannels); - } - - return copy; - } - - /* dialed channels */ - - public AsteriskChannel getDialedChannel() - { - synchronized (dialedChannels) - { - for (AsteriskChannel channel : dialedChannels) - { - if (channel != null) - return channel; - } - } - return null; - } - - public List getDialedChannelHistory() - { - final List copy; - - synchronized (dialedChannelHistory) - { - copy = new ArrayList<>(dialedChannelHistory); - } - - return copy; - } - - synchronized void channelDialed(Date date, AsteriskChannel dialedChannel) - { - final AsteriskChannel oldDialedChannel; - synchronized (dialedChannels) - { - if (dialedChannels.isEmpty()) - oldDialedChannel = null; - else - oldDialedChannel = dialedChannels.get(dialedChannels.size() - 1); - dialedChannels.add(dialedChannel); - } - final DialedChannelHistoryEntry historyEntry; - - historyEntry = new DialedChannelHistoryEntry(date, dialedChannel); - synchronized (dialedChannelHistory) - { - dialedChannelHistory.add(historyEntry); - } - - firePropertyChange(PROPERTY_DIALED_CHANNEL, oldDialedChannel, dialedChannel); - } - - /* dialed channels */ - - public AsteriskChannel getDialingChannel() - { - synchronized (dialingChannels) - { - if (dialingChannels.isEmpty()) - return null; - return dialingChannels.get(0); - } - } - - synchronized void channelDialing(Date date, AsteriskChannel dialingChannel) - { - final AsteriskChannel oldDialingChannel; - synchronized (this.dialingChannels) - { - if (this.dialingChannels.isEmpty()) - { - oldDialingChannel = null; - this.dialingChannels.add(dialingChannel); - } - else - { - oldDialingChannel = this.dialingChannels.get(0); - this.dialingChannels.set(0, dialingChannel); - } - } - - firePropertyChange(PROPERTY_DIALING_CHANNEL, oldDialingChannel, dialingChannel); - } - - /* linked channels */ - - public AsteriskChannel getLinkedChannel() - { - synchronized (linkedChannels) - { - if (linkedChannels.isEmpty()) - return null; - return linkedChannels.get(0); - } - } - - public List getLinkedChannelHistory() - { - final List copy; - - synchronized (linkedChannelHistory) - { - copy = new ArrayList<>(linkedChannelHistory); - } - - return copy; - } - - public boolean wasLinked() - { - return wasLinked; - } - - /** - * Sets the channel this channel is bridged with. - * - * @param date the date this channel was linked. - * @param linkedChannel the channel this channel is bridged with. - */ - synchronized void channelLinked(Date date, AsteriskChannel linkedChannel) - { - final AsteriskChannel oldLinkedChannel; - synchronized (this.linkedChannels) - { - if (this.linkedChannels.isEmpty()) - { - oldLinkedChannel = null; - this.linkedChannels.add(linkedChannel); - } - else - { - oldLinkedChannel = this.linkedChannels.get(0); - this.linkedChannels.set(0, linkedChannel); - } - } - - final LinkedChannelHistoryEntry historyEntry; - - historyEntry = new LinkedChannelHistoryEntry(date, linkedChannel); - synchronized (linkedChannelHistory) - { - linkedChannelHistory.add(historyEntry); - } - this.wasLinked = true; - firePropertyChange(PROPERTY_LINKED_CHANNEL, oldLinkedChannel, linkedChannel); - } - - synchronized void channelUnlinked(Date date) - { - final AsteriskChannel oldLinkedChannel; - - synchronized (this.linkedChannels) - { - if (this.linkedChannels.isEmpty()) - { - oldLinkedChannel = null; - } - else - { - oldLinkedChannel = this.linkedChannels.get(0); - } - linkedChannels.clear(); - } - - final LinkedChannelHistoryEntry historyEntry; - - synchronized (linkedChannelHistory) - { - if (linkedChannelHistory.isEmpty()) - { - historyEntry = null; - } - else - { - historyEntry = linkedChannelHistory.get(linkedChannelHistory.size() - 1); - } - } - - if (historyEntry != null) - { - historyEntry.setDateUnlinked(date); - } - - firePropertyChange(PROPERTY_LINKED_CHANNEL, oldLinkedChannel, null); - } - - /* MeetMe user */ - - public MeetMeUserImpl getMeetMeUser() - { - return meetMeUserImpl; - } - - void setMeetMeUserImpl(MeetMeUserImpl meetMeUserImpl) - { - final MeetMeUserImpl oldMeetMeUserImpl = this.meetMeUserImpl; - this.meetMeUserImpl = meetMeUserImpl; - firePropertyChange(PROPERTY_MEET_ME_USER, oldMeetMeUserImpl, meetMeUserImpl); - } - - // action methods - - public void hangup() throws ManagerCommunicationException, NoSuchChannelException - { - hangup(null); - } - - public void hangup(HangupCause cause) throws ManagerCommunicationException, NoSuchChannelException - { - final HangupAction action; - final ManagerResponse response; - - if (cause != null) - { - setVariable(CAUSE_VARIABLE_NAME, Integer.toString(cause.getCode())); - action = new HangupAction(name, cause.getCode()); - } - else - { - action = new HangupAction(name); - } - - response = server.sendAction(action); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void setAbsoluteTimeout(int seconds) throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new AbsoluteTimeoutAction(name, seconds)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void redirect(String context, String exten, int priority) - throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new RedirectAction(name, context, exten, priority)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void redirectBothLegs(String context, String exten, int priority) - throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - synchronized (linkedChannels) - { - if (linkedChannels.isEmpty()) - { - response = server.sendAction(new RedirectAction(name, context, exten, priority)); - } - else - { - response = server.sendAction(new RedirectAction(name, linkedChannels.get(0).getName(), context, exten, - priority, context, exten, priority)); - } - } - - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public String getVariable(String variable) throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - String value; - - synchronized (variables) - { - - value = variables.get(variable); - if (value != null) - { - return value; - } - - response = server.sendAction(new GetVarAction(name, variable)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - value = response.getAttribute("Value"); - if (value == null) - { - value = response.getAttribute(variable); // for Asterisk 1.0.x - } - - variables.put(variable, value); - } - return value; - } - - public void setVariable(String variable, String value) throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new SetVarAction(name, variable, value)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - synchronized (variables) - { - variables.put(variable, value); - } - } - - public void playDtmf(String digit) throws ManagerCommunicationException, NoSuchChannelException, IllegalArgumentException - { - ManagerResponse response; - - if (digit == null) - { - throw new IllegalArgumentException("DTMF digit to send must not be null"); - } - - response = server.sendAction(new PlayDtmfAction(name, digit)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void startMonitoring(String filename) throws ManagerCommunicationException, NoSuchChannelException - { - startMonitoring(filename, null, false); - } - - public void startMonitoring(String filename, String format) throws ManagerCommunicationException, NoSuchChannelException - { - startMonitoring(filename, format, false); - } - - public void startMonitoring(String filename, String format, boolean mix) - throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new MonitorAction(name, filename, format, mix)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void changeMonitoring(String filename) - throws ManagerCommunicationException, NoSuchChannelException, IllegalArgumentException - { - ManagerResponse response; - - if (filename == null) - { - throw new IllegalArgumentException("New filename must not be null"); - } - - response = server.sendAction(new ChangeMonitorAction(name, filename)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void stopMonitoring() throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new StopMonitorAction(name)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void pauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new PauseMonitorAction(name)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void unpauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException - { - ManagerResponse response; - - response = server.sendAction(new UnpauseMonitorAction(name)); - if (response instanceof ManagerError) - { - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void pauseMixMonitor(MixMonitorDirection direction) - throws ManagerCommunicationException, NoSuchChannelException, RecordingException - { - ManagerResponse response; - response = server.sendAction(new PauseMixMonitorAction(this.name, 1, direction.getStateName())); - if (response instanceof ManagerError) - { - if (response.getMessage().equals("Cannot set mute flag")) - { - throw new RecordingException(response.getMessage() + " on channel: '" + name); - } - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public void unPauseMixMonitor(MixMonitorDirection direction) - throws ManagerCommunicationException, NoSuchChannelException, RecordingException - { - ManagerResponse response; - response = server.sendAction(new PauseMixMonitorAction(this.name, 0, direction.getStateName())); - if (response instanceof ManagerError) - { - if (response.getMessage().equals("Cannot set mute flag")) - { - throw new RecordingException(response.getMessage() + " on channel: '" + name); - } - throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage()); - } - } - - public Extension getParkedAt() - { - // warning: the context of this extension will be null until we get the - // context property from - // the parked call event! - return parkedAt; - } - - void setParkedAt(Extension parkedAt) - { - final Extension oldParkedAt = this.parkedAt; - - this.parkedAt = parkedAt; - firePropertyChange(PROPERTY_PARKED_AT, oldParkedAt, parkedAt); - } - - void updateVariable(String name, String value) - { - synchronized (variables) - { - // final String oldValue = variables.get(name); - variables.put(name, value); - // TODO add notification for updated channel variables - } - } - - public Map getVariables() - { - synchronized (variables) - { - return new HashMap<>(variables); - } - } - - public Character getDtmfReceived() - { - return this.dtmfReceived; - } - - public Character getDtmfSent() - { - return this.dtmfSent; - } - - void dtmfReceived(Character digit) - { - final Character oldDtmfReceived = this.dtmfReceived; - - this.dtmfReceived = digit; - firePropertyChange(PROPERTY_DTMF_RECEIVED, oldDtmfReceived, digit); - } - - void dtmfSent(Character digit) - { - final Character oldDtmfSent = this.dtmfSent; - - this.dtmfSent = digit; - firePropertyChange(PROPERTY_DTMF_SENT, oldDtmfSent, digit); - } - - public AsteriskQueueEntryImpl getQueueEntry() - { - return queueEntryImpl; - } - - void setQueueEntry(AsteriskQueueEntryImpl queueEntry) - { - final AsteriskQueueEntry oldQueueEntry = this.queueEntryImpl; - - this.queueEntryImpl = queueEntry; - firePropertyChange(PROPERTY_QUEUE_ENTRY, oldQueueEntry, queueEntry); - } - - public boolean isMonitored() - { - return this.isMonitored; - } - - void setMonitored(boolean monitored) - { - final boolean oldMonitored = this.isMonitored; - - this.isMonitored = monitored; - firePropertyChange(PROPERTY_MONITORED, oldMonitored, monitored); - } - - @Override - public String toString() - { - final StringBuilder sb; - final List dialedChannels; - final List dialingChannel; - final List linkedChannel; - - sb = new StringBuilder("AsteriskChannel["); - - synchronized (this) - { - sb.append("id='").append(getId()).append("',"); - sb.append("name='").append(getName()).append("',"); - sb.append("callerId='").append(getCallerId()).append("',"); - sb.append("state='").append(getState()).append("',"); - sb.append("account='").append(getAccount()).append("',"); - sb.append("dateOfCreation=").append(getDateOfCreation()).append(","); - dialedChannels = getDialedChannels(); - dialingChannel = this.dialingChannels; - linkedChannel = this.linkedChannels; - } - if (dialedChannels.isEmpty()) - { - sb.append("dialedChannel=null,"); - } - else - { - sb.append("dialedChannel=AsteriskChannel["); - synchronized (dialedChannels) - { - for (AsteriskChannel dialedChannel : dialedChannels) - { - sb.append("[id='").append(dialedChannel.getId()).append("',"); - sb.append("name='").append(dialedChannel.getName()).append("'],"); - } - sb.append("],"); - } - } - if (dialingChannel.isEmpty()) - { - sb.append("dialingChannel=null,"); - } - else - { - sb.append("dialingChannel=AsteriskChannel["); - sb.append("id='").append(dialingChannel.get(0).getId()).append("',"); - sb.append("name='").append(dialingChannel.get(0).getName()).append("'],"); - } - synchronized (linkedChannel) - { - if (linkedChannel.isEmpty()) - { - sb.append("linkedChannel=null"); - } - else - { - sb.append("linkedChannel=AsteriskChannel["); - { - sb.append("id='").append(linkedChannel.get(0).getId()).append("',"); - sb.append("name='").append(linkedChannel.get(0).getName()).append("']"); - } - } - } - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/AsteriskQueueEntryImpl.java b/src/main/java/org/asteriskjava/live/internal/AsteriskQueueEntryImpl.java deleted file mode 100644 index 4ab3d0f90..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AsteriskQueueEntryImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.asteriskjava.live.internal; - -import java.util.Date; - -import org.asteriskjava.live.AsteriskQueueEntry; -import org.asteriskjava.live.QueueEntryState; - -/** - * Default implementation of the AsteriskQueueEntry interface. - * - * @author gmi - */ -class AsteriskQueueEntryImpl extends AbstractLiveObject implements AsteriskQueueEntry -{ - private final AsteriskQueueImpl queue; - private final AsteriskChannelImpl channel; - private final Date dateJoined; - - private Date dateLeft; - private QueueEntryState state; - - // the position as given by asterisk in the queue entry or join event. - // we cannot work reliably with it because asterisk doesn't tell us when it shifts the entries. - private int reportedPosition; - - // The position of this entry in our representation of the queue. Will be set - // and maintained by the respective queue when the entry is added/removed/shifted - private int position = POSITION_UNDETERMINED; - - AsteriskQueueEntryImpl(AsteriskServerImpl server, AsteriskQueueImpl queue, - AsteriskChannelImpl channel, int reportedPosition, Date dateJoined) - { - super(server); - this.queue = queue; - this.channel = channel; - this.dateJoined = dateJoined; - this.state = QueueEntryState.JOINED; - this.reportedPosition = reportedPosition; - } - - public String getChannelName() - { - return channel.getName(); - } - - public AsteriskQueueImpl getQueue() - { - return queue; - } - - public AsteriskChannelImpl getChannel() - { - return channel; - } - - public Date getDateJoined() - { - return dateJoined; - } - - public Date getDateLeft() - { - return dateLeft; - } - - /** - * Sets the status to {@link QueueEntryState#LEFT} and dateLeft to the given date. - * - * @param dateLeft the date this member left the queue. - */ - void left(Date dateLeft) - { - QueueEntryState oldState; - synchronized (this) - { - oldState = this.state; - this.dateLeft = dateLeft; - this.state = QueueEntryState.LEFT; - } - firePropertyChange(PROPERTY_STATE, oldState, state); - } - - public QueueEntryState getState() - { - return state; - } - - /** - * Gets the position as reported by Asterisk when the entry was created. - * Currently we don't update this property as the entry shifts through the queue, - * see getPosition() instead. - * - * @return the position of the entry in the respective queue, starting at 1 - */ - public int getReportedPosition() - { - return reportedPosition; - } - - /** - * Gets the position in the queue based on the queue's internal list - *
- * As Asterisk doesn't send events when it shifts entries in the queue - * we'll base our positions on our internal queue entries ordered list. - * It should be coherent as entries are always added at the end of the queue - * and we don't mind if it is different from asterisk's view as long as the - * relative order stays the same. Most of the time the position will be the same - * but right after asterisk removes an entry it could differ as the shift occurs - * asynchronously in asterisk queues. As a consequence we might have temporary holes - * in the asterisk numbering. - * - * @return the position of the entry in the respective queue, starting at 1 - */ - public int getPosition() - { - return position; - } - - void setPosition(int position) - { - int oldPosition = this.position; - this.position = position; - firePropertyChange(PROPERTY_POSITION, oldPosition, position); - } - - void setReportedPosition(int reportedPosition) - { - int oldPosition = this.reportedPosition; - this.reportedPosition = reportedPosition; - firePropertyChange(PROPERTY_REPORTED_POSITION, oldPosition, reportedPosition); - } - - @Override - public String toString() - { - StringBuilder sb; - int systemHashcode; - - sb = new StringBuilder("AsteriskQueueEntry["); - - synchronized (this) - { - sb.append("dateJoined=").append(getDateJoined()).append(","); - sb.append("postition=").append(getPosition()).append(","); - sb.append("dateLeft=").append(getDateLeft()).append(","); - systemHashcode = System.identityHashCode(this); - } - if (channel != null) - { - sb.append("channel=AsteriskChannel["); - synchronized (channel) - { - sb.append("id='").append(channel.getId()).append("',"); - sb.append("name='").append(channel.getName()).append("'],"); - } - } - else - { - sb.append("channel=null,"); - } - sb.append("systemHashcode=").append(systemHashcode); - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/AsteriskQueueImpl.java b/src/main/java/org/asteriskjava/live/internal/AsteriskQueueImpl.java deleted file mode 100644 index 227739802..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AsteriskQueueImpl.java +++ /dev/null @@ -1,762 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; - -import org.asteriskjava.live.AsteriskQueue; -import org.asteriskjava.live.AsteriskQueueEntry; -import org.asteriskjava.live.AsteriskQueueListener; -import org.asteriskjava.live.AsteriskQueueMember; -import org.asteriskjava.util.AstUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Default implementation of the AsteriskQueue interface. - * - * @author srt - * @version $Id$ - */ -class AsteriskQueueImpl extends AbstractLiveObject implements AsteriskQueue -{ - /** - * TimerTask that monitors exceeding service levels. - * - * @author Patrick Breucking - */ - private class ServiceLevelTimerTask extends TimerTask - { - private final AsteriskQueueEntry entry; - - ServiceLevelTimerTask(AsteriskQueueEntry entry) - { - this.entry = entry; - } - - @Override - public void run() - { - fireServiceLevelExceeded(entry); - } - } - - private final Log logger = LogFactory.getLog(this.getClass()); - private final String name; - private Integer max; - private String strategy; - private Integer serviceLevel; - - /** 101118 Octavio Luna Agregado para Ver cambios en Vivo **/ - private Integer calls; - private Integer holdTime; - private Integer talkTime; - private Integer completed; - private Integer abandoned; - private Double serviceLevelPerf; - /****/ - - private Integer weight; - private final List entries; - private final Timer timer; - private final Map members; - private final List listeners; - private final Map serviceLevelTimerTasks; - - AsteriskQueueImpl(AsteriskServerImpl server, String name, Integer max, - String strategy, Integer serviceLevel, Integer weight, - Integer calls, Integer holdTime, Integer talkTime, - Integer completed, Integer abandoned, Double serviceLevelPerf) - { - super(server); - this.name = name; - this.max = max; - this.strategy = strategy; - this.serviceLevel = serviceLevel; - this.weight = weight; - entries = new ArrayList<>(25); - listeners = new ArrayList<>(); - members = new HashMap<>(); - timer = new Timer("ServiceLevelTimer-" + name, true); - serviceLevelTimerTasks = new HashMap<>(); - this.calls = calls; - this.holdTime = holdTime; - this.talkTime = talkTime; - this.completed = completed; - this.abandoned = abandoned; - this.serviceLevelPerf = serviceLevelPerf; - - stampLastUpdate(); - } - - void cancelServiceLevelTimer() - { - timer.cancel(); - } - - public String getName() - { - return name; - } - - public Integer getMax() - { - return max; - } - - public String getStrategy() - { - return strategy; - } - - /** - * - * @param max - * @return true if value updated, false otherwise - */ - boolean setMax(Integer max) - { - if(!AstUtil.isEqual(this.max, max)){ - this.max = max; - stampLastUpdate(); - return true; - } - return false; - } - - public Integer getServiceLevel() - { - return serviceLevel; - } - - /** - * - * @param serviceLevel - * @return - */ - boolean setServiceLevel(Integer serviceLevel) - { - if(!AstUtil.isEqual(this.serviceLevel, serviceLevel)){ - this.serviceLevel = serviceLevel; - stampLastUpdate(); - return true; - } - return false; - - } - - @Override - public Integer getCalls() { - return calls; - } - - /** - * - * @param calls - * @return true if value updated, false otherwise - */ - boolean setCalls(Integer calls) { - if(!AstUtil.isEqual(this.calls, calls)){ - this.calls = calls; - stampLastUpdate(); - return true; - } - return false; - } - - @Override - public Integer getWaiting() { - return calls; - } - - @Override - public Integer getHoldTime() { - return holdTime; - } - - /** - * - * @param holdTime - * @return true if value updated, false otherwise - */ - boolean setHoldTime(Integer holdTime) { - if(!AstUtil.isEqual(this.holdTime, holdTime)){ - this.holdTime = holdTime; - stampLastUpdate(); - return true; - } - return false; - } - - @Override - public Integer getTalkTime() { - return talkTime; - } - - /** - * - * @param talkTime - * @return true if value updated, false otherwise - */ - boolean setTalkTime(Integer talkTime) { - if(!AstUtil.isEqual(this.talkTime, talkTime)){ - this.talkTime = talkTime; - stampLastUpdate(); - return true; - } - return false; - } - - @Override - public Integer getCompleted() { - return completed; - } - - /** - * - * @param completed - * @return true if value updated, false otherwise - */ - boolean setCompleted(Integer completed) { - if(!AstUtil.isEqual(this.completed, completed)){ - this.completed = completed; - stampLastUpdate(); - return true; - } - return false; - } - - @Override - public Integer getAbandoned() { - return abandoned; - } - - /** - * - * @param abandoned - * @return true if value updated, false otherwise - */ - boolean setAbandoned(Integer abandoned) { - if(!AstUtil.isEqual(this.abandoned, abandoned)){ - this.abandoned = abandoned; - stampLastUpdate(); - return true; - } - - return false; - } - - @Override - public Double getServiceLevelPerf() { - return serviceLevelPerf; - } - - /** - * - * @param serviceLevelPerf - * @return true if value updated, false otherwise - */ - boolean setServiceLevelPerf(Double serviceLevelPerf) { - if(!AstUtil.isEqual(this.serviceLevelPerf, serviceLevelPerf)){ - this.serviceLevelPerf = serviceLevelPerf; - stampLastUpdate(); - return true; - } - return false; - } - - public Integer getWeight() - { - return weight; - } - - /** - * - * @param weight - * @return true if value updated, false otherwise - */ - boolean setWeight(Integer weight) - { - if(!AstUtil.isEqual(this.weight, weight)){ - this.weight = weight; - stampLastUpdate(); - return true; - } - return false; - } - - public List getEntries() - { - synchronized (entries) - { - return new ArrayList(entries); - } - } - - /** - * Shifts the position of the queue entries if needed - * (and fire PCE on queue entries if appropriate). - */ - private void shift() - { - int currentPos = 1; // Asterisk starts at 1 - - synchronized (entries) - { - for (AsteriskQueueEntryImpl qe : entries) - { - // Only set (and fire PCE on qe) if necessary - if (qe.getPosition() != currentPos) - { - qe.setPosition(currentPos); - } - currentPos++; - } - } - } - - /** - * Creates a new AsteriskQueueEntry, adds it to this queue.

- * Fires: - *

    - *
  • PCE on channel
  • - *
  • NewEntry on this queue
  • - *
  • PCE on other queue entries if shifted (never happens)
  • - *
  • NewQueueEntry on server
  • - *
- * - * @param channel the channel that joined the queue - * @param reportedPosition the position as given by Asterisk (currently not used) - * @param dateReceived the date the hannel joined the queue - */ - void createNewEntry(AsteriskChannelImpl channel, int reportedPosition, Date dateReceived) - { - AsteriskQueueEntryImpl qe = new AsteriskQueueEntryImpl(server, this, channel, reportedPosition, dateReceived); - - long delay = serviceLevel * 1000L; - if (delay > 0) - { - ServiceLevelTimerTask timerTask = new ServiceLevelTimerTask(qe); - timer.schedule(timerTask, delay); - synchronized (serviceLevelTimerTasks) - { - serviceLevelTimerTasks.put(qe, timerTask); - } - } - - synchronized (entries) - { - entries.add(qe); // at the end of the list - - // Keep the lock ! - // This will fire PCE on the newly created queue entry - // but hopefully this one has no listeners yet - shift(); - } - - // Set the channel property ony here as queue entries and channels - // maintain a reciprocal reference. - // That way property change on channel and new entry event on queue will be - // lanched when BOTH channel and queue are correctly set. - channel.setQueueEntry(qe); - fireNewEntry(qe); - server.fireNewQueueEntry(qe); - } - - /** - * Removes the given queue entry from the queue.

- * Fires if needed: - *

    - *
  • PCE on channel
  • - *
  • EntryLeave on this queue
  • - *
  • PCE on other queue entries if shifted
  • - *
- * - * @param entry an existing entry object. - * @param dateReceived the remove event was received. - */ - void removeEntry(AsteriskQueueEntryImpl entry, Date dateReceived) - { - synchronized (serviceLevelTimerTasks) - { - if (serviceLevelTimerTasks.containsKey(entry)) - { - ServiceLevelTimerTask timerTask = serviceLevelTimerTasks.get(entry); - timerTask.cancel(); - serviceLevelTimerTasks.remove(entry); - } - } - - boolean changed; - synchronized (entries) - { - changed = entries.remove(entry); - - if (changed) - { - // Keep the lock ! - shift(); - } - } - - // Fire outside lock - if (changed) - { - entry.getChannel().setQueueEntry(null); - entry.left(dateReceived); - fireEntryLeave(entry); - } - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder("AsteriskQueue["); - sb.append("name='").append(getName()).append("',"); - sb.append("max='").append(getMax()).append("',"); - sb.append("strategy='").append(getStrategy()).append("',"); - sb.append("serviceLevel='").append(getServiceLevel()).append("',"); - sb.append("weight='").append(getWeight()).append("',"); - sb.append("calls='").append(getCalls()).append("',"); - sb.append("holdTime='").append(getHoldTime()).append("',"); - sb.append("talkTime='").append(getTalkTime()).append("',"); - sb.append("completed='").append(getCompleted()).append("',"); - sb.append("abandoned='").append(getAbandoned()).append("',"); - sb.append("serviceLevelPerf='").append(getServiceLevelPerf()).append("',"); - - synchronized (entries) - { - sb.append("entries='").append(entries.toString()).append("',"); - } - synchronized (members) - { - sb.append("members='").append(members.toString()).append("',"); - } - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } - - public void addAsteriskQueueListener(AsteriskQueueListener listener) - { - synchronized (listeners) - { - listeners.add(listener); - } - } - - public void removeAsteriskQueueListener(AsteriskQueueListener listener) - { - synchronized (listeners) - { - listeners.remove(listener); - } - } - - /** - * Notifies all registered listener that an entry joins the queue. - * - * @param entry that joins the queue - */ - void fireNewEntry(AsteriskQueueEntryImpl entry) - { - synchronized (listeners) - { - for (AsteriskQueueListener listener : listeners) - { - try - { - listener.onNewEntry(entry); - } - catch (Exception e) - { - logger.warn("Exception in onNewEntry()", e); - } - } - } - } - - /** - * Notifies all registered listener that an entry leaves the queue. - * - * @param entry that leaves the queue. - */ - void fireEntryLeave(AsteriskQueueEntryImpl entry) - { - synchronized (listeners) - { - for (AsteriskQueueListener listener : listeners) - { - try - { - listener.onEntryLeave(entry); - } - catch (Exception e) - { - logger.warn("Exception in onEntryLeave()", e); - } - } - } - } - - /** - * Notifies all registered listener that a member has been added to the queue. - * - * @param member added to the queue - */ - void fireMemberAdded(AsteriskQueueMemberImpl member) - { - synchronized (listeners) - { - for (AsteriskQueueListener listener : listeners) - { - try - { - listener.onMemberAdded(member); - } - catch (Exception e) - { - logger.warn("Exception in onMemberAdded()", e); - } - } - } - } - - /** - * Notifies all registered listener that a member has been removed from the queue. - * - * @param member that has been removed. - */ - void fireMemberRemoved(AsteriskQueueMemberImpl member) - { - synchronized (listeners) - { - for (AsteriskQueueListener listener : listeners) - { - try - { - listener.onMemberRemoved(member); - } - catch (Exception e) - { - logger.warn("Exception in onMemberRemoved()", e); - } - } - } - } - - /** - * Returns a collection of members of this queue. - * - * @see org.asteriskjava.live.AsteriskQueue#getMembers() - */ - public Collection getMembers() - { - List listOfMembers = new ArrayList<>(members.size()); - synchronized (members) - { - for (AsteriskQueueMemberImpl asteriskQueueMember : members.values()) - { - listOfMembers.add(asteriskQueueMember); - } - } - return listOfMembers; - } - - /** - * Returns a member by its location. - * - * @param location ot the member - * @return the member by its location. - */ - AsteriskQueueMemberImpl getMember(String location) - { - synchronized (members) - { - if (members.containsKey(location)) - { - return members.get(location); - } - } - return null; - } - - /** - * Add a new member to this queue. - * - * @param member to add - */ - void addMember(AsteriskQueueMemberImpl member) - { - synchronized (members) - { - // Check if member already exists - if (members.containsValue(member)) - { - return; - } - // If not, add the new member. - logger.info("Adding new member to the queue " + getName() + ": " + member.toString()); - members.put(member.getLocation(), member); - } - - fireMemberAdded(member); - } - - /** - * Retrieves a member by its location. - * - * @param location of the member - * @return the requested member. - */ - AsteriskQueueMemberImpl getMemberByLocation(String location) - { - AsteriskQueueMemberImpl member; - synchronized (members) - { - member = members.get(location); - } - if (member == null) - { - logger.error("Requested member at location " + location + " not found!"); - } - return member; - } - - /** - * Notifies all registered listener that a queue member changes its state. - * - * @param member the changed member. - */ - void fireMemberStateChanged(AsteriskQueueMemberImpl member) - { - synchronized (listeners) - { - for (AsteriskQueueListener listener : listeners) - { - try - { - listener.onMemberStateChange(member); - } - catch (Exception e) - { - logger.warn("Exception in onMemberStateChange()", e); - } - } - } - } - - /** - * Gets an entry of the queue by its channel name. - * - * @param channelName The entry's channel name. - * @return the queue entry if found, null otherwise. - */ - AsteriskQueueEntryImpl getEntry(String channelName) - { - synchronized (entries) - { - for (AsteriskQueueEntryImpl entry : entries) - { - if (entry.getChannel().getName().equals(channelName)) - { - return entry; - } - } - } - return null; - } - - - /** - * Removes a member from this queue. - * - * @param member the member to remove. - */ - public void removeMember(AsteriskQueueMemberImpl member) - { - synchronized (members) - { - // Check if member exists - if (!members.containsValue(member)) - { - return; - } - // If so, remove the member. - logger.info("Remove member from the queue " + getName() + ": " - + member.toString()); - members.remove(member.getLocation()); - } - - fireMemberRemoved(member); - } - - void fireServiceLevelExceeded(AsteriskQueueEntry entry) - { - synchronized (listeners) - { - for (AsteriskQueueListener listener : listeners) - { - try - { - listener.onEntryServiceLevelExceeded(entry); - } - catch (Exception e) - { - logger.warn("Exception in fireServiceLevelExceeded()", e); - } - } - } - } - - /** - * Gets an entry by its (estimated) position in the queue. - * - * @param position the position, starting at 1. - * @return the queue entry if exiting at this position, null otherwise. - */ - AsteriskQueueEntryImpl getEntry(int position) - { - // positions in asterisk start at 1, but list starts at 0 - position--; - AsteriskQueueEntryImpl foundEntry = null; - synchronized (entries) - { - try - { - foundEntry = entries.get(position); - } - catch (IndexOutOfBoundsException e) - { - // For consistency with the above method, - // swallow. We might indeed request the 1st one from time to time - } // NOPMD - } - return foundEntry; - } - -} diff --git a/src/main/java/org/asteriskjava/live/internal/AsteriskQueueMemberImpl.java b/src/main/java/org/asteriskjava/live/internal/AsteriskQueueMemberImpl.java deleted file mode 100644 index 104579866..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AsteriskQueueMemberImpl.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import org.asteriskjava.live.AsteriskQueue; -import org.asteriskjava.live.AsteriskQueueMember; -import org.asteriskjava.live.InvalidPenaltyException; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.NoSuchInterfaceException; -import org.asteriskjava.live.QueueMemberState; -import org.asteriskjava.manager.action.QueuePauseAction; -import org.asteriskjava.manager.action.QueuePenaltyAction; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.AstUtil; - -/** - * Default implementation of a queue member. - * - * @author Patrick Breucking - * @version $Id$ - * @see AsteriskQueueMember - * @since 0.3.1 - */ -class AsteriskQueueMemberImpl extends AbstractLiveObject implements AsteriskQueueMember -{ - private AsteriskQueue queue; - private QueueMemberState state; - private String location; - private Integer penalty; - private boolean paused; - private Integer callsTaken; - private Long lastCall; - private String membership; - - /** - * Creates a new queue member. - * - * @param server server this channel belongs to. - * @param queue queue this member is registered to. - * @param location location of member. - * @param state state of this member. - * @param paused true if this member is currently paused, - * false otherwise. - * @param penalty penalty of this member. - * @param membership "dynamic" if the added member is a dynamic queue - * member, "static" if the added member is a static queue member. - */ - AsteriskQueueMemberImpl(final AsteriskServerImpl server, final AsteriskQueueImpl queue, String location, - QueueMemberState state, boolean paused, Integer penalty, String membership, Integer callsTaken, Long lastCall) - { - super(server); - this.queue = queue; - this.location = location; - this.state = state; - this.penalty = penalty; - this.paused = paused; - this.callsTaken = callsTaken; - this.lastCall = lastCall; - this.membership = membership; - } - - public AsteriskQueue getQueue() - { - return queue; - } - - public String getLocation() - { - return location; - } - - public QueueMemberState getState() - { - return state; - } - - @Override - public Integer getCallsTaken() - { - return callsTaken; - } - - public void setCallsTaken(Integer callsTaken) - { - this.callsTaken = callsTaken; - } - - /** - * Returns the time the last successful call answered by the added member - * was hungup. - * - * @return the time (in seconds since 01/01/1970) the last successful call - * answered by the added member was hungup. - */ - @Override - public Long getLastCall() - { - return lastCall; - } - - public void setLastCall(Long lastCall) - { - this.lastCall = lastCall; - } - - @Deprecated - public boolean getPaused() - { - return isPaused(); - } - - public boolean isPaused() - { - return paused; - } - - public void setPaused(boolean paused) throws ManagerCommunicationException, NoSuchInterfaceException - { - sendPauseAction(new QueuePauseAction(location, queue.getName(), paused)); - } - - public void setPausedAll(boolean paused) throws ManagerCommunicationException, NoSuchInterfaceException - { - sendPauseAction(new QueuePauseAction(location, paused)); - } - - private void sendPauseAction(QueuePauseAction action) throws ManagerCommunicationException, NoSuchInterfaceException - { - final ManagerResponse response = server.sendAction(action); - - if (response instanceof ManagerError) - { - // Message: Interface not found - if (action.getQueue() != null) - { - // Message: Interface not found - throw new NoSuchInterfaceException("Unable to change paused state for '" + action.getInterface() + "' on '" - + action.getQueue() + "': " + response.getMessage()); - } - throw new NoSuchInterfaceException("Unable to change paused state for '" + action.getInterface() - + "' on all queues: " + response.getMessage()); - } - } - - public String getMembership() - { - return membership; - } - - public boolean isStatic() - { - return membership != null && "static".equals(membership); - } - - public boolean isDynamic() - { - return membership != null && "dynamic".equals(membership); - } - - public Integer getPenalty() - { - return penalty; - } - - public void setPenalty(int penalty) - throws IllegalArgumentException, ManagerCommunicationException, InvalidPenaltyException - { - if (penalty < 0) - { - throw new IllegalArgumentException("Penalty must not be negative"); - } - - final ManagerResponse response = server.sendAction(new QueuePenaltyAction(location, penalty, queue.getName())); - if (response instanceof ManagerError) - { - throw new InvalidPenaltyException( - "Unable to set penalty for '" + location + "' on '" + queue.getName() + "': " + response.getMessage()); - } - } - - @Override - public String toString() - { - final StringBuilder sb; - - sb = new StringBuilder("AsteriskQueueMember["); - sb.append("location='").append(location).append("'"); - sb.append("state='").append(state).append("'"); - sb.append("paused='").append(paused).append("'"); - sb.append("membership='").append(membership).append("'"); - sb.append("queue='").append(queue.getName()).append("'"); - sb.append("callsTaken='").append(getCallsTaken()).append("'"); - sb.append("lastCall='").append(getLastCall()).append("'"); - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } - - synchronized boolean stateChanged(QueueMemberState state) - { - if (!AstUtil.isEqual(this.state, state)) - { - QueueMemberState oldState = this.state; - this.state = state; - firePropertyChange(PROPERTY_STATE, oldState, state); - return true; - } - return false; - } - - synchronized boolean penaltyChanged(Integer penalty) - { - if (!AstUtil.isEqual(this.penalty, penalty)) - { - Integer oldPenalty = this.penalty; - this.penalty = penalty; - firePropertyChange(PROPERTY_PENALTY, oldPenalty, penalty); - return true; - } - - return false; - } - - synchronized boolean pausedChanged(boolean paused) - { - if (!AstUtil.isEqual(this.paused, paused)) - { - boolean oldPaused = this.paused; - this.paused = paused; - firePropertyChange(PROPERTY_PAUSED, oldPaused, paused); - return true; - } - return false; - } - - synchronized boolean callsTakenChanged(Integer callsTaken) - { - if (!AstUtil.isEqual(this.callsTaken, callsTaken)) - { - Integer oldcallsTaken = this.callsTaken; - this.callsTaken = callsTaken; - firePropertyChange(PROPERTY_CALLSTAKEN, oldcallsTaken, callsTaken); - return true; - } - return false; - } - - synchronized boolean lastCallChanged(Long lastCall) - { - if (!AstUtil.isEqual(this.lastCall, lastCall)) - { - Long oldlastCall = this.lastCall; - this.lastCall = lastCall; - firePropertyChange(PROPERTY_LASTCALL, oldlastCall, lastCall); - return true; - } - return false; - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/AsteriskServerImpl.java b/src/main/java/org/asteriskjava/live/internal/AsteriskServerImpl.java deleted file mode 100644 index f05b33e40..000000000 --- a/src/main/java/org/asteriskjava/live/internal/AsteriskServerImpl.java +++ /dev/null @@ -1,1494 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.config.ConfigFile; -import org.asteriskjava.live.AsteriskAgent; -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.AsteriskQueue; -import org.asteriskjava.live.AsteriskQueueEntry; -import org.asteriskjava.live.AsteriskServer; -import org.asteriskjava.live.AsteriskServerListener; -import org.asteriskjava.live.CallerId; -import org.asteriskjava.live.ChannelState; -import org.asteriskjava.live.LiveException; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.MeetMeRoom; -import org.asteriskjava.live.MeetMeUser; -import org.asteriskjava.live.NoSuchChannelException; -import org.asteriskjava.live.OriginateCallback; -import org.asteriskjava.live.Voicemailbox; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerConnectionState; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.ManagerEventListenerProxy; -import org.asteriskjava.manager.ResponseEvents; -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.DbGetAction; -import org.asteriskjava.manager.action.DbPutAction; -import org.asteriskjava.manager.action.EventGeneratingAction; -import org.asteriskjava.manager.action.GetConfigAction; -import org.asteriskjava.manager.action.GetVarAction; -import org.asteriskjava.manager.action.MailboxCountAction; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.action.ModuleCheckAction; -import org.asteriskjava.manager.action.ModuleLoadAction; -import org.asteriskjava.manager.action.OriginateAction; -import org.asteriskjava.manager.action.SetVarAction; -import org.asteriskjava.manager.action.SipPeersAction; -import org.asteriskjava.manager.event.AbstractMeetMeEvent; -import org.asteriskjava.manager.event.AgentCallbackLoginEvent; -import org.asteriskjava.manager.event.AgentCallbackLogoffEvent; -import org.asteriskjava.manager.event.AgentCalledEvent; -import org.asteriskjava.manager.event.AgentCompleteEvent; -import org.asteriskjava.manager.event.AgentConnectEvent; -import org.asteriskjava.manager.event.AgentLoginEvent; -import org.asteriskjava.manager.event.AgentLogoffEvent; -import org.asteriskjava.manager.event.AgentsEvent; -import org.asteriskjava.manager.event.BridgeEvent; -import org.asteriskjava.manager.event.CdrEvent; -import org.asteriskjava.manager.event.ConnectEvent; -import org.asteriskjava.manager.event.DbGetResponseEvent; -import org.asteriskjava.manager.event.DialEvent; -import org.asteriskjava.manager.event.DisconnectEvent; -import org.asteriskjava.manager.event.DtmfEvent; -import org.asteriskjava.manager.event.HangupEvent; -import org.asteriskjava.manager.event.JoinEvent; -import org.asteriskjava.manager.event.LeaveEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.MonitorStartEvent; -import org.asteriskjava.manager.event.MonitorStopEvent; -import org.asteriskjava.manager.event.NewCallerIdEvent; -import org.asteriskjava.manager.event.NewChannelEvent; -import org.asteriskjava.manager.event.NewExtenEvent; -import org.asteriskjava.manager.event.NewStateEvent; -import org.asteriskjava.manager.event.OriginateResponseEvent; -import org.asteriskjava.manager.event.ParkedCallEvent; -import org.asteriskjava.manager.event.ParkedCallGiveUpEvent; -import org.asteriskjava.manager.event.ParkedCallTimeOutEvent; -import org.asteriskjava.manager.event.PeerEntryEvent; -import org.asteriskjava.manager.event.QueueMemberAddedEvent; -import org.asteriskjava.manager.event.QueueMemberPausedEvent; -import org.asteriskjava.manager.event.QueueMemberPenaltyEvent; -import org.asteriskjava.manager.event.QueueMemberRemovedEvent; -import org.asteriskjava.manager.event.QueueMemberStatusEvent; -import org.asteriskjava.manager.event.RenameEvent; -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.UnparkedCallEvent; -import org.asteriskjava.manager.event.VarSetEvent; -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.GetConfigResponse; -import org.asteriskjava.manager.response.MailboxCountResponse; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.manager.response.ModuleCheckResponse; -import org.asteriskjava.util.AstUtil; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Default implementation of the {@link AsteriskServer} interface. - * - * @author srt - * @version $Id$ - */ -public class AsteriskServerImpl implements AsteriskServer, ManagerEventListener -{ - private static final String ACTION_ID_PREFIX_ORIGINATE = "AJ_ORIGINATE_"; - private static final String SHOW_VERSION_COMMAND = "show version"; - private static final String SHOW_VERSION_1_6_COMMAND = "core show version"; - private static final String SHOW_VERSION_FILES_COMMAND = "show version files"; - private static final String SHOW_VERSION_FILES_1_6_COMMAND = "core show file version"; - private static final Pattern SHOW_VERSION_FILES_PATTERN = Pattern.compile("^([\\S]+)\\s+Revision: ([0-9\\.]+)"); - private static final String SHOW_VOICEMAIL_USERS_COMMAND = "show voicemail users"; - private static final String SHOW_VOICEMAIL_USERS_1_6_COMMAND = "voicemail show users"; - private static final Pattern SHOW_VOICEMAIL_USERS_PATTERN = Pattern.compile("^(\\S+)\\s+(\\S+)\\s+(.{25})"); - - private final Log logger = LogFactory.getLog(this.getClass()); - - /** - * The underlying manager connection used to receive events from Asterisk. - */ - private ManagerConnection eventConnection; - private ManagerEventListener eventListener = null; - private ManagerEventListenerProxy managerEventListenerProxy; - - private boolean initialized = false; - private boolean initializing = false; - - final Set listeners; - - final ChannelManager channelManager; - final MeetMeManager meetMeManager; - final QueueManager queueManager; - final AgentManager agentManager; - - /** - * The exact version string of the Asterisk server we are connected to. - *

- * Contains null until lazily initialized. - */ - private String version; - - /** - * Holds the version of Asterisk's source files. - *

- * That corresponds to the output of the CLI command - * show version files. - *

- * Contains null until lazily initialized. - */ - private Map versions; - - /** - * Maps the traceId to the corresponding callback data. - */ - private final Map originateCallbacks; - - private final AtomicLong idCounter; - - /* config options */ - - /** - * Flag to skip initializing queues as that results in a timeout on Asterisk - * 1.0.x. - */ - private boolean skipQueues; - - /** - * Set to true to not handle ManagerEvents in the reader tread - * but process them asynchronously. This is a good idea :) - */ - private boolean asyncEventHandling = true; - - /** - * The chainListener allows a listener to receive manager events after they - * have been processed by the AsteriskServer. If the AsteriskServer is - * handling messages using the asyncEventHandling then these messages will - * also be async. You would use the chainListener if you are processing raw - * events and using the AJ live ChannelManager. If you don't use the chain - * listener then you can't be certain that a channel name passed in a raw - * event will match the channel name held by the Channel Manager. By - * chaining events you can be certain that events such as channel Rename - * events have been processed by the live ChannelManager before you receive - * an event and as such the names will always match. - */ - private List chainListeners = new ArrayList<>(); - - /** - * Creates a new instance. - */ - public AsteriskServerImpl() - { - idCounter = new AtomicLong(); - listeners = new LinkedHashSet<>(); - originateCallbacks = new HashMap<>(); - channelManager = new ChannelManager(this); - agentManager = new AgentManager(this); - meetMeManager = new MeetMeManager(this, channelManager); - queueManager = new QueueManager(this, channelManager); - } - - /** - * Creates a new instance. - * - * @param eventConnection the ManagerConnection to use for receiving events - * from Asterisk. - */ - public AsteriskServerImpl(ManagerConnection eventConnection) - { - this(); - setManagerConnection(eventConnection); // todo: !!! Possible bug !!!: - // call to overridable method - // over object construction - } - - /** - * Determines if queue status is retrieved at startup. If you don't need - * queue information and still run Asterisk 1.0.x you can set this to - * true to circumvent the startup delay caused by the missing - * QueueStatusComplete event.
- * Default is false. - * - * @param skipQueues true to skip queue initialization, - * false to not skip. - * @since 0.2 - */ - public void setSkipQueues(boolean skipQueues) - { - this.skipQueues = skipQueues; - } - - public void setManagerConnection(ManagerConnection eventConnection) - { - if (this.eventConnection != null) - { - throw new IllegalStateException("ManagerConnection already set."); - } - - this.eventConnection = eventConnection; - } - - public ManagerConnection getManagerConnection() - { - return eventConnection; - } - - public void initialize() throws ManagerCommunicationException - { - initializeIfNeeded(); - } - - private synchronized void initializeIfNeeded() throws ManagerCommunicationException - { - if (initialized || initializing) - { - return; - } - if (asyncEventHandling && managerEventListenerProxy == null) - { - managerEventListenerProxy = new ManagerEventListenerProxy(this); - eventConnection.addEventListener(managerEventListenerProxy); - } - else if (!asyncEventHandling && eventListener == null) - { - eventListener = this; - eventConnection.addEventListener(eventListener); - } - - initializing = true; - - if (eventConnection.getState() == ManagerConnectionState.INITIAL - || eventConnection.getState() == ManagerConnectionState.DISCONNECTED) - { - try - { - eventConnection.login(); - } - catch (Exception e) - { - throw new ManagerCommunicationException("Unable to login: " + e.getMessage(), e); - } - } - - channelManager.initialize(); - agentManager.initialize(); - meetMeManager.initialize(); - if (!skipQueues) - { - queueManager.initialize(); - } - - if (asyncEventHandling && managerEventListenerProxy == null) - { - managerEventListenerProxy = new ManagerEventListenerProxy(this); - eventConnection.addEventListener(managerEventListenerProxy); - } - else if (!asyncEventHandling && eventListener == null) - { - eventListener = this; - eventConnection.addEventListener(eventListener); - } - logger.info("Initializing done"); - initializing = false; - initialized = true; - } - - /* Implementation of the AsteriskServer interface */ - - public AsteriskChannel originateToExtension(String channel, String context, String exten, int priority, long timeout) - throws ManagerCommunicationException, NoSuchChannelException - { - return originateToExtension(channel, context, exten, priority, timeout, null, null); - } - - public AsteriskChannel originateToExtension(String channel, String context, String exten, int priority, long timeout, - CallerId callerId, Map variables) throws ManagerCommunicationException, NoSuchChannelException - { - final OriginateAction originateAction; - - originateAction = new OriginateAction(); - originateAction.setChannel(channel); - originateAction.setContext(context); - originateAction.setExten(exten); - originateAction.setPriority(priority); - originateAction.setTimeout(timeout); - if (callerId != null) - { - originateAction.setCallerId(callerId.toString()); - } - originateAction.setVariables(variables); - - return originate(originateAction); - } - - public AsteriskChannel originateToApplication(String channel, String application, String data, long timeout) - throws ManagerCommunicationException, NoSuchChannelException - { - return originateToApplication(channel, application, data, timeout, null, null); - } - - public AsteriskChannel originateToApplication(String channel, String application, String data, long timeout, - CallerId callerId, Map variables) throws ManagerCommunicationException, NoSuchChannelException - { - final OriginateAction originateAction; - - originateAction = new OriginateAction(); - originateAction.setChannel(channel); - originateAction.setApplication(application); - originateAction.setData(data); - originateAction.setTimeout(timeout); - if (callerId != null) - { - originateAction.setCallerId(callerId.toString()); - } - originateAction.setVariables(variables); - - return originate(originateAction); - } - - public AsteriskChannel originate(OriginateAction originateAction) - throws ManagerCommunicationException, NoSuchChannelException - { - final ResponseEvents responseEvents; - final Iterator responseEventIterator; - String uniqueId; - AsteriskChannel channel = null; - - // must set async to true to receive OriginateEvents. - originateAction.setAsync(Boolean.TRUE); - - initializeIfNeeded(); - - // 2000 ms extra for the OriginateFailureEvent should be fine - responseEvents = sendEventGeneratingAction(originateAction, originateAction.getTimeout() + 2000); - - responseEventIterator = responseEvents.getEvents().iterator(); - if (responseEventIterator.hasNext()) - { - ResponseEvent responseEvent; - - responseEvent = responseEventIterator.next(); - if (responseEvent instanceof OriginateResponseEvent) - { - uniqueId = ((OriginateResponseEvent) responseEvent).getUniqueId(); - logger.debug(responseEvent.getClass().getName() + " received with uniqueId " + uniqueId); - channel = getChannelById(uniqueId); - } - } - - if (channel == null) - { - throw new NoSuchChannelException("Channel '" + originateAction.getChannel() + "' is not available"); - } - - return channel; - } - - public void originateToExtensionAsync(String channel, String context, String exten, int priority, long timeout, - OriginateCallback cb) throws ManagerCommunicationException - { - originateToExtensionAsync(channel, context, exten, priority, timeout, null, null, cb); - } - - public void originateToExtensionAsync(String channel, String context, String exten, int priority, long timeout, - CallerId callerId, Map variables, OriginateCallback cb) throws ManagerCommunicationException - { - final OriginateAction originateAction; - - originateAction = new OriginateAction(); - originateAction.setChannel(channel); - originateAction.setContext(context); - originateAction.setExten(exten); - originateAction.setPriority(priority); - originateAction.setTimeout(timeout); - if (callerId != null) - { - originateAction.setCallerId(callerId.toString()); - } - originateAction.setVariables(variables); - - originateAsync(originateAction, cb); - } - - public void originateToApplicationAsync(String channel, String application, String data, long timeout, - OriginateCallback cb) throws ManagerCommunicationException - { - originateToApplicationAsync(channel, application, data, timeout, null, null, cb); - } - - public void originateToApplicationAsync(String channel, String application, String data, long timeout, CallerId callerId, - Map variables, OriginateCallback cb) throws ManagerCommunicationException - { - final OriginateAction originateAction; - - originateAction = new OriginateAction(); - originateAction.setChannel(channel); - originateAction.setApplication(application); - originateAction.setData(data); - originateAction.setTimeout(timeout); - if (callerId != null) - { - originateAction.setCallerId(callerId.toString()); - } - originateAction.setVariables(variables); - - originateAsync(originateAction, cb); - } - - public void originateAsync(OriginateAction originateAction, OriginateCallback cb) throws ManagerCommunicationException - { - final Map variables; - final String traceId; - - traceId = ACTION_ID_PREFIX_ORIGINATE + idCounter.getAndIncrement(); - if (originateAction.getVariables() == null) - { - variables = new HashMap<>(); - } - else - { - variables = new HashMap<>(originateAction.getVariables()); - } - - // prefix variable name by "__" to enable variable inheritence across - // channels - variables.put("__" + Constants.VARIABLE_TRACE_ID, traceId); - originateAction.setVariables(variables); - - // async must be set to true to receive OriginateEvents. - originateAction.setAsync(Boolean.TRUE); - originateAction.setActionId(traceId); - - if (cb != null) - { - final OriginateCallbackData callbackData; - - callbackData = new OriginateCallbackData(originateAction, DateUtil.getDate(), cb); - // register callback - synchronized (originateCallbacks) - { - originateCallbacks.put(traceId, callbackData); - } - } - - initializeIfNeeded(); - sendActionOnEventConnection(originateAction); - } - - public Collection getChannels() throws ManagerCommunicationException - { - initializeIfNeeded(); - return channelManager.getChannels(); - } - - public AsteriskChannel getChannelByName(String name) throws ManagerCommunicationException - { - initializeIfNeeded(); - return channelManager.getChannelImplByName(name); - } - - public AsteriskChannel getChannelById(String id) throws ManagerCommunicationException - { - initializeIfNeeded(); - return channelManager.getChannelImplById(id); - } - - public Collection getMeetMeRooms() throws ManagerCommunicationException - { - initializeIfNeeded(); - return meetMeManager.getMeetMeRooms(); - } - - public MeetMeRoom getMeetMeRoom(String name) throws ManagerCommunicationException - { - initializeIfNeeded(); - return meetMeManager.getOrCreateRoomImpl(name); - } - - public Collection getQueues() throws ManagerCommunicationException - { - initializeIfNeeded(); - return queueManager.getQueues(); - } - - @Override - public AsteriskQueue getQueueByName(String queueName) - { - initializeIfNeeded(); - return queueManager.getQueueByName(queueName); - } - - @Override - public List getQueuesUpdatedAfter(Date date) - { - initializeIfNeeded(); - return queueManager.getQueuesUpdatedAfter(date); - } - - public synchronized String getVersion() throws ManagerCommunicationException - { - final ManagerResponse response; - final String command; - - initializeIfNeeded(); - if (version == null) - { - if (eventConnection.getVersion().isAtLeast(AsteriskVersion.ASTERISK_1_6)) - { - command = SHOW_VERSION_1_6_COMMAND; - } - else - { - command = SHOW_VERSION_COMMAND; - } - - response = sendAction(new CommandAction(command)); - if (response instanceof CommandResponse) - { - final List result; - - result = ((CommandResponse) response).getResult(); - if (!result.isEmpty()) - { - version = result.get(0); - } - } - else - { - logger.error("Response to CommandAction(\"" + command + "\") was not a CommandResponse but " + response); - } - } - - return version; - } - - public int[] getVersion(String file) throws ManagerCommunicationException - { - String fileVersion = null; - String[] parts; - int[] intParts; - - initializeIfNeeded(); - if (versions == null) - { - Map map; - ManagerResponse response; - - map = new HashMap<>(); - try - { - final String command; - - if (eventConnection.getVersion().isAtLeast(AsteriskVersion.ASTERISK_1_6)) - { - command = SHOW_VERSION_FILES_1_6_COMMAND; - } - else - { - command = SHOW_VERSION_FILES_COMMAND; - } - response = sendAction(new CommandAction(command)); - if (response instanceof CommandResponse) - { - List result; - - result = ((CommandResponse) response).getResult(); - for (int i = 2; i < result.size(); i++) - { - String line; - Matcher matcher; - - line = result.get(i); - matcher = SHOW_VERSION_FILES_PATTERN.matcher(line); - if (matcher.find()) - { - String key = matcher.group(1); - String value = matcher.group(2); - - map.put(key, value); - } - } - - fileVersion = map.get(file); - versions = map; - } - else - { - logger.error("Response to CommandAction(\"" + command + "\") was not a CommandResponse but " + response); - } - } - catch (Exception e) - { - logger.warn("Unable to send '" + SHOW_VERSION_FILES_COMMAND + "' command.", e); - } - } - else - { - synchronized (versions) - { - fileVersion = versions.get(file); - } - } - - if (fileVersion == null) - { - return null; - } - - parts = fileVersion.split("\\."); - intParts = new int[parts.length]; - - for (int i = 0; i < parts.length; i++) - { - try - { - intParts[i] = Integer.parseInt(parts[i]); - } - catch (NumberFormatException e) - { - intParts[i] = 0; - } - } - - return intParts; - } - - public String getGlobalVariable(String variable) throws ManagerCommunicationException - { - ManagerResponse response; - String value; - - initializeIfNeeded(); - response = sendAction(new GetVarAction(variable)); - if (response instanceof ManagerError) - { - return null; - } - value = response.getAttribute("Value"); - if (value == null) - { - value = response.getAttribute(variable); // for Asterisk 1.0.x - } - return value; - } - - public void setGlobalVariable(String variable, String value) throws ManagerCommunicationException - { - ManagerResponse response; - - initializeIfNeeded(); - response = sendAction(new SetVarAction(variable, value)); - if (response instanceof ManagerError) - { - logger.error("Unable to set global variable '" + variable + "' to '" + value + "':" + response.getMessage()); - } - } - - public Collection getVoicemailboxes() throws ManagerCommunicationException - { - final Collection voicemailboxes; - ManagerResponse response; - final List result; - - initializeIfNeeded(); - voicemailboxes = new ArrayList<>(); - if (eventConnection.getVersion().isAtLeast(AsteriskVersion.ASTERISK_1_6)) - { - response = sendAction(new CommandAction(SHOW_VOICEMAIL_USERS_1_6_COMMAND)); - } - else - { - response = sendAction(new CommandAction(SHOW_VOICEMAIL_USERS_COMMAND)); - } - if (!(response instanceof CommandResponse)) - { - logger.error("Response to CommandAction(\"" + SHOW_VOICEMAIL_USERS_COMMAND + "\") was not a CommandResponse but " - + response); - return voicemailboxes; - } - - result = ((CommandResponse) response).getResult(); - if (result == null || result.isEmpty()) - { - return voicemailboxes; - } - - // remove headline - result.remove(0); - - for (String line : result) - { - final Matcher matcher; - final Voicemailbox voicemailbox; - final String context; - final String mailbox; - final String user; - - matcher = SHOW_VOICEMAIL_USERS_PATTERN.matcher(line); - if (!matcher.find()) - { - continue; - } - - context = matcher.group(1); - mailbox = matcher.group(2); - user = matcher.group(3).trim(); - - voicemailbox = new Voicemailbox(mailbox, context, user); - voicemailboxes.add(voicemailbox); - } - - // get message count for each mailbox - for (Voicemailbox voicemailbox : voicemailboxes) - { - final String fullname; - - fullname = voicemailbox.getMailbox() + "@" + voicemailbox.getContext(); - response = sendAction(new MailboxCountAction(fullname)); - if (response instanceof MailboxCountResponse) - { - MailboxCountResponse mailboxCountResponse; - - mailboxCountResponse = (MailboxCountResponse) response; - voicemailbox.setNewMessages(mailboxCountResponse.getNewMessages()); - voicemailbox.setOldMessages(mailboxCountResponse.getOldMessages()); - } - else - { - logger.error("Response to MailboxCountAction was not a MailboxCountResponse but " + response); - } - } - - return voicemailboxes; - } - - public List executeCliCommand(String command) throws ManagerCommunicationException - { - final ManagerResponse response; - - initializeIfNeeded(); - response = sendAction(new CommandAction(command)); - if (!(response instanceof CommandResponse)) - { - throw new ManagerCommunicationException( - "Response to CommandAction(\"" + command + "\") was not a CommandResponse but " + response, null); - } - - return ((CommandResponse) response).getResult(); - } - - public boolean isModuleLoaded(String module) throws ManagerCommunicationException - { - return sendAction(new ModuleCheckAction(module)) instanceof ModuleCheckResponse; - } - - public void loadModule(String module) throws ManagerCommunicationException - { - sendModuleLoadAction(module, ModuleLoadAction.LOAD_TYPE_LOAD); - } - - public void unloadModule(String module) throws ManagerCommunicationException - { - sendModuleLoadAction(module, ModuleLoadAction.LOAD_TYPE_UNLOAD); - } - - public void reloadModule(String module) throws ManagerCommunicationException - { - sendModuleLoadAction(module, ModuleLoadAction.LOAD_TYPE_RELOAD); - } - - public void reloadAllModules() throws ManagerCommunicationException - { - sendModuleLoadAction(null, ModuleLoadAction.LOAD_TYPE_RELOAD); - } - - protected void sendModuleLoadAction(String module, String loadType) throws ManagerCommunicationException - { - final ManagerResponse response; - - response = sendAction(new ModuleLoadAction(module, loadType)); - if (response instanceof ManagerError) - { - final ManagerError error = (ManagerError) response; - throw new ManagerCommunicationException(error.getMessage(), null); - } - } - - public ConfigFile getConfig(String filename) throws ManagerCommunicationException - { - final ManagerResponse response; - final GetConfigResponse getConfigResponse; - - initializeIfNeeded(); - response = sendAction(new GetConfigAction(filename)); - if (!(response instanceof GetConfigResponse)) - { - throw new ManagerCommunicationException( - "Response to GetConfigAction(\"" + filename + "\") was not a CommandResponse but " + response, null); - } - - getConfigResponse = (GetConfigResponse) response; - - final Map categoryMap = getConfigResponse.getCategories(); - final Map> categories = new LinkedHashMap<>(); - for (Map.Entry categoryEntry : categoryMap.entrySet()) - { - final List lines; - final Map lineMap = getConfigResponse.getLines(categoryEntry.getKey()); - - if (lineMap == null) - { - lines = new ArrayList<>(); - } - else - { - lines = new ArrayList<>(lineMap.values()); - } - - categories.put(categoryEntry.getValue(), lines); - } - - return new ConfigFileImpl(filename, categories); - } - - @Override - public void addAsteriskServerListener(AsteriskServerListener listener) throws ManagerCommunicationException - { - initializeIfNeeded(); - synchronized (listeners) - { - if (!listeners.contains(listener)) - { - listeners.add(listener); - } - } - } - - @Override - public void removeAsteriskServerListener(AsteriskServerListener listener) - { - synchronized (listeners) - { - listeners.remove(listener); - } - } - - @Override - public boolean isAsteriskServerListening(AsteriskServerListener listener) - { - return listeners.contains(listener); - } - - public void addChainListener(ManagerEventListener chainListener) - { - synchronized (this.chainListeners) - { - if (!this.chainListeners.contains(chainListener)) - this.chainListeners.add(chainListener); - } - - } - - public void removeChainListener(ManagerEventListener chainListener) - { - this.chainListeners.remove(chainListener); - } - - void fireNewAsteriskChannel(AsteriskChannel channel) - { - synchronized (listeners) - { - for (AsteriskServerListener listener : listeners) - { - try - { - listener.onNewAsteriskChannel(channel); - } - catch (Exception e) - { - logger.warn("Exception in onNewAsteriskChannel()", e); - } - } - } - } - - void fireNewMeetMeUser(MeetMeUser user) - { - synchronized (listeners) - { - for (AsteriskServerListener listener : listeners) - { - try - { - listener.onNewMeetMeUser(user); - } - catch (Exception e) - { - logger.warn("Exception in onNewMeetMeUser()", e); - } - } - } - } - - ManagerResponse sendActionOnEventConnection(ManagerAction action) throws ManagerCommunicationException - { - try - { - return eventConnection.sendAction(action); - } - catch (Exception e) - { - throw ManagerCommunicationExceptionMapper.mapSendActionException(action.getAction(), e); - } - } - - ManagerResponse sendAction(ManagerAction action) throws ManagerCommunicationException - { - // return connectionPool.sendAction(action); - try - { - return eventConnection.sendAction(action); - } - catch (Exception e) - { - throw ManagerCommunicationExceptionMapper.mapSendActionException(action.getAction(), e); - } - } - - ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) throws ManagerCommunicationException - { - // return connectionPool.sendEventGeneratingAction(action); - try - { - return eventConnection.sendEventGeneratingAction(action); - } - catch (Exception e) - { - throw ManagerCommunicationExceptionMapper.mapSendActionException(action.getAction(), e); - } - } - - ResponseEvents - - sendEventGeneratingAction(EventGeneratingAction action, long timeout) throws ManagerCommunicationException - { - // return connectionPool.sendEventGeneratingAction(action, timeout); - try - { - return eventConnection.sendEventGeneratingAction(action, timeout); - } - catch (Exception e) - { - throw ManagerCommunicationExceptionMapper.mapSendActionException(action.getAction(), e); - } - } - - OriginateCallbackData getOriginateCallbackDataByTraceId(String traceId) - { - synchronized (originateCallbacks) - { - return originateCallbacks.get(traceId); - } - } - - /* Implementation of the ManagerEventListener interface */ - - /** - * Handles all events received from the Asterisk server.
- * Events are queued until channels and queues are initialized and then - * delegated to the dispatchEvent method. - */ - public void onManagerEvent(ManagerEvent event) - { - // Handle Channel related events - if (event instanceof ConnectEvent) - { - handleConnectEvent((ConnectEvent) event); - } - else if (event instanceof DisconnectEvent) - { - handleDisconnectEvent((DisconnectEvent) event); - } - else if (event instanceof NewChannelEvent) - { - channelManager.handleNewChannelEvent((NewChannelEvent) event); - } - else if (event instanceof NewExtenEvent) - { - channelManager.handleNewExtenEvent((NewExtenEvent) event); - } - else if (event instanceof NewStateEvent) - { - channelManager.handleNewStateEvent((NewStateEvent) event); - } - else if (event instanceof NewCallerIdEvent) - { - channelManager.handleNewCallerIdEvent((NewCallerIdEvent) event); - } - else if (event instanceof DialEvent) - { - channelManager.handleDialEvent((DialEvent) event); - } - else if (event instanceof BridgeEvent) - { - channelManager.handleBridgeEvent((BridgeEvent) event); - } - else if (event instanceof RenameEvent) - { - channelManager.handleRenameEvent((RenameEvent) event); - } - else if (event instanceof HangupEvent) - { - channelManager.handleHangupEvent((HangupEvent) event); - } - else if (event instanceof CdrEvent) - { - channelManager.handleCdrEvent((CdrEvent) event); - } - else if (event instanceof VarSetEvent) - { - channelManager.handleVarSetEvent((VarSetEvent) event); - } - else if (event instanceof DtmfEvent) - { - channelManager.handleDtmfEvent((DtmfEvent) event); - } - else if (event instanceof MonitorStartEvent) - { - channelManager.handleMonitorStartEvent((MonitorStartEvent) event); - } - else if (event instanceof MonitorStopEvent) - { - channelManager.handleMonitorStopEvent((MonitorStopEvent) event); - } - // End of channel related events - // Handle parking related event - else if (event instanceof ParkedCallEvent) - { - channelManager.handleParkedCallEvent((ParkedCallEvent) event); - } - else if (event instanceof ParkedCallGiveUpEvent) - { - channelManager.handleParkedCallGiveUpEvent((ParkedCallGiveUpEvent) event); - } - else if (event instanceof ParkedCallTimeOutEvent) - { - channelManager.handleParkedCallTimeOutEvent((ParkedCallTimeOutEvent) event); - } - else if (event instanceof UnparkedCallEvent) - { - channelManager.handleUnparkedCallEvent((UnparkedCallEvent) event); - } - // End of parking related events - // Handle queue related event - else if (event instanceof JoinEvent) - { - queueManager.handleJoinEvent((JoinEvent) event); - } - else if (event instanceof LeaveEvent) - { - queueManager.handleLeaveEvent((LeaveEvent) event); - } - else if (event instanceof QueueMemberStatusEvent) - { - queueManager.handleQueueMemberStatusEvent((QueueMemberStatusEvent) event); - } - else if (event instanceof QueueMemberPenaltyEvent) - { - queueManager.handleQueueMemberPenaltyEvent((QueueMemberPenaltyEvent) event); - } - else if (event instanceof QueueMemberAddedEvent) - { - queueManager.handleQueueMemberAddedEvent((QueueMemberAddedEvent) event); - } - else if (event instanceof QueueMemberRemovedEvent) - { - queueManager.handleQueueMemberRemovedEvent((QueueMemberRemovedEvent) event); - } - else if (event instanceof QueueMemberPausedEvent) - { - queueManager.handleQueueMemberPausedEvent((QueueMemberPausedEvent) event); - } - // >>>>>> AJ 94 - // Handle meetMeEvents - else if (event instanceof AbstractMeetMeEvent) - { - meetMeManager.handleMeetMeEvent((AbstractMeetMeEvent) event); - } - else if (event instanceof OriginateResponseEvent) - { - handleOriginateEvent((OriginateResponseEvent) event); - } - // Handle agents-related events - else if (event instanceof AgentsEvent) - { - agentManager.handleAgentsEvent((AgentsEvent) event); - } - else if (event instanceof AgentCalledEvent) - { - agentManager.handleAgentCalledEvent((AgentCalledEvent) event); - } - else if (event instanceof AgentConnectEvent) - { - agentManager.handleAgentConnectEvent((AgentConnectEvent) event); - } - else if (event instanceof AgentCompleteEvent) - { - agentManager.handleAgentCompleteEvent((AgentCompleteEvent) event); - } - else if (event instanceof AgentCallbackLoginEvent) - { - agentManager.handleAgentCallbackLoginEvent((AgentCallbackLoginEvent) event); - } - else if (event instanceof AgentCallbackLogoffEvent) - { - agentManager.handleAgentCallbackLogoffEvent((AgentCallbackLogoffEvent) event); - } - else if (event instanceof AgentLoginEvent) - { - agentManager.handleAgentLoginEvent((AgentLoginEvent) event); - } - else if (event instanceof AgentLogoffEvent) - { - agentManager.handleAgentLogoffEvent((AgentLogoffEvent) event); - } - // End of agent-related events - - // dispatch the events to the chainListener if they exist. - fireChainListeners(event); - } - - /** - * dispatch the event to the chainListener if they exist. - * - * @param event - */ - private void fireChainListeners(ManagerEvent event) - { - synchronized (this.chainListeners) - { - for (ManagerEventListener listener : this.chainListeners) - listener.onManagerEvent(event); - } - } - - /* - * Resets the internal state when the connection to the asterisk server is - * lost. - */ - - private void handleDisconnectEvent(DisconnectEvent disconnectEvent) - { - // reset version information as it might have changed while Asterisk - // restarted - version = null; - versions = null; - - // same for channels, agents and queues rooms, they are reinitialized - // when reconnected - channelManager.disconnected(); - agentManager.disconnected(); - meetMeManager.disconnected(); - queueManager.disconnected(); - initialized = false; - initializing = false; - } - - /* - * Requests the current state from the asterisk server after the connection - * to the asterisk server is restored. - */ - - private void handleConnectEvent(ConnectEvent connectEvent) - { - try - { - initialize(); - - channelManager.initialize(); - agentManager.initialize(); - meetMeManager.initialize(); - if (!skipQueues) - { - queueManager.initialize(); - } - - logger.info("Initializing done"); - initialized = true; - initializing = false; - } - catch (Exception e) - { - logger.error("Unable to reinitialize state after reconnection", e); - } - } - - private void handleOriginateEvent(OriginateResponseEvent originateEvent) - { - final String traceId; - final OriginateCallbackData callbackData; - final OriginateCallback cb; - final AsteriskChannelImpl channel; - final AsteriskChannelImpl otherChannel; // the other side if local - // channel - - traceId = originateEvent.getActionId(); - if (traceId == null) - { - return; - } - - synchronized (originateCallbacks) - { - callbackData = originateCallbacks.get(traceId); - if (callbackData == null) - { - return; - } - originateCallbacks.remove(traceId); - } - - cb = callbackData.getCallback(); - if (!AstUtil.isNull(originateEvent.getUniqueId())) - { - channel = channelManager.getChannelImplById(originateEvent.getUniqueId()); - } - else - { - channel = callbackData.getChannel(); - } - - try - { - if (channel == null) - { - final LiveException cause; - - cause = new NoSuchChannelException( - "Channel '" + callbackData.getOriginateAction().getChannel() + "' is not available"); - cb.onFailure(cause); - return; - } - - if (channel.wasInState(ChannelState.UP)) - { - cb.onSuccess(channel); - return; - } - - if (channel.wasBusy()) - { - cb.onBusy(channel); - return; - } - - otherChannel = channelManager.getOtherSideOfLocalChannel(channel); - // special treatment of local channels: - // the interesting things happen to the other side so we have a look - // at that - if (otherChannel != null) - { - final AsteriskChannel dialedChannel; - - dialedChannel = otherChannel.getDialedChannel(); - - // on busy the other channel is in state busy when we receive - // the originate event - if (otherChannel.wasBusy()) - { - cb.onBusy(channel); - return; - } - - // alternative: - // on busy the dialed channel is hung up when we receive the - // originate event having a look at the hangup cause reveals the - // information we are interested in - // this alternative has the drawback that there might by - // multiple channels that have been dialed by the local channel - // but we only look at the last one. - if (dialedChannel != null && dialedChannel.wasBusy()) - { - cb.onBusy(channel); - return; - } - } - - // if nothing else matched we asume no answer - cb.onNoAnswer(channel); - } - catch (Throwable t) - { - logger.warn("Exception dispatching originate progress", t); - } - } - - @Override - public void shutdown() - { - if (eventConnection != null && (eventConnection.getState() == ManagerConnectionState.CONNECTED - || eventConnection.getState() == ManagerConnectionState.RECONNECTING)) - { - try - { - eventConnection.logoff(); - } - catch (Exception ignore) - { - } - } - - if (managerEventListenerProxy != null) - { - if (eventConnection != null) - { - eventConnection.removeEventListener(managerEventListenerProxy); - } - managerEventListenerProxy.shutdown(); - } - - if (eventConnection != null && eventListener != null) - { - eventConnection.removeEventListener(eventListener); - } - - managerEventListenerProxy = null; - eventListener = null; - - if (initialized) - {// incredible, but it happened - handleDisconnectEvent(null); - } // i - - }// shutdown - - public List getPeerEntries() throws ManagerCommunicationException - { - ResponseEvents responseEvents = sendEventGeneratingAction(new SipPeersAction(), 2000); - List peerEntries = new ArrayList<>(30); - for (ResponseEvent re : responseEvents.getEvents()) - { - if (re instanceof PeerEntryEvent) - { - peerEntries.add((PeerEntryEvent) re); - } - } - return peerEntries; - } - - public DbGetResponseEvent dbGet(String family, String key) throws ManagerCommunicationException - { - ResponseEvents responseEvents = sendEventGeneratingAction(new DbGetAction(family, key), 2000); - DbGetResponseEvent dbgre = null; - for (ResponseEvent re : responseEvents.getEvents()) - { - dbgre = (DbGetResponseEvent) re; - } - return dbgre; - } - - public void dbDel(String family, String key) throws ManagerCommunicationException - { - // The following only works with BRIStuffed asrterisk: sendAction(new - // DbDelAction(family,key)); - // Use cli command instead ... - sendAction(new CommandAction("database del " + family + " " + key)); - } - - public void dbPut(String family, String key, String value) throws ManagerCommunicationException - { - sendAction(new DbPutAction(family, key, value)); - } - - public AsteriskChannel getChannelByNameAndActive(String name) throws ManagerCommunicationException - { - initializeIfNeeded(); - return channelManager.getChannelImplByNameAndActive(name); - } - - public Collection getAgents() throws ManagerCommunicationException - { - initializeIfNeeded(); - return agentManager.getAgents(); - } - - void fireNewAgent(AsteriskAgentImpl agent) - { - synchronized (listeners) - { - for (AsteriskServerListener listener : listeners) - { - try - { - listener.onNewAgent(agent); - } - catch (Exception e) - { - logger.warn("Exception in onNewAgent()", e); - } - } - } - } - - void fireNewQueueEntry(AsteriskQueueEntry entry) - { - synchronized (listeners) - { - for (AsteriskServerListener listener : listeners) - { - try - { - listener.onNewQueueEntry(entry); - } - catch (Exception e) - { - logger.warn("Exception in onNewQueueEntry()", e); - } - } - } - } - - /* OCTAVIO LUNA */ - @Override - public void forceQueuesMonitor(boolean force) - { - queueManager.forceQueuesMonitor(force); - } - - @Override - public boolean isQueuesMonitorForced() - { - return queueManager.isQueuesMonitorForced(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/CallDetailRecordImpl.java b/src/main/java/org/asteriskjava/live/internal/CallDetailRecordImpl.java deleted file mode 100644 index cc93521ba..000000000 --- a/src/main/java/org/asteriskjava/live/internal/CallDetailRecordImpl.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; - -import org.asteriskjava.live.AmaFlags; -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.CallDetailRecord; -import org.asteriskjava.live.Disposition; -import org.asteriskjava.manager.event.CdrEvent; - -/** - * Default implementation of the CallDetailRecord interface. - */ -public class CallDetailRecordImpl implements CallDetailRecord -{ - private static final Map DISPOSITION_MAP; - private static final Map AMA_FLAGS_MAP; - private final AsteriskChannelImpl channel; - private final AsteriskChannelImpl destinationChannel; - - private final String accountCode; - private final String destinationContext; - private final String destinationExtension; - private final String lastApplication; - private final String lastAppData; - private final Date startDate; - private final Date answerDate; - private final Date endDate; - private final Integer duration; - private final Integer billableSeconds; - private final Disposition disposition; - private final AmaFlags amaFlags; - private final String userField; - - static - { - DISPOSITION_MAP = new HashMap<>(); - DISPOSITION_MAP.put(CdrEvent.DISPOSITION_ANSWERED, Disposition.ANSWERED); - DISPOSITION_MAP.put(CdrEvent.DISPOSITION_BUSY, Disposition.BUSY); - DISPOSITION_MAP.put(CdrEvent.DISPOSITION_FAILED, Disposition.FAILED); - DISPOSITION_MAP.put(CdrEvent.DISPOSITION_NO_ANSWER, Disposition.NO_ANSWER); - DISPOSITION_MAP.put(CdrEvent.DISPOSITION_UNKNOWN, Disposition.UNKNOWN); - - AMA_FLAGS_MAP = new HashMap<>(); - AMA_FLAGS_MAP.put(CdrEvent.AMA_FLAG_BILLING, AmaFlags.BILLING); - AMA_FLAGS_MAP.put(CdrEvent.AMA_FLAG_DOCUMENTATION, AmaFlags.DOCUMENTATION); - AMA_FLAGS_MAP.put(CdrEvent.AMA_FLAG_OMIT, AmaFlags.OMIT); - AMA_FLAGS_MAP.put(CdrEvent.AMA_FLAG_UNKNOWN, AmaFlags.UNKNOWN); - } - - CallDetailRecordImpl(AsteriskChannelImpl channel, AsteriskChannelImpl destinationChannel, CdrEvent cdrEvent) - { - //TODO add timezone to AsteriskServer - TimeZone tz = TimeZone.getDefault(); - this.channel = channel; - this.destinationChannel = destinationChannel; - - accountCode = cdrEvent.getAccountCode(); - destinationContext = cdrEvent.getDestinationContext(); - destinationExtension = cdrEvent.getDestination(); - lastApplication = cdrEvent.getLastApplication(); - lastAppData = cdrEvent.getLastData(); - startDate = cdrEvent.getStartTimeAsDate(tz); - answerDate = cdrEvent.getAnswerTimeAsDate(tz); - endDate = cdrEvent.getEndTimeAsDate(tz); - duration = cdrEvent.getDuration(); - billableSeconds = cdrEvent.getBillableSeconds(); - if (cdrEvent.getAmaFlags() != null) - { - amaFlags = AMA_FLAGS_MAP.get(cdrEvent.getAmaFlags()); - } - else - { - amaFlags = null; - } - if (cdrEvent.getDisposition() != null) - { - disposition = DISPOSITION_MAP.get(cdrEvent.getDisposition()); - } - else - { - disposition = null; - } - userField = cdrEvent.getUserField(); - } - - public AsteriskChannel getChannel() - { - return channel; - } - - public AsteriskChannel getDestinationChannel() - { - return destinationChannel; - } - - public String getAccountCode() - { - return accountCode; - } - - public AmaFlags getAmaFlags() - { - return amaFlags; - } - - public Date getAnswerDate() - { - return answerDate; - } - - public Integer getBillableSeconds() - { - return billableSeconds; - } - - public String getDestinationContext() - { - return destinationContext; - } - - public String getDestinationExtension() - { - return destinationExtension; - } - - public Disposition getDisposition() - { - return disposition; - } - - public Integer getDuration() - { - return duration; - } - - public Date getEndDate() - { - return endDate; - } - - public String getLastApplication() - { - return lastApplication; - } - - public String getLastAppData() - { - return lastAppData; - } - - public Date getStartDate() - { - return startDate; - } - - public String getUserField() - { - return userField; - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/ChannelManager.java b/src/main/java/org/asteriskjava/live/internal/ChannelManager.java deleted file mode 100644 index 9ee0c2136..000000000 --- a/src/main/java/org/asteriskjava/live/internal/ChannelManager.java +++ /dev/null @@ -1,1040 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.CallerId; -import org.asteriskjava.live.ChannelState; -import org.asteriskjava.live.Extension; -import org.asteriskjava.live.HangupCause; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.NoSuchChannelException; -import org.asteriskjava.manager.ResponseEvents; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.event.AbstractChannelEvent; -import org.asteriskjava.manager.event.BridgeEvent; -import org.asteriskjava.manager.event.CdrEvent; -import org.asteriskjava.manager.event.DialEvent; -import org.asteriskjava.manager.event.DtmfEvent; -import org.asteriskjava.manager.event.HangupEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.MonitorStartEvent; -import org.asteriskjava.manager.event.MonitorStopEvent; -import org.asteriskjava.manager.event.NewCallerIdEvent; -import org.asteriskjava.manager.event.NewChannelEvent; -import org.asteriskjava.manager.event.NewExtenEvent; -import org.asteriskjava.manager.event.NewStateEvent; -import org.asteriskjava.manager.event.ParkedCallEvent; -import org.asteriskjava.manager.event.ParkedCallGiveUpEvent; -import org.asteriskjava.manager.event.ParkedCallTimeOutEvent; -import org.asteriskjava.manager.event.RenameEvent; -import org.asteriskjava.manager.event.StatusEvent; -import org.asteriskjava.manager.event.UnparkedCallEvent; -import org.asteriskjava.manager.event.VarSetEvent; -import org.asteriskjava.util.DaemonThreadFactory; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Manages channel events on behalf of an AsteriskServer. - * - * @author srt - * @version $Id$ - */ -class ChannelManager -{ - private final Log logger = LogFactory.getLog(getClass()); - - /** - * How long we wait before we remove hung up channels from memory (in - * milliseconds). - */ - private static final long REMOVAL_THRESHOLD = 15 * 60 * 1000L; // 15 minutes - private static final long SLEEP_TIME_BEFORE_GET_VAR = 50L; - - private final AsteriskServerImpl server; - - /** - * A map of all active channel by their unique id. - */ - final Map channels = new LinkedHashMap<>(); - - ScheduledThreadPoolExecutor traceScheduledExecutorService; - - /** - * Creates a new instance. - * - * @param server the server this channel manager belongs to. - */ - ChannelManager(AsteriskServerImpl server) - { - this.server = server; - } - - void initialize() throws ManagerCommunicationException - { - initialize(null); - } - - void initialize(List variables) throws ManagerCommunicationException - { - ResponseEvents re; - - shutdown(); - - traceScheduledExecutorService = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory());// Executors.newSingleThreadScheduledExecutor - - StatusAction sa = new StatusAction(); - sa.setVariables(variables); - re = server.sendEventGeneratingAction(sa); - for (ManagerEvent event : re.getEvents()) - { - if (event instanceof StatusEvent) - { - handleStatusEvent((StatusEvent) event); - } - } - logger.debug("ChannelManager has been initialised"); - - } - - void disconnected() - { - shutdown(); - logger.debug("ChannelManager has been disconnected from Asterisk."); - } - - private void shutdown() - { - if (traceScheduledExecutorService != null) - { - traceScheduledExecutorService.shutdown(); - } - synchronized (channels) - { - channels.clear(); - } - - } - - - /** - * Returns a collection of all active AsteriskChannels. - * - * @return a collection of all active AsteriskChannels. - */ - Collection getChannels() - { - Collection copy; - - synchronized (channels) - { - copy = new ArrayList<>(channels.size() + 2); - for (AsteriskChannel channel : channels.values()) - { - if (channel.getState() != ChannelState.HUNGUP) - { - copy.add(channel); - } - } - } - return copy; - } - - private void addChannel(AsteriskChannelImpl channel) - { - synchronized (channels) - { - channels.put(channel.getId(), channel); - } - } - - /** - * Removes channels that have been hung more than {@link #REMOVAL_THRESHOLD} - * milliseconds. - */ - private void removeOldChannels() - { - Iterator i; - - synchronized (channels) - { - i = channels.values().iterator(); - while (i.hasNext()) - { - final AsteriskChannel channel = i.next(); - final Date dateOfRemoval = channel.getDateOfRemoval(); - if (channel.getState() == ChannelState.HUNGUP && dateOfRemoval != null) - { - final long diff = DateUtil.getDate().getTime() - dateOfRemoval.getTime(); - if (diff >= REMOVAL_THRESHOLD) - { - i.remove(); - } - } - } - } - } - - private AsteriskChannelImpl addNewChannel(String uniqueId, final String name, Date dateOfCreation, String callerIdNumber, - String callerIdName, ChannelState state, String account) - { - final AsteriskChannelImpl channel = new AsteriskChannelImpl(server, name, uniqueId, dateOfCreation); - channel.setCallerId(new CallerId(callerIdName, callerIdNumber)); - channel.setAccount(account); - channel.stateChanged(dateOfCreation, state); - logger.info("Adding channel " + channel.getName() + "(" + channel.getId() + ")"); - - if (SLEEP_TIME_BEFORE_GET_VAR > 0) - { - long start = System.currentTimeMillis(); - long end = start + SLEEP_TIME_BEFORE_GET_VAR; - while (System.currentTimeMillis() < end) - { - try - { - channel.getVariable(Constants.VARIABLE_TRACE_ID); - } - catch (NoSuchChannelException e) - { - try - { - Thread.sleep(1L); - } - catch (InterruptedException intEx) - { - Thread.currentThread().interrupt(); - } - } - } - } - - String traceId = getTraceId(channel); - channel.setTraceId(traceId); - - addChannel(channel); - - // todo getChannelImplById -> LinkedHashMap, callbacks order - traceScheduledExecutorService.schedule(new Runnable() - { - @Override - public void run() - { - final String traceId = getTraceId(channel); - channel.setTraceId(traceId); - - if (traceId != null && (!name.toLowerCase(Locale.ENGLISH).startsWith("local/") || name.endsWith(",1") - || name.endsWith(";1"))) - { - final OriginateCallbackData callbackData = server.getOriginateCallbackDataByTraceId(traceId); - - if (callbackData != null && callbackData.getChannel() == null) - { - callbackData.setChannel(channel); - try - { - callbackData.getCallback().onDialing(channel); - } - catch (Throwable t) - { - logger.warn("Exception dispatching originate progress. " + channel, t); - } // t - } // i - } // i - } - }, SLEEP_TIME_BEFORE_GET_VAR, TimeUnit.MILLISECONDS); - - server.fireNewAsteriskChannel(channel); - return channel; - }// addNewChannel - - void handleStatusEvent(StatusEvent event) - { - AsteriskChannelImpl channel; - final Extension extension; - boolean isNew = false; - Map variables = event.getVariables(); - - channel = getChannelImplById(event.getUniqueId()); - if (channel == null) - { - Date dateOfCreation; - - if (event.getSeconds() != null) - { - dateOfCreation = new Date(DateUtil.getDate().getTime() - (event.getSeconds() * 1000L)); - } - else - { - dateOfCreation = DateUtil.getDate(); - } - channel = new AsteriskChannelImpl(server, event.getChannel(), event.getUniqueId(), dateOfCreation); - isNew = true; - if (variables != null) - { - for (Entry variable : variables.entrySet()) - { - channel.updateVariable(variable.getKey(), variable.getValue()); - } - } - } - - if (event.getContext() == null && event.getExtension() == null && event.getPriority() == null) - { - extension = null; - } - else - { - extension = new Extension(event.getContext(), event.getExtension(), event.getPriority()); - } - - synchronized (channel) - { - channel.setCallerId(new CallerId(event.getCallerIdName(), event.getCallerIdNum())); - channel.setAccount(event.getAccountCode()); - if (event.getChannelState() != null) - { - channel.stateChanged(event.getDateReceived(), ChannelState.valueOf(event.getChannelState())); - } - channel.extensionVisited(event.getDateReceived(), extension); - - if (event.getBridgedChannel() != null) - { - final AsteriskChannelImpl linkedChannel = getChannelImplByName(event.getBridgedChannel()); - if (linkedChannel != null) - { - // the date used here is not correct! - channel.channelLinked(event.getDateReceived(), linkedChannel); - synchronized (linkedChannel) - { - linkedChannel.channelLinked(event.getDateReceived(), channel); - } - } - } - } - - if (isNew) - { - logger.info("Adding new channel " + channel.getName()); - addChannel(channel); - server.fireNewAsteriskChannel(channel); - } - } - - /** - * Returns a channel from the ChannelManager's cache with the given name If - * multiple channels are found, returns the most recently CREATED one. If - * two channels with the very same date exist, avoid HUNGUP ones. - * - * @param name the name of the requested channel. - * @return the (most recent) channel if found, in any state, or null if none - * found. - */ - AsteriskChannelImpl getChannelImplByName(String name) - { - Date dateOfCreation = null; - AsteriskChannelImpl channel = null; - - if (name == null) - { - return null; - } - - synchronized (channels) - { - for (AsteriskChannelImpl tmp : channels.values()) - { - if (name.equals(tmp.getName())) - { - // return the most recent channel or when dates are similar, - // the active one - if (dateOfCreation == null || tmp.getDateOfCreation().after(dateOfCreation) - || (tmp.getDateOfCreation().equals(dateOfCreation) && tmp.getState() != ChannelState.HUNGUP)) - { - channel = tmp; - dateOfCreation = channel.getDateOfCreation(); - } - } - } - } - return channel; - } - - /** - * Returns a NON-HUNGUP channel from the ChannelManager's cache with the - * given name. - * - * @param name the name of the requested channel. - * @return the NON-HUNGUP channel if found, or null if none is found. - */ - AsteriskChannelImpl getChannelImplByNameAndActive(String name) - { - - // In non bristuffed AST 1.2, we don't have uniqueid header to match the - // channel - // So we must use the channel name - // Channel name is unique at any give moment in the * server - // But asterisk-java keeps Hungup channels for a while. - // We don't want to retrieve hungup channels. - - AsteriskChannelImpl channel = null; - - if (name == null) - { - return null; - } - - synchronized (channels) - { - for (AsteriskChannelImpl tmp : channels.values()) - { - if (name.equals(tmp.getName()) && tmp.getState() != ChannelState.HUNGUP) - { - channel = tmp; - } - } - } - return channel; - } - - AsteriskChannelImpl getChannelImplById(String uniqueId) - { - if (uniqueId == null) - { - return null; - } - - synchronized (channels) - { - return channels.get(uniqueId); - } - }// getChannelImplById - - /** - * Returns the other side of a local channel.
- * Local channels consist of two sides, like "Local/1234@from-local-60b5,1" - * and "Local/1234@from-local-60b5,2" (for Asterisk 1.4) or - * "Local/1234@from-local-60b5;1" and "Local/1234@from-local-60b5;2" (for - * Asterisk 1.6) this method returns the other side. - * - * @param localChannel one side - * @return the other side, or null if not available or if the - * given channel is not a local channel. - */ - AsteriskChannelImpl getOtherSideOfLocalChannel(AsteriskChannel localChannel) - { - final String name; - final char num; - - if (localChannel == null) - { - return null; - } - - name = localChannel.getName(); - if (name == null || !name.startsWith("Local/") - || (name.charAt(name.length() - 2) != ',' && name.charAt(name.length() - 2) != ';')) - { - return null; - } - - num = name.charAt(name.length() - 1); - - if (num == '1') - { - return getChannelImplByName(name.substring(0, name.length() - 1) + "2"); - } - else if (num == '2') - { - return getChannelImplByName(name.substring(0, name.length() - 1) + "1"); - } - else - { - return null; - } - } - - void handleNewChannelEvent(NewChannelEvent event) - { - final AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - - if (channel == null) - { - if (event.getChannel() == null) - { - logger.info("Ignored NewChannelEvent with empty channel name (uniqueId=" + event.getUniqueId() + ")"); - } - else - { - addNewChannel(event.getUniqueId(), event.getChannel(), event.getDateReceived(), event.getCallerIdNum(), - event.getCallerIdName(), ChannelState.valueOf(event.getChannelState()), event.getAccountCode()); - } - } - else - { - // channel had already been created probably by a NewCallerIdEvent - synchronized (channel) - { - channel.nameChanged(event.getDateReceived(), event.getChannel()); - channel.setCallerId(new CallerId(event.getCallerIdName(), event.getCallerIdNum())); - channel.stateChanged(event.getDateReceived(), ChannelState.valueOf(event.getChannelState())); - } - } - } - - void handleNewExtenEvent(NewExtenEvent event) - { - AsteriskChannelImpl channel; - final Extension extension; - - channel = getChannelImplById(event.getUniqueId()); - if (channel == null) - { - logger.warn("handleNewExtenEvent: Ignored NewExtenEvent for unknown channel " + event.getChannel()); - return; - } - - extension = new Extension(event.getContext(), event.getExtension(), event.getPriority(), event.getApplication(), - event.getAppData()); - - synchronized (channel) - { - channel.extensionVisited(event.getDateReceived(), extension); - } - } - - private void idChanged(AsteriskChannelImpl channel, AbstractChannelEvent event) - { - if (channel != null) - { - final String oldId = channel.getId(); - final String newId = event.getUniqueId(); - - if (oldId != null && oldId.equals(newId)) - { - return; - } - - logger.info("Changing unique_id for '" + channel.getName() + "' from " + oldId + " to " + newId + " < " + event); - synchronized (channels) - { - channels.remove(oldId); - channels.put(newId, channel); - channel.idChanged(event.getDateReceived(), newId); - } - } - }// idChanged - - void handleNewStateEvent(NewStateEvent event) - { - AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - - if (channel == null) - { - // NewStateEvent can occur for an existing channel that now has a - // different unique id (originate with Local/) - channel = getChannelImplByNameAndActive(event.getChannel()); - idChanged(channel, event); - - if (channel == null) - { - logger.info("Creating new channel due to NewStateEvent '" + event.getChannel() + "' unique id " - + event.getUniqueId()); - // NewStateEvent can occur instead of a NewChannelEvent - channel = addNewChannel(event.getUniqueId(), event.getChannel(), event.getDateReceived(), - event.getCallerIdNum(), event.getCallerIdName(), ChannelState.valueOf(event.getChannelState()), - null /* account code not available */); - } - } - - // NewStateEvent can provide a new CallerIdNum or CallerIdName not - // previously received through a - // NewCallerIdEvent. This happens at least on outgoing legs from the - // queue application to agents. - if (event.getCallerIdNum() != null || event.getCallerIdName() != null) - { - String cidnum = ""; - String cidname = ""; - CallerId currentCallerId = channel.getCallerId(); - - if (currentCallerId != null) - { - cidnum = currentCallerId.getNumber(); - cidname = currentCallerId.getName(); - } - - if (event.getCallerIdNum() != null) - { - cidnum = event.getCallerIdNum(); - } - - if (event.getCallerIdName() != null) - { - cidname = event.getCallerIdName(); - } - - CallerId newCallerId = new CallerId(cidname, cidnum); - logger.debug("Updating CallerId (following NewStateEvent) to: " + newCallerId.toString()); - channel.setCallerId(newCallerId); - - // Also, NewStateEvent can return a new channel name for the same - // channel uniqueid, indicating the channel has been - // renamed but no related RenameEvent has been received. - // This happens with mISDN channels (see AJ-153) - if (event.getChannel() != null && !event.getChannel().equals(channel.getName())) - { - logger.info("Renaming channel (following NewStateEvent) '" + channel.getName() + "' to '" - + event.getChannel() + "'"); - synchronized (channel) - { - channel.nameChanged(event.getDateReceived(), event.getChannel()); - } - } - } - - if (event.getChannelState() != null) - { - synchronized (channel) - { - channel.stateChanged(event.getDateReceived(), ChannelState.valueOf(event.getChannelState())); - } - } - } - - void handleNewCallerIdEvent(NewCallerIdEvent event) - { - AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - - if (channel == null) - { - // NewCallerIdEvent can occur for an existing channel that now has a - // different unique id (originate with Local/) - channel = getChannelImplByNameAndActive(event.getChannel()); - idChanged(channel, event); - - if (channel == null) - { - // NewCallerIdEvent can occur before NewChannelEvent - channel = addNewChannel(event.getUniqueId(), event.getChannel(), event.getDateReceived(), - event.getCallerIdNum(), event.getCallerIdName(), ChannelState.DOWN, - null /* account code not available */); - } - } - - synchronized (channel) - { - channel.setCallerId(new CallerId(event.getCallerIdName(), event.getCallerIdNum())); - } - } - - void handleHangupEvent(HangupEvent event) - { - HangupCause cause = null; - AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - - if (channel == null) - { - logger.warn("handleHangupEvent: Ignored HangupEvent for unknown channel " + event.getChannel()); - return; - } - - if (event.getCause() != null) - { - cause = HangupCause.getByCode(event.getCause()); - } - - synchronized (channel) - { - channel.hungup(event.getDateReceived(), cause, event.getCauseTxt()); - } - - logger.info("Removing channel " + channel.getName() + " due to hangup (" + cause + ")"); - removeOldChannels(); - } - - void handleDialEvent(DialEvent event) - { - final AsteriskChannelImpl sourceChannel = getChannelImplById(event.getUniqueId()); - final AsteriskChannelImpl destinationChannel = getChannelImplById(event.getDestUniqueId()); - - if (sourceChannel == null) - { - logger.warn("handleDialEvent: Ignored DialEvent for unknown source channel " + event.getChannel() - + " with unique id " + event.getUniqueId()); - return; - } - if (destinationChannel == null) - { - if (DialEvent.SUBEVENT_END.equalsIgnoreCase(event.getSubEvent())) - { - sourceChannel.updateVariable(AsteriskChannel.VAR_AJ_DIAL_STATUS, event.getDialStatus()); - logger.info("handleDialEvent: Ignored DialEvent for unknown dst channel " + event.getDestination() - + " with unique_id " + event.getDestUniqueId()); - } - else - { - logger.warn("handleDialEvent: Ignored DialEvent for unknown dst channel " + event.getDestination() - + " with unique_id " + event.getDestUniqueId()); - } - return; - } // i - - logger.info(sourceChannel.getName() + " dialed " + destinationChannel.getName()); - getTraceId(sourceChannel); - getTraceId(destinationChannel); - synchronized (sourceChannel) - { - sourceChannel.channelDialed(event.getDateReceived(), destinationChannel); - } - synchronized (destinationChannel) - { - destinationChannel.channelDialing(event.getDateReceived(), sourceChannel); - } - } - - void handleBridgeEvent(BridgeEvent event) - { - final AsteriskChannelImpl channel1 = getChannelImplById(event.getUniqueId1()); - final AsteriskChannelImpl channel2 = getChannelImplById(event.getUniqueId2()); - - if (channel1 == null) - { - logger.warn("handleBridgeEvent: Ignored BridgeEvent for unknown channel " + event.getChannel1()); - return; - } - if (channel2 == null) - { - logger.warn("handleBridgeEvent: Ignored BridgeEvent for unknown channel " + event.getChannel2()); - return; - } - - if (event.isLink()) - { - logger.info("Linking channels " + channel1.getName() + " and " + channel2.getName()); - synchronized (channel1) - { - channel1.channelLinked(event.getDateReceived(), channel2); - } - - synchronized (channel2) - { - channel2.channelLinked(event.getDateReceived(), channel1); - } - } - - if (event.isUnlink()) - { - logger.info("Unlinking channels " + channel1.getName() + " and " + channel2.getName()); - synchronized (channel1) - { - channel1.channelUnlinked(event.getDateReceived()); - } - - synchronized (channel2) - { - channel2.channelUnlinked(event.getDateReceived()); - } - } - } - - void handleRenameEvent(RenameEvent event) - { - AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - - if (channel == null) - { - logger.warn("handleRenameEvent: Ignored RenameEvent for unknown channel with uniqueId " + event.getUniqueId()); - return; - } - - logger.info("Renaming channel '" + channel.getName() + "' to '" + event.getNewname() + "', uniqueId is " - + event.getUniqueId()); - synchronized (channel) - { - channel.nameChanged(event.getDateReceived(), event.getNewname()); - } - } - - void handleCdrEvent(CdrEvent event) - { - final AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - final AsteriskChannelImpl destinationChannel = getChannelImplByName(event.getDestinationChannel()); - final CallDetailRecordImpl cdr; - - if (channel == null) - { - logger.info("Ignored CdrEvent for unknown channel with uniqueId " + event.getUniqueId()); - return; - } - - cdr = new CallDetailRecordImpl(channel, destinationChannel, event); - - synchronized (channel) - { - channel.callDetailRecordReceived(event.getDateReceived(), cdr); - } - } - - private String getTraceId(AsteriskChannel channel) - { - String traceId; - - try - { - traceId = channel.getVariable(Constants.VARIABLE_TRACE_ID); - } - catch (Exception e) - { - traceId = null; - } - // logger.info("TraceId for channel " + channel.getName() + " is " + - // traceId); - return traceId; - } - - void handleParkedCallEvent(ParkedCallEvent event) - { - // Only bristuffed versions: AsteriskChannelImpl channel = - // getChannelImplById(event.getUniqueId()); - AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getParkeeChannel()); - - if (channel == null) - { - logger.info("Ignored ParkedCallEvent for unknown channel " + event.getParkeeChannel()); - return; - } - - synchronized (channel) - { - // todo The context should be "parkedcalls" or whatever has been - // configured in features.conf - // unfortunately we don't get the context in the ParkedCallEvent so - // for now we'll set it to null. - Extension ext = new Extension(null, event.getExten(), 1); - channel.setParkedAt(ext); - logger.info("Channel " + channel.getName() + " is parked at " + channel.getParkedAt().getExtension()); - } - } - - void handleParkedCallGiveUpEvent(ParkedCallGiveUpEvent event) - { - // Only bristuffed versions: AsteriskChannelImpl channel = - // getChannelImplById(event.getUniqueId()); - AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getParkeeChannel()); - - if (channel == null) - { - logger.info("Ignored ParkedCallGiveUpEvent for unknown channel " + event.getParkeeChannel()); - return; - } - - Extension wasParkedAt = channel.getParkedAt(); - - if (wasParkedAt == null) - { - logger.info("Ignored ParkedCallGiveUpEvent as the channel was not parked"); - return; - } - - synchronized (channel) - { - channel.setParkedAt(null); - } - logger.info("Channel " + channel.getName() + " is unparked (GiveUp) from " + wasParkedAt.getExtension()); - } - - void handleParkedCallTimeOutEvent(ParkedCallTimeOutEvent event) - { - // Only bristuffed versions: AsteriskChannelImpl channel = - // getChannelImplById(event.getUniqueId()); - final AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getParkeeChannel()); - - if (channel == null) - { - logger.info("Ignored ParkedCallTimeOutEvent for unknown channel " + event.getParkeeChannel()); - return; - } - - Extension wasParkedAt = channel.getParkedAt(); - - if (wasParkedAt == null) - { - logger.info("Ignored ParkedCallTimeOutEvent as the channel was not parked"); - return; - } - - synchronized (channel) - { - channel.setParkedAt(null); - } - logger.info("Channel " + channel.getName() + " is unparked (Timeout) from " + wasParkedAt.getExtension()); - } - - void handleUnparkedCallEvent(UnparkedCallEvent event) - { - // Only bristuffed versions: AsteriskChannelImpl channel = - // getChannelImplById(event.getUniqueId()); - final AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getParkeeChannel()); - - if (channel == null) - { - logger.info("Ignored UnparkedCallEvent for unknown channel " + event.getParkeeChannel()); - return; - } - - Extension wasParkedAt = channel.getParkedAt(); - - if (wasParkedAt == null) - { - logger.info("Ignored UnparkedCallEvent as the channel was not parked"); - return; - } - - synchronized (channel) - { - channel.setParkedAt(null); - } - logger.info("Channel " + channel.getName() + " is unparked (moved away) from " + wasParkedAt.getExtension()); - } - - void handleVarSetEvent(VarSetEvent event) - { - if (event.getUniqueId() == null) - { - return; - } - - final AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - if (channel == null) - { - logger.info("Ignored VarSetEvent for unknown channel with uniqueId " + event.getUniqueId()); - return; - } - - synchronized (channel) - { - channel.updateVariable(event.getVariable(), event.getValue()); - } - } - - void handleDtmfEvent(DtmfEvent event) - { - // we are only intrested in END events - if (event.isBegin()) - { - return; - } - - if (event.getUniqueId() == null) - { - return; - } - - final AsteriskChannelImpl channel = getChannelImplById(event.getUniqueId()); - if (channel == null) - { - logger.info("Ignored DtmfEvent for unknown channel with uniqueId " + event.getUniqueId()); - return; - } - - final Character dtmfDigit; - if (event.getDigit() == null || event.getDigit().length() < 1) - { - dtmfDigit = null; - } - else - { - dtmfDigit = event.getDigit().charAt(0); - } - - synchronized (channel) - { - if (event.isReceived()) - { - channel.dtmfReceived(dtmfDigit); - } - if (event.isSent()) - { - channel.dtmfSent(dtmfDigit); - } - } - } - - void handleMonitorStartEvent(MonitorStartEvent event) - { - final AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getChannel()); - - if (channel == null) - { - logger.info("Ignored MonitorStartEvent for unknown channel " + event.getChannel()); - return; - } - - boolean isMonitored = channel.isMonitored(); - - if (isMonitored) - { - logger.info("Ignored MonitorStartEvent as the channel was already monitored"); - return; - } - - synchronized (channel) - { - channel.setMonitored(true); - } - logger.info("Channel " + channel.getName() + " is monitored"); - } - - void handleMonitorStopEvent(MonitorStopEvent event) - { - final AsteriskChannelImpl channel = getChannelImplByNameAndActive(event.getChannel()); - - if (channel == null) - { - logger.info("Ignored MonitorStopEvent for unknown channel " + event.getChannel()); - return; - } - - boolean isMonitored = channel.isMonitored(); - - if (!isMonitored) - { - logger.info("Ignored MonitorStopEvent as the channel was not monitored"); - return; - } - - synchronized (channel) - { - channel.setMonitored(false); - } - logger.info("Channel " + channel.getName() + " is not monitored"); - } - -} diff --git a/src/main/java/org/asteriskjava/live/internal/ConfigFileImpl.java b/src/main/java/org/asteriskjava/live/internal/ConfigFileImpl.java deleted file mode 100644 index 20239ad82..000000000 --- a/src/main/java/org/asteriskjava/live/internal/ConfigFileImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.List; -import java.util.Map; - -import org.asteriskjava.config.ConfigFile; - -/** - * ConfigFile implementation based on the config actions of the Manager API. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class ConfigFileImpl implements ConfigFile -{ - private final String filename; - private final Map> categories; - - public ConfigFileImpl(String filename, Map> categories) - { - this.filename = filename; - this.categories = categories; - } - - public String getFilename() - { - return filename; - } - - public Map> getCategories() - { - return categories; - } - - public String getValue(String category, String key) - { - throw new UnsupportedOperationException("Not yet inmplemented"); - } - - public List getValues(String category, String key) - { - throw new UnsupportedOperationException("Not yet inmplemented"); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/live/internal/Constants.java b/src/main/java/org/asteriskjava/live/internal/Constants.java deleted file mode 100644 index 230c98a64..000000000 --- a/src/main/java/org/asteriskjava/live/internal/Constants.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.live.internal; - -/** - * Defines constants used internally in the live package in multiple classes. - * - * @author srt - * @version $Id$ - */ -class Constants -{ - // hide constructor - private Constants() - { - - } - - static final String VARIABLE_TRACE_ID = "AJ_TRACE_ID"; -} diff --git a/src/main/java/org/asteriskjava/live/internal/ManagerCommunicationExceptionMapper.java b/src/main/java/org/asteriskjava/live/internal/ManagerCommunicationExceptionMapper.java deleted file mode 100644 index 61d0cdc49..000000000 --- a/src/main/java/org/asteriskjava/live/internal/ManagerCommunicationExceptionMapper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.manager.EventTimeoutException; - -/** - * Maps exceptions received from - * {@link org.asteriskjava.manager.ManagerConnection} to the corresponding - * {@link org.asteriskjava.live.ManagerCommunicationException}. - * - * @author srt - * @version $Id$ - */ -class ManagerCommunicationExceptionMapper -{ - // hide constructor - private ManagerCommunicationExceptionMapper() - { - - } - - /** - * Maps exceptions received from - * {@link org.asteriskjava.manager.ManagerConnection} when sending a - * {@link org.asteriskjava.manager.action.ManagerAction} to the corresponding - * {@link org.asteriskjava.live.ManagerCommunicationException}. - * - * @param actionName name of the action that has been tried to send - * @param exception exception received - * @return the corresponding ManagerCommunicationException - */ - static ManagerCommunicationException mapSendActionException(String actionName, Exception exception) - { - if (exception instanceof IllegalStateException) - { - return new ManagerCommunicationException("Not connected to Asterisk Server", exception); - } - else if (exception instanceof EventTimeoutException) - { - return new ManagerCommunicationException("Timeout waiting for events from " + actionName + "Action", exception); - } - else - { - return new ManagerCommunicationException("Unable to send " + actionName + "Action", exception); - } - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/MeetMeManager.java b/src/main/java/org/asteriskjava/live/internal/MeetMeManager.java deleted file mode 100644 index ffe49497f..000000000 --- a/src/main/java/org/asteriskjava/live/internal/MeetMeManager.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.MeetMeRoom; -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.event.AbstractMeetMeEvent; -import org.asteriskjava.manager.event.MeetMeLeaveEvent; -import org.asteriskjava.manager.event.MeetMeMuteEvent; -import org.asteriskjava.manager.event.MeetMeTalkingEvent; -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Manages MeetMe events on behalf of an AsteriskServer. - * - * @author srt - */ -class MeetMeManager -{ - private static final String MEETME_LIST_COMMAND = "meetme list"; - private static final Pattern MEETME_LIST_PATTERN = Pattern.compile("^User #: ([0-9]+).*Channel: (\\S+).*$"); - - private final Log logger = LogFactory.getLog(getClass()); - private final AsteriskServerImpl server; - private final ChannelManager channelManager; - - /** - * Maps room number to MeetMe room. - */ - private final Map rooms; - - MeetMeManager(AsteriskServerImpl server, ChannelManager channelManager) - { - this.server = server; - this.channelManager = channelManager; - this.rooms = new HashMap<>(); - } - - void initialize() - { - synchronized (rooms) - { - for (MeetMeRoomImpl room : rooms.values()) - { - populateRoom(room); - } - } - } - - void disconnected() - { - /* - * synchronized (rooms) { rooms.clear(); } - */ - } - - Collection getMeetMeRooms() - { - final Collection result; - - result = new ArrayList<>(); - synchronized (rooms) - { - for (MeetMeRoom room : rooms.values()) - { - if (!room.isEmpty()) - { - result.add(room); - } - } - } - return result; - } - - void handleMeetMeEvent(AbstractMeetMeEvent event) - { - String roomNumber; - Integer userNumber; - AsteriskChannelImpl channel; - MeetMeRoomImpl room; - MeetMeUserImpl user; - - roomNumber = event.getMeetMe(); - if (roomNumber == null) - { - logger.warn("RoomNumber (meetMe property) is null. Ignoring " + event.getClass().getName()); - return; - } - - userNumber = event.getUser(); - if (userNumber == null) - { - logger.warn("UserNumber (userNum property) is null. Ignoring " + event.getClass().getName()); - return; - } - - user = getOrCreateUserImpl(event); - if (user == null) - { - return; - } - - channel = user.getChannel(); - room = user.getRoom(); - - if (event instanceof MeetMeLeaveEvent) - { - logger.info("Removing channel " + channel.getName() + " from room " + roomNumber); - if (room != user.getRoom()) - { - if (user.getRoom() != null) - { - logger.error("Channel " + channel.getName() + " should be removed from room " + roomNumber - + " but is user of room " + user.getRoom().getRoomNumber()); - user.getRoom().removeUser(user); - } - else - { - logger.error("Channel " + channel.getName() + " should be removed from room " + roomNumber - + " but is user of no room"); - } - } - // Mmmm should remove from the room before firing - // PropertyChangeEvents ? - user.left(event.getDateReceived()); - room.removeUser(user); - channel.setMeetMeUserImpl(null); - } - else if (event instanceof MeetMeTalkingEvent) - { - Boolean status; - - status = ((MeetMeTalkingEvent) event).getStatus(); - if (status != null) - { - user.setTalking(status); - } - else - { - user.setTalking(true); - } - } - else if (event instanceof MeetMeMuteEvent) - { - Boolean status; - - status = ((MeetMeMuteEvent) event).getStatus(); - if (status != null) - { - user.setMuted(status); - } - } - } - - private void populateRoom(MeetMeRoomImpl room) - { - final CommandAction meetMeListAction; - final ManagerResponse response; - final List lines; - final Collection userNumbers = new ArrayList<>(); // list - // of - // user - // numbers - // in - // the - // room - - meetMeListAction = new CommandAction(MEETME_LIST_COMMAND + " " + room.getRoomNumber()); - try - { - response = server.sendAction(meetMeListAction); - } - catch (ManagerCommunicationException e) - { - logger.error("Unable to send \"" + MEETME_LIST_COMMAND + "\" command", e); - return; - } - if (response instanceof ManagerError) - { - logger.error("Unable to send \"" + MEETME_LIST_COMMAND + "\" command: " + response.getMessage()); - return; - } - if (!(response instanceof CommandResponse)) - { - logger.error("Response to \"" + MEETME_LIST_COMMAND + "\" command is not a CommandResponse but " - + response.getClass()); - return; - } - - lines = ((CommandResponse) response).getResult(); - for (String line : lines) - { - final Matcher matcher; - final Integer userNumber; - final AsteriskChannelImpl channel; - boolean muted = false; - boolean talking = false; - MeetMeUserImpl channelUser; - MeetMeUserImpl roomUser; - - matcher = MEETME_LIST_PATTERN.matcher(line); - if (!matcher.matches()) - { - continue; - } - - userNumber = Integer.valueOf(matcher.group(1)); - channel = channelManager.getChannelImplByName(matcher.group(2)); - if (channel == null) // User has left the room already in the - // meanwhile - { - continue; - } - - userNumbers.add(userNumber); - - if (line.contains("(Admin Muted)") || line.contains("(Muted)")) - { - muted = true; - } - - if (line.contains("(talking)")) - { - talking = true; - } - - channelUser = channel.getMeetMeUser(); - if (channelUser != null && channelUser.getRoom() != room) - { - channelUser.left(DateUtil.getDate()); - channelUser = null; - } - - roomUser = room.getUser(userNumber); - if (roomUser != null && roomUser.getChannel() != channel) - { - room.removeUser(roomUser); - roomUser = null; - } - - if (channelUser == null && roomUser == null) - { - final MeetMeUserImpl user; - // using the current date as dateJoined is not correct but we - // don't have anything that is better - user = new MeetMeUserImpl(server, room, userNumber, channel, DateUtil.getDate()); - user.setMuted(muted); - user.setTalking(talking); - room.addUser(user); - channel.setMeetMeUserImpl(user); - server.fireNewMeetMeUser(user); - } - else if (channelUser != null && roomUser == null) - { - channelUser.setMuted(muted); - room.addUser(channelUser); - } - else if (channelUser == null && roomUser != null) - { - roomUser.setMuted(muted); - channel.setMeetMeUserImpl(roomUser); - } - else - { - if (channelUser != roomUser) - { - logger.error("Inconsistent state: channelUser != roomUser, channelUser=" + channelUser + ", roomUser=" - + roomUser); - } - } - } - - Collection users = room.getUserImpls(); - Collection usersToRemove = new ArrayList<>(); - for (MeetMeUserImpl user : users) - { - if (!userNumbers.contains(user.getUserNumber())) - { - // remove user as he is no longer in the room - usersToRemove.add(user); - } - } - for (MeetMeUserImpl user : usersToRemove) - { - user.left(DateUtil.getDate()); - room.removeUser(user); - user.getChannel().setMeetMeUserImpl(null); - } - } - - private MeetMeUserImpl getOrCreateUserImpl(AbstractMeetMeEvent event) - { - final String roomNumber; - final MeetMeRoomImpl room; - final String uniqueId; - final AsteriskChannelImpl channel; - MeetMeUserImpl user; - - roomNumber = event.getMeetMe(); - room = getOrCreateRoomImpl(roomNumber); - user = room.getUser(event.getUser()); - if (user != null) - { - return user; - } - - // ok create a new one - uniqueId = event.getUniqueId(); - if (uniqueId == null) - { - logger.warn("UniqueId is null. Ignoring MeetMeEvent"); - return null; - } - - channel = channelManager.getChannelImplById(uniqueId); - if (channel == null) - { - logger.warn("No channel with unique id " + uniqueId + ". Ignoring MeetMeEvent"); - return null; - } - - user = channel.getMeetMeUser(); - if (user != null) - { - logger.error("Got MeetMeEvent for channel " + channel.getName() + " that is already user of a room"); - user.left(event.getDateReceived()); - if (user.getRoom() != null) - { - user.getRoom().removeUser(user); - } - channel.setMeetMeUserImpl(null); - } - - logger.info("Adding channel " + channel.getName() + " as user " + event.getUser() + " to room " + roomNumber); - user = new MeetMeUserImpl(server, room, event.getUser(), channel, event.getDateReceived()); - room.addUser(user); - channel.setMeetMeUserImpl(user); - server.fireNewMeetMeUser(user); - - return user; - } - - /** - * Returns the room with the given number or creates a new one if none is - * there yet. - * - * @param roomNumber number of the room to get or create. - * @return the room with the given number. - */ - MeetMeRoomImpl getOrCreateRoomImpl(String roomNumber) - { - MeetMeRoomImpl room; - boolean created = false; - - synchronized (rooms) - { - room = rooms.get(roomNumber); - if (room == null) - { - room = new MeetMeRoomImpl(server, roomNumber); - populateRoom(room); - rooms.put(roomNumber, room); - created = true; - } - } - - if (created) - { - logger.debug("Created MeetMeRoom " + roomNumber); - } - - return room; - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/MeetMeRoomImpl.java b/src/main/java/org/asteriskjava/live/internal/MeetMeRoomImpl.java deleted file mode 100644 index 026d155d7..000000000 --- a/src/main/java/org/asteriskjava/live/internal/MeetMeRoomImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.MeetMeRoom; -import org.asteriskjava.live.MeetMeUser; -import org.asteriskjava.manager.action.CommandAction; - -/** - * Default implementation of the MeetMeRoom interface. - */ -class MeetMeRoomImpl extends AbstractLiveObject implements MeetMeRoom -{ - private static final String COMMAND_PREFIX = "meetme"; - private static final String LOCK_COMMAND = "lock"; - private static final String UNLOCK_COMMAND = "unlock"; - - private final String roomNumber; - - /** - * Maps userNumber to user. - */ - private final Map users; - - MeetMeRoomImpl(AsteriskServerImpl server, String roomNumber) - { - super(server); - this.roomNumber = roomNumber; - this.users = new HashMap<>(20); - } - - public String getRoomNumber() - { - return roomNumber; - } - - public Collection getUsers() - { - synchronized (users) - { - return new ArrayList(users.values()); - } - } - - public boolean isEmpty() - { - synchronized (users) - { - return users.isEmpty(); - } - } - - Collection getUserImpls() - { - synchronized (users) - { - return new ArrayList<>(users.values()); - } - } - - void addUser(MeetMeUserImpl user) - { - synchronized (users) - { - users.put(user.getUserNumber(), user); - } - } - - MeetMeUserImpl getUser(Integer userNumber) - { - synchronized (users) - { - return users.get(userNumber); - } - } - - void removeUser(MeetMeUserImpl user) - { - synchronized (users) - { - users.remove(user.getUserNumber()); - } - } - - // action methods - - public void lock() throws ManagerCommunicationException - { - sendMeetMeCommand(LOCK_COMMAND); - } - - public void unlock() throws ManagerCommunicationException - { - sendMeetMeCommand(UNLOCK_COMMAND); - } - - private void sendMeetMeCommand(String command) throws ManagerCommunicationException - { - final StringBuilder sb = new StringBuilder(); - sb.append(COMMAND_PREFIX); - sb.append(" "); - sb.append(command); - sb.append(" "); - sb.append(roomNumber); - - server.sendAction(new CommandAction(sb.toString())); - } - - @Override - public String toString() - { - StringBuilder sb; - int systemHashcode; - - sb = new StringBuilder("MeetMeRoom["); - - synchronized (this) - { - sb.append("roomNumber='").append(getRoomNumber()).append("',"); - systemHashcode = System.identityHashCode(this); - } - sb.append("systemHashcode=").append(systemHashcode); - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/MeetMeUserImpl.java b/src/main/java/org/asteriskjava/live/internal/MeetMeUserImpl.java deleted file mode 100644 index 9b2b5f501..000000000 --- a/src/main/java/org/asteriskjava/live/internal/MeetMeUserImpl.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.Date; - -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.MeetMeUser; -import org.asteriskjava.live.MeetMeUserState; -import org.asteriskjava.manager.action.CommandAction; - -class MeetMeUserImpl extends AbstractLiveObject implements MeetMeUser -{ - private static final String COMMAND_PREFIX = "meetme"; - private static final String MUTE_COMMAND = "mute"; - private static final String UNMUTE_COMMAND = "unmute"; - private static final String KICK_COMMAND = "kick"; - - private final MeetMeRoomImpl room; - private final Integer userNumber; - private final AsteriskChannelImpl channel; - private final Date dateJoined; - - private Date dateLeft; - private MeetMeUserState state; - private boolean talking; - private boolean muted; - - MeetMeUserImpl(AsteriskServerImpl server, MeetMeRoomImpl room, Integer userNumber, - AsteriskChannelImpl channel, Date dateJoined) - { - super(server); - this.room = room; - this.userNumber = userNumber; - this.channel = channel; - this.dateJoined = dateJoined; - this.state = MeetMeUserState.JOINED; - } - - public MeetMeRoomImpl getRoom() - { - return room; - } - - public Integer getUserNumber() - { - return userNumber; - } - - public AsteriskChannelImpl getChannel() - { - return channel; - } - - public Date getDateJoined() - { - return dateJoined; - } - - public Date getDateLeft() - { - return dateLeft; - } - - /** - * Sets the status to {@link MeetMeUserState#LEFT} and dateLeft to the given date. - * - * @param dateLeft the date this user left the room. - */ - void left(Date dateLeft) - { - MeetMeUserState oldState; - synchronized (this) - { - oldState = this.state; - this.dateLeft = dateLeft; - this.state = MeetMeUserState.LEFT; - } - firePropertyChange(PROPERTY_STATE, oldState, state); - } - - public MeetMeUserState getState() - { - return state; - } - - public boolean isTalking() - { - return talking; - } - - void setTalking(boolean talking) - { - boolean oldTalking = this.talking; - this.talking = talking; - firePropertyChange(PROPERTY_TALKING, oldTalking, talking); - } - - public boolean isMuted() - { - return muted; - } - - void setMuted(boolean muted) - { - boolean oldMuted = this.muted; - this.muted = muted; - firePropertyChange(PROPERTY_MUTED, oldMuted, muted); - } - - // action methods - - public void kick() throws ManagerCommunicationException - { - sendMeetMeUserCommand(KICK_COMMAND); - } - - public void mute() throws ManagerCommunicationException - { - sendMeetMeUserCommand(MUTE_COMMAND); - } - - public void unmute() throws ManagerCommunicationException - { - sendMeetMeUserCommand(UNMUTE_COMMAND); - } - - private void sendMeetMeUserCommand(String command) throws ManagerCommunicationException - { - StringBuilder sb = new StringBuilder(); - sb.append(COMMAND_PREFIX); - sb.append(" "); - sb.append(command); - sb.append(" "); - sb.append(room.getRoomNumber()); - sb.append(" "); - sb.append(userNumber); - - server.sendAction(new CommandAction(sb.toString())); - } - - @Override - public String toString() - { - StringBuilder sb; - int systemHashcode; - - sb = new StringBuilder("MeetMeUser["); - - synchronized (this) - { - sb.append("dateJoined='").append(getDateJoined()).append("',"); - sb.append("dateLeft='").append(getDateLeft()).append("',"); - sb.append("talking=").append(isTalking()).append(","); - sb.append("muted=").append(isMuted()).append(","); - sb.append("room=").append(room).append(","); - systemHashcode = System.identityHashCode(this); - } - sb.append("channel=AsteriskChannel["); - synchronized (channel) - { - sb.append("id='").append(channel.getId()).append("',"); - sb.append("name='").append(channel.getName()).append("'],"); - } - sb.append("systemHashcode=").append(systemHashcode); - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/OriginateCallbackData.java b/src/main/java/org/asteriskjava/live/internal/OriginateCallbackData.java deleted file mode 100644 index bc7236190..000000000 --- a/src/main/java/org/asteriskjava/live/internal/OriginateCallbackData.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - */ -package org.asteriskjava.live.internal; - -import java.util.Date; - -import org.asteriskjava.live.OriginateCallback; -import org.asteriskjava.manager.action.OriginateAction; - -/** - * Wrapper class for OriginateCallbacks. - * - * @author srt - * @version $Id$ - */ -class OriginateCallbackData -{ - private OriginateAction originateAction; - private Date dateSent; - private OriginateCallback callback; - private AsteriskChannelImpl channel; - - /** - * Creates a new instance. - * - * @param originateAction the action that has been sent to the Asterisk - * server - * @param dateSent date when the the action has been sent - * @param callback callback to notify about result - */ - OriginateCallbackData(OriginateAction originateAction, Date dateSent, OriginateCallback callback) - { - super(); - this.originateAction = originateAction; - this.dateSent = dateSent; - this.callback = callback; - } - - OriginateAction getOriginateAction() - { - return originateAction; - } - - Date getDateSent() - { - return dateSent; - } - - OriginateCallback getCallback() - { - return callback; - } - - AsteriskChannelImpl getChannel() - { - return channel; - } - - void setChannel(AsteriskChannelImpl channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/QueueManager.java b/src/main/java/org/asteriskjava/live/internal/QueueManager.java deleted file mode 100644 index 360bd5dda..000000000 --- a/src/main/java/org/asteriskjava/live/internal/QueueManager.java +++ /dev/null @@ -1,621 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.asteriskjava.live.AsteriskQueue; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.QueueMemberState; -import org.asteriskjava.manager.EventTimeoutException; -import org.asteriskjava.manager.ResponseEvents; -import org.asteriskjava.manager.action.QueueStatusAction; -import org.asteriskjava.manager.event.JoinEvent; -import org.asteriskjava.manager.event.LeaveEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.QueueEntryEvent; -import org.asteriskjava.manager.event.QueueMemberAddedEvent; -import org.asteriskjava.manager.event.QueueMemberEvent; -import org.asteriskjava.manager.event.QueueMemberPausedEvent; -import org.asteriskjava.manager.event.QueueMemberPenaltyEvent; -import org.asteriskjava.manager.event.QueueMemberRemovedEvent; -import org.asteriskjava.manager.event.QueueMemberStatusEvent; -import org.asteriskjava.manager.event.QueueParamsEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Manages queue events on behalf of an AsteriskServer. - * - * @author srt - * @version $Id$ - */ -class QueueManager -{ - private final Log logger = LogFactory.getLog(this.getClass()); - - private final AsteriskServerImpl server; - private final ChannelManager channelManager; - private boolean queuesMonitorForced = false; - private long queueMonitorLastTimeReloaded; - private long queuesMonitorLeaseTime = 1000; - - /** - * A map of ACD queues by there name. 101119 OLB: Modified to act as a LRU - * Cache to optimize updates - */ - private final Map queuesLRU = new LinkedHashMap<>(); - - QueueManager(AsteriskServerImpl server, ChannelManager channelManager) - { - this.server = server; - this.channelManager = channelManager; - } - - void initialize() throws ManagerCommunicationException - { - ResponseEvents re; - - try - { - re = server.sendEventGeneratingAction(new QueueStatusAction()); - } - catch (ManagerCommunicationException e) - { - final Throwable cause = e.getCause(); - - if (cause instanceof EventTimeoutException) - { - // this happens with Asterisk 1.0.x as it doesn't send a - // QueueStatusCompleteEvent - re = ((EventTimeoutException) cause).getPartialResult(); - } - else - { - throw e; - } - } - - for (ManagerEvent event : re.getEvents()) - { - if (event instanceof QueueParamsEvent) - { - handleQueueParamsEvent((QueueParamsEvent) event); - } - else if (event instanceof QueueMemberEvent) - { - handleQueueMemberEvent((QueueMemberEvent) event); - } - else if (event instanceof QueueEntryEvent) - { - handleQueueEntryEvent((QueueEntryEvent) event); - } - } - - } - - /** - * Method to ask for a Queue data update - * - * @author Octavio Luna - * @param queue - * @throws ManagerCommunicationException - */ - void updateQueue(String queue) throws ManagerCommunicationException - { - ResponseEvents re; - - try - { - QueueStatusAction queueStatusAction = new QueueStatusAction(); - queueStatusAction.setQueue(queue); - re = server.sendEventGeneratingAction(queueStatusAction); - } - catch (ManagerCommunicationException e) - { - final Throwable cause = e.getCause(); - - if (cause instanceof EventTimeoutException) - { - // this happens with Asterisk 1.0.x as it doesn't send a - // QueueStatusCompleteEvent - re = ((EventTimeoutException) cause).getPartialResult(); - } - else - { - throw e; - } - } - - for (ManagerEvent event : re.getEvents()) - { - // 101119 OLB: solo actualizamos el QUEUE por ahora - if (event instanceof QueueParamsEvent) - { - handleQueueParamsEvent((QueueParamsEvent) event); - } - - else if (event instanceof QueueMemberEvent) - { - handleQueueMemberEvent((QueueMemberEvent) event); - } - else if (event instanceof QueueEntryEvent) - { - handleQueueEntryEvent((QueueEntryEvent) event); - } - - } - } - - void disconnected() - { - synchronized (queuesLRU) - { - for (AsteriskQueueImpl queue : queuesLRU.values()) - { - queue.cancelServiceLevelTimer(); - } - queuesLRU.clear(); - } - } - - /** - * Gets (a copy of) the list of the queues. - * - * @return a copy of the list of the queues. - */ - Collection getQueues() - { - refreshQueuesIfForced(); - - Collection copy; - - synchronized (queuesLRU) - { - copy = new ArrayList(queuesLRU.values()); - } - return copy; - } - - public List getQueuesUpdatedAfter(Date date) - { - refreshQueuesIfForced(); - - List copy = new ArrayList<>(); - synchronized (queuesLRU) - { - List> list = new ArrayList<>(queuesLRU.entrySet()); - ListIterator> iter = list.listIterator(list.size()); - - Entry entry; - while (iter.hasPrevious()) - { - entry = iter.previous(); - AsteriskQueueImpl astQueue = entry.getValue(); - if (astQueue.getLastUpdateMillis() <= date.getTime()) - { - break; - } - copy.add(astQueue); - } - - } - - return copy; - } - - /** - * Adds a queue to the internal map, keyed by name. - * - * @param queue the AsteriskQueueImpl to be added - */ - private void addQueue(AsteriskQueueImpl queue) - { - synchronized (queuesLRU) - { - queuesLRU.put(queue.getName(), queue); - } - } - - /** - * Called during initialization to populate the list of queues. - * - * @param event the event received - */ - private void handleQueueParamsEvent(QueueParamsEvent event) - { - AsteriskQueueImpl queue; - - final String name = event.getQueue(); - final Integer max = event.getMax(); - final String strategy = event.getStrategy(); - final Integer serviceLevel = event.getServiceLevel(); - final Integer weight = event.getWeight(); - final Integer calls = event.getCalls(); - final Integer holdTime = event.getHoldTime(); - final Integer talkTime = event.getTalkTime(); - final Integer completed = event.getCompleted(); - final Integer abandoned = event.getAbandoned(); - final Double serviceLevelPerf = event.getServiceLevelPerf(); - - queue = getInternalQueueByName(name); - - if (queue == null) - { - queue = new AsteriskQueueImpl(server, name, max, strategy, serviceLevel, weight, calls, holdTime, talkTime, - completed, abandoned, serviceLevelPerf); - logger.info("Adding new queue " + queue); - addQueue(queue); - } - else - { - // We should never reach that code as this method is only called for - // initialization - // So the queue should never be in the queues list - synchronized (queue) - { - synchronized (queuesLRU) - { - - if (queue.setMax(max) | queue.setServiceLevel(serviceLevel) | queue.setWeight(weight) - | queue.setCalls(calls) | queue.setHoldTime(holdTime) | queue.setTalkTime(talkTime) - | queue.setCompleted(completed) | queue.setAbandoned(abandoned) - | queue.setServiceLevelPerf(serviceLevelPerf)) - { - - queuesLRU.remove(queue.getName()); - queuesLRU.put(queue.getName(), queue); - } - } - } - } - } - - /** - * Called during initialization to populate the members of the queues. - * - * @param event the QueueMemberEvent received - */ - private void handleQueueMemberEvent(QueueMemberEvent event) - { - final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - if (queue == null) - { - logger.error("Ignored QueueEntryEvent for unknown queue " + event.getQueue()); - return; - } - - AsteriskQueueMemberImpl member = queue.getMember(event.getLocation()); - if (member == null) - { - member = new AsteriskQueueMemberImpl(server, queue, event.getLocation(), QueueMemberState.valueOf(event - .getStatus()), event.getPaused(), event.getPenalty(), event.getMembership(), event.getCallsTaken(), - event.getLastCall()); - - queue.addMember(member); - } - else - { - manageQueueMemberChange(queue, member, event); - } - - } - - private void manageQueueMemberChange(AsteriskQueueImpl queue, AsteriskQueueMemberImpl member, QueueMemberEvent event) - { - if (member.stateChanged(QueueMemberState.valueOf(event.getStatus())) | member.pausedChanged(event.getPaused()) - | member.penaltyChanged(event.getPenalty()) | member.callsTakenChanged(event.getCallsTaken()) - | member.lastCallChanged(event.getLastCall())) - { - queue.stampLastUpdate(); - } - } - - /** - * Called during initialization to populate entries of the queues. Currently - * does the same as handleJoinEvent() - * - * @param event - the QueueEntryEvent received - */ - private void handleQueueEntryEvent(QueueEntryEvent event) - { - final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - final AsteriskChannelImpl channel = channelManager.getChannelImplByName(event.getChannel()); - - if (queue == null) - { - logger.error("Ignored QueueEntryEvent for unknown queue " + event.getQueue()); - return; - } - if (channel == null) - { - logger.error("Ignored QueueEntryEvent for unknown channel " + event.getChannel()); - return; - } - - if (queue.getEntry(event.getChannel()) != null) - { - logger.debug("Ignored duplicate queue entry during population in queue " + event.getQueue() + " for channel " - + event.getChannel()); - return; - } - - // Asterisk gives us an initial position but doesn't tell us when he - // shifts the others - // We won't use this data for ordering until there is a appropriate - // event in AMI. - // (and refreshing the whole queue is too intensive and suffers - // incoherencies - // due to asynchronous shift that leaves holes if requested too fast) - int reportedPosition = event.getPosition(); - - queue.createNewEntry(channel, reportedPosition, event.getDateReceived()); - } - - /** - * Called from AsteriskServerImpl whenever a new entry appears in a queue. - * - * @param event the JoinEvent received - */ - void handleJoinEvent(JoinEvent event) - { - final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - final AsteriskChannelImpl channel = channelManager.getChannelImplByName(event.getChannel()); - - if (queue == null) - { - logger.error("Ignored JoinEvent for unknown queue " + event.getQueue()); - return; - } - if (channel == null) - { - logger.error("Ignored JoinEvent for unknown channel " + event.getChannel()); - return; - } - - if (queue.getEntry(event.getChannel()) != null) - { - logger.error("Ignored duplicate queue entry in queue " + event.getQueue() + " for channel " + event.getChannel()); - return; - } - - // Asterisk gives us an initial position but doesn't tell us when he - // shifts the others - // We won't use this data for ordering until there is a appropriate - // event in AMI. - // (and refreshing the whole queue is too intensive and suffers - // incoherencies - // due to asynchronous shift that leaves holes if requested too fast) - int reportedPosition = event.getPosition(); - - queue.createNewEntry(channel, reportedPosition, event.getDateReceived()); - } - - /** - * Called from AsteriskServerImpl whenever an enty leaves a queue. - * - * @param event - the LeaveEvent received - */ - void handleLeaveEvent(LeaveEvent event) - { - final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - final AsteriskChannelImpl channel = channelManager.getChannelImplByName(event.getChannel()); - - if (queue == null) - { - logger.error("Ignored LeaveEvent for unknown queue " + event.getQueue()); - return; - } - if (channel == null) - { - logger.error("Ignored LeaveEvent for unknown channel " + event.getChannel()); - return; - } - - final AsteriskQueueEntryImpl existingQueueEntry = queue.getEntry(event.getChannel()); - if (existingQueueEntry == null) - { - logger.error("Ignored leave event for non existing queue entry in queue " + event.getQueue() + " for channel " - + event.getChannel()); - return; - } - - queue.removeEntry(existingQueueEntry, event.getDateReceived()); - } - - /** - * Challange a QueueMemberStatusEvent. Called from AsteriskServerImpl - * whenever a member state changes. - * - * @param event that was triggered by Asterisk server. - */ - void handleQueueMemberStatusEvent(QueueMemberStatusEvent event) - { - AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - - if (queue == null) - { - logger.error("Ignored QueueMemberStatusEvent for unknown queue " + event.getQueue()); - return; - } - - AsteriskQueueMemberImpl member = queue.getMemberByLocation(event.getLocation()); - if (member == null) - { - logger.error("Ignored QueueMemberStatusEvent for unknown member " + event.getLocation()); - return; - } - - manageQueueMemberChange(queue, member, event); - queue.fireMemberStateChanged(member); - } - - void handleQueueMemberPausedEvent(QueueMemberPausedEvent event) - { - AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - - if (queue == null) - { - logger.error("Ignored QueueMemberPausedEvent for unknown queue " + event.getQueue()); - return; - } - - AsteriskQueueMemberImpl member = queue.getMemberByLocation(event.getLocation()); - if (member == null) - { - logger.error("Ignored QueueMemberPausedEvent for unknown member " + event.getLocation()); - return; - } - - member.pausedChanged(event.getPaused()); - } - - void handleQueueMemberPenaltyEvent(QueueMemberPenaltyEvent event) - { - AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - - if (queue == null) - { - logger.error("Ignored QueueMemberStatusEvent for unknown queue " + event.getQueue()); - return; - } - - AsteriskQueueMemberImpl member = queue.getMemberByLocation(event.getLocation()); - if (member == null) - { - logger.error("Ignored QueueMemberStatusEvent for unknown member " + event.getLocation()); - return; - } - - member.penaltyChanged(event.getPenalty()); - } - - /** - * Retrieves a queue by its name. - * - * @param queueName name of the queue. - * @return the requested queue or null if there is no queue - * with the given name. - */ - AsteriskQueueImpl getQueueByName(String queueName) - { - refreshQueueIfForced(queueName); - - AsteriskQueueImpl queue = getInternalQueueByName(queueName); - if (queue == null) - { - logger.error("Requested queue '" + queueName + "' not found!"); - } - - return queue; - } - - private AsteriskQueueImpl getInternalQueueByName(String queueName) - { - AsteriskQueueImpl queue; - - synchronized (queuesLRU) - { - queue = queuesLRU.get(queueName); - } - return queue; - } - - private void refreshQueueIfForced(String queueName) - { - if (queuesMonitorForced) - { - updateQueue(queueName); - } - } - - private void refreshQueuesIfForced() - { - if (queuesMonitorForced && (System.currentTimeMillis() - queueMonitorLastTimeReloaded) > queuesMonitorLeaseTime) - { - initialize(); - queueMonitorLastTimeReloaded = System.currentTimeMillis(); - } - } - - /** - * Challange a QueueMemberAddedEvent. - * - * @param event - the generated QueueMemberAddedEvent. - */ - public void handleQueueMemberAddedEvent(QueueMemberAddedEvent event) - { - final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - if (queue == null) - { - logger.error("Ignored QueueMemberAddedEvent for unknown queue " + event.getQueue()); - return; - } - - AsteriskQueueMemberImpl member = queue.getMember(event.getLocation()); - if (member == null) - { - member = new AsteriskQueueMemberImpl(server, queue, event.getLocation(), QueueMemberState.valueOf(event - .getStatus()), event.getPaused(), event.getPenalty(), event.getMembership(), event.getCallsTaken(), - event.getLastCall()); - } - - queue.addMember(member); - } - - /** - * Challange a QueueMemberRemovedEvent. - * - * @param event - the generated QueueMemberRemovedEvent. - */ - public void handleQueueMemberRemovedEvent(QueueMemberRemovedEvent event) - { - final AsteriskQueueImpl queue = getInternalQueueByName(event.getQueue()); - if (queue == null) - { - logger.error("Ignored QueueMemberRemovedEvent for unknown queue " + event.getQueue()); - return; - } - - final AsteriskQueueMemberImpl member = queue.getMember(event.getLocation()); - if (member == null) - { - logger.error("Ignored QueueMemberRemovedEvent for unknown agent name: " + event.getMemberName() + " location: " - + event.getLocation() + " queue: " + event.getQueue()); - return; - } - - queue.removeMember(member); - } - - public void forceQueuesMonitor(boolean force) - { - queuesMonitorForced = force; - } - - public boolean isQueuesMonitorForced() - { - return queuesMonitorForced; - } -} diff --git a/src/main/java/org/asteriskjava/live/internal/package.html b/src/main/java/org/asteriskjava/live/internal/package.html deleted file mode 100644 index 90995dfa5..000000000 --- a/src/main/java/org/asteriskjava/live/internal/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides private implementations and helper classes for interfaces - defined in the org.asteriskjava.live package.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/live/package.html b/src/main/java/org/asteriskjava/live/package.html deleted file mode 100644 index 1560b214b..000000000 --- a/src/main/java/org/asteriskjava/live/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

Provides a higher level API on top of Asterisk's Manager API.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/.gitignore b/src/main/java/org/asteriskjava/manager/.gitignore deleted file mode 100644 index 3ffd5d977..000000000 --- a/src/main/java/org/asteriskjava/manager/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -/AbstractManagerEventListener.class -/AsteriskMapping.class -/AuthenticationFailedException.class -/DefaultManagerConnection.class -/EventTimeoutException.class -/ExpectedResponse.class -/ManagerConnection.class -/ManagerConnectionFactory.class -/ManagerConnectionState.class -/ManagerEventListener.class -/ManagerEventListenerProxy$1.class -/ManagerEventListenerProxy.class -/PingThread.class -/ResponseEvents.class -/SendActionCallback.class -/TimeoutException.class -/NetAddress.class diff --git a/src/main/java/org/asteriskjava/manager/AbstractManagerEventListener.java b/src/main/java/org/asteriskjava/manager/AbstractManagerEventListener.java deleted file mode 100644 index 1e507ef13..000000000 --- a/src/main/java/org/asteriskjava/manager/AbstractManagerEventListener.java +++ /dev/null @@ -1,789 +0,0 @@ -package org.asteriskjava.manager; - -import org.asteriskjava.manager.event.AgentCallbackLoginEvent; -import org.asteriskjava.manager.event.AgentCallbackLogoffEvent; -import org.asteriskjava.manager.event.AgentCalledEvent; -import org.asteriskjava.manager.event.AgentCompleteEvent; -import org.asteriskjava.manager.event.AgentConnectEvent; -import org.asteriskjava.manager.event.AgentDumpEvent; -import org.asteriskjava.manager.event.AgentLoginEvent; -import org.asteriskjava.manager.event.AgentLogoffEvent; -import org.asteriskjava.manager.event.AgentsCompleteEvent; -import org.asteriskjava.manager.event.AgentsEvent; -import org.asteriskjava.manager.event.AlarmClearEvent; -import org.asteriskjava.manager.event.AlarmEvent; -import org.asteriskjava.manager.event.BridgeEvent; -import org.asteriskjava.manager.event.CdrEvent; -import org.asteriskjava.manager.event.ChanSpyStartEvent; -import org.asteriskjava.manager.event.ChanSpyStopEvent; -import org.asteriskjava.manager.event.ConnectEvent; -import org.asteriskjava.manager.event.CoreShowChannelEvent; -import org.asteriskjava.manager.event.CoreShowChannelsCompleteEvent; -import org.asteriskjava.manager.event.DAHDIChannelEvent; -import org.asteriskjava.manager.event.DahdiShowChannelsCompleteEvent; -import org.asteriskjava.manager.event.DahdiShowChannelsEvent; -import org.asteriskjava.manager.event.DbGetResponseEvent; -import org.asteriskjava.manager.event.DialEvent; -import org.asteriskjava.manager.event.DisconnectEvent; -import org.asteriskjava.manager.event.DndStateEvent; -import org.asteriskjava.manager.event.DongleCENDEvent; -import org.asteriskjava.manager.event.DongleCallStateChangeEvent; -import org.asteriskjava.manager.event.DongleDeviceEntryEvent; -import org.asteriskjava.manager.event.DongleNewCMGREvent; -import org.asteriskjava.manager.event.DongleNewSMSBase64Event; -import org.asteriskjava.manager.event.DongleNewSMSEvent; -import org.asteriskjava.manager.event.DongleStatusEvent; -import org.asteriskjava.manager.event.ExtensionStatusEvent; -import org.asteriskjava.manager.event.FaxReceivedEvent; -import org.asteriskjava.manager.event.HangupEvent; -import org.asteriskjava.manager.event.HangupRequestEvent; -import org.asteriskjava.manager.event.HoldEvent; -import org.asteriskjava.manager.event.HoldedCallEvent; -import org.asteriskjava.manager.event.JoinEvent; -import org.asteriskjava.manager.event.LeaveEvent; -import org.asteriskjava.manager.event.LogChannelEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.MeetMeJoinEvent; -import org.asteriskjava.manager.event.MeetMeLeaveEvent; -import org.asteriskjava.manager.event.MeetMeMuteEvent; -import org.asteriskjava.manager.event.MeetMeTalkingEvent; -import org.asteriskjava.manager.event.MessageWaitingEvent; -import org.asteriskjava.manager.event.NewCallerIdEvent; -import org.asteriskjava.manager.event.NewChannelEvent; -import org.asteriskjava.manager.event.NewExtenEvent; -import org.asteriskjava.manager.event.NewStateEvent; -import org.asteriskjava.manager.event.OriginateResponseEvent; -import org.asteriskjava.manager.event.ParkedCallEvent; -import org.asteriskjava.manager.event.ParkedCallGiveUpEvent; -import org.asteriskjava.manager.event.ParkedCallTimeOutEvent; -import org.asteriskjava.manager.event.ParkedCallsCompleteEvent; -import org.asteriskjava.manager.event.PeerEntryEvent; -import org.asteriskjava.manager.event.PeerStatusEvent; -import org.asteriskjava.manager.event.PeerlistCompleteEvent; -import org.asteriskjava.manager.event.ProtocolIdentifierReceivedEvent; -import org.asteriskjava.manager.event.QueueEntryEvent; -import org.asteriskjava.manager.event.QueueEvent; -import org.asteriskjava.manager.event.QueueMemberAddedEvent; -import org.asteriskjava.manager.event.QueueMemberEvent; -import org.asteriskjava.manager.event.QueueMemberPausedEvent; -import org.asteriskjava.manager.event.QueueMemberRemovedEvent; -import org.asteriskjava.manager.event.QueueMemberStatusEvent; -import org.asteriskjava.manager.event.QueueParamsEvent; -import org.asteriskjava.manager.event.QueueStatusCompleteEvent; -import org.asteriskjava.manager.event.RegistrationsCompleteEvent; -import org.asteriskjava.manager.event.RegistryEntryEvent; -import org.asteriskjava.manager.event.RegistryEvent; -import org.asteriskjava.manager.event.ReloadEvent; -import org.asteriskjava.manager.event.RenameEvent; -import org.asteriskjava.manager.event.ShutdownEvent; -import org.asteriskjava.manager.event.SoftHangupRequestEvent; -import org.asteriskjava.manager.event.StatusCompleteEvent; -import org.asteriskjava.manager.event.StatusEvent; -import org.asteriskjava.manager.event.UnparkedCallEvent; -import org.asteriskjava.manager.event.UserEvent; -import org.asteriskjava.manager.event.ZapShowChannelsCompleteEvent; -import org.asteriskjava.manager.event.ZapShowChannelsEvent; - -/** - * Utility class that provides a protected handler method for each concrete manager event. - * Makes life easier by removing the need to code endless if-then-else constructs with instanceof - * checking for the events you are interested in. - *

- * Kindly donated by Steve Prior. - *

- * Example based on HelloEvents from the tutorial: - * - *

- * public class HelloEvents extends AbstractManagerEventListener
- * {
- *     private ManagerConnection managerConnection;
- * 
- *     public HelloEvents(String machine, String userid, String password) throws IOException
- *     {
- *         ManagerConnectionFactory factory = new ManagerConnectionFactory(machine, userid, password);
- *         this.managerConnection = factory.createManagerConnection();
- *     }
- * 
- *     public void run() throws Exception
- *     {
- *         // register for events
- *         managerConnection.addEventListener(this);
- * 
- *         // connect to Asterisk and log in
- *         managerConnection.login();
- * 
- *         // request channel state
- *         managerConnection.sendAction(new StatusAction());
- * 
- *         // wait 10 seconds for events to come in
- *         Thread.sleep(10000);
- * 
- *         // and finally log off and disconnect
- *         managerConnection.logoff();
- *     }
- * 
- *     protected void handleEvent(StatusEvent event)
- *     {
- *         System.out.println(event.getChannel() + ":" + event.getState());
- *     }
- * 
- *     public static void main(String[] args) throws Exception
- *     {
- *         HelloEvents helloEvents;
- *         helloEvents = new HelloEvents("machine", "userid", "password");
- *         helloEvents.run();
- *     }
- * }
- * 
- * - * @author srt - * @since 0.3 - */ -public abstract class AbstractManagerEventListener implements ManagerEventListener -{ - protected void handleEvent(AgentCallbackLoginEvent event) - { - } - - protected void handleEvent(AgentCallbackLogoffEvent event) - { - } - - protected void handleEvent(AgentCalledEvent event) - { - } - - protected void handleEvent(AgentLoginEvent event) - { - } - - protected void handleEvent(AgentLogoffEvent event) - { - } - - protected void handleEvent(AlarmClearEvent event) - { - } - - protected void handleEvent(AlarmEvent event) - { - } - - protected void handleEvent(CdrEvent event) - { - } - - protected void handleEvent(ChanSpyStartEvent event) - { - } - - protected void handleEvent(ChanSpyStopEvent event) - { - } - - protected void handleEvent(ConnectEvent event) - { - } - protected void handleEvent(DAHDIChannelEvent event) - { - } - protected void handleEvent(SoftHangupRequestEvent event) - { - } - - protected void handleEvent(DialEvent event) - { - } - - protected void handleEvent(HangupRequestEvent event) - { - } - protected void handleEvent(DisconnectEvent event) - { - } - - protected void handleEvent(DndStateEvent event) - { - } - - protected void handleEvent(ExtensionStatusEvent event) - { - } - - protected void handleEvent(HoldedCallEvent event) - { - } - - protected void handleEvent(HoldEvent event) - { - } - - protected void handleEvent(LogChannelEvent event) - { - } - - protected void handleEvent(MessageWaitingEvent event) - { - } - - protected void handleEvent(NewExtenEvent event) - { - } - - protected void handleEvent(PeerStatusEvent event) - { - } - - protected void handleEvent(ProtocolIdentifierReceivedEvent event) - { - } - - protected void handleEvent(QueueEvent event) - { - } - - protected void handleEvent(RegistryEntryEvent event) - { - } - - protected void handleEvent(RegistryEvent event) - { - } - - protected void handleEvent(ReloadEvent event) - { - } - - protected void handleEvent(RenameEvent event) - { - } - - protected void handleEvent(ShutdownEvent event) - { - } - - protected void handleEvent(UserEvent event) - { - } - - protected void handleEvent(AgentCompleteEvent event) - { - } - - protected void handleEvent(AgentConnectEvent event) - { - } - - protected void handleEvent(AgentDumpEvent event) - { - } - - protected void handleEvent(FaxReceivedEvent event) - { - } - - protected void handleEvent(NewCallerIdEvent event) - { - } - - protected void handleEvent(HangupEvent event) - { - } - - protected void handleEvent(NewChannelEvent event) - { - } - - protected void handleEvent(NewStateEvent event) - { - } - - protected void handleEvent(MeetMeJoinEvent event) - { - } - - protected void handleEvent(MeetMeLeaveEvent event) - { - } - - protected void handleEvent(MeetMeMuteEvent event) - { - } - - protected void handleEvent(MeetMeTalkingEvent event) - { - } - - protected void handleEvent(ParkedCallGiveUpEvent event) - { - } - - protected void handleEvent(ParkedCallTimeOutEvent event) - { - } - - protected void handleEvent(UnparkedCallEvent event) - { - } - - protected void handleEvent(QueueMemberAddedEvent event) - { - } - - protected void handleEvent(QueueMemberPausedEvent event) - { - } - - protected void handleEvent(QueueMemberRemovedEvent event) - { - } - - protected void handleEvent(AgentsCompleteEvent event) - { - } - - protected void handleEvent(AgentsEvent event) - { - } - - protected void handleEvent(DbGetResponseEvent event) - { - } - protected void handleEvent(DongleNewSMSBase64Event event) - { - } - protected void handleEvent(DongleStatusEvent event) - { - } - protected void handleEvent(DongleCENDEvent event) - { - } - protected void handleEvent(DongleCallStateChangeEvent event) - { - } - protected void handleEvent(DongleNewSMSEvent event) - { - } - protected void handleEvent(DongleNewCMGREvent event) - { - } - protected void handleEvent(DongleDeviceEntryEvent event) - { - } - protected void handleEvent(JoinEvent event) - { - } - - protected void handleEvent(LeaveEvent event) - { - } - - protected void handleEvent(BridgeEvent event) - { - } - - protected void handleEvent(OriginateResponseEvent event) - { - } - - protected void handleEvent(ParkedCallEvent event) - { - } - - protected void handleEvent(ParkedCallsCompleteEvent event) - { - } - - protected void handleEvent(PeerEntryEvent event) - { - } - - protected void handleEvent(PeerlistCompleteEvent event) - { - } - - protected void handleEvent(QueueEntryEvent event) - { - } - - protected void handleEvent(QueueMemberEvent event) - { - } - - protected void handleEvent(QueueMemberStatusEvent event) - { - } - - protected void handleEvent(QueueParamsEvent event) - { - } - - protected void handleEvent(QueueStatusCompleteEvent event) - { - } - - protected void handleEvent(RegistrationsCompleteEvent event) - { - } - - protected void handleEvent(StatusCompleteEvent event) - { - } - - protected void handleEvent(StatusEvent event) - { - } - - protected void handleEvent(ZapShowChannelsCompleteEvent event) - { - } - - protected void handleEvent(DahdiShowChannelsCompleteEvent event) - { - } - protected void handleEvent(ZapShowChannelsEvent event) - { - } - - protected void handleEvent(DahdiShowChannelsEvent event) - { - } - - protected void handleEvent(CoreShowChannelEvent event) - { - } - - protected void handleEvent(CoreShowChannelsCompleteEvent event) - { - } - - /** - * Dispatches to the appropriate handleEvent(...) method. - * - * @param event the event to handle - */ - @Override - public void onManagerEvent(ManagerEvent event) - { - if (event instanceof AgentCallbackLoginEvent) - { - handleEvent((AgentCallbackLoginEvent) event); - } - else if (event instanceof AgentCallbackLogoffEvent) - { - handleEvent((AgentCallbackLogoffEvent) event); - } - else if (event instanceof AgentCalledEvent) - { - handleEvent((AgentCalledEvent) event); - } - else if (event instanceof AgentLoginEvent) - { - handleEvent((AgentLoginEvent) event); - } - else if (event instanceof AgentLogoffEvent) - { - handleEvent((AgentLogoffEvent) event); - } - else if (event instanceof AlarmClearEvent) - { - handleEvent((AlarmClearEvent) event); - } - else if (event instanceof AlarmEvent) - { - handleEvent((AlarmEvent) event); - } - else if (event instanceof CdrEvent) - { - handleEvent((CdrEvent) event); - } - else if (event instanceof ConnectEvent) - { - handleEvent((ConnectEvent) event); - } - else if (event instanceof DAHDIChannelEvent) - { - handleEvent((DAHDIChannelEvent) event); - } - else if (event instanceof SoftHangupRequestEvent) - { - handleEvent((SoftHangupRequestEvent) event); - } - else if (event instanceof DialEvent) - { - handleEvent((DialEvent) event); - } - else if (event instanceof HangupRequestEvent) - { - handleEvent((HangupRequestEvent) event); - } - else if (event instanceof DisconnectEvent) - { - handleEvent((DisconnectEvent) event); - } - else if (event instanceof DndStateEvent) - { - handleEvent((DndStateEvent) event); - } - else if (event instanceof ExtensionStatusEvent) - { - handleEvent((ExtensionStatusEvent) event); - } - else if (event instanceof HoldedCallEvent) - { - handleEvent((HoldedCallEvent) event); - } - else if (event instanceof HoldEvent) - { - handleEvent((HoldEvent) event); - } - else if (event instanceof LogChannelEvent) - { - handleEvent((LogChannelEvent) event); - } - else if (event instanceof MessageWaitingEvent) - { - handleEvent((MessageWaitingEvent) event); - } - else if (event instanceof NewExtenEvent) - { - handleEvent((NewExtenEvent) event); - } - else if (event instanceof PeerStatusEvent) - { - handleEvent((PeerStatusEvent) event); - } - else if (event instanceof ProtocolIdentifierReceivedEvent) - { - handleEvent((ProtocolIdentifierReceivedEvent) event); - } - else if (event instanceof JoinEvent) - { - handleEvent((JoinEvent) event); - } - else if (event instanceof LeaveEvent) - { - handleEvent((LeaveEvent) event); - } - else if (event instanceof QueueEvent) - { - handleEvent((QueueEvent) event); - } - else if (event instanceof RegistrationsCompleteEvent) - { - handleEvent((RegistrationsCompleteEvent) event); - } - else if (event instanceof RegistryEntryEvent) - { - handleEvent((RegistryEntryEvent) event); - } - else if (event instanceof RegistryEvent) - { - handleEvent((RegistryEvent) event); - } - else if (event instanceof ReloadEvent) - { - handleEvent((ReloadEvent) event); - } - else if (event instanceof RenameEvent) - { - handleEvent((RenameEvent) event); - } - else if (event instanceof ShutdownEvent) - { - handleEvent((ShutdownEvent) event); - } - else if (event instanceof UserEvent) - { - handleEvent((UserEvent) event); - } - else if (event instanceof AgentCompleteEvent) - { - handleEvent((AgentCompleteEvent) event); - } - else if (event instanceof AgentConnectEvent) - { - handleEvent((AgentConnectEvent) event); - } - else if (event instanceof AgentDumpEvent) - { - handleEvent((AgentDumpEvent) event); - } - else if (event instanceof FaxReceivedEvent) - { - handleEvent((FaxReceivedEvent) event); - } - else if (event instanceof NewCallerIdEvent) - { - handleEvent((NewCallerIdEvent) event); - } - else if (event instanceof HangupEvent) - { - handleEvent((HangupEvent) event); - } - else if (event instanceof NewChannelEvent) - { - handleEvent((NewChannelEvent) event); - } - else if (event instanceof NewStateEvent) - { - handleEvent((NewStateEvent) event); - } - else if (event instanceof MeetMeJoinEvent) - { - handleEvent((MeetMeJoinEvent) event); - } - else if (event instanceof DongleNewSMSBase64Event) - { - handleEvent((DongleNewSMSBase64Event) event); - } - else if (event instanceof DongleCENDEvent) - { - handleEvent((DongleCENDEvent) event); - } - else if (event instanceof DongleCallStateChangeEvent) - { - handleEvent((DongleCallStateChangeEvent) event); - } - else if (event instanceof DongleNewSMSEvent) - { - handleEvent((DongleNewSMSEvent) event); - } - else if (event instanceof DongleNewCMGREvent) - { - handleEvent((DongleNewCMGREvent) event); - } - else if (event instanceof DongleStatusEvent) - { - handleEvent((DongleStatusEvent) event); - } - else if (event instanceof DongleDeviceEntryEvent) - { - handleEvent((DongleDeviceEntryEvent) event); - } - else if (event instanceof MeetMeLeaveEvent) - { - handleEvent((MeetMeLeaveEvent) event); - } - else if (event instanceof MeetMeMuteEvent) - { - handleEvent((MeetMeMuteEvent) event); - } - else if (event instanceof MeetMeTalkingEvent) - { - handleEvent((MeetMeTalkingEvent) event); - } - else if (event instanceof ParkedCallGiveUpEvent) - { - handleEvent((ParkedCallGiveUpEvent) event); - } - else if (event instanceof ParkedCallTimeOutEvent) - { - handleEvent((ParkedCallTimeOutEvent) event); - } - else if (event instanceof UnparkedCallEvent) - { - handleEvent((UnparkedCallEvent) event); - } - else if (event instanceof QueueMemberAddedEvent) - { - handleEvent((QueueMemberAddedEvent) event); - } - else if (event instanceof QueueMemberPausedEvent) - { - handleEvent((QueueMemberPausedEvent) event); - } - else if (event instanceof QueueMemberRemovedEvent) - { - handleEvent((QueueMemberRemovedEvent) event); - } - else if (event instanceof AgentsCompleteEvent) - { - handleEvent((AgentsCompleteEvent) event); - } - else if (event instanceof AgentsEvent) - { - handleEvent((AgentsEvent) event); - } - else if (event instanceof DbGetResponseEvent) - { - handleEvent((DbGetResponseEvent) event); - } - else if (event instanceof BridgeEvent) - { - handleEvent((BridgeEvent) event); - } - else if (event instanceof OriginateResponseEvent) - { - handleEvent((OriginateResponseEvent) event); - } - else if (event instanceof ParkedCallEvent) - { - handleEvent((ParkedCallEvent) event); - } - else if (event instanceof ParkedCallsCompleteEvent) - { - handleEvent((ParkedCallsCompleteEvent) event); - } - else if (event instanceof PeerEntryEvent) - { - handleEvent((PeerEntryEvent) event); - } - else if (event instanceof PeerlistCompleteEvent) - { - handleEvent((PeerlistCompleteEvent) event); - } - else if (event instanceof QueueEntryEvent) - { - handleEvent((QueueEntryEvent) event); - } - else if (event instanceof QueueMemberEvent) - { - handleEvent((QueueMemberEvent) event); - } - else if (event instanceof QueueMemberStatusEvent) - { - handleEvent((QueueMemberStatusEvent) event); - } - else if (event instanceof QueueParamsEvent) - { - handleEvent((QueueParamsEvent) event); - } - else if (event instanceof QueueStatusCompleteEvent) - { - handleEvent((QueueStatusCompleteEvent) event); - } - else if (event instanceof StatusCompleteEvent) - { - handleEvent((StatusCompleteEvent) event); - } - else if (event instanceof StatusEvent) - { - handleEvent((StatusEvent) event); - } - else if (event instanceof ZapShowChannelsCompleteEvent) - { - handleEvent((ZapShowChannelsCompleteEvent) event); - } - else if (event instanceof DahdiShowChannelsCompleteEvent) - { - handleEvent((DahdiShowChannelsCompleteEvent) event); - } - else if (event instanceof ZapShowChannelsEvent) - { - handleEvent((ZapShowChannelsEvent) event); - } - else if (event instanceof DahdiShowChannelsEvent) - { - handleEvent((DahdiShowChannelsEvent) event); - } - else if (event instanceof CoreShowChannelEvent) - { - handleEvent((CoreShowChannelEvent) event); - } - else if (event instanceof CoreShowChannelsCompleteEvent) - { - handleEvent((CoreShowChannelsCompleteEvent) event); - } - } -} diff --git a/src/main/java/org/asteriskjava/manager/AsteriskMapping.java b/src/main/java/org/asteriskjava/manager/AsteriskMapping.java deleted file mode 100644 index 25ed99913..000000000 --- a/src/main/java/org/asteriskjava/manager/AsteriskMapping.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.manager; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Customized the mapping to Asterisk. In general the mapping is done implicitly based - * on reflection but there are certain action that are using headers with specical - * characters that can not be represented in Java. In those cases you can annotate - * the property (getter, setter or field) and provide the header name that Asterisk expects. - * - * @since 1.0.0 - */ -@Target({METHOD, FIELD}) -@Retention(RUNTIME) -public @interface AsteriskMapping -{ - public abstract String value(); -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/AuthenticationFailedException.java b/src/main/java/org/asteriskjava/manager/AuthenticationFailedException.java deleted file mode 100644 index f74a5481d..000000000 --- a/src/main/java/org/asteriskjava/manager/AuthenticationFailedException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -/** - * An AuthenticationFailedException is thrown when a login fails due to an incorrect username and/or - * password. - * - * @author srt - * @version $Id$ - */ -public class AuthenticationFailedException extends Exception -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 7674248607624140309L; - - /** - * Creates a new AuthenticationFailedException with the given message. - * - * @param message message describing the authentication failure - */ - public AuthenticationFailedException(final String message) - { - super(message); - } - - /** - * Creates a new AuthenticationFailedException with the given message and cause. - * - * @param message message describing the authentication failure - * @param cause exception that caused the authentication failure - */ - public AuthenticationFailedException(final String message, final Throwable cause) - { - super(message, cause); - } -} diff --git a/src/main/java/org/asteriskjava/manager/DefaultManagerConnection.java b/src/main/java/org/asteriskjava/manager/DefaultManagerConnection.java deleted file mode 100644 index 032ee340d..000000000 --- a/src/main/java/org/asteriskjava/manager/DefaultManagerConnection.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -import java.io.IOException; -import java.net.InetAddress; -import java.nio.charset.Charset; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.EventGeneratingAction; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.internal.ManagerConnectionImpl; -import org.asteriskjava.manager.response.ManagerResponse; - -/** - * Default implemention of the - * {@link org.asteriskjava.manager.ManagerConnection} interface. - *

- * Generelly avoid direct use of this class. Use a - * {@link org.asteriskjava.manager.ManagerConnectionFactory} to obtain a - * {@link org.asteriskjava.manager.ManagerConnection} instead. - *

- * When using a dependency injection framework like the Spring Framework direct - * usage for wiring up beans that require a - * {@link org.asteriskjava.manager.ManagerConnection} property is fine though. - *

- * Note that the DefaultManagerConnection will create one new Thread for reading - * data from Asterisk once it is - * {@link org.asteriskjava.manager.ManagerConnectionState#CONNECTING}. - * - * @see org.asteriskjava.manager.ManagerConnectionFactory - * @author srt - * @version $Id$ - */ -public class DefaultManagerConnection implements ManagerConnection -{ - private ManagerConnectionImpl impl; - - /** - * Creates a new instance. - */ - public DefaultManagerConnection() - { - this.impl = new ManagerConnectionImpl(); - } - - /** - * Creates a new instance with the given connection parameters using - * Asterisk's default port. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param username the username to use for login - * @param password the password to use for login - */ - public DefaultManagerConnection(String hostname, String username, String password) - { - this(); - impl.setHostname(hostname); - impl.setUsername(username); - impl.setPassword(password); - } - - /** - * Creates a new instance with the given connection parameters. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param port the port where Asterisk listens for incoming Manager API - * connections, usually 5038. - * @param username the username to use for login - * @param password the password to use for login - */ - public DefaultManagerConnection(String hostname, int port, String username, String password) - { - this(); - impl.setHostname(hostname); - impl.setPort(port); - impl.setUsername(username); - impl.setPassword(password); - } - - /** - * Sets the hostname of the Asterisk server to connect to. - *

- * Default is localhost. - * - * @param hostname the hostname to connect to - */ - public void setHostname(String hostname) - { - impl.setHostname(hostname); - } - - /** - * Sets the port to use to connect to the Asterisk server. This is the port - * specified in Asterisk's manager.conf file. - *

- * Default is 5038. - * - * @param port the port to connect to - */ - public void setPort(int port) - { - impl.setPort(port); - } - - /** - * Sets whether to use SSL. - *

- * Default is false. - * - * @param ssl true to use SSL for the connection, - * false for a plain text connection. - * @since 0.3 - */ - public void setSsl(boolean ssl) - { - impl.setSsl(ssl); - } - - /** - * Sets the username to use to connect to the Asterisk server. This is the - * username specified in Asterisk's manager.conf file. - * - * @param username the username to use for login - */ - public void setUsername(String username) - { - impl.setUsername(username); - } - - /** - * Sets the password to use to connect to the Asterisk server. This is the - * password specified in Asterisk's manager.conf file. - * - * @param password the password to use for login - */ - public void setPassword(String password) - { - impl.setPassword(password); - } - - @Override - public void setEncoding(Charset encoding) - { - impl.setEncoding(encoding); - } - - /** - * Sets the time in milliseconds the synchronous sendAction methods - * {@link #sendAction(ManagerAction)} will wait for a response before - * throwing a TimeoutException. - *

- * Default is 2000. - * - * @param defaultTimeout default timeout in milliseconds - * @deprecated use {@link #setDefaultResponseTimeout(long)} instead - */ - @Deprecated - public void setDefaultTimeout(long defaultTimeout) - { - impl.setDefaultResponseTimeout(defaultTimeout); - } - - /** - * Sets the time in milliseconds the synchronous method - * {@link #sendAction(ManagerAction)} will wait for a response before - * throwing a TimeoutException. - *

- * Default is 2000. - * - * @param defaultResponseTimeout default response timeout in milliseconds - * @since 0.2 - */ - public void setDefaultResponseTimeout(long defaultResponseTimeout) - { - impl.setDefaultResponseTimeout(defaultResponseTimeout); - } - - /** - * Sets the time in milliseconds the synchronous method - * {@link #sendEventGeneratingAction(EventGeneratingAction)} will wait for a - * response and the last response event before throwing a TimeoutException. - *

- * Default is 5000. - * - * @param defaultEventTimeout default event timeout in milliseconds - * @since 0.2 - */ - public void setDefaultEventTimeout(long defaultEventTimeout) - { - impl.setDefaultEventTimeout(defaultEventTimeout); - } - - /** - * This method is deprecated and will be removed in Asterisk-Java 0.4. - *

- * It does nothing. - * - * @deprecated no longer needed as we now use an interrupt based response - * checking approach. - */ - @Deprecated - public void setSleepTime(long sleepTime) - { - - } - - /** - * Set to true to try reconnecting to ther asterisk serve even - * if the reconnection attempt threw an AuthenticationFailedException. - *

- * Default is true. - */ - public void setKeepAliveAfterAuthenticationFailure(boolean keepAliveAfterAuthenticationFailure) - { - impl.setKeepAliveAfterAuthenticationFailure(keepAliveAfterAuthenticationFailure); - } - - /* Implementation of ManagerConnection interface */ - - public String getHostname() - { - return impl.getHostname(); - } - - public int getPort() - { - return impl.getPort(); - } - - public String getUsername() - { - return impl.getUsername(); - } - - public String getPassword() - { - return impl.getPassword(); - } - - @Override - public Charset getEncoding() - { - return impl.getEncoding(); - } - - public AsteriskVersion getVersion() - { - return impl.getVersion(); - } - - public boolean isSsl() - { - return impl.isSsl(); - } - - public InetAddress getLocalAddress() - { - return impl.getLocalAddress(); - } - - public int getLocalPort() - { - return impl.getLocalPort(); - } - - public InetAddress getRemoteAddress() - { - return impl.getRemoteAddress(); - } - - public int getRemotePort() - { - return impl.getRemotePort(); - } - - public void registerUserEventClass(Class< ? extends ManagerEvent> userEventClass) - { - impl.registerUserEventClass(userEventClass); - } - - public void setSocketTimeout(int socketTimeout) - { - impl.setSocketTimeout(socketTimeout); - } - - public void setSocketReadTimeout(int socketReadTimeout) - { - impl.setSocketReadTimeout(socketReadTimeout); - } - - public void login() throws IllegalStateException, IOException, AuthenticationFailedException, TimeoutException - { - impl.login(); - } - - public void login(String events) - throws IllegalStateException, IOException, AuthenticationFailedException, TimeoutException - { - impl.login(events); - } - - public void logoff() throws IllegalStateException - { - impl.logoff(); - } - - public ManagerResponse sendAction(ManagerAction action) - throws IOException, TimeoutException, IllegalArgumentException, IllegalStateException - { - return impl.sendAction(action); - } - - public ManagerResponse sendAction(ManagerAction action, long timeout) - throws IOException, TimeoutException, IllegalArgumentException, IllegalStateException - { - return impl.sendAction(action, timeout); - } - - public void sendAction(ManagerAction action, SendActionCallback callbackHandler) - throws IOException, IllegalArgumentException, IllegalStateException - { - impl.sendAction(action, callbackHandler); - } - - public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException - { - return impl.sendEventGeneratingAction(action); - } - - public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, long timeout) - throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException - { - return impl.sendEventGeneratingAction(action, timeout); - } - - public void addEventListener(final ManagerEventListener listener) - { - impl.addEventListener(listener); - } - - public void removeEventListener(final ManagerEventListener listener) - { - impl.removeEventListener(listener); - } - - public String getProtocolIdentifier() - { - return impl.getProtocolIdentifier(); - } - - public ManagerConnectionState getState() - { - return impl.getState(); - } - - @Override - public String toString() - { - final StringBuilder sb = new StringBuilder("DefaultManagerConnection["); - sb.append("hostname='").append(getHostname()).append("',"); - sb.append("port=").append(getPort()).append("]"); - return sb.toString(); - } - - @Override - public void deregisterEventClass(Class< ? extends ManagerEvent> eventClass) - { - impl.deregisterEventClass(eventClass); - - } -} diff --git a/src/main/java/org/asteriskjava/manager/EventTimeoutException.java b/src/main/java/org/asteriskjava/manager/EventTimeoutException.java deleted file mode 100644 index 8da0c19e7..000000000 --- a/src/main/java/org/asteriskjava/manager/EventTimeoutException.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -/** - * An EventTimeoutException is thrown if a ManagerResponse or some - * ResponseEvents are not completely received within the expected time period.

- * This exception allows you to retrieve the partial result, that is the events - * that have been successfully received before the timeout occured. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class EventTimeoutException extends TimeoutException -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 5461825583966922L; - private transient final ResponseEvents partialResult; - - /** - * Creates a new EventTimeoutException with the given message and partial - * result. - * - * @param message message with details about the timeout. - * @param partialResult the ResponseEvents object filled with the parts that - * have been received before the timeout occured. - */ - public EventTimeoutException(String message, ResponseEvents partialResult) - { - super(message); - this.partialResult = partialResult; - } - - /** - * Returns the partial result that has been received before the timeout - * occured.

- * Note: Using the partial result in your application should be avoided - * wherever possible. This is only a hack to handle those versions of - * Asterisk that don't follow the Manager API conventions, for example by - * not sending the correct ActionCompleteEvent. - * - * @return the ResponseEvents object filled with the parts that have been - * received before the timeout occured. Note: The response attribute - * may be null when no response has been received. - */ - public ResponseEvents getPartialResult() - { - return partialResult; - } -} diff --git a/src/main/java/org/asteriskjava/manager/ExpectedResponse.java b/src/main/java/org/asteriskjava/manager/ExpectedResponse.java deleted file mode 100644 index 06bd2cda2..000000000 --- a/src/main/java/org/asteriskjava/manager/ExpectedResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.manager; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import org.asteriskjava.manager.response.ManagerResponse; - -/** - * Indicates that an annotated {@link org.asteriskjava.manager.action.ManagerAction} expects - * a specific subclass of {@link org.asteriskjava.manager.response.ManagerResponse} when executed - * successfully. - * - * @since 1.0.0 - */ -@Target(TYPE) -@Retention(RUNTIME) -public @interface ExpectedResponse -{ - Class value(); -} diff --git a/src/main/java/org/asteriskjava/manager/ManagerConnection.java b/src/main/java/org/asteriskjava/manager/ManagerConnection.java deleted file mode 100644 index 8c6e613ce..000000000 --- a/src/main/java/org/asteriskjava/manager/ManagerConnection.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -import java.io.IOException; -import java.net.InetAddress; -import java.nio.charset.Charset; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.EventGeneratingAction; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.ManagerResponse; - -/** - * The main interface to talk to an Asterisk server via the Asterisk Manager - * API. - *

- * The ManagerConnection repesents a connection to an Asterisk server and is - * capable of sending {@link org.asteriskjava.manager.action.ManagerAction}s and - * receiving {@link org.asteriskjava.manager.response.ManagerResponse}s and - * {@link org.asteriskjava.manager.event.ManagerEvent}s. It does not add any - * further functionality but rather provides a Java view to Asterisk's Manager - * API (freeing you from TCP/IP connection and parsing stuff). - *

- * It is used as the foundation for higher leveled interfaces like the - * Asterisk-Java Live. - *

- * A concrete implementation of this interface can be obtained from a - * {@link org.asteriskjava.manager.ManagerConnectionFactory}. - * - * @see org.asteriskjava.manager.ManagerConnectionFactory - * @author srt - * @version $Id$ - */ -public interface ManagerConnection -{ - /** - * Returns the hostname of the connected Asterisk server. - * - * @return the hostname of the connected Asterisk server. - * @since 0.3 - */ - String getHostname(); - - /** - * Returns the Manager API port of the connected Asterisk server. - * - * @return the Manager API port of the connected Asterisk server. - * @since 0.3 - */ - int getPort(); - - /** - * Returns the username to use to connect to the Asterisk server. This is - * the username specified in Asterisk's manager.conf file. - * - * @return the username to use for login - * @since 0.3 - */ - String getUsername(); - - /** - * Returns the password to use to connect to the Asterisk server. This is - * the username specified in Asterisk's manager.conf file. - * - * @return the password to use for login - * @since 0.3 - */ - String getPassword(); - - /** - * Returns the version of Asterisk running in the server. - * - * @return the Asterisk version running in the server. - * @since 1.0.0 - */ - AsteriskVersion getVersion(); - - /** - * Sets the encoding to use to connect to the Asterisk server (eg. important - * for manager/user events). All connections should use the same encoding. - * The default is UTF-8. - * - * @param encoding the encoding to use for manager/user events etc. - */ - void setEncoding(Charset encoding); - - /** - * Returns the encoding to use to connect to the Asterisk server (eg. - * important for manager/user events). All connections should use the same - * encoding. The default is UTF-8. - * - * @return the encoding to use for manager/user events etc. - */ - Charset getEncoding(); - - /** - * Returns whether to use SSL. - *

- * Default is false. - * - * @return true if SSL is used for the connection, - * false for a plain text connection. - * @since 0.3 - */ - boolean isSsl(); - - /** - * Returns the local address of the underlying socket connection. - * - * @return the local address of the underlying socket connection. - * @since 1.0.0 - */ - InetAddress getLocalAddress(); - - /** - * Returns the local port of the underlying socket connection. - * - * @return the local port of the underlying socket connection. - * @since 1.0.0 - */ - int getLocalPort(); - - /** - * Returns the remote address of the underlying socket connection. - * - * @return the remote address of the underlying socket connection. - * @since 1.0.0 - */ - InetAddress getRemoteAddress(); - - /** - * Returns the remote port of the underlying socket connection. - * - * @return the remote port of the underlying socket connection. - * @since 1.0.0 - */ - int getRemotePort(); - - /** - * Registers a new user event type. - *

- * Asterisk allows you to send custom events via the UserEvent application. - * If you choose to send such events you can extend the abstract class - * UserEvent provide a name for your new event and optionally add your own - * attributes. After registering a user event type Asterisk-Java will handle - * such events the same way it handles the internal events and inform your - * registered event handlers. - *

- * Note: If you write your own Asterisk applications that use Asterisk's - * manager_event() function directly and don't use the channel - * and uniqueid attributes provided by UserEvent you can also register - * events that directly subclass {@link ManagerEvent}. - *

- * The event class must be a concrete class with a default constructor (one - * that takes no arguments). - * - * @param userEventClass the class representing the user event to register. - * @throws IllegalArgumentException if userEventClass is not a valid event - * class. - * @see org.asteriskjava.manager.event.UserEvent - * @see ManagerEvent - */ - void registerUserEventClass(Class< ? extends ManagerEvent> userEventClass); - - /** - * The timeout to use when connecting the the Asterisk server. - *

- * Default is 0, that is using Java's built-in default. - * - * @param socketTimeout the timeout value to be used in milliseconds. - * @see java.net.Socket#connect(java.net.SocketAddress, int) - * @since 0.2 - */ - public void setSocketTimeout(int socketTimeout); - - /** - * Connection is dropped (and restarted) if it stales on read longer than - * the timeout. - *

- * If you set this property to a non zero value be sure to also use a - * {@link PingThread} or somthing similar to make sure there is some network - * traffic, otherwise you will encounter lots of unexpected reconnects. The - * read timeout should be at least twice the interval set for the - * PingThread. - *

- * Default is 0, that is no read timeout. - * - * @param socketReadTimeout the read timeout value to be used in - * milliseconds. - * @see java.net.Socket#setSoTimeout(int) - * @since 0.3 - */ - void setSocketReadTimeout(int socketReadTimeout); - - /** - * Logs in to the Asterisk server with the username and password specified - * when this connection was created. - * - * @throws IllegalStateException if connection is not in state INITIAL or - * DISCONNECTED. - * @throws IOException if the network connection is disrupted. - * @throws AuthenticationFailedException if the username and/or password are - * incorrect or the ChallengeResponse could not be built. - * @throws TimeoutException if a timeout occurs while waiting for the - * protocol identifier. The connection is closed in this case. - * @see org.asteriskjava.manager.action.LoginAction - * @see org.asteriskjava.manager.action.ChallengeAction - */ - void login() throws IllegalStateException, IOException, AuthenticationFailedException, TimeoutException; - - /** - * Logs in to the Asterisk server with the username and password specified - * when this connection was created and a given event mask. - * - * @param events the event mask. Set to "on" if all events should be send, - * "off" if not events should be sent or a combination of - * "system", "call" and "log" (separated by ',') to specify what - * kind of events should be sent. - * @throws IllegalStateException if connection is not in state INITIAL or - * DISCONNECTED. - * @throws IOException if the network connection is disrupted. - * @throws AuthenticationFailedException if the username and/or password are - * incorrect or the ChallengeResponse could not be built. - * @throws TimeoutException if a timeout occurs while waiting for the - * protocol identifier. The connection is closed in this case. - * @since 0.3 - * @see org.asteriskjava.manager.action.LoginAction - * @see org.asteriskjava.manager.action.ChallengeAction - */ - void login(String events) throws IllegalStateException, IOException, AuthenticationFailedException, TimeoutException; - - /** - * Sends a LogoffAction to the Asterisk server and disconnects. - * - * @throws IllegalStateException if not in state CONNECTED or RECONNECTING. - * @see org.asteriskjava.manager.action.LogoffAction - */ - void logoff() throws IllegalStateException; - - /** - * Returns the protocol identifier, that is a string like "Asterisk Call - * Manager/1.0". - * - * @return the protocol identifier of the Asterisk Manager Interface in use - * if it has already been received; null otherwise - */ - String getProtocolIdentifier(); - - /** - * Returns the lifecycle status of this connection. - * - * @return the lifecycle status of this connection. - */ - ManagerConnectionState getState(); - - /** - * Sends a ManagerAction to the Asterisk server and waits for the - * corresponding ManagerResponse. - * - * @param action the action to send to the Asterisk server - * @return the corresponding response received from the Asterisk server - * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no response is received within the default - * timeout period. - * @throws IllegalArgumentException if the action is null. - * @throws IllegalStateException if you are not connected to an Asterisk - * server. - * @see #sendAction(ManagerAction, long) - * @see #sendAction(ManagerAction, SendActionCallback) - */ - ManagerResponse sendAction(ManagerAction action) - throws IOException, TimeoutException, IllegalArgumentException, IllegalStateException; - - /** - * Sends a ManagerAction to the Asterisk server and waits for the - * corresponding {@link ManagerResponse}. - * - * @param action the action to send to the Asterisk server - * @param timeout milliseconds to wait for the response before throwing a - * TimeoutException - * @return the corresponding response received from the Asterisk server - * @throws IOException if the network connection is disrupted. - * @throws TimeoutException if no response is received within the given - * timeout period. - * @throws IllegalArgumentException if the action is null. - * @throws IllegalStateException if you are not connected to an Asterisk - * server. - * @see #sendAction(ManagerAction, SendActionCallback) - */ - ManagerResponse sendAction(ManagerAction action, long timeout) - throws IOException, TimeoutException, IllegalArgumentException, IllegalStateException; - - /** - * Sends a ManagerAction to the Asterisk server and registers a callback - * handler to be called when the corresponding {@link ManagerResponse} is - * received. Be very careful that your callbackHandler terminates very - * quickly and does not do any fancy processing because it is called from - * the reader thread which is blocked for the time it takes to execute your - * callbackHandler. - * - * @param action the action to send to the Asterisk server - * @param callback the callback handler to call when the response is - * received or null if you are not interested in the - * response - * @throws IOException if the network connection is disrupted. - * @throws IllegalArgumentException if the action is null. - * @throws IllegalStateException if you are not connected to the Asterisk - * server. - */ - void sendAction(ManagerAction action, SendActionCallback callback) - throws IOException, IllegalArgumentException, IllegalStateException; - - /** - * Sends an {@link EventGeneratingAction} to the Asterisk server and waits - * for the corresponding {@link ManagerResponse} and the - * {@link org.asteriskjava.manager.event.ResponseEvent}s - *

- * EventGeneratingActions are {@link ManagerAction}s that don't return their - * response in the corresponding {@link ManagerResponse} but send a series - * of events that contain the payload. - *

- * This method will block until the correpsonding action complete event has - * been received. The action complete event is determined by - * {@link EventGeneratingAction#getActionCompleteEventClass()}. - *

- * Examples for EventGeneratingActions are - * {@link org.asteriskjava.manager.action.StatusAction}, - * {@link org.asteriskjava.manager.action.QueueStatusAction} or - * {@link org.asteriskjava.manager.action.AgentsAction}. - * - * @param action the action to send to the Asterisk server - * @return a ResponseEvents that contains the corresponding response and - * response events received from the Asterisk server - * @throws IOException if the network connection is disrupted. - * @throws EventTimeoutException if no response or not all response events - * are received within the given timeout period. - * @throws IllegalArgumentException if the action is null, the - * actionCompleteEventClass property of the action is - * null or if actionCompleteEventClass is not a - * ResponseEvent. - * @throws IllegalStateException if you are not connected to an Asterisk - * server. - * @see EventGeneratingAction - * @see org.asteriskjava.manager.event.ResponseEvent - * @since 0.2 - */ - ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException; - - /** - * Sends an {@link EventGeneratingAction} to the Asterisk server and waits - * for the corresponding {@link ManagerResponse} and the - * {@link org.asteriskjava.manager.event.ResponseEvent}s - *

- * EventGeneratingActions are {@link ManagerAction}s that don't return their - * response in the corresponding {@link ManagerResponse} but send a series - * of events that contain the payload. - *

- * This method will block until the correpsonding action complete event has - * been received but no longer that timeout seconds. The action complete - * event is determined by - * {@link EventGeneratingAction#getActionCompleteEventClass()}. - *

- * Examples for EventGeneratingActions are the - * {@link org.asteriskjava.manager.action.StatusAction}, the - * {@link org.asteriskjava.manager.action.QueueStatusAction} or the - * {@link org.asteriskjava.manager.action.AgentsAction}. - * - * @param action the action to send to the Asterisk server - * @param timeout milliseconds to wait for the response and the action - * complete event before throwing a TimeoutException - * @return a ResponseEvents that contains the corresponding response and - * response events received from the Asterisk server - * @throws IOException if the network connection is disrupted. - * @throws EventTimeoutException if no response or not all response events - * are received within the given timeout period. - * @throws IllegalArgumentException if the action is null, the - * actionCompleteEventClass property of the action is - * null or if actionCompleteEventClass is not a - * ResponseEvent. - * @throws IllegalStateException if you are not connected to an Asterisk - * server. - * @see EventGeneratingAction - * @see org.asteriskjava.manager.event.ResponseEvent - * @since 0.2 - */ - ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, long timeout) - throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException; - - /** - * Registers an event listener that is called whenever an - * {@link org.asteriskjava.manager.event.ManagerEvent} is receiced from the - * Asterisk server. - *

- * Event listeners are notified about new events in the same order as they - * were registered. - * - * @param eventListener the listener to call whenever a manager event is - * received - * @see #removeEventListener(ManagerEventListener) - */ - void addEventListener(ManagerEventListener eventListener); - - /** - * Unregisters a previously registered event listener. - *

- * Does nothing if the given event listener hasn't be been regiered before. - * - * @param eventListener the listener to remove - * @see #addEventListener(ManagerEventListener) - */ - void removeEventListener(ManagerEventListener eventListener); - - void deregisterEventClass(Class< ? extends ManagerEvent> eventClass); -} diff --git a/src/main/java/org/asteriskjava/manager/ManagerConnectionFactory.java b/src/main/java/org/asteriskjava/manager/ManagerConnectionFactory.java deleted file mode 100644 index 7672b35df..000000000 --- a/src/main/java/org/asteriskjava/manager/ManagerConnectionFactory.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -/** - * This factory is the canonical way to obtain new - * {@link org.asteriskjava.manager.ManagerConnection}s.

- * It creates new connections in state - * {@link org.asteriskjava.manager.ManagerConnectionState#INITIAL}. Before - * you can start using such a connection (i.e. sending - * {@link org.asteriskjava.manager.action.ManagerAction}s you must - * {@link org.asteriskjava.manager.ManagerConnection#login()} to change its state - * to {@link org.asteriskjava.manager.ManagerConnectionState#CONNECTED}.

- * Example: - *

- * ManagerConnectionFactory factory;
- * ManagerConnection connection;
- * 
- * factory = new ManagerConnectionFactory("localhost", "manager", "secret");
- * connection = factory.createManagerConnection();
- * connection.login();
- * ...
- * connection.logoff();
- * 
- * If want you can use the factory to create multiple connections to the same - * server by calling {@link #createManagerConnection()} multiple times.

- * - * @see org.asteriskjava.manager.ManagerConnection - * @author srt - * @version $Id$ - */ -public class ManagerConnectionFactory -{ - private static final int DEFAULT_PORT = 5038; - - private final String hostname; - private final int port; - private final String username; - private final String password; - - /** - * Creates a new ManagerConnectionFactory with the given connection data and - * the default port 5038. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param username the username to use for login as defined in Asterisk's manager.conf. - * @param password the password to use for login as defined in Asterisk's manager.conf. - * @since 0.3 - */ - public ManagerConnectionFactory(String hostname, String username, String password) - { - this.hostname = hostname; - this.port = DEFAULT_PORT; - this.username = username; - this.password = password; - } - - /** - * Creates a new ManagerConnectionFactory with the given connection data. - * - * @param hostname the hostname of the Asterisk server to connect to. - * @param port the port where Asterisk listens for incoming Manager API - * connections, usually 5038. - * @param username the username to use for login as defined in Asterisk's manager.conf. - * @param password the password to use for login as defined in Asterisk's manager.conf. - * @since 0.3 - */ - public ManagerConnectionFactory(String hostname, int port, String username, String password) - { - this.hostname = hostname; - this.port = port; - this.username = username; - this.password = password; - } - - /** - * Returns a new ManagerConnection in state {@link ManagerConnectionState#CONNECTED}. - * - * @return the created connection to the Asterisk server. - * @since 0.3 - */ - public ManagerConnection createManagerConnection() - { - return new DefaultManagerConnection(hostname, port, username, password); - } - - /** - * Returns a new SSL secured ManagerConnection in state {@link ManagerConnectionState#CONNECTED}. - * - * @return the created connection to the Asterisk server. - * @since 0.3 - */ - public ManagerConnection createSecureManagerConnection() - { - DefaultManagerConnection dmc; - dmc = new DefaultManagerConnection(hostname, port, username, password); - dmc.setSsl(true); - return dmc; - } -} diff --git a/src/main/java/org/asteriskjava/manager/ManagerConnectionState.java b/src/main/java/org/asteriskjava/manager/ManagerConnectionState.java deleted file mode 100644 index 4ec1209ad..000000000 --- a/src/main/java/org/asteriskjava/manager/ManagerConnectionState.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.asteriskjava.manager; - -/** - * The lifecycle status of a {@link org.asteriskjava.manager.ManagerConnection}. - * - * @author srt - * @since 0.3 - */ -public enum ManagerConnectionState -{ - /** - * The initial state after the ManagerConnection object has been created - * but the connection has not yet been established.

- * Changes to {@link #CONNECTING} when {@link org.asteriskjava.manager.ManagerConnection#login()} - * is called. - */ - INITIAL, - - /** - * The connection is being made and login is performed.

- * Changes to {@link #CONNECTED} when login has successfully completed or - * {@link #DISCONNECTED} if login fails. - */ - CONNECTING, - - /** - * The connection has been successfully established, login has been perfomed and - * the connection is ready to be used.

- * This is the required state for sending actions to the Asterisk server.

- * Changes to {@link #RECONNECTING} when connection is lost or {@link #DISCONNECTING} - * when {@link org.asteriskjava.manager.ManagerConnection#logoff()} is called. - */ - CONNECTED, - - /** - * The connection has been disrupted and is about to be reestablished.

- * Changes to {@link #CONNECTED} when connection is successfully reestablished or - * {@link #DISCONNECTING} when {@link org.asteriskjava.manager.ManagerConnection#logoff()} - * is called. - */ - RECONNECTING, - - /** - * The connection is about to be closed by user request.

- * Changes to {@link #DISCONNECTED} when connection has been closed. - */ - DISCONNECTING, - - /** - * The connection has been closed on user's request is not about to be reestablished.

- * Can be changed to {@link #CONNECTING} by calling - * {@link org.asteriskjava.manager.ManagerConnection#login()}. - */ - DISCONNECTED -} diff --git a/src/main/java/org/asteriskjava/manager/ManagerEventListener.java b/src/main/java/org/asteriskjava/manager/ManagerEventListener.java deleted file mode 100644 index 33ac2f9a6..000000000 --- a/src/main/java/org/asteriskjava/manager/ManagerEventListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -import java.util.EventListener; - -import org.asteriskjava.manager.event.ManagerEvent; - - -/** - * An interface to listen for events received from an Asterisk server. - * - * @see org.asteriskjava.manager.event.ManagerEvent - * @author srt - * @version $Id$ - */ -public interface ManagerEventListener extends EventListener -{ - /** - * This method is called when an event is received. - * - * @param event the event that has been received - */ - void onManagerEvent(ManagerEvent event); -} diff --git a/src/main/java/org/asteriskjava/manager/ManagerEventListenerProxy.java b/src/main/java/org/asteriskjava/manager/ManagerEventListenerProxy.java deleted file mode 100644 index 2813cfbba..000000000 --- a/src/main/java/org/asteriskjava/manager/ManagerEventListenerProxy.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.asteriskjava.manager; - -import java.util.concurrent.Executors; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.util.DaemonThreadFactory; - -/** - * Proxies a ManagerEventListener and dispatches events asynchronously by using - * a single threaded executor.

- * Use this proxy to prevent the reader thread from being blocked while your - * application processes {@link org.asteriskjava.manager.event.ManagerEvent}s. - * If you want to use the {@link org.asteriskjava.manager.ManagerConnection} for - * sending actions in your {@link org.asteriskjava.manager.ManagerEventListener} - * using a proxy like this one is mandatory; otherwise you will always run into - * a timeout because the reader thread that is supposed to read the response to - * your action is still blocked processing the event.

- * If in doubt use the proxy as it won't hurt.

- * Example: - *

- * ManagerConnection connection;
- * ManagerEventListener myListener;
- * ...
- * connection.addEventListener(new ManagerEventListenerProxy(myListener));
- * 
- * - * @author srt - * @author fink - * @since 0.3 - */ -public class ManagerEventListenerProxy implements ManagerEventListener { - private final ThreadPoolExecutor executor; - private final ManagerEventListener target; - - - /** - * Creates a new ManagerEventListenerProxy that notifies the given target - * asynchronously when new events are received. - * - * @param target the target listener to invoke. - * @see Executors#newSingleThreadExecutor(ThreadFactory) - */ - public ManagerEventListenerProxy(ManagerEventListener target) { - executor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new DaemonThreadFactory()); - this.target = target; - if (target == null) { - throw new NullPointerException("ManagerEventListener target is null!"); - } - }//new - - - @Override public void onManagerEvent(final ManagerEvent event) { - executor.execute(new Runnable() { - @Override public void run() { - target.onManagerEvent(event); - } - }); - }//onManagerEvent - - - public void shutdown() { - executor.shutdown(); - } - - public static class Access { - private Access() { - - } - - public static int getThreadQueueSize (ManagerEventListenerProxy proxy) { - return proxy.executor.getQueue().size(); - } - }//Access -} diff --git a/src/main/java/org/asteriskjava/manager/PingThread.java b/src/main/java/org/asteriskjava/manager/PingThread.java deleted file mode 100644 index ee5edf9b4..000000000 --- a/src/main/java/org/asteriskjava/manager/PingThread.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; - -import org.asteriskjava.manager.action.PingAction; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * A Thread that pings the Asterisk server at a given interval. - * You can use this to prevent the connection being shut down when there is no - * traffic. - *

- * Since 1.0.0 PingThread supports mutliple connections so do don't have to - * start multiple threads to keep several connections alive. - * - * @author srt - * @version $Id$ - */ -public class PingThread extends Thread -{ - private static final long DEFAULT_INTERVAL = 20 * 1000L; - private static final long DEFAULT_TIMEOUT = 0L; - private static final AtomicLong idCounter = new AtomicLong(0); - - /** - * Instance logger. - */ - private final Log logger = LogFactory.getLog(getClass()); - - private long interval = DEFAULT_INTERVAL; - private long timeout = DEFAULT_TIMEOUT; - private volatile boolean die; - private final Set connections; - - /** - * Creates a new PingThread. Use {@link #addConnection(ManagerConnection)} to add connections - * that will be pinged. - * - * @since 1.0.0 - */ - public PingThread() - { - super(); - this.connections = new HashSet<>(); - this.die = false; - long id = idCounter.getAndIncrement(); - setName("Asterisk-Java Ping-" + id); - setDaemon(true); - } - - /** - * Creates a new PingThread that uses the given ManagerConnection. - * - * @param connection ManagerConnection that is pinged - */ - public PingThread(ManagerConnection connection) - { - this(); - this.connections.add(connection); - } - - /** - * Adjusts how often a PingAction is sent. - *
- * Default is 20000ms, i.e. 20 seconds. - * - * @param interval the interval in milliseconds - */ - public void setInterval(long interval) - { - this.interval = interval; - } - - /** - * Sets the timeout to wait for the ManagerResponse before throwing an - * excpetion. - *
- * If set to 0 the response will be ignored an no exception will be thrown - * at all. - *
- * Default is 0. - * - * @param timeout the timeout in milliseconds or 0 to indicate no timeout. - * @since 0.3 - */ - public void setTimeout(long timeout) - { - this.timeout = timeout; - } - - /** - * Adds a connection to the list of pinged connections. - * - * @param connection the connection to ping. - * @since 1.0.0 - */ - public void addConnection(ManagerConnection connection) - { - synchronized (connections) - { - connections.add(connection); - } - } - - /** - * Removes a connection from the list of pinged connections. - * - * @param connection the connection that will no longer be pinged. - * @since 1.0.0 - */ - public void removeConnection(ManagerConnection connection) - { - synchronized (connections) - { - connections.remove(connection); - } - } - - /** - * Terminates this PingThread. - */ - public void die() - { - this.die = true; - interrupt(); - } - - @Override - public void run() - { - while (!die) - { - try - { - sleep(interval); - } - catch (InterruptedException e) // NOPMD - { - Thread.currentThread().interrupt(); - } - - // exit if die is set - if (die) - { - break; - } - - synchronized (connections) - { - for (ManagerConnection c : connections) - { - // skip if not connected - if (c.getState() != ManagerConnectionState.CONNECTED) - { - continue; - } - - ping(c); - } - } - } - } - - /** - * Sends a ping to Asterisk and logs any errors that may occur. - * - * @param c the connection to ping. - */ - protected void ping(ManagerConnection c) - { - try - { - if (timeout <= 0) - { - c.sendAction(new PingAction(), null); - } - else - { - final ManagerResponse response; - - response = c.sendAction(new PingAction(), timeout); - logger.debug("Ping response '" + response + "' for " + c.toString()); - } - } - catch (Exception e) - { - logger.warn("Exception on sending Ping to " + c.toString(), e); - } - } -} diff --git a/src/main/java/org/asteriskjava/manager/ResponseEvents.java b/src/main/java/org/asteriskjava/manager/ResponseEvents.java deleted file mode 100644 index 568b254fd..000000000 --- a/src/main/java/org/asteriskjava/manager/ResponseEvents.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -import java.util.Collection; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.response.ManagerResponse; - - -/** - * Contains the result of executing an - * {@link org.asteriskjava.manager.action.EventGeneratingAction}, that is the - * {@link org.asteriskjava.manager.response.ManagerResponse} and any received - * {@link org.asteriskjava.manager.event.ManagerEvent}s. - * - * @see org.asteriskjava.manager.action.EventGeneratingAction - * @author srt - * @version $Id$ - * @since 0.2 - */ -public interface ResponseEvents -{ - /** - * Returns the response received. - * - * @return the response received. - */ - ManagerResponse getResponse(); - - /** - * Returns a Collection of ManagerEvents that have been received including - * the last one that indicates completion. - * - * @return a Collection of ManagerEvents received. - */ - Collection getEvents(); -} diff --git a/src/main/java/org/asteriskjava/manager/SendActionCallback.java b/src/main/java/org/asteriskjava/manager/SendActionCallback.java deleted file mode 100644 index 3f2f9f542..000000000 --- a/src/main/java/org/asteriskjava/manager/SendActionCallback.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.response.ManagerResponse; - -/** - * Callback interface to send {@link org.asteriskjava.manager.action.ManagerAction}s - * asynchronously. - * - * @see org.asteriskjava.manager.ManagerConnection#sendAction(ManagerAction, SendActionCallback) - * @author srt - * @version $Id$ - */ -public interface SendActionCallback -{ - /** - * This method is called when a response is received. - * - * @param response the response that has been received - */ - void onResponse(ManagerResponse response); -} diff --git a/src/main/java/org/asteriskjava/manager/TimeoutException.java b/src/main/java/org/asteriskjava/manager/TimeoutException.java deleted file mode 100644 index 372df55bc..000000000 --- a/src/main/java/org/asteriskjava/manager/TimeoutException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager; - -/** - * A TimeoutException is thrown if a ManagerResponse is not received within the - * expected time period. - * - * @author srt - * @version $Id$ - */ -public class TimeoutException extends Exception -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 7674248607624140309L; - - /** - * Creates a new TimeoutException with the given message. - * - * @param message message with details about the timeout. - */ - public TimeoutException(final String message) - { - super(message); - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/.gitignore b/src/main/java/org/asteriskjava/manager/action/.gitignore deleted file mode 100644 index 454bd64b1..000000000 --- a/src/main/java/org/asteriskjava/manager/action/.gitignore +++ /dev/null @@ -1,98 +0,0 @@ -/AbsoluteTimeoutAction.class -/AbstractManagerAction.class -/AbstractMeetMeMuteAction.class -/AgentCallbackLoginAction.class -/AgentLogoffAction.class -/AgentsAction.class -/AgiAction.class -/AtxferAction.class -/BridgeAction.class -/ChallengeAction.class -/ChangeMonitorAction.class -/CommandAction.class -/ConfbridgeKickAction.class -/ConfbridgeListAction.class -/ConfbridgeListRoomsAction.class -/ConfbridgeLockAction.class -/ConfbridgeMuteAction.class -/ConfbridgeSetSingleVideoSrcAction.class -/ConfbridgeStartRecordAction.class -/ConfbridgeStopRecordAction.class -/ConfbridgeUnlockAction.class -/ConfbridgeUnmuteAction.class -/CoreSettingsAction.class -/CoreShowChannelsAction.class -/CoreStatusAction.class -/DahdiShowChannelsAction.class -/DbDelAction.class -/DbDelTreeAction.class -/DbGetAction.class -/DbPutAction.class -/DongleSendSMSAction.class -/DongleShowDevicesAction.class -/EventGeneratingAction.class -/EventsAction.class -/ExtensionStateAction.class -/GetConfigAction.class -/GetVarAction.class -/HangupAction.class -/IaxPeerListAction.class -/JabberSendAction.class -/ListCommandsAction.class -/LocalOptimizeAwayAction.class -/LoginAction.class -/LogoffAction.class -/MailboxCountAction.class -/MailboxStatusAction.class -/ManagerAction.class -/MeetMeMuteAction.class -/MeetMeUnmuteAction.class -/MixMonitorMuteAction.class -/ModuleCheckAction.class -/ModuleLoadAction.class -/MonitorAction.class -/OriginateAction.class -/ParkAction.class -/ParkedCallsAction.class -/PauseMixMonitorAction.class -/PauseMonitorAction.class -/PingAction.class -/PlayDtmfAction.class -/QueueAddAction.class -/QueueLogAction.class -/QueuePauseAction.class -/QueuePenaltyAction.class -/QueueRemoveAction.class -/QueueResetAction.class -/QueueStatusAction.class -/QueueSummaryAction.class -/RedirectAction.class -/SendTextAction.class -/SetCdrUserFieldAction.class -/SetVarAction.class -/ShowDialplanAction.class -/SipNotifyAction.class -/SipPeersAction.class -/SipShowPeerAction.class -/SipShowRegistryAction.class -/SkypeAccountPropertyAction.class -/SkypeAddBuddyAction.class -/SkypeBuddiesAction.class -/SkypeBuddyAction.class -/SkypeChatSendAction.class -/SkypeLicenseListAction.class -/SkypeLicenseStatusAction.class -/SkypeRemoveBuddyAction.class -/StatusAction.class -/StopMonitorAction.class -/UnpauseMonitorAction.class -/UpdateConfigAction.class -/UserEventAction.class -/VoicemailUsersListAction.class -/ZapDialOffhookAction.class -/ZapDndOffAction.class -/ZapDndOnAction.class -/ZapHangupAction.class -/ZapRestartAction.class -/ZapShowChannelsAction.class -/ZapTransferAction.class diff --git a/src/main/java/org/asteriskjava/manager/action/AbsoluteTimeoutAction.java b/src/main/java/org/asteriskjava/manager/action/AbsoluteTimeoutAction.java deleted file mode 100644 index c1ef7c3aa..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AbsoluteTimeoutAction.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted - * for a call on a given channel, it hangs up the channel after a certain time. - *

- * Note that the timeout is set from the current time forward, not counting the - * number of seconds the call has already been up.

- * When setting a new timeout all previous absolute timeouts are cancelled.

- * When the timeout is reached the call is returned to the T extension so that - * you can playback an explanatory note to the calling party (the called party - * will not hear that).

- * This action corresponds the the AbsoluteTimeout command used in the dialplan. - *

- * Implemented in manager.c - * - * @author srt - * @version $Id$ - */ -public class AbsoluteTimeoutAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 3073237188819825503L; - - private String channel; - private Integer timeout; - - /** - * Creates a new empty AbsoluteTimeoutAction. - */ - public AbsoluteTimeoutAction() - { - - } - - /** - * Creates a new AbsoluteTimeoutAction with the given channel and timeout. - * - * @param channel the name of the channel - * @param timeout the maximum duation of the call in seconds or 0 to cancel the AbsoluteTimeout - * @since 0.2 - */ - public AbsoluteTimeoutAction(String channel, Integer timeout) - { - this.channel = channel; - this.timeout = timeout; - } - - /** - * Returns the name of this action, i.e. "AbsoluteTimeout". - */ - @Override - public String getAction() - { - return "AbsoluteTimeout"; - } - - /** - * Returns the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the the maximum duation of the call (in seconds) to set. - */ - public Integer getTimeout() - { - return timeout; - } - - /** - * Sets the the maximum duation of the call (in seconds) to set on channel.

- * Setting the timeout to 0 cancels the timeout. - */ - public void setTimeout(Integer timeout) - { - this.timeout = timeout; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/AbstractManagerAction.java b/src/main/java/org/asteriskjava/manager/action/AbstractManagerAction.java deleted file mode 100644 index 386934f0a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AbstractManagerAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import java.lang.reflect.Method; -import java.util.Map; - -import org.asteriskjava.util.ReflectionUtil; - -/** - * This class implements the ManagerAction interface and can serve as base class - * for your concrete Action implementations. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public abstract class AbstractManagerAction implements ManagerAction -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = -7667827187378395689L; - - private String actionId; - - public abstract String getAction(); - - public String getActionId() - { - return actionId; - } - - public void setActionId(String actionId) - { - this.actionId = actionId; - } - - @Override - public String toString() - { - StringBuilder sb; - Map getters; - - sb = new StringBuilder(getClass().getName() + "["); - sb.append("action='").append(getAction()).append("',"); - getters = ReflectionUtil.getGetters(getClass()); - for (Map.Entry entry : getters.entrySet()) - { - final String attribute = entry.getKey(); - if ("action".equals(attribute) || "class".equals(attribute)) - { - continue; - } - - try - { - Object value; - value = entry.getValue().invoke(this); - sb.append(attribute).append("='").append(value).append("',"); - } - catch (Exception e) // NOPMD - { - // swallow - } - } - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/AbstractMeetMeMuteAction.java b/src/main/java/org/asteriskjava/manager/action/AbstractMeetMeMuteAction.java deleted file mode 100644 index 515097aca..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AbstractMeetMeMuteAction.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Abstract base class for mute and unmute actions. - * - * @author srt - * @version $Id$ - */ -public abstract class AbstractMeetMeMuteAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2930397629192323391L; - - private String meetMe; - private Integer userNum; - - protected AbstractMeetMeMuteAction() - { - super(); - } - - protected AbstractMeetMeMuteAction(String meetMe, Integer userNum) - { - super(); - this.meetMe = meetMe; - this.userNum = userNum; - } - - /** - * Returns the conference number. - * - * @return the conference number. - */ - public String getMeetMe() - { - return meetMe; - } - - /** - * Sets the conference number.

- * This property is mandatory. - * - * @param meetMe the conference number. - */ - public void setMeetMe(String meetMe) - { - this.meetMe = meetMe; - } - - /** - * Returns the index of the user in the conference. - * - * @return the index of the user in the conference. - */ - public Integer getUserNum() - { - return userNum; - } - - /** - * Sets the index of the user in the conference.

- * This property is mandatory. - * - * @param userNum the index of the user in the conference. - */ - public void setUserNum(Integer userNum) - { - this.userNum = userNum; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/AgentCallbackLoginAction.java b/src/main/java/org/asteriskjava/manager/action/AgentCallbackLoginAction.java deleted file mode 100644 index e00cde322..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AgentCallbackLoginAction.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The AgentCallbackLoginAction sets an agent as logged in with callback.

- * You can pass an extentsion (and optionally a context) to specify the - * destination of the callback.

- * In contrast to the AgentCallbackLogin application that you can use within - * Asterisk's dialplan, you don't need to know the agent's password when logging - * in an agent.

- * Available since Asterisk 1.2, deprecated in Asterisk 1.4 and removed in Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 0.2 - * @deprecated use {@link org.asteriskjava.manager.action.QueueAddAction} instead. - */ -@Deprecated public class AgentCallbackLoginAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 5239805071977668779L; - private String agent; - private String exten; - private String context; - private Boolean ackCall; - private Long wrapupTime; - - /** - * Creates a new empty AgentCallbackLoginAction. - */ - public AgentCallbackLoginAction() - { - - } - - /** - * Creates a new AgentCallbackLoginAction, that logs in the given agent at - * the given callback extension. - * - * @param agent the name of the agent to log in - * @param exten the extension that is called to connect a queue member with - * this agent - */ - public AgentCallbackLoginAction(String agent, String exten) - { - this.agent = agent; - this.exten = exten; - } - - /** - * Creates a new AgentCallbackLoginAction, that logs in the given agent at - * the given callback extension in the given context. - * - * @param agent the name of the agent to log in - * @param exten the extension that is called to connect a queue member with - * this agent - * @param context the context of the extension to use for callback - */ - public AgentCallbackLoginAction(String agent, String exten, String context) - { - this(agent, exten); - this.context = context; - } - - /** - * Creates a new AgentCallbackLoginAction, that logs in the given agent at - * the given callback extension in the given context. - * - * @param agent the name of the agent to log in - * @param exten the extension that is called to connect a queue member with - * this agent - * @param context the context of the extension to use for callback - * @param ackCall Boolean.TRUE to require an acknowledgement by - * '#' when agent is called back, Boolean.FALSE otherwise. - * null if default should be used. - * @param wrapupTime the minimum amount of time (in seconds) after disconnecting before - * the caller can receive a new call. - * null if default should be used. - * @since 1.0.0 - */ - public AgentCallbackLoginAction(String agent, String exten, String context, Boolean ackCall, Long wrapupTime) - { - this(agent, exten, context); - this.ackCall = ackCall; - this.wrapupTime = wrapupTime; - } - - /** - * Returns the name of this action, i.e. "AgentCallbackLogin". - * - * @return the name of this action - */ - @Override - public String getAction() - { - return "AgentCallbackLogin"; - } - - /** - * Returns the name of the agent to log in, for example "1002". - * - * @return the name of the agent to log in - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the name of the agent to log in, for example "1002".

- * This is property is mandatory. - * - * @param agent the name of the agent to log in - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - /** - * Returns the extension to use for callback. - * - * @return the extension to use for callback. - */ - public String getExten() - { - return exten; - } - - /** - * Sets the extension to use for callback.

- * This is property is mandatory. - * - * @param exten the extension to use for callback. - */ - public void setExten(String exten) - { - this.exten = exten; - } - - /** - * Returns the context of the extension to use for callback. - * - * @return the context of the extension to use for callback. - */ - public String getContext() - { - return context; - } - - /** - * Sets the context of the extension to use for callback. - * - * @param context the context of the extension to use for callback. - */ - public void setContext(String context) - { - this.context = context; - } - - /** - * Returns if an acknowledgement is needed when agent is called back. - * - * @return Boolean.TRUE if acknowledgement by '#' is required when agent is - * called back, Boolean.FALSE otherwise. null if - * default should be used. - */ - public Boolean getAckCall() - { - return ackCall; - } - - /** - * Sets if an acknowledgement is needed when agent is called back.

- * This property is optional, it allows you to override the defaults defined - * in Asterisk's configuration. - * - * @param ackCall Boolean.TRUE to require an acknowledgement by - * '#' when agent is called back, Boolean.FALSE otherwise. - * null if default should be used. - */ - public void setAckCall(Boolean ackCall) - { - this.ackCall = ackCall; - } - - /** - * Returns the minimum amount of time after disconnecting before the caller - * can receive a new call. - * - * @return the minimum amount of time after disconnecting before the caller - * can receive a new call in seconds. - */ - public Long getWrapupTime() - { - return wrapupTime; - } - - /** - * Sets the minimum amount of time after disconnecting before the caller can - * receive a new call.

- * This property is optional, it allows you to override the defaults defined - * in Asterisk's configuration. - * - * @param wrapupTime the minimum amount of time (in seconds) after disconnecting before - * the caller can receive a new call. - * null if default should be used. - */ - public void setWrapupTime(Long wrapupTime) - { - this.wrapupTime = wrapupTime; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/AgentLogoffAction.java b/src/main/java/org/asteriskjava/manager/action/AgentLogoffAction.java deleted file mode 100644 index 2ed5ba1d4..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AgentLogoffAction.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The AgentLogoffAction sets an agent as no longer logged in.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentLogoffAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 5239805071977668779L; - private String agent; - private Boolean soft; - - /** - * Creates a new empty AgentLogoffAction. - */ - public AgentLogoffAction() - { - - } - - /** - * Creates a new AgentLogoffAction that logs off the given agent - * - * @param agent the name of the agent to log off. - */ - public AgentLogoffAction(String agent) - { - this.agent = agent; - } - - /** - * Creates a new AgentLogoffAction that logs off the given agent - * - * @param agent the name of the agent to log off. - * @param soft Boolean.TRUE if exisiting calls should not be hung up on - * logout. - */ - public AgentLogoffAction(String agent, Boolean soft) - { - this(agent); - this.soft = soft; - } - - /** - * Returns the name of this action, i.e. "AgentLogoff". - * - * @return the name of this action - */ - @Override - public String getAction() - { - return "AgentLogoff"; - } - - /** - * Returns the name of the agent to log off, for example "1002". - * - * @return the name of the agent to log off - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the name of the agent to log off, for example "1002".

- * This is property is mandatory. - * - * @param agent the name of the agent to log off - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - /** - * Returns whether to hangup existing calls or not.

- * Default is to hangup existing calls on logoff. - * - * @return Boolean.TRUE if existing calls should not be hung up, - * Boolean.FALSE otherwise. null if default should be - * used. - */ - public Boolean getSoft() - { - return soft; - } - - /** - * Sets whether existing calls should be hung up or not.

- * Default is to hangup existing calls on logoff. - * - * @param soft Boolean.TRUE if existing calls should not be hung up, - * Boolean.FALSE otherwise. null if default should - * be used. - */ - public void setSoft(Boolean soft) - { - this.soft = soft; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/AgentsAction.java b/src/main/java/org/asteriskjava/manager/action/AgentsAction.java deleted file mode 100644 index 8e2324d62..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AgentsAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.AgentsCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The AgentsAction requests the state of all agents.

- * For each agent an AgentsEvent is generated. After the state of all agents has been - * reported an AgentsCompleteEvent is generated.

- * Available since Asterisk 1.2 - * - * @see org.asteriskjava.manager.event.AgentsEvent - * @see org.asteriskjava.manager.event.AgentsCompleteEvent - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentsAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = -320228893513973367L; - - /** - * Creates a new AgentsAction. - */ - public AgentsAction() - { - - } - - /** - * Returns the name of this action, i.e. "Agents". - */ - @Override - public String getAction() - { - return "Agents"; - } - - public Class getActionCompleteEventClass() - { - return AgentsCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/AgiAction.java b/src/main/java/org/asteriskjava/manager/action/AgiAction.java deleted file mode 100644 index de2bfa66f..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AgiAction.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.AsyncAgiEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Add a new AGI command to execute by the Async AGI application.

- * It will append the application to the specified channel's queue. - * If the channel is not inside Async AGI application it will return an error.

- * It is implemented in res/res_agi.c - *
- * Available since Asterisk 1.6 - * - * @see org.asteriskjava.manager.event.AsyncAgiEvent - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class AgiAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private String channel; - private String command; - private String commandId; - - /** - * Creates a new empty AgiAction. - */ - public AgiAction() - { - - } - - /** - * Creates a new AgiAction with channel and command. - * - * @param channel the name of the channel to execute the AGI command on. - * @param command the AGI command to execute. - */ - public AgiAction(String channel, String command) - { - this.channel = channel; - this.command = command; - } - - /** - * Creates a new AgiAction with channel, command and commandId. - * - * @param channel the name of the channel to execute the AGI command on. - * @param command the AGI command to execute. - * @param commandId the command id to track execution progress. - */ - public AgiAction(String channel, String command, String commandId) - { - this.channel = channel; - this.command = command; - this.commandId = commandId; - } - - /** - * Returns the name of this action. - */ - @Override - public String getAction() - { - return "AGI"; - } - - public Class getActionCompleteEventClass() - { - return AsyncAgiEvent.class; - } - - /** - * Returns the name of the channel to execute the AGI command on. - * - * @return the name of the channel to execute the AGI command on. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to execute the AGI command on.

- * The channel must be running the Async AGI application "AGI(agi:async)".

- * This property is required. - * - * @param channel the name of the channel to execute the AGI command on. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the AGI command to execute. - * - * @return the AGI command to execute. - */ - public String getCommand() - { - return command; - } - - /** - * Sets the AGI command to execute.

- * This property is required. - * - * @param command the AGI command to execute. - */ - public void setCommand(String command) - { - this.command = command; - } - - /** - * Returns the command id to track execution progress. - * - * @return the command id to track execution progress. - */ - public String getCommandId() - { - return commandId; - } - - /** - * Sets the command id to track execution progress.

- * This value will be sent back in the CommandID header of AsyncAGI exec event notifications. - * - * @param commandId the command id to track execution progress. - */ - public void setCommandId(String commandId) - { - this.commandId = commandId; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/AtxferAction.java b/src/main/java/org/asteriskjava/manager/action/AtxferAction.java deleted file mode 100644 index 01e6f65f7..000000000 --- a/src/main/java/org/asteriskjava/manager/action/AtxferAction.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Starts an attended transfer. This action seems to be a bit of a hack. See - * http://bugs.digium.com/view.php?id=12158 - * for details.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class AtxferAction extends AbstractManagerAction -{ - static final long serialVersionUID = 1L; - - private String channel; - private String exten; - private String context; - private Integer priority; - - /** - * Creates a new empty AtxferAction. - */ - public AtxferAction() - { - - } - - /** - * Creates a new AtxferAction that initiates an attended transfer of the given channel to the - * given context, extension, priority triple. - * - * @param channel the name of the channel to transfer - * @param context the destination context - * @param exten the destination extension - * @param priority the destination priority - */ - public AtxferAction(String channel, String context, String exten, Integer priority) - { - this.channel = channel; - this.context = context; - this.exten = exten; - this.priority = priority; - } - - - /** - * Returns the name of this action, i.e. "Atxfer". - */ - @Override - public String getAction() - { - return "Atxfer"; - } - - /** - * Returns name of the channel to transfer. - * - * @return the name of the channel to transfer - */ - public String getChannel() - { - return channel; - } - - /** - * Sets name of the channel to transfer. - * - * @param channel the name of the channel to transfer - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the destination context. - * - * @return the destination context - */ - public String getContext() - { - return context; - } - - /** - * Sets the destination context. - * - * @param context the destination context - */ - public void setContext(String context) - { - this.context = context; - } - - /** - * Returns the destination extension. - * - * @return the destination extension - */ - public String getExten() - { - return exten; - } - - /** - * Sets the destination extension. - * - * @param exten the destination extension - */ - public void setExten(String exten) - { - this.exten = exten; - } - - /** - * Returns the destination priority. - * - * @return the destination priority - */ - public Integer getPriority() - { - return priority; - } - - /** - * Sets the destination priority. - * - * @param priority the destination priority - */ - public void setPriority(Integer priority) - { - this.priority = priority; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/BridgeAction.java b/src/main/java/org/asteriskjava/manager/action/BridgeAction.java deleted file mode 100644 index 1de6df0f9..000000000 --- a/src/main/java/org/asteriskjava/manager/action/BridgeAction.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The BridgeAction bridges two channels that are currently active on the system.

- * It is definied in res/res_features.c.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class BridgeAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - private String channel1; - private String channel2; - private Boolean tone; - - /** - * Creates a new empty BridgeAction. - */ - public BridgeAction() - { - - } - - /** - * Creates a new BridgeAction that bridges the two given channels. - * - * @param channel1 the name of the channel to bridge to channel2. - * @param channel2 the name of the channel to bridge to channel1. - */ - public BridgeAction(String channel1, String channel2) - { - this.channel1 = channel1; - this.channel2 = channel2; - } - - /** - * Creates a new BridgeAction that bridges the two given channels. - * - * @param channel1 the name of the channel to bridge to channel2. - * @param channel2 the name of the channel to bridge to channel1. - * @param tone true to play a courtesy tone to channel2, false otherwise. - */ - public BridgeAction(String channel1, String channel2, Boolean tone) - { - this.channel1 = channel1; - this.channel2 = channel2; - this.tone = tone; - } - - /** - * Returns the name of this action, i.e. "Bridge". - */ - @Override - public String getAction() - { - return "Bridge"; - } - - /** - * Returns the name of the channel to bridge to channel2. - * - * @return the name of the channel to bridge to channel2. - */ - public String getChannel1() - { - return channel1; - } - - /** - * Sets the name of the channel to bridge to channel2. - * - * @param channel1 the name of the channel to bridge to channel2. - */ - public void setChannel1(String channel1) - { - this.channel1 = channel1; - } - - /** - * Returns the name of the channel to bridge to channel1. - * - * @return the name of the channel to bridge to channel1. - */ - public String getChannel2() - { - return channel2; - } - - /** - * Sets the name of the channel to bridge to channel1. - * - * @param channel2 the name of the channel to bridge to channel1. - */ - public void setChannel2(String channel2) - { - this.channel2 = channel2; - } - - /** - * Returns whether a courtesy tone will be played to channel2. - * - * @return true to play a courtesy tone to channel2, false or - * null (if not set) otherwise. - */ - public Boolean getTone() - { - return tone; - } - - /** - * Sets whether a courtesy tone will be played to channel2. - * - * @param tone true to play a courtesy tone to channel2, false otherwise. - */ - public void setTone(Boolean tone) - { - this.tone = tone; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/ChallengeAction.java b/src/main/java/org/asteriskjava/manager/action/ChallengeAction.java deleted file mode 100644 index 01e10a25c..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ChallengeAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.ChallengeResponse; - -/** - * The ChallengeAction requests a challenge from the server to use when logging - * in using challenge/response. Sending this action to the asterisk server - * results in a ChallengeResponse being received from the server. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.LoginAction - * @see org.asteriskjava.manager.response.ChallengeResponse - */ -@ExpectedResponse(ChallengeResponse.class) -public class ChallengeAction extends AbstractManagerAction -{ - static final long serialVersionUID = 7240516124871953971L; - private String authType; - - /** - * Creates a new empty ChallengeAction. - */ - public ChallengeAction() - { - - } - - /** - * Creates a new ChallengeAction that requests a new login challenge for use - * with the given digest algorithm. - * - * @param authType the digest alogrithm to use. - * @since 0.2 - */ - public ChallengeAction(String authType) - { - this.authType = authType; - } - - /** - * Returns Returns the name of this action, i.e. "Challenge". - */ - @Override - public String getAction() - { - return "Challenge"; - } - - /** - * Returns the digest alogrithm to use. - */ - public String getAuthType() - { - return authType; - } - - /** - * Sets the digest alogrithm to use. Currently asterisk only supports "MD5". - */ - public void setAuthType(String authType) - { - this.authType = authType; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ChangeMonitorAction.java b/src/main/java/org/asteriskjava/manager/action/ChangeMonitorAction.java deleted file mode 100644 index a413fd3a4..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ChangeMonitorAction.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ChangeMonitorAction changes the monitoring filename of a channel. It has - * no effect if the channel is not monitored.

- * It is implemented in res/res_monitor.c - * - * @author srt - * @version $Id$ - */ -public class ChangeMonitorAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -798530703607827118L; - private String channel; - private String file; - - /** - * Creates a new empty ChangeMonitorAction. - */ - public ChangeMonitorAction() - { - - } - - /** - * Creates a new ChangeMonitorAction that causes monitoring data for the - * given channel to be written to the given file(s). - * - * @param channel the name of the channel that is monitored - * @param file the (base) name of the file(s) to which the voice data is - * written - * @since 0.2 - */ - public ChangeMonitorAction(String channel, String file) - { - this.channel = channel; - this.file = file; - } - - /** - * Returns the name of this action, i.e. "ChangeMonitor". - */ - @Override - public String getAction() - { - return "ChangeMonitor"; - } - - /** - * Returns the name of the monitored channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the monitored channel.

- * This property is mandatory. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the file to which the voice data is written. - */ - public String getFile() - { - return file; - } - - /** - * Sets the (base) name of the file(s) to which the voice data is written.

- * This property is mandatory. - */ - public void setFile(String file) - { - this.file = file; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/CommandAction.java b/src/main/java/org/asteriskjava/manager/action/CommandAction.java deleted file mode 100644 index df7a4eaec..000000000 --- a/src/main/java/org/asteriskjava/manager/action/CommandAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.CommandResponse; - -/** - * The CommandAction sends a command line interface (CLI) command to the - * asterisk server.

- * For a list of supported commands type help on Asterisk's - * command line.

- * In response to a CommandAction you will receive a CommandResponse that - * contains the CLI output.

- * Example: - *

- * CommandAction commandAction = new CommandAction("iax2 show peers");
- * CommandResponse response = (CommandResponse) c.sendAction(commandAction);
- * for (String line : response.getResult())
- * {
- *     System.out.println(line);
- * }
- * 
- * Where c is an instance of - * {@link org.asteriskjava.manager.ManagerConnection}. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.response.CommandResponse - */ -@ExpectedResponse(CommandResponse.class) -public class CommandAction extends AbstractManagerAction -{ - static final long serialVersionUID = 4753117770471622025L; - protected String command; - - /** - * Creates a new CommandAction. - */ - public CommandAction() - { - - } - - /** - * Creates a new CommandAction with the given command. - * - * @param command the CLI command to execute. - * @since 0.2 - */ - public CommandAction(String command) - { - this.command = command; - } - - /** - * Returns the name of this action, i.e. "Command". - */ - @Override - public String getAction() - { - return "Command"; - } - - /** - * Returns the command. - */ - public String getCommand() - { - return command; - } - - /** - * Sets the CLI command to send to the Asterisk server. - */ - public void setCommand(String command) - { - this.command = command; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeKickAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeKickAction.java deleted file mode 100644 index e6192a62a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeKickAction.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeKickAction kicks a channel out of a conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeKickAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 3827556611709875112L; - - private String conference; - private String channel; - - /** - * Creates a new empty ConfbridgeKickAction. - */ - public ConfbridgeKickAction() { - super(); - } - - /** - * Creates a new ConfbridgeKickAction. - * - * @param conference the conference number. - * @param channel number of the channel in the conference. - */ - public ConfbridgeKickAction(String conference, String channel) { - this.setConference(conference); - this.setChannel(channel); - } - - /** - * Returns the name of this action, i.e. "ConfbridgeKick". - */ - @Override - public String getAction() { - return "ConfbridgeKick"; - } - - /** - * Sets the id of the conference to kick a channel from. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference to kick a channel from. - */ - public String getConference() { - return conference; - } - - /** - * Sets the number of the channel to kick. - */ - public void setChannel(String channel) { - this.channel = channel; - } - - /** - * Returns the number of the channel to kick. - */ - public String getChannel() { - return channel; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeListAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeListAction.java deleted file mode 100644 index 45d4d4bd7..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeListAction.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ConfbridgeListCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events, - * followed by a final event called ConfbridgeListComplete. - * - * @since 1.0.0 - */ -public class ConfbridgeListAction extends AbstractManagerAction implements EventGeneratingAction -{ - private static final long serialVersionUID = 1L; - private String conference; - - public ConfbridgeListAction() - { - } - - public ConfbridgeListAction(String conference) - { - this.conference = conference; - } - - public void setConference(String conference) - { - this.conference = conference; - } - - public String getConference() - { - return conference; - } - - @Override - public String getAction() - { - return "ConfbridgeList"; - } - - @Override - public Class getActionCompleteEventClass() - { - return ConfbridgeListCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeListRoomsAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeListRoomsAction.java deleted file mode 100644 index 551ecf3bd..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeListRoomsAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ConfbridgeListRoomsCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Lists data about all active conferences. ConfbridgeListRoomsEvent will follow as separate events, - * followed by a final event called ConfbridgeListRoomsComplete. - * - * @since 1.0.0 - */ -public class ConfbridgeListRoomsAction extends AbstractManagerAction implements EventGeneratingAction -{ - private static final long serialVersionUID = 1L; - - @Override - public String getAction() - { - return "ConfbridgeListRooms"; - } - - @Override - public Class getActionCompleteEventClass() - { - return ConfbridgeListRoomsCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeLockAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeLockAction.java deleted file mode 100644 index 64e0704e0..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeLockAction.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeLockAction lockes a specified conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeLockAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 6146611916322541533L; - - private String conference; - - /** - * Creates a new empty ConfbridgeLockAction. - */ - public ConfbridgeLockAction() { - super(); - } - - /** - * Creates a new ConfbridgeLockAction for a specific conference. - */ - public ConfbridgeLockAction(String conference) { - this.setConference(conference); - } - - /** - * Returns the name of this action "ConfbridgeLock". - */ - @Override - public String getAction() { - return "ConfbridgeLock"; - } - - /** - * Sets the id of the conference to lock. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference to lock. - */ - public String getConference() { - return conference; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeMuteAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeMuteAction.java deleted file mode 100644 index 9e10e62ed..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeMuteAction.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeMuteAction mutes a channel in a conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeMuteAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1439791922666681989L; - - private String conference; - private String channel; - - /** - * Creates a new empty ConfbridgeMuteAction. - */ - public ConfbridgeMuteAction() { - super(); - } - - /** - * Creates a new ConfbridgeMuteAction. - * - * @param conference the conference number. - * @param channel number of the channel in the conference. - */ - public ConfbridgeMuteAction(String conference, String channel) { - this.setConference(conference); - this.setChannel(channel); - } - - /** - * Returns the name of this action, i.e. "ConfbridgeMute". - */ - @Override - public String getAction() { - return "ConfbridgeMute"; - } - - /** - * Sets the id of the conference. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference. - */ - public String getConference() { - return conference; - } - - /** - * Sets the number of the channel to mute. - */ - public void setChannel(String channel) { - this.channel = channel; - } - - public String getChannel() { - return channel; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeSetSingleVideoSrcAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeSetSingleVideoSrcAction.java deleted file mode 100644 index a8f89b5ce..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeSetSingleVideoSrcAction.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeSetSingleVideoSrcAction sets a conference user as the single video source distributed to all other video-capable participants. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeSetSingleVideoSrcAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 88241670521642551L; - - private String conference; - private String channel; - - /** - * Creates a new empty ConfbridgeSetSingleVideoSrcAction. - */ - public ConfbridgeSetSingleVideoSrcAction() { - super(); - } - - /** - * Returns the name of this action "ConfbridgeSetSingleVideoSrc". - */ - @Override - public String getAction() { - return "ConfbridgeSetSingleVideoSrc"; - } - - /** - * Sets the id of the conference for which the video source is to be set. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference for which the video source is to be set. - */ - public String getConference() { - return conference; - } - - /** - * Sets the channel which will be the single video source of the conference. - */ - public void setChannel(String channel) { - this.channel = channel; - } - - /** - * Returns the channel which will be the single video source of the conference. - */ - public String getChannel() { - return channel; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeStartRecordAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeStartRecordAction.java deleted file mode 100644 index 8202944ed..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeStartRecordAction.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeStartAction starts an audio recording of a conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeStartRecordAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 3059632508521358701L; - - private String conference; - - /** - * Creates a new empty ConfbridgeStartRecordAction. - */ - public ConfbridgeStartRecordAction() { - super(); - } - - /** - * Creates a new ConfbridgeStartRecordAction for a specific conference. - */ - public ConfbridgeStartRecordAction(String conference) { - this.setConference(conference); - } - - /** - * Returns the name of this action, i.e. "ConfbridgeStartRecord". - */ - @Override - public String getAction() { - return "ConfbridgeStartRecord"; - } - - /** - * Sets the id of the conference for which to start an audio recording. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference for which to start an audio recording. - */ - public String getConference() { - return conference; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeStopRecordAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeStopRecordAction.java deleted file mode 100644 index 5abf5dec8..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeStopRecordAction.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeStopAction stops an audio recording of a conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeStopRecordAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 7429055239528793083L; - - private String conference; - - /** - * Creates a new empty ConfbridgeStopRecordAction. - */ - public ConfbridgeStopRecordAction() { - super(); - } - - /** - * Creates a new ConfbridgeStopRecordAction for a specific conference. - */ - public ConfbridgeStopRecordAction(String conference) { - this.setConference(conference); - } - - /** - * Returns the name of this action, i.e. "ConfbridgeStopRecord". - */ - @Override - public String getAction() { - return "ConfbridgeStopRecord"; - } - - /** - * Sets the id of the conference for which to stop an audio recording. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference for which to stop an audio recording. - */ - public String getConference() { - return conference; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeUnlockAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeUnlockAction.java deleted file mode 100644 index 056dac808..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeUnlockAction.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeUnlockAction unlocks a specified conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeUnlockAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 88241670521642551L; - - private String conference; - - /** - * Creates a new empty ConfbridgeUnlockAction. - */ - public ConfbridgeUnlockAction() { - super(); - } - - /** - * Creates a new ConfbridgeUnlockAction for a specific conference. - */ - public ConfbridgeUnlockAction(String conference) { - this.setConference(conference); - } - - /** - * Returns the name of this action "ConfbridgeUnlock". - */ - @Override - public String getAction() { - return "ConfbridgeUnlock"; - } - - /** - * Sets the id of the conference to unlock. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference to unlock. - */ - public String getConference() { - return conference; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ConfbridgeUnmuteAction.java b/src/main/java/org/asteriskjava/manager/action/ConfbridgeUnmuteAction.java deleted file mode 100644 index 40a18ece5..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ConfbridgeUnmuteAction.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * The ConfbridgeUnmuteAction unmutes a channel in a conference. - * - * @author jmb - * @version $Id$ - */ -public class ConfbridgeUnmuteAction extends AbstractManagerAction { - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -590852239774371298L; - - private String conference; - private String channel; - - /** - * Creates a new empty ConfbridgeUnmuteAction. - */ - public ConfbridgeUnmuteAction() { - super(); - } - - /** - * Creates a new ConfbridgeUnmuteAction. - * - * @param conference the conference number. - * @param channel number of the channel in the conference. - */ - public ConfbridgeUnmuteAction(String conference, String channel) { - this.setConference(conference); - this.setChannel(channel); - } - - /** - * Returns the name of this action, i.e. "ConfbridgeUnmute". - */ - @Override - public String getAction() { - return "ConfbridgeUnmute"; - } - - /** - * Sets the id of the conference. - */ - public void setConference(String conference) { - this.conference = conference; - } - - /** - * Returns the id of the conference. - */ - public String getConference() { - return conference; - } - - /** - * Sets the number of the channel to unmute. - */ - public void setChannel(String channel) { - this.channel = channel; - } - - /** - * Returns the number of the channel to unmute. - */ - public String getChannel() { - return channel; - } - -} - diff --git a/src/main/java/org/asteriskjava/manager/action/CoreSettingsAction.java b/src/main/java/org/asteriskjava/manager/action/CoreSettingsAction.java deleted file mode 100644 index 64dee5171..000000000 --- a/src/main/java/org/asteriskjava/manager/action/CoreSettingsAction.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.CoreSettingsResponse; - -/** - * The CoreStatusAction requests a settings summary from the server. The settings - * include the version, system name, and various system limits.

- * It returns a {@link org.asteriskjava.manager.response.CoreSettingsResponse}.

- * Available since Asterisk 1.6.0 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.response.CoreSettingsResponse - * @since 1.0.0 - */ -@ExpectedResponse(CoreSettingsResponse.class) -public class CoreSettingsAction extends AbstractManagerAction -{ - static final long serialVersionUID = 1L; - - /** - * Creates a new CoreSettingsAction. - */ - public CoreSettingsAction() - { - - } - - /** - * Returns the name of this action, i.e. "CoreSettings". - */ - @Override - public String getAction() - { - return "CoreSettings"; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/CoreShowChannelsAction.java b/src/main/java/org/asteriskjava/manager/action/CoreShowChannelsAction.java deleted file mode 100644 index 4c0eea236..000000000 --- a/src/main/java/org/asteriskjava/manager/action/CoreShowChannelsAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2009 Sebastian. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * under the License. - */ - -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.CoreShowChannelsCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The CoreShowChannelsAction requests the state of all active channels.

- * It is simmilar to StatusAction but with more information about that channel - * For each active channel a CoreShowChannelEvent is generated. After the state of all - * channels has been reported a CoreShowChannelsCompleteEvent is generated.

- * This action only works properly in 1.6.2 later than beta3. - * - * @author sebastian gutierrez - * @see org.asteriskjava.manager.event.CoreShowChannelEvent - * @see org.asteriskjava.manager.event.CoreShowChannelsCompleteEvent - * @since 1.0.0 - */ -public class CoreShowChannelsAction extends AbstractManagerAction implements EventGeneratingAction -{ - - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - public CoreShowChannelsAction() - { - - } - - @Override - public String getAction() - { - return "CoreShowChannels"; - } - - public Class getActionCompleteEventClass() - { - return CoreShowChannelsCompleteEvent.class; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/action/CoreStatusAction.java b/src/main/java/org/asteriskjava/manager/action/CoreStatusAction.java deleted file mode 100644 index 5f7180497..000000000 --- a/src/main/java/org/asteriskjava/manager/action/CoreStatusAction.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.CoreStatusResponse; - -/** - * The CoreStatusAction requests a status summary from the server.

- * It returns a {@link org.asteriskjava.manager.response.CoreStatusResponse}.

- * Available since Asterisk 1.6.0 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.response.CoreStatusResponse - * @since 1.0.0 - */ -@ExpectedResponse(CoreStatusResponse.class) -public class CoreStatusAction extends AbstractManagerAction -{ - static final long serialVersionUID = 1L; - - /** - * Creates a new CoreStatusAction. - */ - public CoreStatusAction() - { - - } - - /** - * Returns the name of this action, i.e. "CoreStatus". - */ - @Override - public String getAction() - { - return "CoreStatus"; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/DahdiShowChannelsAction.java b/src/main/java/org/asteriskjava/manager/action/DahdiShowChannelsAction.java deleted file mode 100644 index 1d5b72785..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DahdiShowChannelsAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.DahdiShowChannelsCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The DahdiShowChannelsAction requests the state of all Dahdi channels.

- * For each Dahdi channel aDahdiShowChannelsEvent is generated. After all Dahdi - * channels have been listed a DahdiShowChannelsCompleteEvent is generated. - * - * @see org.asteriskjava.manager.event.DahdiShowChannelsEvent - * @see org.asteriskjava.manager.event.DahdiShowChannelsCompleteEvent - * @author srt - * @version $Id$ - */ -public class DahdiShowChannelsAction extends AbstractManagerAction - implements - EventGeneratingAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 8697000330085766825L; - - /** - * Creates a new DahdiShowChannelsAction. - */ - public DahdiShowChannelsAction() - { - - } - - /** - * Returns the name of this action, i.e. "DahdiShowChannels". - */ - @Override - public String getAction() - { - return "DahdiShowChannels"; - } - - public Class getActionCompleteEventClass() - { - return DahdiShowChannelsCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/DbDelAction.java b/src/main/java/org/asteriskjava/manager/action/DbDelAction.java deleted file mode 100644 index f64aa4dc4..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DbDelAction.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Deletes an entry in the Asterisk database for a given family and key.

- * Available since Asterisk 1.2 with BRIStuff patches and since Asterisk 1.6 - * - * @author gmi - */ -public class DbDelAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 921037572305993779L; - private String family; - private String key; - - /** - * Creates a new empty DbDelAction. - */ - public DbDelAction() - { - - } - - /** - * Creates a new DbDelAction that deletes the value of the database - * - * @param family the family of the key - * @param key the key of the entry to delete - */ - public DbDelAction(String family, String key) - { - this.family = family; - this.key = key; - } - - @Override - public String getAction() - { - return "DBDel"; - } - - /** - * Returns the family of the key to delete - * - * @return the family of the key to delete - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key to delete - * - * @param family the family of the key to delete - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the key to delete - * - * @return the key to delete - */ - public String getKey() - { - return key; - } - - /** - * Sets the key to delete - * - * @param key the key to delete - */ - public void setKey(String key) - { - this.key = key; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/DbDelTreeAction.java b/src/main/java/org/asteriskjava/manager/action/DbDelTreeAction.java deleted file mode 100644 index 2807135df..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DbDelTreeAction.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Recursivly deletes entries in the Asterisk database for a given family and key.

- * Available since Asterisk 1.6 - * - * @author gmi - * @since 1.0.0 - */ -public class DbDelTreeAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - private String family; - private String key; - - /** - * Creates a new empty DbDelTreeAction. - */ - public DbDelTreeAction() - { - - } - - /** - * Creates a new DbDelTreeAction. - * - * @param family the family of the key - * @param key the key of the entries to delete - */ - public DbDelTreeAction(String family, String key) - { - this.family = family; - this.key = key; - } - - @Override - public String getAction() - { - return "DBDelTree"; - } - - /** - * Returns the family of the key to delete. - * - * @return the family of the key to delete - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key to delete. - * - * @param family the family of the key to delete - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the key to delete. - * - * @return the key to delete - */ - public String getKey() - { - return key; - } - - /** - * Sets the key to delete. - * - * @param key the key to delete - */ - public void setKey(String key) - { - this.key = key; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/DbGetAction.java b/src/main/java/org/asteriskjava/manager/action/DbGetAction.java deleted file mode 100644 index eceda8b05..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DbGetAction.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.DbGetResponseEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Retrieves an entry in the Asterisk database for a given family and key.

- * If an entry is found a DBGetResponseEvent is sent by Asterisk containing the - * value, otherwise a ManagerError indicates that no entry matches.

- * It is implemented in main/db.c.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.DbGetResponseEvent - * @since 0.2 - */ -public class DbGetAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 921037572305993779L; - private String family; - private String key; - - /** - * Creates a new empty DbGetAction. - */ - public DbGetAction() - { - - } - - /** - * Creates a new DbGetAction that retrieves the value of the database entry - * with the given key in the given family. - * - * @param family the family of the key - * @param key the key of the entry to retrieve - * @since 0.2 - */ - public DbGetAction(String family, String key) - { - this.family = family; - this.key = key; - } - - @Override - public String getAction() - { - return "DBGet"; - } - - /** - * Returns the family of the key. - * - * @return the family of the key. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key. - * - * @param family the family of the key. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the key of the entry to retrieve. - * - * @return the key of the entry to retrieve. - */ - public String getKey() - { - return key; - } - - /** - * Sets the key of the entry to retrieve. - * - * @param key the key of the entry to retrieve. - */ - public void setKey(String key) - { - this.key = key; - } - - public Class getActionCompleteEventClass() - { - return DbGetResponseEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/DbPutAction.java b/src/main/java/org/asteriskjava/manager/action/DbPutAction.java deleted file mode 100644 index 9eb4d1f28..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DbPutAction.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Adds or updates an entry in the Asterisk database for a given family, key, - * and value.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class DbPutAction extends AbstractManagerAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 921037572305993779L; - private String family; - private String key; - private String val; - - /** - * Creates a new empty DbPutAction. - */ - public DbPutAction() - { - - } - - /** - * Creates a new DbPutAction that sets the value of the database entry with - * the given key in the given family. - * - * @param family the family of the key - * @param key the key of the entry to set - * @param val the value to set - * @since 0.2 - */ - public DbPutAction(String family, String key, String val) - { - this.family = family; - this.key = key; - this.val = val; - } - - @Override - public String getAction() - { - return "DBPut"; - } - - /** - * Returns the family of the key to set. - * - * @return the family of the key to set. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the key to set. - * - * @param family the family of the key to set. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the the key to set. - * - * @return the key to set. - */ - public String getKey() - { - return key; - } - - /** - * Sets the key to set. - * - * @param key the key to set. - */ - public void setKey(String key) - { - this.key = key; - } - - /** - * Returns the value to set. - * - * @return the value to set. - */ - public String getVal() - { - return val; - } - - /** - * Sets the value to set. - * - * @param val the value to set. - */ - public void setVal(String val) - { - this.val = val; - } - - /** - * Returns the value to set for BRIstuffed versions. - * - * @return the value to set. - * @since 1.0.0 - */ - public String getValue() - { - return val; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/DongleSendSMSAction.java b/src/main/java/org/asteriskjava/manager/action/DongleSendSMSAction.java deleted file mode 100644 index 2a37c2b35..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DongleSendSMSAction.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.asteriskjava.manager.action; - -public class DongleSendSMSAction extends AbstractManagerAction -{ - static final long serialVersionUID = 8194597741743334704L; - private String device; - private String number; - private String message; - - @Override - public String getAction() - { - return "DongleSendSMS"; - } - - public String getDevice() - { - return this.device; - } - - public void setDevice(String d) - { - this.device = d; - } - - public String getNumber() - { - return this.number; - } - - public void setNumber(String callerId) - { - this.number = callerId; - } - - public String getMessage() - { - return this.message; - } - - public void setMessage(String m) - { - this.message = m; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/DongleShowDevicesAction.java b/src/main/java/org/asteriskjava/manager/action/DongleShowDevicesAction.java deleted file mode 100644 index 1f9fd7abe..000000000 --- a/src/main/java/org/asteriskjava/manager/action/DongleShowDevicesAction.java +++ /dev/null @@ -1,38 +0,0 @@ - -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.DongleShowDevicesCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - - -public class DongleShowDevicesAction extends AbstractManagerAction - implements - EventGeneratingAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 8697000330085466825L; - - /** - * Creates a new DahdiShowChannelsAction. - */ - public DongleShowDevicesAction() - { - - } - - /** - * Returns the name of this action, i.e. "DahdiShowChannels". - */ - @Override - public String getAction() - { - return "DongleShowDevices"; - } - - public Class getActionCompleteEventClass() - { - return DongleShowDevicesCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/EventGeneratingAction.java b/src/main/java/org/asteriskjava/manager/action/EventGeneratingAction.java deleted file mode 100644 index c521748a7..000000000 --- a/src/main/java/org/asteriskjava/manager/action/EventGeneratingAction.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The EventGeneratingAction interface is implemented by ManagerActions that - * return their result not in a ManagerResponse but by sending a series of - * events.

- * The event type that indicates that Asterisk is finished is returned by the - * getActionCompleteEventClass() method. - * - * @see org.asteriskjava.manager.event.ResponseEvent - * @author srt - * @version $Id$ - * @since 0.2 - */ -public interface EventGeneratingAction extends ManagerAction -{ - /** - * Returns the event type that indicates that Asterisk is finished sending - * response events for this action. - * - * @return a Class that is an instance of ResponseEvent. - * @see org.asteriskjava.manager.event.ResponseEvent - */ - Class getActionCompleteEventClass(); -} diff --git a/src/main/java/org/asteriskjava/manager/action/EventsAction.java b/src/main/java/org/asteriskjava/manager/action/EventsAction.java deleted file mode 100644 index 811867c03..000000000 --- a/src/main/java/org/asteriskjava/manager/action/EventsAction.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * With the EventsAction you can specify what kind of events should be sent to - * this manager connection. - * - * @author srt - * @version $Id$ - */ -public class EventsAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = -8042435402644984875L; - - private String eventMask; - - /** - * Creates a new empty EventsAction. - */ - public EventsAction() - { - - } - - /** - * Creates a new EventsAction that applies the given event mask to the - * current manager connection. - * - * @param eventMask the event mask. Set to "on" if all events should be - * send, "off" if not events should be sent or a combination of - * "system", "call" and "log" (separated by ',') to specify what - * kind of events should be sent. - * @since 0.2 - */ - public EventsAction(String eventMask) - { - this.eventMask = eventMask; - } - - /** - * Returns the name of this action, i.e. "Events". - */ - @Override - public String getAction() - { - return "Events"; - } - - /** - * Returns the event mask. - */ - public String getEventMask() - { - return eventMask; - } - - /** - * Sets the event mask.

- * Set to "on" if all events should be send, "off" if not events should be - * sent or a combination of "system", "call" and "log" (separated by ',') to - * specify what kind of events should be sent. - */ - public void setEventMask(String eventMask) - { - this.eventMask = eventMask; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ExtensionStateAction.java b/src/main/java/org/asteriskjava/manager/action/ExtensionStateAction.java deleted file mode 100644 index 9f2b3be4f..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ExtensionStateAction.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.ExtensionStateResponse; - -/** - * The ExtensionStateAction queries the state of an extension in a given context. - * If the extension has a hint, will use devicestate to check the status of the - * device connected to the extension. - * - * @author srt - * @version $Id$ - */ -@ExpectedResponse(ExtensionStateResponse.class) -public class ExtensionStateAction extends AbstractManagerAction -{ - static final long serialVersionUID = 6537408784388696403L; - - private String exten; - private String context; - - /** - * Creates a new ExtensionStateAction. - */ - public ExtensionStateAction() - { - } - - /** - * Creates a new ExtensionStateAction that queries the state of the given extension in - * the given context. - * - * @param exten the extension to query. - * @param context the name of the context that contains the extension to query. - * @since 1.0.0 - */ - public ExtensionStateAction(String exten, String context) - { - this.exten = exten; - this.context = context; - } - - /** - * Returns the name of this action, i.e. "ExtensionState". - */ - @Override - public String getAction() - { - return "ExtensionState"; - } - - /** - * Returns the extension to query. - * - * @return the extension to query. - */ - public String getExten() - { - return exten; - } - - /** - * Sets the extension to query. - * - * @param exten the extension to query. - */ - public void setExten(String exten) - { - this.exten = exten; - } - - /** - * Returns the name of the context that contains the extension to query. - * - * @return the name of the context that contains the extension to query. - */ - public String getContext() - { - return context; - } - - /** - * Sets the name of the context that contains the extension to query. - * - * @param context the name of the context that contains the extension to query. - */ - public void setContext(String context) - { - this.context = context; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/GetConfigAction.java b/src/main/java/org/asteriskjava/manager/action/GetConfigAction.java deleted file mode 100644 index dbea4242a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/GetConfigAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.GetConfigResponse; - -/** - * The GetConfigAction sends a GetConfig command to the Asterisk server.

- * The GetConfigAction returns a GetConfigResponse. - * - * @author martins - * @see org.asteriskjava.manager.response.GetConfigResponse - * @since 0.3 - */ -@ExpectedResponse(GetConfigResponse.class) -public class GetConfigAction extends AbstractManagerAction -{ - static final long serialVersionUID = 4753117770471622025L; - private String filename; - - /** - * Creates a new GetConfigAction. - */ - public GetConfigAction() - { - - } - - /** - * Creates a new GetConfigAction with the given filename. - * - * @param filename the name of the file to get. - */ - public GetConfigAction(String filename) - { - this.filename = filename; - } - - /** - * Returns the name of this action, i.e. "GetConfig". - */ - @Override - public String getAction() - { - return "GetConfig"; - } - - /** - * Returns the filename. - */ - public String getFilename() - { - return filename; - } - - /** - * Sets filename. - */ - public void setFilename(String filename) - { - this.filename = filename; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/GetVarAction.java b/src/main/java/org/asteriskjava/manager/action/GetVarAction.java deleted file mode 100644 index 17f988b5f..000000000 --- a/src/main/java/org/asteriskjava/manager/action/GetVarAction.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.GetVarResponse; - -/** - * The GetVarAction queries for a global or local channel variable.

- * Reading global variables is supported since Asterisk 1.2.

- * You cannot read built-in channel variables such as LANGUAGE or - * CALLERIDNUM using the Manager API. You can only - * read channel variables that you have explicitly set using the - * Set or SetVar (for Asterisk 1.0.x) - * applications in the dialplan, in an AGI script or by using - * the {@link org.asteriskjava.manager.action.SetVarAction} through - * the Manager API itself.

- * GetVarAction returns a {@link org.asteriskjava.manager.response.GetVarResponse}. - * To get the actual value from the corresponding - * {@link org.asteriskjava.manager.response.ManagerResponse} call - * {@link org.asteriskjava.manager.response.ManagerResponse#getAttribute(String)} - * with either the variable name as parameter (for Asterisk 1.0.x) or - * with "Value" as parameter (for Asterisk since 1.2).

- * Example (for Asterisk 1.2):

- *

- * GetVarAction getVarAction = new GetVarAction(channel, "MY_VAR");
- * ManagerResponse response = c.sendAction(getVarAction);
- * String value = response.getAttribute("Value");
- * System.out.println("MY_VAR on " + channel + " is " + value);
- * 
- * Where c is an instance of - * {@link org.asteriskjava.manager.ManagerConnection} and channel - * contains the name of a channel instance, for example "SIP/1234-9cd". - *

- * Since Asterisk-Java 1.0.0 you can also call - * {@link org.asteriskjava.manager.response.GetVarResponse#getValue()} - * when using Asterisk 1.2 or later. - *

- * Since Asterisk 1.4 this action also supports built-in functions like - * DB(), CALLERID() and ENV(). - * - * @author srt - * @version $Id$ - */ -@ExpectedResponse(GetVarResponse.class) -public class GetVarAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 5239805071977668779L; - private String channel; - private String variable; - - /** - * Creates a new empty GetVarAction. - */ - public GetVarAction() - { - - } - - /** - * Creates a new GetVarAction that queries for the given global variable. - * - * @param variable the name of the global variable to query. - * @since 0.2 - */ - public GetVarAction(String variable) - { - this.variable = variable; - } - - /** - * Creates a new GetVarAction that queries for the given local channel - * variable. - * - * @param channel the name of the channel, for example "SIP/1234-9cd". - * @param variable the name of the variable to query. - * @since 0.2 - */ - public GetVarAction(String channel, String variable) - { - this.channel = channel; - this.variable = variable; - } - - /** - * Returns the name of this action, i.e. "GetVar". - */ - @Override - public String getAction() - { - return "GetVar"; - } - - /** - * Returns the name of the channel if you query for a local channel variable - * or null if it is a global variable. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel if you query for a local channel variable. - * Leave empty to query for a global variable. - * - * @param channel the channel if you query for a local channel variable or - * null to query for a gloabl variable. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Retruns the name of the variable to query. - */ - public String getVariable() - { - return variable; - } - - /** - * Sets the name of the variable to query. - */ - public void setVariable(String variable) - { - this.variable = variable; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/HangupAction.java b/src/main/java/org/asteriskjava/manager/action/HangupAction.java deleted file mode 100644 index 180a509b1..000000000 --- a/src/main/java/org/asteriskjava/manager/action/HangupAction.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The HangupAction causes Asterisk to hang up a given channel.

- * Hangup with a cause code is only supported by Asterisk versions later than 1.6.2. - * - * @author srt - * @version $Id$ - */ -public class HangupAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 0L; - - private String channel; - private Integer cause; - - /** - * Creates a new empty HangupAction. - */ - public HangupAction() - { - - } - - /** - * Creates a new HangupAction that hangs up the given channel. - * - * @param channel the name of the channel to hangup. - * @since 0.2 - */ - public HangupAction(String channel) - { - this.channel = channel; - } - - /** - * Creates a new HangupAction that hangs up the given channel with the given cause code. - * - * @param channel the name of the channel to hangup. - * @param cause the cause code. The cause code must be >= 0 and <= 127. - * @since 1.0.0 - */ - public HangupAction(String channel, int cause) - { - this.channel = channel; - this.cause = cause; - } - - /** - * Returns the name of this action, i.e. "Hangup". - */ - @Override - public String getAction() - { - return "Hangup"; - } - - /** - * Returns the name of the channel to hangup. - * - * @return the name of the channel to hangup. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to hangup.

- * This property is mandatory. - * - * @param channel the name of the channel to hangup. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the hangup cause. - * - * @return the hangup cause. - * @since 1.0.0 - */ - public Integer getCause() - { - return cause; - } - - /** - * Sets the hangup cause. The cause code must be >= 0 and <= 127.

- * This property is optional. - * - * @param cause the hangup cause. - * @since 1.0.0 - */ - public void setCause(Integer cause) - { - this.cause = cause; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/IaxPeerListAction.java b/src/main/java/org/asteriskjava/manager/action/IaxPeerListAction.java deleted file mode 100644 index 5bc5463ab..000000000 --- a/src/main/java/org/asteriskjava/manager/action/IaxPeerListAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.PeerlistCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Retrieves a list of all defined IAX peers.

- * For each peer that is found a PeerEntryEvent is sent by Asterisk containing - * the details. When all peers have been reported a PeerlistCompleteEvent is - * sent.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.PeerEntryEvent - * @see org.asteriskjava.manager.event.PeerlistCompleteEvent - * @since 1.0.0 - */ -public class IaxPeerListAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * Creates a new IaxPeersAction. - */ - public IaxPeerListAction() - { - - } - - @Override - public String getAction() - { - return "IAXpeerlist"; - } - - public Class getActionCompleteEventClass() - { - return PeerlistCompleteEvent.class; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/JabberSendAction.java b/src/main/java/org/asteriskjava/manager/action/JabberSendAction.java deleted file mode 100644 index a90c42c9a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/JabberSendAction.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The JabberSendAction sends a Jabber (XMPP) message to a recipient.

- * Available since Asterisk 1.6.0 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class JabberSendAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - - private String jabber; - private String screenName; - private String message; - - /** - * Creates a new JabberSendAction. - */ - public JabberSendAction() - { - super(); - } - - /** - * Creates a new JabberSendAction. - * - * @param jabber the client or transport Asterisk uses to connect to Jabber. - * @param screenName the JID of the recipient. - * @param message the message to send to the recipient. - */ - public JabberSendAction(String jabber, String screenName, String message) - { - this.jabber = jabber; - this.screenName = screenName; - this.message = message; - } - - /** - * Returns the name of this action, i.e. "Ping". - */ - @Override - public String getAction() - { - return "JabberSend"; - } - - public String getJabber() - { - return jabber; - } - - /** - * Sets the client or transport Asterisk uses to connect to Jabber. - * - * @param jabber the client or transport Asterisk uses to connect to Jabber. - */ - public void setJabber(String jabber) - { - this.jabber = jabber; - } - - public String getScreenName() - { - return screenName; - } - - /** - * Sets the JID of the recipient. - * - * @param screenName the JID of the recipient. - */ - public void setScreenName(String screenName) - { - this.screenName = screenName; - } - - public String getMessage() - { - return message; - } - - /** - * Sets the message to send to the recipient. - * - * @param message the message to send to the recipient. - */ - public void setMessage(String message) - { - this.message = message; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/ListCommandsAction.java b/src/main/java/org/asteriskjava/manager/action/ListCommandsAction.java deleted file mode 100644 index 2b55b4c7b..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ListCommandsAction.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ListCommandsAction returns possible commands in the Manager interface. - *

- * Use the getAttributes method on the ManagerResponse for a map of commands and explanations. - * - * @see org.asteriskjava.manager.response.ManagerResponse#getAttributes() - * @author martins - * @since 0.3 - */ -public class ListCommandsAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2651441681309280764L; - - /** - * Creates a new ListCommandsAction. - */ - public ListCommandsAction() - { - - } - - /** - * Returns the name of this action, i.e. "ListCommands". - */ - @Override - public String getAction() - { - return "ListCommands"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/LocalOptimizeAwayAction.java b/src/main/java/org/asteriskjava/manager/action/LocalOptimizeAwayAction.java deleted file mode 100644 index b06a25bb6..000000000 --- a/src/main/java/org/asteriskjava/manager/action/LocalOptimizeAwayAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * LocalOptimizeAway action -- Optimize away a local channel when possible. - *

- * Available since Asterisk 1.8 - * - * @author SYON Communications Inc. - */ -public class LocalOptimizeAwayAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - private String channel; - - /** - * Creates a new empty LocalOptimizeAwayAction. - */ - public LocalOptimizeAwayAction() - { - - } - - /** - * Creates a new LocalOptimizeAwayAction with channel name. - * - * @param channel Name of the channel for clears the flag. - */ - public LocalOptimizeAwayAction(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of this action, i.e. "LocalOptimizeAway". - */ - @Override - public String getAction() - { - return "LocalOptimizeAway"; - } - - /** - * Sets the name of the channel. - * - * @return Name of the channel for clears the flag. - */ - public String getChannel() - { - return channel; - } - - /** - * Returns the name of tha channel. - * - * @param channel Name of the channel for clears the flag. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - -} - diff --git a/src/main/java/org/asteriskjava/manager/action/LoginAction.java b/src/main/java/org/asteriskjava/manager/action/LoginAction.java deleted file mode 100644 index e7007544d..000000000 --- a/src/main/java/org/asteriskjava/manager/action/LoginAction.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The LoginAction authenticates the connection.

- * A successful login is the precondition for sending any other action except - * for the ChallengeAction.

- * An unsuccessful login results in an ManagerError being received from the - * server with a message set to "Authentication failed" and the socket being - * closed by Asterisk. - * - * @see org.asteriskjava.manager.action.ChallengeAction - * @see org.asteriskjava.manager.response.ManagerError - * @author srt - * @version $Id$ - */ -public class LoginAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = -2600694249339115032L; - - private String username; - private String secret; - private String authType; - private String key; - private String events; - - /** - * Creates a new empty LoginAction. - */ - public LoginAction() - { - - } - - /** - * Creates a new LoginAction that performs a cleartext login.

- * You should not use cleartext login if you are concerned about security, - * using {@link ChallengeAction} and login with a password hash instead. - * - * @param username the username as configured in Asterisk's - * manager.conf - * @param secret the user's password as configured in Asterisk's - * manager.conf - * @since 0.2 - */ - public LoginAction(String username, String secret) - { - this.username = username; - this.secret = secret; - } - - /** - * Creates a new LoginAction that performs a login via challenge/response. - * - * @param username the username as configured in Asterisk's - * manager.conf - * @param authType the digest alogrithm, must match the digest algorithm - * that was used with the corresponding ChallengeAction. - * @param key the hash of the user's password and the challenge - * @since 0.2 - */ - public LoginAction(String username, String authType, String key) - { - this.username = username; - this.authType = authType; - this.key = key; - } - - /** - * Creates a new LoginAction that performs a login via challenge/response. - * - * @param username the username as configured in Asterisk's - * manager.conf - * @param authType the digest alogrithm, must match the digest algorithm - * that was used with the corresponding ChallengeAction. - * @param key the hash of the user's password and the challenge - * @param events the event mask. Set to "on" if all events should be send, - * "off" if not events should be sent or a combination of - * "system", "call" and "log" (separated by ',') to specify what - * kind of events should be sent. - * @since 0.2 - */ - public LoginAction(String username, String authType, String key, - String events) - { - this.username = username; - this.authType = authType; - this.key = key; - this.events = events; - } - - /** - * Returns the name of this action, i.e. "Login". - */ - @Override - public String getAction() - { - return "Login"; - } - - /** - * Returns the username. - */ - public String getUsername() - { - return username; - } - - /** - * Sets the username as configured in asterik's manager.conf. - */ - public void setUsername(String username) - { - this.username = username; - } - - /** - * Returns the secret. - */ - public String getSecret() - { - return secret; - } - - /** - * Sets the secret to use when using cleartext login.

- * The secret contains the user's password as configured in Asterisk's - * manager.conf.

- * The secret and key properties are mutually exclusive. - */ - public void setSecret(String secret) - { - this.secret = secret; - } - - /** - * Returns the digest alogrithm when using challenge/response. - */ - public String getAuthType() - { - return authType; - } - - /** - * Sets the digest alogrithm when using challenge/response.

- * The digest algorithm is used to create the key based on the challenge and - * the user's password.

- * Currently Asterisk supports only "MD5". - */ - public void setAuthType(String authType) - { - this.authType = authType; - } - - /** - * @return Returns the key. - */ - public String getKey() - { - return key; - } - - /** - * @param key The key to set. - */ - public void setKey(String key) - { - this.key = key; - } - - /** - * Returns the event mask. - * - * @return the event mask. - */ - public String getEvents() - { - return events; - } - - /** - * Sets the event mask. - * - * @param events the event mask. Set to "on" if all events should be send, - * "off" if not events should be sent or a combination of - * "system", "call" and "log" (separated by ',') to specify what - * kind of events should be sent. - */ - public void setEvents(String events) - { - this.events = events; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/LogoffAction.java b/src/main/java/org/asteriskjava/manager/action/LogoffAction.java deleted file mode 100644 index c71063013..000000000 --- a/src/main/java/org/asteriskjava/manager/action/LogoffAction.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The LogoffAction causes the server to close the connection. - * - * @author srt - * @version $Id$ - */ -public class LogoffAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = -7576797478570238525L; - - /** - * Creates a new LogoffAction. - */ - public LogoffAction() - { - - } - - /** - * Returns the name of this action, i.e. "Logoff". - */ - @Override - public String getAction() - { - return "Logoff"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/MailboxCountAction.java b/src/main/java/org/asteriskjava/manager/action/MailboxCountAction.java deleted file mode 100644 index 12fed592a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MailboxCountAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * (c) 2004 Stefan Reuter - * - * Created on Apr 22, 2004 - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.MailboxCountResponse; - -/** - * The MailboxCountAction queries the number of unread and read messages in a - * mailbox.

- * The MailboxCountAction returns a MailboxStatusResponse. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.response.MailboxCountResponse - */ -@ExpectedResponse(MailboxCountResponse.class) -public class MailboxCountAction extends AbstractManagerAction -{ - static final long serialVersionUID = -6900421919824575941L; - - private String mailbox; - - /** - * Creates a new empty MailboxCountAction. - */ - public MailboxCountAction() - { - - } - - /** - * Creates a new MailboxCountAction that queries the number of unread and - * read messages in the given mailbox. - * - * @param mailbox the name of the mailbox to query.

- * This can either be only the number of the mailbox or a string - * of the form mailboxnumber@context. If no context is specified - * "default" is assumed. - * @since 0.2 - */ - public MailboxCountAction(String mailbox) - { - this.mailbox = mailbox; - } - - /** - * Returns the name of this action, i.e. "MailboxCount". - */ - @Override - public String getAction() - { - return "MailboxCount"; - } - - /** - * Returns the name of the mailbox to query. - */ - public String getMailbox() - { - return mailbox; - } - - /** - * Sets the name of the mailbox to query.

- * This can either be only the number of the mailbox or a string of the form - * mailboxnumber@context.If no context is specified "default" is assumed.

- * This property is mandatory. - */ - public void setMailbox(String mailbox) - { - this.mailbox = mailbox; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/MailboxStatusAction.java b/src/main/java/org/asteriskjava/manager/action/MailboxStatusAction.java deleted file mode 100644 index e567ae4fc..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MailboxStatusAction.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.MailboxStatusResponse; - -/** - * The MailboxStatusAction checks if a mailbox contains waiting messages.

- * The MailboxStatusAction returns a MailboxStatusResponse. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.response.MailboxStatusResponse - */ -@ExpectedResponse(MailboxStatusResponse.class) -public class MailboxStatusAction extends AbstractManagerAction -{ - static final long serialVersionUID = -3845028207155711950L; - - private String mailbox; - - /** - * Creates a new empty MailboxStatusAction. - */ - public MailboxStatusAction() - { - - } - - /** - * Creates a new MailboxStatusAction that checks for waiting messages in the - * given mailbox. - * - * @param mailbox the name of the mailbox to check.

- * This can either be only the number of the mailbox or a string - * of the form mailboxnumber@context. If no context is specified - * "default" is assumed. - * @since 0.2 - */ - public MailboxStatusAction(String mailbox) - { - this.mailbox = mailbox; - } - - /** - * Returns the name of this action, i.e. "MailboxStatus". - */ - @Override - public String getAction() - { - return "MailboxStatus"; - } - - /** - * Returns the name of the mailbox to query. - */ - public String getMailbox() - { - return mailbox; - } - - /** - * Sets the name of the mailbox to query.

- * This can either be only the name of the mailbox or a string of the form - * mailboxnumber@context. If no context is specified "default" is assumed.

- * Multiple mailboxes may be given, separated by ','. In this case the - * action checks whether at least one of the given mailboxes has waiting - * messages.

- * This property is mandatory.

- * Example: "1234,1235@mycontext" - */ - public void setMailbox(String mailbox) - { - this.mailbox = mailbox; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ManagerAction.java b/src/main/java/org/asteriskjava/manager/action/ManagerAction.java deleted file mode 100644 index 83ee2a6e6..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ManagerAction.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import java.io.Serializable; - -/** - * Interface that all Actions that can be sent to the Asterisk server must - * impement.

- * Instances of this class represent a command sent to Asterisk via Manager API, - * requesting a particular Action be performed. The number of actions available - * to the client are determined by the modules presently loaded in the Asterisk - * engine.

- * There is one conrete subclass of ManagerAction per each supported Asterisk - * Action. - * - * @author srt - * @version $Id$ - */ -public interface ManagerAction extends Serializable -{ - /** - * Returns the name of the action for example "Hangup". - */ - String getAction(); - - /** - * Returns the action id. - * - * @return the user provied action id. - */ - String getActionId(); - - /** - * Sets the action id.

- * If the action id is set and sent to the asterisk server any response - * returned by the Asterisk server will include the same id. This way - * the action id can be used to track actions and their corresponding - * responses and response events.

- * Note that Asterisk-Java uses its own internal action id to match - * actions with the corresponding responses and events. Though the internal - * action is never exposed to the application code. So if you want to - * handle reponses or response events on your own your application must - * set a unique action id using this method otherwise the action id of - * the reponse and response event objects passed to your application - * will be null. - * - * @param actionId the user provided action id to set. - * @see org.asteriskjava.manager.response.ManagerResponse#getActionId() - * @see org.asteriskjava.manager.event.ResponseEvent#getActionId() - */ - void setActionId(String actionId); - -} diff --git a/src/main/java/org/asteriskjava/manager/action/MeetMeMuteAction.java b/src/main/java/org/asteriskjava/manager/action/MeetMeMuteAction.java deleted file mode 100644 index ff607beab..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MeetMeMuteAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The MeetMeMuteAction mutes a user in a conference.

- * Defined in apps/app_meetme.c

- * Available since Asterisk 1.4. - * - * @author srt - * @version $Id$ - */ -public class MeetMeMuteAction extends AbstractMeetMeMuteAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -3843949939190283779L; - - /** - * Creates a new empty MeetMeMuteAction. - */ - public MeetMeMuteAction() - { - super(); - } - - /** - * Creates a new MeetMeMuteAction. - * - * @param meetMe the conference number. - * @param userNum the index of the user in the conference. - */ - public MeetMeMuteAction(String meetMe, Integer userNum) - { - super(meetMe, userNum); - } - - /** - * Returns the name of this action, i.e. "MeetMeMute". - */ - @Override - public String getAction() - { - return "MeetMeMute"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/MeetMeUnmuteAction.java b/src/main/java/org/asteriskjava/manager/action/MeetMeUnmuteAction.java deleted file mode 100644 index 6fa44a1f9..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MeetMeUnmuteAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The MeetMeUnmuteAction unmutes a user in a conference.

- * Defined in apps/app_meetme.c

- * Available since Asterisk 1.4. - * - * @author srt - * @version $Id$ - */ -public class MeetMeUnmuteAction extends AbstractMeetMeMuteAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -3843949939190283779L; - - /** - * Creates a new empty MeetMeUnmuteAction. - */ - public MeetMeUnmuteAction() - { - super(); - } - - /** - * Creates a new MeetMeUnmuteAction. - * - * @param meetMe the conference number. - * @param userNum the index of the user in the conference. - */ - public MeetMeUnmuteAction(String meetMe, Integer userNum) - { - super(meetMe, userNum); - } - - /** - * Returns the name of this action, i.e. "MeetMeUnmute". - */ - @Override - public String getAction() - { - return "MeetMeUnmute"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/MessageSendAction.java b/src/main/java/org/asteriskjava/manager/action/MessageSendAction.java deleted file mode 100644 index b9f65b78f..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MessageSendAction.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.asteriskjava.manager.action; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Send a custom SIP message to the specified peer. Available since Asterisk 11 - * - * @author Michael Will - * @version $Id$ - * @since 1.0.0 - */ -public class MessageSendAction extends AbstractManagerAction -{ - - private static final long serialVersionUID = -6554282385166411723L; - private String to; - private String from; - private String body; - private String base64body; - private Map variables; - - @Override - public String getAction() - { - return "MessageSend"; - } - - /** - * Returns the variables to set on the originated call. - * - * @return a Map containing the variable names as key and their values as - * value. - * @since 1.0.0 - */ - public Map getVariables() - { - return variables; - } - - /** - * Sets an variable on the originated call. - * - * @param name the name of the variable to set. - * @param value the value of the variable to set. - * @since 1.0.0 - */ - public void setVariable(String name, String value) - { - if (variables == null) - { - variables = new LinkedHashMap<>(); - } - - variables.put(name, value); - } - - /** - * Retrives destination of message - * - * @return String in format like sip:userid - */ - public String getTo() - { - return to; - } - - /** - * Set destination of message - * - * @param to String in format like sip:userid - */ - public void setTo(String to) - { - this.to = to; - } - - /** - * get From String - * - * @return String in form like sip:asterisk@server-ip - */ - public String getFrom() - { - return from; - } - - /** - * set From String - * @param String from in form like sip:asterisk@server-ip - */ - public void setFrom(String from) - { - this.from = from; - } - - /** - * Content of the message in plain text ascii - * Please consider to use getBase64Body instead to avoid encoding problems - * - * @return String with Message content - */ - public String getBody() - { - return body; - } - - /** - * Sets the content of the message - * Please consider to use setBase64Body instead to avoid encoding problems - * - * @param body String with plain ascii content - */ - public void setBody(String body) - { - this.body = body; - } - - /** - * Retrieves content encoded in base64 - * - * @code new String(Base64.decode(getBase64body(), Formatting (for ex "UTF-8")) - * @return Base64 encoded String - */ - public String getBase64body() - { - return base64body; - } - - /** - * Sets the content of the message body encode in base64 - * - * {@code MessageSendAction sipSendMessage = new MessageSendAction(); - * sipSendMessage.setTo("sip:phoneuserid"); - * sipSendMessage.setVariable("Content-Type", "text/plain"); - * sipSendMessage.setVariable("P-hint", "usrloc applied"); - * - * sipSendMessage.setActionId(UUID.randomUUID().toString()); - * sipSendMessage.setBase64body(new String(Base64.encodeBase64(message.getBytes("UTF-8")), "UTF-8")); - * } - * @param base64body - */ - public void setBase64body(String base64body) - { - this.base64body = base64body; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/MixMonitorMuteAction.java b/src/main/java/org/asteriskjava/manager/action/MixMonitorMuteAction.java deleted file mode 100644 index 0be1bc764..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MixMonitorMuteAction.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2012 Stefan Reuter. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.asteriskjava.manager.action; - -/** - * MixMonitorMute can be used to mute and un-mute an existing recording. - * @author Bob Wienholt - * @version $Id$ - */ -public class MixMonitorMuteAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - private String channel; - private String direction; - private Integer state; - - /** - * Creates a new empty MixMonitorMuteAction - */ - public MixMonitorMuteAction() - { - super(); - } - - /** - * Mutes the monitor on the given channel. - * @param channel - */ - public MixMonitorMuteAction(String channel) - { - super(); - this.channel = channel; - } - - /** - * Mutes the monitor on the given channel for the given portion - * of the call. - * @param channel - * @param direction - */ - public MixMonitorMuteAction(String channel, String direction) - { - super(); - this.channel = channel; - this.direction = direction; - } - - /** - * Either mutes or un-mutes the monitor on the given channel for - * the given portion of the call. - * @param channel - * @param direction - * @param state - */ - public MixMonitorMuteAction(String channel, String direction, Integer state) - { - super(); - this.channel = channel; - this.direction = direction; - this.state = state; - } - - /** - * Either mutes or un-mutes the monitor on the given channel. - * @param channel - * @param state - */ - public MixMonitorMuteAction(String channel, Integer state) - { - super(); - this.channel = channel; - this.state = state; - } - - /** - * Returns the name of this action. - */ - @Override - public String getAction() { - return "MixMonitorMute"; - } - - /** - * Returns the name of the channel to mute. - */ - public String getChannel() { - return channel; - } - - /** - * Sets the name of the channel to mute. - * @param channel - */ - public void setChannel(String channel) { - this.channel = channel; - } - - /** - * Gets the direction of the part of the recording to mute. - */ - public String getDirection() { - return direction; - } - - /** - * Sets the direction of the part of the recording to mute. - * Can be one of: read, write, or both. Defaults to both. - * @param direction - */ - public void setDirection(String direction) { - this.direction = direction; - } - - /** - * Gets the state of the mute. - */ - public Integer getState() { - return state; - } - - /** - * Sets the state of the mute operation. 1 = on, 0 = off. - * @param state - */ - public void setState(Integer state) { - this.state = state; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/ModuleCheckAction.java b/src/main/java/org/asteriskjava/manager/action/ModuleCheckAction.java deleted file mode 100644 index 8822b4582..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ModuleCheckAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.ModuleCheckResponse; - -/** - * The ModuleLoadAction checks if an Asterisk module is loaded and reports its version.

- * The ModuleLoadAction returns a {@link org.asteriskjava.manager.response.ModuleCheckResponse} with - * the version of the module if the module is loaded and a {@link org.asteriskjava.manager.response.ManagerError} - * if the module is not loaded.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -@ExpectedResponse(ModuleCheckResponse.class) -public class ModuleCheckAction extends AbstractManagerAction -{ - static final long serialVersionUID = 1L; - - private String module; - - /** - * Creates a new ModuleCheckAction. - */ - public ModuleCheckAction() - { - - } - - /** - * Creates a new ModuleCheckAction with the given parameters. - * - * @param module the name of the module (including or not including the ".so" extension). - */ - public ModuleCheckAction(String module) - { - this.module = module; - } - - /** - * Returns the name of this action, i.e. "ModuleLoad". - */ - @Override - public String getAction() - { - return "ModuleCheck"; - } - - /** - * Returns the name of the module to check. - * - * @return the name of the module to check. - */ - public String getModule() - { - return module; - } - - /** - * Sets the name of the module (including or not including the ".so" extension) to check. - * - * @param module the name of the module (including or not including the ".so" extension) to check. - */ - public void setModule(String module) - { - this.module = module; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/ModuleLoadAction.java b/src/main/java/org/asteriskjava/manager/action/ModuleLoadAction.java deleted file mode 100644 index 0d92b99cf..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ModuleLoadAction.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ModuleLoadAction loads, unloads or reloads Asterisk modules.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class ModuleLoadAction extends AbstractManagerAction -{ - static final long serialVersionUID = 1L; - - public static final String SUBSYSTEM_CDR = "cdr"; - public static final String SUBSYSTEM_ENUM = "enum"; - public static final String SUBSYSTEM_DNSMGR = "dnsmgr"; - public static final String SUBSYSTEM_EXTCONFIG = "extconfig"; - public static final String SUBSYSTEM_MANAGER = "manager"; - public static final String SUBSYSTEM_RTP = "rtp"; - public static final String SUBSYSTEM_HTTP = "http"; - - public static final String LOAD_TYPE_LOAD = "load"; - public static final String LOAD_TYPE_UNLOAD = "unload"; - public static final String LOAD_TYPE_RELOAD = "reload"; - - private String module; - private String loadType; - - /** - * Creates a new ModuleLoadAction. - */ - public ModuleLoadAction() - { - - } - - /** - * Creates a new ModuleLoadAction with the given parameters. - * - * @param module the name of the module including the ".so" extension or subsystem - * to perform the operation on or null combined with loadType "reload" - * to reload all modules. - * @param loadType the operation to perform ("load", "unload" or "reload"). - */ - public ModuleLoadAction(String module, String loadType) - { - this.module = module; - this.loadType = loadType; - } - - /** - * Returns the name of this action, i.e. "ModuleLoad". - */ - @Override - public String getAction() - { - return "ModuleLoad"; - } - - /** - * Returns the name of the module or subsystem to perform the operation on. - * - * @return the name of the module or subsystem to perform the operation on. - */ - public String getModule() - { - return module; - } - - /** - * Sets the name of the module including the ".so" extension or subsystem ("cdr", "enum", "dnsmgr", - * "extconfig", "manager", "rtp" or "http") to perform the operation on. - * - * @param module the name of the module including the ".so" extension or subsystem - * to perform the operation on or null combined with loadType "reload" - * to reload all modules. - * @see #SUBSYSTEM_CDR - * @see #SUBSYSTEM_ENUM - * @see #SUBSYSTEM_DNSMGR - * @see #SUBSYSTEM_EXTCONFIG - * @see #SUBSYSTEM_MANAGER - * @see #SUBSYSTEM_RTP - * @see #SUBSYSTEM_HTTP - */ - public void setModule(String module) - { - this.module = module; - } - - /** - * Returns the operation to perform. - * - * @return the operation to perform. - */ - public String getLoadType() - { - return loadType; - } - - /** - * Sets the operation to perform ("load", "unload" or "reload"). - * - * @param loadType the operation to perform ("load", "unload" or "reload"). - * @see #LOAD_TYPE_LOAD - * @see #LOAD_TYPE_UNLOAD - * @see #LOAD_TYPE_RELOAD - */ - public void setLoadType(String loadType) - { - this.loadType = loadType; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/MonitorAction.java b/src/main/java/org/asteriskjava/manager/action/MonitorAction.java deleted file mode 100644 index ba8416771..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MonitorAction.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The MonitorAction starts monitoring (recording) a channel.

- * It is implemented in res/res_monitor.c - * - * @author srt - * @version $Id$ - */ -public class MonitorAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 6840975934278794758L; - private String channel; - private String file; - private String format; - private Boolean mix; - - /** - * Creates a new empty MonitorAction. - */ - public MonitorAction() - { - super(); - } - - /** - * Creates a new MonitorAction that starts monitoring the given channel and - * writes voice data to the given files.

- * The format of the files is "wav", they are not mixed. - * - * @param channel the name of the channel to monitor - * @param file the (base) name of the files to which the voice data is - * written - * @since 0.2 - */ - public MonitorAction(String channel, String file) - { - super(); - this.channel = channel; - this.file = file; - } - - /** - * Creates a new MonitorAction that starts monitoring the given channel and - * writes voice data to the given files.

- * The files are not mixed. - * - * @param channel the name of the channel to monitor - * @param file the (base) name of the files to which the voice data is - * written - * @param format the format to use for encoding the voice files - * @since 0.2 - */ - public MonitorAction(String channel, String file, String format) - { - super(); - this.channel = channel; - this.file = file; - this.format = format; - } - - /** - * Creates a new MonitorAction that starts monitoring the given channel and - * writes voice data to the given file(s). - * - * @param channel the name of the channel to monitor - * @param file the (base) name of the file(s) to which the voice data is - * written - * @param format the format to use for encoding the voice files - * @param mix true if the two voice files should be joined at the end of the - * call - * @since 0.2 - */ - public MonitorAction(String channel, String file, String format, Boolean mix) - { - super(); - this.channel = channel; - this.file = file; - this.format = format; - this.mix = mix; - } - - /** - * Returns the name of this action, i.e. "Monitor". - */ - @Override - public String getAction() - { - return "Monitor"; - } - - /** - * Returns the name of the channel to monitor. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to monitor.

- * This property is mandatory. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the file to which the voice data is written. - */ - public String getFile() - { - return file; - } - - /** - * Sets the (base) name of the file(s) to which the voice data is written.

- * If this property is not set it defaults to to the channel name as per CLI - * with the '/' replaced by '-'. - */ - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the format to use for encoding the voice files. - */ - public String getFormat() - { - return format; - } - - /** - * Sets the format to use for encoding the voice files.

- * If this property is not set it defaults to "wav". - */ - public void setFormat(String format) - { - this.format = format; - } - - /** - * Returns true if the two voice files should be joined at the end of the - * call. - */ - public Boolean getMix() - { - return mix; - } - - /** - * Set to true if the two voice files should be joined at the end of the - * call. - */ - public void setMix(Boolean mix) - { - this.mix = mix; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/MuteAudioAction.java b/src/main/java/org/asteriskjava/manager/action/MuteAudioAction.java deleted file mode 100644 index e206fe345..000000000 --- a/src/main/java/org/asteriskjava/manager/action/MuteAudioAction.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Action: MuteAudio Synopsis: Mute an audio stream Privilege: system,all - * Description: Mute an incoming or outbound audio stream in a channel. - * Variables: Channel: The channel you want to mute. Direction: in | out - * |all The stream you want to mute. State: on | off Whether to turn mute on or - * off. ActionID: Optional action ID for this AMI transaction. - * - * It is defined in res/res_mutestream.c. - *

- * Available since Asterisk 1.8 - * - * @author sbs - * @version $Id: MuteAction.java 938 2007-12-31 03:23:38Z srt $ - * @since 1.0.0 - */ -public class MuteAudioAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - private String channel; - - /** The audio direct (relative to the pbx) which is to be muted. */ - public enum Direction - { - IN("in"), OUT("out"), ALL("all"); - - String value; - - Direction(String value) - { - this.value = value; - } - - public String toString() - { - return this.value; - } - } - - private Direction direction; - - /** Controls whether to mute (on) or unmute (off) the call **/ - public enum State - { - MUTE("on"), UNMUTE("off"); //$NON-NLS-1$//$NON-NLS-2$ - - String value; - - State(String value) - { - this.value = value; - } - - public String toString() - { - return this.value; - } - - } - - private State state; - - /** - * Creates a new empty MuteAction. - */ - public MuteAudioAction() - { - - } - - /** - * Creates a new MuteAction that Mutes or Unmutes the two given channel. - * - * @param channel - * the name of the channel to Mute. - * - * @param direction - * the audio direction which is to be muted/unmuted - * - * @param state controls whether we are muting or unmuting the channel. - */ - - public MuteAudioAction(String channel, Direction direction, State state) - { - this.channel = channel; - this.direction = direction; - this.state = state; - } - - /** - * Returns the name of this action, i.e. "MuteAudio". - */ - @Override - public String getAction() - { - return "MuteAudio"; //$NON-NLS-1$ - } - - /** - * Returns the name of the channel to monitor. - */ - public String getChannel() - { - return this.channel; - } - - /** - * Returns the audio direction which is to be muted/unmuted. - */ - public Direction getDirection() - { - return this.direction; - } - - /** - * Returns the state controls whether we are muting or unmuting the channel. - */ - public State getState() - { - return this.state; - } - - /** - * Sets the name of the channel to monitor.

- * This property is mandatory. - */ - public void setChannel(String channel) { - this.channel = channel; - } - - /** - * Sets the audio direction which is to be muted/unmuted.

- * This property is mandatory. - */ - public void setDirection(Direction direction) { - this.direction = direction; - } - - /** - * Sets the state controls whether we are muting or unmuting the channel.

- * This property is mandatory. - */ - public void setState(State state) { - this.state = state; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/OriginateAction.java b/src/main/java/org/asteriskjava/manager/action/OriginateAction.java deleted file mode 100644 index fe5b510fe..000000000 --- a/src/main/java/org/asteriskjava/manager/action/OriginateAction.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import org.asteriskjava.manager.event.OriginateResponseEvent; -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * The OriginateAction generates an outgoing call to the extension in the given - * context with the given priority or to a given application with optional - * parameters. - *

- * If you want to connect to an extension use the properties context, exten and - * priority. If you want to connect to an application use the properties - * application and data if needed. Note that no call detail record will be - * written when directly connecting to an application, so it may be better to - * connect to an extension that starts the application you wish to connect to. - *

- * The response to this action is sent when the channel has been answered and - * asterisk starts connecting it to the given extension. So be careful not to - * choose a too short timeout when waiting for the response. - *

- * If you set async to true Asterisk reports an OriginateSuccess- - * and OriginateFailureEvents. The action id of these events equals the action - * id of this OriginateAction. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.OriginateResponseEvent - */ -public class OriginateAction extends AbstractManagerAction implements EventGeneratingAction -{ - - private final Log logger = LogFactory.getLog(getClass()); - - /** - * Serializable version identifier - */ - static final long serialVersionUID = 8194597741743334704L; - - private String channel; - private String exten; - private String context; - private Integer priority; - private Long timeout; - private String callerId; - private Integer callingPres; - private Map variables; - private String account; - private String application; - private String data; - private Boolean async; - private String codecs; - - /** - * Returns the name of this action, i.e. "Originate". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "Originate"; - } - - /** - * Returns the account code to use for the originated call. - * - * @return the account code to use for the originated call. - */ - public String getAccount() - { - return account; - } - - /** - * Sets the account code to use for the originated call. - *

- * The account code is included in the call detail record generated for this - * call and will be used for billing. - * - * @param account the account code to use for the originated call. - */ - public void setAccount(String account) - { - this.account = account; - } - - /** - * Returns the caller id to set on the outgoing channel. - */ - public String getCallerId() - { - return callerId; - } - - /** - * Sets the caller id to set on the outgoing channel. - *

- * This includes both the Caller*Id Number and Caller*Id Name in the form - * "Jon Doe <1234>". - * - * @param callerId the caller id to set on the outgoing channel. - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - /** - * Returns the calling presentation for the outgoing channel. - *

- * This property is only available on BRIstuffed Asterisk servers. - * - * @return the calling presentation for the outgoing channel. - * @see #setCallingPres(Integer) - */ - public Integer getCallingPres() - { - return callingPres; - } - - /** - * Sets the calling presentation for the outgoing channel. - *

- * The number is an octet and the only bits you need worry about are bits - * 1,2,6 and 7. - *

- * Bits 1 and 2 define the screening indicator and bits 6 and 7 define the - * presentation indicator. - *

- * In essence, it says, 'Is the person who has been called allowed to see - * the callers number?' (presentation) and 'What authority was used to - * verify that this is a genuine number?' (screening). - *

- *
- * Presentation indicator (Bits 6 and 7): - * - *

-     * Bits Meaning
-     *  7 6
-     *  0 0 Presentation allowed
-     *  0 1 Presentation restricted
-     *  1 0 Number not available due to interworking
-     *  1 1 Reserved
-     * 
- * - * Screening indicator (Bits 1 and 2): - * - *
-     * Bits Meaning
-     *  2 1
-     *  0 0 User-provided, not screened
-     *  0 1 User-provided, verified and passed
-     *  1 0 User-provided, verified and failed
-     *  1 1 Network provided
-     * 
- * - * Examples for some general settings: - * - *
-     * Presentation Allowed, Network Provided: 3 (00000011)
-     * Presentation Restricted, User-provided, not screened: 32 (00100000)
-     * Presentation Restricted, User-provided, verified, and passed: 33 (00100001)
-     * Presentation Restricted, Network Provided: 35 (00100011)
-     * 
- * - * This property is only available on BRIstuffed Asterisk servers. - * - * @param callingPres the calling presentation for the outgoing channel. - */ - public void setCallingPres(Integer callingPres) - { - this.callingPres = callingPres; - } - - /** - * Returns the name of the channel to connect to the outgoing call. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to connect to the outgoing call. - *

- * This property is mandatory. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the context of the extension to connect to. - */ - public String getContext() - { - return context; - } - - /** - * Sets the name of the context of the extension to connect to. - *

- * If you set the context you also have to set the exten and priority - * properties. - */ - public void setContext(String context) - { - this.context = context; - } - - /** - * Returns the extension to connect to. - */ - public String getExten() - { - return exten; - } - - /** - * Sets the extension to connect to. - *

- * If you set the extension you also have to set the context and priority - * properties. - */ - public void setExten(String exten) - { - this.exten = exten; - } - - /** - * Returns the priority of the extension to connect to. - */ - public Integer getPriority() - { - return priority; - } - - /** - * Sets the priority of the extension to connect to. If you set the priority - * you also have to set the context and exten properties. - */ - public void setPriority(Integer priority) - { - this.priority = priority; - } - - /** - * Returns the name of the application to connect to. - */ - public String getApplication() - { - return application; - } - - /** - * Sets the name of the application to connect to. - */ - public void setApplication(String application) - { - this.application = application; - } - - /** - * Returns the parameters to pass to the application. - */ - public String getData() - { - return data; - } - - /** - * Sets the parameters to pass to the application. - */ - public void setData(String data) - { - this.data = data; - } - - /** - * Returns the timeout for the origination. - */ - public Long getTimeout() - { - return timeout; - } - - /** - * Sets the timeout (in milliseconds) for the origination. - *

- * The channel must be answered within this time, otherwise the origination - * is considered to have failed and an OriginateFailureEvent is generated. - *

- * If not set, Asterisk assumes a default value of 30000 meaning 30 seconds. - * - * @param timeout the timeout in milliseconds - * @deprecated use {@link #setTimeout(Long)} instead. - */ - @Deprecated - public void setTimeout(Integer timeout) - { - if (timeout != null) - { - if (timeout < 1000) - { - logger.error("A timeout of 1000 will cause the originate to almost cretainly fail!"); - } - if (timeout < 10000) - { - logger.warn( - "A timeout of less than 10000 will cause the originate to fail if not answered within 10 seconds!"); - } - this.timeout = timeout.longValue(); - } - else - { - this.timeout = null; - } - } - - /** - * Sets the timeout (in milliseconds) for the origination. - *

- * The channel must be answered within this time, otherwise the origination - * is considered to have failed and an OriginateFailureEvent is generated. - *

- * If not set, Asterisk assumes a default value of 30000 meaning 30 seconds. - * - * @param timeout the timeout in milliseconds - */ - public void setTimeout(Long timeout) - { - if (timeout != null) - { - if (timeout < 1000) - { - logger.error("A timeout of 1000 will cause the originate to almost cretainly fail!"); - } - if (timeout < 10000) - { - logger.warn( - "A timeout of less than 100000 will cause the originate to fail if not answered within 10 seconds!"); - } - } - this.timeout = timeout; - } - - /** - * Sets the variables to set on the originated call. - *

- * Variable assignments are of the form "VARNAME=VALUE". You can specify - * multiple variable assignments separated by the '|' character. - *

- * Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and - * VAR2 to "def". - * - * @deprecated use {@link #setVariables(Map)} instead. - */ - @Deprecated - public void setVariable(String variable) - { - final StringTokenizer st; - - if (variable == null) - { - this.variables = null; - return; - } - - st = new StringTokenizer(variable, "|"); - variables = new LinkedHashMap<>(); - while (st.hasMoreTokens()) - { - String[] keyValue; - - keyValue = st.nextToken().split("=", 2); - if (keyValue.length < 2) - { - variables.put(keyValue[0], null); - } - else - { - variables.put(keyValue[0], keyValue[1]); - } - } - } - - /** - * Sets an variable on the originated call. - * - * @param name the name of the variable to set. - * @param value the value of the variable to set. - * @since 0.3 - */ - public void setVariable(String name, String value) - { - if (variables == null) - { - variables = new LinkedHashMap<>(); - } - - variables.put(name, value); - } - - /** - * Returns the variables to set on the originated call. - * - * @return a Map containing the variable names as key and their values as - * value. - * @since 0.2 - */ - public Map getVariables() - { - return variables; - } - - /** - * Sets the variables to set on the originated call. - * - * @param variables a Map containing the variable names as key and their - * values as value. - * @since 0.2 - */ - public void setVariables(Map variables) - { - this.variables = variables; - } - - /** - * Returns true if this is a fast origination. - */ - public Boolean getAsync() - { - return async; - } - - /** - * Set to true for fast origination. Only with fast origination Asterisk - * will send OriginateSuccess- and OriginateFailureEvents. - */ - public void setAsync(Boolean async) - { - this.async = async; - } - - /** - * Returns the codecs to use for the call. - * - * @return the codecs to use for the call. - * @since 1.0.0 - */ - public String getCodecs() - { - return codecs; - } - - /** - * Sets the codecs to use for the call. For example "alaw, ulaw, h264". - *

- * Available since Asterisk 1.6. - * - * @param codecs comma separated list of codecs to use for the call. - * @since 1.0.0 - */ - public void setCodecs(String codecs) - { - this.codecs = codecs; - } - - /** - * Sets the codecs to use for the call. - *

- * Available since Asterisk 1.6. - * - * @param codecs list of codecs to use for the call. - * @since 1.0.0 - */ - public void setCodecs(List codecs) - { - if (codecs == null || codecs.isEmpty()) - { - this.codecs = null; - return; - } - - Iterator iter = codecs.iterator(); - StringBuilder buffer = new StringBuilder(iter.next()); - while (iter.hasNext()) - { - buffer.append(",").append(iter.next()); - } - this.codecs = buffer.toString(); - } - - public Class< ? extends ResponseEvent> getActionCompleteEventClass() - { - return OriginateResponseEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ParkAction.java b/src/main/java/org/asteriskjava/manager/action/ParkAction.java deleted file mode 100644 index 7693c097e..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ParkAction.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ParkAction parks a channel using Asterisk's park feature. - *

- * Defined in res/res_features.c

- * Available since Asterisk 1.4. - * - * @author srt - * @version $Id$ - */ -public class ParkAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2930397629192323391L; - - private String channel; - private String channel2; - private Integer timeout; - - /** - * Creates a new empty ParkAction. - */ - public ParkAction() - { - super(); - } - - /** - * Creates a new ParkAction. - * - * @param channel name of the channel to park. - * @param channel2 name of the channel to announce park info to and return - * to on timeout. - */ - public ParkAction(String channel, String channel2) - { - super(); - this.channel = channel; - this.channel2 = channel2; - } - - /** - * Creates a new ParkAction with a timeout. - * - * @param channel the name of the channel to park. - * @param channel2 the name of the channel to announce park info to and - * return to on timeout. - * @param timeout the timeout in seconds before callback. - */ - public ParkAction(String channel, String channel2, Integer timeout) - { - super(); - this.channel = channel; - this.channel2 = channel2; - this.timeout = timeout; - } - - /** - * Returns the name of this action, i.e. "Park". - */ - @Override - public String getAction() - { - return "Park"; - } - - /** - * Returns the name of the channel to park. - * - * @return the name of the channel to park. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to park.

- * This property is mandatory. - * - * @param channel the name of the channel to park. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the channel to announce park info to and return to on - * timeout. - * - * @return the name of the channel to announce park info to and return to on - * timeout. - */ - public String getChannel2() - { - return channel2; - } - - /** - * Sets the name of the channel to announce park info to and return to on - * timeout.

- * This property is mandatory. - * - * @param channel2 the name of the channel to announce park info to and - * return to on timeout. - */ - public void setChannel2(String channel2) - { - this.channel2 = channel2; - } - - /** - * Returns the timeout in seconds before callback. - * - * @return the timeout in seconds before callback. - */ - public Integer getTimeout() - { - return timeout; - } - - /** - * Sets the timeout in seconds before callback. - * - * @param timeout the timeout in seconds before callback. - */ - public void setTimeout(Integer timeout) - { - this.timeout = timeout; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ParkedCallsAction.java b/src/main/java/org/asteriskjava/manager/action/ParkedCallsAction.java deleted file mode 100644 index 2ab3efb3f..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ParkedCallsAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ParkedCallsCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The ParkedCallsAction requests a list of all currently parked calls.

- * For each active channel a ParkedCallEvent is generated. After all parked - * calls have been reported a ParkedCallsCompleteEvent is generated. - * - * @see org.asteriskjava.manager.event.ParkedCallEvent - * @see org.asteriskjava.manager.event.ParkedCallsCompleteEvent - * @author srt - * @version $Id$ - */ -public class ParkedCallsAction extends AbstractManagerAction - implements - EventGeneratingAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1859575016378824743L; - - /** - * Creates a new ParkedCallsAction. - */ - public ParkedCallsAction() - { - - } - - /** - * Returns the name of this action, i.e. "ParkedCalls". - */ - @Override - public String getAction() - { - return "ParkedCalls"; - } - - public Class getActionCompleteEventClass() - { - return ParkedCallsCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/PauseMixMonitorAction.java b/src/main/java/org/asteriskjava/manager/action/PauseMixMonitorAction.java deleted file mode 100644 index 501a09e0a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/PauseMixMonitorAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.asteriskjava.manager.action; -/** - * The PauseMixMonitorAction temporarily stop/start monitoring (recording) a/both channel(s). - * - * Available since Asterisk 1.4. - * Channel - Used to specify the channel to mute. - * Direction - Which part of the recording to mute: read, write or both (from channel, to channel or both channels). - * State - Turn mute on or off : 1 to turn on, 0 to turn off. - * - * @author Adrian Videanu - * @since 0.3 - * @version $Id$ - */ - -public class PauseMixMonitorAction extends AbstractManagerAction{ - - private static final long serialVersionUID = -7438670441797420390L; - - private String channel; - private Integer state; - private String direction; - - public PauseMixMonitorAction() { - super(); - } - - public PauseMixMonitorAction(String ch, Integer st,String dir) { - this.channel = ch; - this.state = st; - this.direction = dir; - } - - @Override - public String getAction() { - return "MixMonitorMute"; - } - - public String getChannel() { - return channel; - } - - public void setChannel(String channel) { - this.channel = channel; - } - - public Integer getState() { - return state; - } - - public void setState(Integer state) { - this.state = state; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/PauseMonitorAction.java b/src/main/java/org/asteriskjava/manager/action/PauseMonitorAction.java deleted file mode 100644 index e69600cc7..000000000 --- a/src/main/java/org/asteriskjava/manager/action/PauseMonitorAction.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The PauseMonitorAction temporarily stop monitoring (recording) a channel. - *

- * It is implemented in res/res_monitor.c - *

- * Available since Asterisk 1.4. - * - * @see UnpauseMonitorAction - * @author srt - * @since 0.3 - * @version $Id$ - */ -public class PauseMonitorAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -6316010713240389305L; - - /** - * The name of the channel to temporarily stop monitoring. - */ - private String channel; - - /** - * Creates a new empty PauseMonitorAction. - */ - public PauseMonitorAction() - { - - } - - /** - * Creates a new PauseMonitorAction that temporarily stops monitoring the - * given channel. - * - * @param channel the name of the channel to temporarily stop monitoring. - */ - public PauseMonitorAction(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of this action, i.e. "PauseMonitor". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "PauseMonitor"; - } - - /** - * Returns the name of the channel to temporarily stop monitoring. - * - * @return the name of the channel to temporarily stop monitoring. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to temporarily stop monitoring. - *

- * This property is mandatory. - * - * @param channel the name of the channel to temporarily stop monitoring. - */ - public void setChannel(String channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/PingAction.java b/src/main/java/org/asteriskjava/manager/action/PingAction.java deleted file mode 100644 index 36a907fa3..000000000 --- a/src/main/java/org/asteriskjava/manager/action/PingAction.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.PingResponse; - -/** - * The PingAction is used to keep the manager connection open and performs no operation.

- * Asterisk versions prior to 1.6 send a "Pong" response, since Asterisk 1.6 a - * "Success" response is sent with a "Ping" property set to "Pong". - * - * @author srt - * @version $Id$ - */ -@ExpectedResponse(PingResponse.class) -public class PingAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = -2930397629192323391L; - - /** - * Creates a new PingAction. - */ - public PingAction() - { - super(); - } - - /** - * Returns the name of this action, i.e. "Ping". - */ - @Override - public String getAction() - { - return "Ping"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/PlayDtmfAction.java b/src/main/java/org/asteriskjava/manager/action/PlayDtmfAction.java deleted file mode 100644 index db4b9c175..000000000 --- a/src/main/java/org/asteriskjava/manager/action/PlayDtmfAction.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The PlayDTMFAction plays a DTMF digit on the specified channel.

- * It is definied in apps/app_senddtmf.c.

- * Available since Asterisk 1.2.8 - * - * @since 0.3 - * @author srt - * @version $Id$ - */ -public class PlayDtmfAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 9002288048692675696L; - - private String channel; - private String digit; - - /** - * Creates a new empty PlayDtmfAction. - */ - public PlayDtmfAction() - { - - } - - /** - * Creates a new PlayDtmfAction that sends the given DTMF digit to the given channel. - * - * @param channel the name of the channel to send the digit to. - * @param digit the DTML digit to play. - */ - public PlayDtmfAction(String channel, String digit) - { - this.channel = channel; - this.digit = digit; - } - - /** - * Returns the name of this action, i.e. "PlayDTMF". - */ - @Override - public String getAction() - { - return "PlayDTMF"; - } - - /** - * Returns the name of the channel to send the digit to. - * - * @return the name of the channel to send the digit to. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to send the digit to. - * - * @param channel the name of the channel to send the digit to. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the DTMF digit to play. - * - * @return the DTMF digit to play. - */ - public String getDigit() - { - return digit; - } - - /** - * Sets the DTMF digit to play. - * - * @param digit the DTMF digit to play. - */ - public void setDigit(String digit) - { - this.digit = digit; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/QueueAddAction.java b/src/main/java/org/asteriskjava/manager/action/QueueAddAction.java deleted file mode 100644 index dcb2d84e1..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueueAddAction.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The QueueAddAction adds a new member to a queue.

- * It is implemented in apps/app_queue.c

- * The memberName property was added in Asterisk 1.4, the - * stateInterface property in Asterisk 1.6. - * - * @author srt - * @version $Id$ - */ -public class QueueAddAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 2L; - private String queue; - private String iface; - private Integer penalty; - private Boolean paused; - private String memberName; - private String stateInterface; - - /** - * Creates a new empty QueueAddAction. - */ - public QueueAddAction() - { - - } - - /** - * Creates a new QueueAddAction that adds a new member on the given - * interface to the given queue. - * - * @param queue the name of the queue the new member will be added to - * @param iface Sets the interface to add. To add a specific channel just - * use the channel name, e.g. "SIP/1234". - * @since 0.2 - */ - public QueueAddAction(String queue, String iface) - { - this.queue = queue; - this.iface = iface; - } - - /** - * Creates a new QueueAddAction that adds a new member on the given - * interface to the given queue with the given penalty. - * - * @param queue the name of the queue the new member will be added to - * @param iface Sets the interface to add. To add a specific channel just - * use the channel name, e.g. "SIP/1234". - * @param penalty the penalty for this member. The penalty must be a - * positive integer or 0 for no penalty. When calls are - * distributed members with higher penalties are considered last. - * @since 0.2 - */ - public QueueAddAction(String queue, String iface, Integer penalty) - { - this.queue = queue; - this.iface = iface; - this.penalty = penalty; - } - - /** - * Returns the name of this action, i.e. "QueueAdd". - */ - @Override - public String getAction() - { - return "QueueAdd"; - } - - /** - * Returns the name of the queue the new member will be added to. - * - * @return the name of the queue the new member will be added to. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue the new member will be added to.

- * This property is mandatory. - * - * @param queue the name of the queue the new member will be added to. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the name of the channel to dial to reach this member. - * - * @return the name of the channel to dial to reach this member. - */ - public String getInterface() - { - return iface; - } - - /** - * Sets the name of the channel (Technology/Location) to dial to reach this member.

- * This property is mandatory. - * - * @param iface the name of the channel to dial to reach this member, e.g. "SIP/1234". - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * Returns the penalty for this member. - * - * @return the penalty for this member. - */ - public Integer getPenalty() - { - return penalty; - } - - /** - * Sets the penalty for this member.

- * The penalty must be a positive integer or 0 for no penalty. If it is - * not set 0 is assumed.

- * When calls are distributed members with higher penalties are considered - * last. - * - * @param penalty the penalty for this member. - */ - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } - - /** - * Returns if the queue member should be paused when added. - * - * @return Boolean.TRUE if the queue member should be paused when added. - * @since 0.2 - */ - public Boolean getPaused() - { - return paused; - } - - /** - * Sets if the queue member should be paused when added. - * - * @param paused Boolean.TRUE if the queue member should be paused when - * added. - * @since 0.2 - */ - public void setPaused(Boolean paused) - { - this.paused = paused; - } - - /** - * Returns the name of the queue memeber (agent name).

- * Available since Asterisk 1.4 - * - * @return the name of the queue memeber (agent name). - * @since 1.0.0 - */ - public String getMemberName() - { - return memberName; - } - - /** - * Sets the name of the queue memeber (agent name).

- * Available since Asterisk 1.4 - * - * @param memberName the name of the queue memeber (agent name). - * @since 1.0.0 - */ - public void setMemberName(String memberName) - { - this.memberName = memberName; - } - - /** - * Returns the name of the channel from which to read devicestate changes.

- * Available since Asterisk 1.6 - * - * @return the name of the channel from which to read devicestate changes. - * @since 1.0.0 - */ - public String getStateInterface() - { - return stateInterface; - } - - /** - * Sets the name of the channel (Technology/Location) from which to read devicestate changes.

- * Available since Asterisk 1.6 - * - * @param stateInterface the name of the channel from which to read devicestate changes. - * @since 1.0.0 - */ - public void setStateInterface(String stateInterface) - { - this.stateInterface = stateInterface; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/QueueLogAction.java b/src/main/java/org/asteriskjava/manager/action/QueueLogAction.java deleted file mode 100644 index fa69f942b..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueueLogAction.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The QueueLogAction adds a custom log entry to the queue_log.

- * It is implemented in apps/app_queue.c

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class QueueLogAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - - private String iface; - private String queue; - private String uniqueId; - private String event; - private String message; - - /** - * Creates a new empty QueueLogAction. - */ - public QueueLogAction() - { - - } - - /** - * Creates a new QueueLogAction with the mandatory properties queue and event. - * - * @param queue the name of the queue to log the event for. - * @param event the event to log. - */ - public QueueLogAction(String queue, String event) - { - this.queue = queue; - this.event = event; - } - - /** - * Creates a new QueueLogAction with the mandatory properties queue and event. - * - * @param queue the name of the queue to log the event for. - * @param event the event to log. - * @param message the message to log, may be null. - * @param iface the interface of the member to log the event for, may be null. - * @param uniqueId the unique id of the channel to log the event for, may be null. - */ - public QueueLogAction(String queue, String event, String message, String iface, String uniqueId) - { - this.queue = queue; - this.event = event; - this.message = message; - this.iface = iface; - this.uniqueId = uniqueId; - } - - /** - * Returns the name of this action, i.e. "QueueLog". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "QueueLog"; - } - - /** - * Returns the interface of the member to log the event for. - * - * @return the interface of the member to log the event for. - */ - public String getInterface() - { - return iface; - } - - /** - * Sets the interface of the member to log the event for. - * - * @param iface the interface of the member to log the event for. - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * Returns the name of the queue to log the event for. - * - * @return the name of the queue to log the event for. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue to log the event for.

- * This property is mandatory. - * - * @param queue the name of the queue to log the event for. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the unique id of the channel to log the event for. - * - * @return the unique id of the channel to log the event for. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel to log the event for. - * - * @param uniqueId the unique id of the channel to log the event for. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the event to log. - * - * @return the event to log. - */ - public String getEvent() - { - return event; - } - - /** - * Sets the event to log.

- * This property is mandatory. - * - * @param event the event to log. - */ - public void setEvent(String event) - { - this.event = event; - } - - /** - * Returns the message to log. - * - * @return the message to log. - */ - public String getMessage() - { - return message; - } - - /** - * Sets the message to log. - * - * @param message the message to log. - */ - public void setMessage(String message) - { - this.message = message; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/QueuePauseAction.java b/src/main/java/org/asteriskjava/manager/action/QueuePauseAction.java deleted file mode 100644 index cda358b14..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueuePauseAction.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The QueuePauseAction makes a queue member temporarily unavailabe (or - * available again).

- * It is implemented in apps/app_queue.c

- * Available since Asterisk 1.2. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class QueuePauseAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -4296471882045706821L; - - private String iface; - private Boolean paused; - private String queue; - private String reason; - - /** - * Creates a new empty QueuePauseAction. - */ - public QueuePauseAction() - { - - } - - /** - * Creates a new QueuePauseAction that makes the member on the given - * interface unavailable on all queues. - * - * @param iface the interface of the member to make unavailable - */ - public QueuePauseAction(String iface) - { - this.iface = iface; - this.paused = Boolean.TRUE; - } - - /** - * Creates a new QueuePauseAction that makes the member on the given - * interface unavailable on the given queue. - * - * @param iface the interface of the member to make unavailable - * @param queue the queue the member is made unvailable on - */ - public QueuePauseAction(String iface, String queue) - { - this.iface = iface; - this.queue = queue; - this.paused = Boolean.TRUE; - } - - /** - * Creates a new QueuePauseAction that makes the member on the given - * interface available or unavailable on all queues. - * - * @param iface the interface of the member to make unavailable - * @param paused Boolean.TRUE to make the member unavailbale, Boolean.FALSE - * to make the member available - */ - public QueuePauseAction(String iface, Boolean paused) - { - this.iface = iface; - this.paused = paused; - } - - /** - * Creates a new QueuePauseAction that makes the member on the given - * interface unavailable on the given queue. - * - * @param iface the interface of the member to make unavailable - * @param queue the queue the member is made unvailable on - * @param paused Boolean.TRUE to make the member unavailbale, Boolean.FALSE - * to make the member available - */ - public QueuePauseAction(String iface, String queue, Boolean paused) - { - this.iface = iface; - this.queue = queue; - this.paused = paused; - } - - /** - * Returns the name of this action, i.e. "QueuePause". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "QueuePause"; - } - - /** - * Returns the interface of the member to make available or unavailable. - * - * @return the interface of the member to make available or unavailable. - */ - public String getInterface() - { - return iface; - } - - /** - * Sets the interface of the member to make available or unavailable.

- * This property is mandatory. - * - * @param iface the interface of the member to make available or - * unavailable. - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * Returns the name of the queue the member is made available or unavailable - * on. - * - * @return the name of the queue the member is made available or unavailable - * on or null for all queues. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue the member is made available or unavailable - * on. - * - * @param queue the name of the queue the member is made available or - * unavailable on or null for all queues. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns if the member is made available or unavailable. - * - * @return Boolean.TRUE to make the member unavailbale, Boolean.FALSE to - * make the member available - */ - public Boolean getPaused() - { - return paused; - } - - /** - * Sets if the member is made available or unavailable.

- * This property is mandatory. - * - * @param paused Boolean.TRUE to make the member unavailbale, Boolean.FALSE - * to make the member available - */ - public void setPaused(Boolean paused) - { - this.paused = paused; - } - - /** - * Sets the name of the local reason.

- * Available since Asterisk 1.6. - * - * @return Name of the local reason for clears the flag. - */ - public String getReason() - { - return reason; - } - - /** - * Returns the name of the reason.

- * Available since Asterisk 1.6. - * - * @param reason Name of the local reason for clears the flag. - */ - public void setReason(String reason) - { - this.reason = reason; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/QueuePenaltyAction.java b/src/main/java/org/asteriskjava/manager/action/QueuePenaltyAction.java deleted file mode 100644 index 8f6d91410..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueuePenaltyAction.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The QueuePenaltyAction sets the penalty for a queue member.

- * It is implemented in apps/app_queue.c

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class QueuePenaltyAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - private String iface; - private Integer penalty; - private String queue; - - /** - * Creates a new empty QueuePenaltyAction. - */ - public QueuePenaltyAction() - { - - } - - /** - * Creates a new QueuePenaltyAction that sets the penalty for the given - * interface on all queues. - * - * @param iface the interface of the member to set the penalty for - * @param penalty new penalty value. - */ - public QueuePenaltyAction(String iface, int penalty) - { - this.iface = iface; - this.penalty = penalty; - } - - /** - * Creates a new QueuePenaltyAction that sets the penalty for the given - * interface on the given queue. - * - * @param iface the interface of the member to set the penalty for - * @param penalty new penalty value. - * @param queue the queue the member is assigned the penalty for - */ - public QueuePenaltyAction(String iface, int penalty, String queue) - { - this.iface = iface; - this.penalty = penalty; - this.queue = queue; - } - - /** - * Returns the name of this action, i.e. "QueuePenalty". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "QueuePenalty"; - } - - /** - * Returns the interface of the member to set the penalty for. - * - * @return the interface of the member to to set the penalty for. - */ - public String getInterface() - { - return iface; - } - - /** - * Sets the interface of the member to set the penalty for.

- * This property is mandatory. - * - * @param iface the interface of the member to to set the penalty for. - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * Returns the new penalty. - * - * @return the new penalty. - */ - public Integer getPenalty() - { - return penalty; - } - - /** - * Sets the new penalty.

- * This property is mandatory. - * - * @param penalty the new penalty. - */ - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } - - /** - * Returns the name of the queue. - * - * @return the name of the queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue. - * - * @param queue the name of the queue or null for all queues. - */ - public void setQueue(String queue) - { - this.queue = queue; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/QueueRemoveAction.java b/src/main/java/org/asteriskjava/manager/action/QueueRemoveAction.java deleted file mode 100644 index 4f1ff5d60..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueueRemoveAction.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The QueueRemoveAction removes a member from a queue.

- * It is implemented in apps/app_queue.c - * - * @author srt - * @version $Id$ - */ -public class QueueRemoveAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -4296471882045706821L; - - /** - * The name of the queue the member will be removed from. - */ - private String queue; - private String iface; - - /** - * Creates a new empty QueueRemoveAction. - */ - public QueueRemoveAction() - { - - } - - /** - * Creates a new QueueRemoveAction that removes the member on the given - * interface from the given queue. - * - * @param queue the name of the queue the member will be removed from - * @param iface the interface of the member to remove - * @since 0.2 - */ - public QueueRemoveAction(String queue, String iface) - { - this.queue = queue; - this.iface = iface; - } - - /** - * Returns the name of this action, i.e. "QueueRemove". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "QueueRemove"; - } - - /** - * Returns the name of the queue the member will be removed from. - * - * @return the name of the queue the member will be removed from. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue the member will be removed from.

- * This property is mandatory. - * - * @param queue the name of the queue the member will be removed from. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the interface to remove. - */ - public String getInterface() - { - return iface; - } - - /** - * Sets the interface to remove.

- * This property is mandatory. - */ - public void setInterface(String iface) - { - this.iface = iface; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/QueueResetAction.java b/src/main/java/org/asteriskjava/manager/action/QueueResetAction.java deleted file mode 100644 index e602aadf3..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueueResetAction.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The QueueResetAction resets all statistical data of a given queue or all queues.

- * It is implemented in apps/app_queue.c

- * Available since Asterisk 1.6. - * - * @author Sebastian - * @since 1.0.0 - */ -public class QueueResetAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - - private String queue; - - /** - * Creates a new QueueResetAction that resets statistical data of all queues. - */ - public QueueResetAction() - { - } - - /** - * Creates a new QueueResetAction that resets statistical data of the given queue. - * - * @param queue the name of the queue to reset. - */ - public QueueResetAction(String queue) - { - this.queue = queue; - } - - @Override - public String getAction() - { - return "QueueReset"; - } - - /** - * Returns the name of the queue to reset. - * - * @return the name of the queue to reset or null for all queues. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue to reset. - * - * @param queue the name of the queue to reset or null for all queues. - */ - public void setQueue(String queue) - { - this.queue = queue; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/QueueStatusAction.java b/src/main/java/org/asteriskjava/manager/action/QueueStatusAction.java deleted file mode 100644 index 1d24cc397..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueueStatusAction.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.QueueStatusCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The QueueStatusAction requests the state of all defined queues their members - * (agents) and entries (callers).

- * For each queue a QueueParamsEvent is generated, followed by a - * QueueMemberEvent for each member of that queue and a QueueEntryEvent for each - * entry in the queue.

- * Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of - * the generated dump.

- * This action is implemented in apps/app_queue.c - * - * @see org.asteriskjava.manager.event.QueueParamsEvent - * @see org.asteriskjava.manager.event.QueueMemberEvent - * @see org.asteriskjava.manager.event.QueueEntryEvent - * @see org.asteriskjava.manager.event.QueueStatusCompleteEvent - * @author srt - * @version $Id$ - */ -public class QueueStatusAction extends AbstractManagerAction - implements - EventGeneratingAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -8599401015517232869L; - - private String queue; - private String member; - - /** - * Creates a new QueueStatusAction. - */ - public QueueStatusAction() - { - - } - - /** - * Returns the name of this action, i.e. "QueueStatus". - */ - @Override - public String getAction() - { - return "QueueStatus"; - } - - /** - * Returns the queue filter. - * - * @return the queue filter. - * @since 0.2 - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the queue filter. If set QueueParamEvents are only generated for the - * given queue name. - * - * @param queue the queue filter. - * @since 0.2 - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the member filter. - * - * @return the member filter. - * @since 0.2 - */ - public String getMember() - { - return member; - } - - /** - * Sets the member filter. If set QueueMemberEvents are only generated for the - * given member name. - * - * @param member the member filter. - * @since 0.2 - */ - public void setMember(String member) - { - this.member = member; - } - - public Class getActionCompleteEventClass() - { - return QueueStatusCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/QueueSummaryAction.java b/src/main/java/org/asteriskjava/manager/action/QueueSummaryAction.java deleted file mode 100644 index 40dfff5d6..000000000 --- a/src/main/java/org/asteriskjava/manager/action/QueueSummaryAction.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.QueueSummaryCompleteEvent; -import org.asteriskjava.manager.event.QueueSummaryEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * The QueueSummaryAction retrieves the summary for one or all queues. - *

- * Available in Asterisk post-1.4. - *

- * This action has been added by - * http://bugs.digium.com/view.php?id=8035. - * - * @see QueueSummaryEvent - * @see QueueSummaryCompleteEvent - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class QueueSummaryAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1635765034452468357L; - private String queue; - - /** - * Creates a new QueueSummaryAction that retrieves the summary for all - * queues. - */ - public QueueSummaryAction() - { - - } - - /** - * Creates a new QueueSummaryAction that retrieves the summary for the given - * queue. - * - * @param queue name of the queue to retrieve the summary for. - */ - public QueueSummaryAction(String queue) - { - this.queue = queue; - } - - @Override - public String getAction() - { - return "QueueSummary"; - } - - public Class getActionCompleteEventClass() - { - return QueueSummaryCompleteEvent.class; - } - - /** - * Returns the name of the queue to retrieve the summary for. - * - * @return the name of the queue to retrieve the summary for or - * null to retrieve the summary for all queues. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue to retrieve the summary for. - * - * @param queue the name of the queue to retrieve the summary for or - * null to retrieve the summary for all queues. - */ - public void setQueue(String queue) - { - this.queue = queue; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/RedirectAction.java b/src/main/java/org/asteriskjava/manager/action/RedirectAction.java deleted file mode 100644 index c67d86c0d..000000000 --- a/src/main/java/org/asteriskjava/manager/action/RedirectAction.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Redirects a given channel (and an optional additional channel) to a new - * extension. - *

- * The additional channel is usually used when redirecting two bridged channel - * for example to a MeetMe room. - *

- * Note that BRIstuffed versions of Asterisk behave slightly different: While - * the standard version only allows redirecting the two channels to the same - * context, extension, priority the BRIstuffed version uses context, extension, - * priority only for the first channel and extraContext, extraExtension, - * extraPriority for the second channel. The standard version ignores the - * extraContext, extraExtension, extraPriority properties. - * - * @author srt - * @version $Id$ - */ -public class RedirectAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1869279324159418150L; - - private String channel; - private String extraChannel; - private String exten; - private String context; - private Integer priority; - private String extraExten; - private String extraContext; - private Integer extraPriority; - - /** - * Creates a new empty RedirectAction. - */ - public RedirectAction() - { - - } - - /** - * Creates a new RedirectAction that redirects the given channel to the - * given context, extension, priority triple. - * - * @param channel the name of the channel to redirect - * @param context the destination context - * @param exten the destination extension - * @param priority the destination priority - * @since 0.2 - */ - public RedirectAction(String channel, String context, String exten, Integer priority) - { - this.channel = channel; - this.context = context; - this.exten = exten; - this.priority = priority; - } - - /** - * Creates a new RedirectAction that redirects the given channels to the - * given context, extension, priority triple. - *

- * This constructor only works standard versions of Asterisk, i.e. - * non-BRIstuffed versions. When used with a BRIstuffed version (and not - * setting extraContext, extraExten and extraPriority) the second channel is - * just hung up. - * - * @param channel the name of the first channel to redirect - * @param extraChannel the name of the second channel to redirect - * @param context the destination context - * @param exten the destination extension - * @param priority the destination priority - * @since 0.2 - */ - public RedirectAction(String channel, String extraChannel, String context, String exten, Integer priority) - { - this.channel = channel; - this.extraChannel = extraChannel; - this.context = context; - this.exten = exten; - this.priority = priority; - } - - /** - * Creates a new RedirectAction that redirects the given channels to the - * given context, extension, priority triples. - *

- * This constructor works for BRIstuffed versions of Asterisk, if used with - * a standard version the extraContext, extraExten and extraPriroity - * attributes are ignored. - * - * @param channel the name of the first channel to redirect - * @param extraChannel the name of the second channel to redirect - * @param context the destination context for the first channel - * @param exten the destination extension for the first channel - * @param priority the destination priority for the first channel - * @param extraContext the destination context for the second channel - * @param extraExten the destination extension for the second channel - * @param extraPriority the destination priority for the second channel - * @since 0.3 - */ - public RedirectAction(String channel, String extraChannel, String context, String exten, Integer priority, - String extraContext, String extraExten, Integer extraPriority) - { - this.channel = channel; - this.extraChannel = extraChannel; - this.context = context; - this.exten = exten; - this.priority = priority; - this.extraContext = extraContext; - this.extraExten = extraExten; - this.extraPriority = extraPriority; - if (channel.equalsIgnoreCase(extraChannel)) - { - throw new RuntimeException("ExtraChannel = channel ... bad things will happen to asterisk"); - } - } - - /** - * Returns the name of this action, i.e. "Redirect". - */ - @Override - public String getAction() - { - return "Redirect"; - } - - /** - * Returns name of the channel to redirect. - * - * @return the name of the channel to redirect - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to redirect. - * - * @param channel the name of the channel to redirect - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the additional channel to redirect. - * - * @return the name of the additional channel to redirect - */ - public String getExtraChannel() - { - return extraChannel; - } - - /** - * Sets the name of the additional channel to redirect. - * - * @param extraChannel the name of the additional channel to redirect - */ - public void setExtraChannel(String extraChannel) - { - this.extraChannel = extraChannel; - if (channel.equalsIgnoreCase(extraChannel)) - { - throw new RuntimeException("ExtraChannel = channel ... bad things will happen to asterisk"); - } - } - - /** - * Returns the destination context. - * - * @return the destination context - */ - public String getContext() - { - return context; - } - - /** - * Sets the destination context. - * - * @param context the destination context - */ - public void setContext(String context) - { - this.context = context; - } - - /** - * Returns the destination extension. - * - * @return the destination extension - */ - public String getExten() - { - return exten; - } - - /** - * Sets the destination extension. - * - * @param exten the destination extension - */ - public void setExten(String exten) - { - this.exten = exten; - } - - /** - * Returns the destination priority. - * - * @return the destination priority - */ - public Integer getPriority() - { - return priority; - } - - /** - * Sets the destination priority. - * - * @param priority the destination priority - */ - public void setPriority(Integer priority) - { - this.priority = priority; - } - - /** - * Returns the destination context for the additional channel. - *

- * This property is only used by BRIstuffed Asterisk servers. - * - * @return the destination context for the additional channel. - */ - public String getExtraContext() - { - return extraContext; - } - - /** - * Sets the destination context for the additional channel. - *

- * This property is only used by BRIstuffed Asterisk servers. - * - * @param extraContext the destination context for the additional channel. - */ - public void setExtraContext(String extraContext) - { - this.extraContext = extraContext; - } - - /** - * Sets the destination extension for the additional channel. - *

- * This property is only used by BRIstuffed Asterisk servers. - * - * @return the destination extension for the additional channel. - */ - public String getExtraExten() - { - return extraExten; - } - - /** - * Sets the destination extension for the additional channel. - *

- * This property is only used by BRIstuffed Asterisk servers. - * - * @param extraExten the destination extension for the additional channel. - */ - public void setExtraExten(String extraExten) - { - this.extraExten = extraExten; - } - - /** - * Returns the destination priority for the additional channel. - *

- * This property is only used by BRIstuffed Asterisk servers. - * - * @return the destination priority for the additional channel. - */ - public Integer getExtraPriority() - { - return extraPriority; - } - - /** - * Sets the destination priority for the additional channel. - *

- * This property is only used by BRIstuffed Asterisk servers. - * - * @param extraPriority the destination priority for the additional channel. - */ - public void setExtraPriority(Integer extraPriority) - { - this.extraPriority = extraPriority; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SendTextAction.java b/src/main/java/org/asteriskjava/manager/action/SendTextAction.java deleted file mode 100644 index c2545e71b..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SendTextAction.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * Sends a text message to a given channel while in a call. - * An active channel and a text message are required in order to success.

- * It is defined in main/manager.c.

- * Available since Asterisk 1.6.0 - * - * @author Laureano - * @version $Id$ - * @since 1.0.0 - */ -public class SendTextAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - - private String channel; - private String message; - - /** - * Creates a new empty SendTextAction. - */ - public SendTextAction() - { - super(); - } - - /** - * Creates a new SendTextAction that sends the given message to the given channel. - * - * @param channel the name of the channel to send the message to. - * @param message the message to send. - */ - public SendTextAction(String channel, String message) - { - super(); - this.channel = channel; - this.message = message; - } - - /** - * Returns the name of this action, i.e. "SendText". - */ - @Override - public String getAction() - { - return "SendText"; - } - - /** - * Returns the name of the channel to send the message to. - * - * @return the name of the channel to send the message to. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to send the message to. - * - * @param channel the name of the channel to send the message to. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the message to send. - * - * @return the message to send. - */ - public String getMessage() - { - return message; - } - - /** - * Sets the message to send. - * - * @param message the message to send. - */ - public void setMessage(String message) - { - this.message = message; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SetCdrUserFieldAction.java b/src/main/java/org/asteriskjava/manager/action/SetCdrUserFieldAction.java deleted file mode 100644 index 503393557..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SetCdrUserFieldAction.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The SetCDRUserFieldAction causes the user field of the call detail record for - * the given channel to be changed.

- * Depending on the value of the append property the value is appended or - * overwritten.

- * The SetCDRUserFieldAction is implemented in - * apps/app_setcdruserfield.c - * - * @author srt - * @version $Id$ - */ -public class SetCdrUserFieldAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2024074141079750509L; - private String channel; - private String userField; - private Boolean append; - - /** - * Creates a new empty SetCdrUserFieldAction. - */ - public SetCdrUserFieldAction() - { - - } - - /** - * Creates a new SetCdrUserFieldAction that sets the user field of the call - * detail record for the given channel to the given value. - * - * @param channel the name of the channel - * @param userField the new value of the userfield - * @since 0.2 - */ - public SetCdrUserFieldAction(String channel, String userField) - { - this.channel = channel; - this.userField = userField; - } - - /** - * Creates a new SetCDRUserFieldAction that sets the user field of the call - * detail record for the given channel to the given value. - * - * @param channel the name of the channel - * @param userField the new value of the userfield - * @param append true to append the value to the cdr user field or false to - * overwrite - * @since 0.2 - */ - public SetCdrUserFieldAction(String channel, String userField, - Boolean append) - { - this.channel = channel; - this.userField = userField; - this.append = append; - } - - /** - * Returns the name of the action, i.e. "SetCDRUserField". - */ - @Override - public String getAction() - { - return "SetCDRUserField"; - } - - /** - * Returns the name of the channel to set the cdr user field on. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to set the cdr user field on.

- * This property is mandatory. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the value of the cdr user field to set or append. - */ - public String getUserField() - { - return userField; - } - - /** - * Sets the value of the cdr user field to set or append.

- * This property is mandatory. - */ - public void setUserField(String userField) - { - this.userField = userField; - } - - /** - * Returns if the value of the cdr user field is appended or overwritten. - */ - public Boolean getAppend() - { - return append; - } - - /** - * Set to true to append the value to the cdr user field or false to - * overwrite. - */ - public void setAppend(Boolean append) - { - this.append = append; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SetVarAction.java b/src/main/java/org/asteriskjava/manager/action/SetVarAction.java deleted file mode 100644 index 0d222f447..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SetVarAction.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The SetVarAction sets the value of a global or local channel variable.

- * Setting global variables is supported since Asterisk 1.2. - * - * @author Asteria Solutions Group, Inc. http://www.asteriasgi.com - * @author srt - * @version $Id$ - */ -public class SetVarAction extends AbstractManagerAction -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 3978144348493591607L; - - /** - * The channel on which to set the variable. - */ - private String channel; - - /** - * The name of the variable to set. - */ - private String variable; - - /** - * The value to store. - */ - private String value; - - /** - * Creates a new empty SetVarAction. - */ - public SetVarAction() - { - - } - - /** - * Creates a new SetVarAction that sets the given global variable to a new value. - * - * @param variable the name of the global variable to set - * @param value the new value - * @since 0.2 - */ - public SetVarAction(String variable, String value) - { - this.variable = variable; - this.value = value; - } - - /** - * Creates a new SetVarAction that sets the given channel variable of the - * given channel to a new value. - * - * @param channel the name of the channel to set the variable on - * @param variable the name of the channel variable - * @param value the new value - * @since 0.2 - */ - public SetVarAction(String channel, String variable, String value) - { - this.channel = channel; - this.variable = variable; - this.value = value; - } - - /** - * Returns the name of this action, i.e. "SetVar". - * - * @return the name of this action - */ - @Override - public String getAction() - { - return "SetVar"; - } - - /** - * Returns the name of the channel. - * - * @return the name of channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - * - * @param channel the name of the channel to set. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the variable to set. - * - * @return the name of the variable to set. - */ - public String getVariable() - { - return variable; - } - - /** - * Sets the name of the variable to set. - * - * @param variable the name of the variable to set. - */ - public void setVariable(String variable) - { - this.variable = variable; - } - - /** - * Returns the value to store. - * - * @return the value to store. - */ - public String getValue() - { - return value; - } - - /** - * Sets the value to store. - * - * @param value the value to set. - */ - public void setValue(String value) - { - this.value = value; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ShowDialplanAction.java b/src/main/java/org/asteriskjava/manager/action/ShowDialplanAction.java deleted file mode 100644 index 276c987f1..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ShowDialplanAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.ShowDialplanCompleteEvent; - -/** - * Retrieves a list of all priorities defined in the dialplan.

- * For each priority a ListDialplanEvent is sent by Asterisk containing - * the details. When all priorities have been reported a ShowDialplanCompleteEvent is - * sent.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.ListDialplanEvent - * @see org.asteriskjava.manager.event.ShowDialplanCompleteEvent - * @since 1.0.0 - */ -public class ShowDialplanAction extends AbstractManagerAction implements EventGeneratingAction -{ - private static final long serialVersionUID = 1L; - - /** - * Creates a new ShowDialplanAction. - */ - public ShowDialplanAction() - { - - } - - @Override - public String getAction() - { - return "ShowDialplan"; - } - - public Class getActionCompleteEventClass() - { - return ShowDialplanCompleteEvent.class; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/SipNotifyAction.java b/src/main/java/org/asteriskjava/manager/action/SipNotifyAction.java deleted file mode 100644 index e7d8ab04b..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SipNotifyAction.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.asteriskjava.manager.action; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Send a custom SIP notify message to the specified peer.

- * All parameters for this event must be specified in the body of this request - * via multiple variables. At least one variable pair must be specified.

- * Available since Asterisk 1.6 - * - * @author Laureano - * @version $Id$ - * @since 1.0.0 - */ -public class SipNotifyAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0; - - private String channel; - private Map variables; - - /** - * Creates a new SipNotifyAction. - */ - public SipNotifyAction() - { - super(); - } - - /** - * Creates a new SipNotifyAction that will be sent to the specified peer. - * - * @param channel the peer to send the notify to either "SIP/peer" or just "peer". - */ - public SipNotifyAction(String channel) - { - super(); - this.channel = channel; - } - - /** - * Returns the name of this action, i.e. "SipNotify". - */ - @Override - public String getAction() - { - return "SipNotify"; - } - - /** - * Sets the peer to receive the notify to. - * - * @param channel peer to receive the notify to either "SIP/peer" or just "peer". - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the peer that will receive the notify. - * - * @return peer - */ - public String getChannel() - { - return channel; - } - - /** - * Returns the variables to set on the originated call. - * - * @return a Map containing the variable names as key and their - * values as value. - * @since 1.0.0 - */ - public Map getVariables() - { - return variables; - } - - /** - * Sets an variable on the originated call. - * - * @param name the name of the variable to set. - * @param value the value of the variable to set. - * @since 1.0.0 - */ - public void setVariable(String name, String value) - { - if (variables == null) - { - variables = new LinkedHashMap<>(); - } - - variables.put(name, value); - } - - /** - * Sets the variables to set on the originated call. - * - * @param variables a Map containing the variable names as key and their - * values as value. - * @since 1.0.0 - */ - public void setVariables(Map variables) - { - this.variables = variables; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/SipPeersAction.java b/src/main/java/org/asteriskjava/manager/action/SipPeersAction.java deleted file mode 100644 index 47cfb2094..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SipPeersAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.PeerlistCompleteEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Retrieves a list of all defined SIP peers.

- * For each peer that is found a PeerEntryEvent is sent by Asterisk containing - * the details. When all peers have been reported a PeerlistCompleteEvent is - * sent.

- * Available since Asterisk 1.2 - * - * Permission required: write=system - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.PeerEntryEvent - * @see org.asteriskjava.manager.event.PeerlistCompleteEvent - * @since 0.2 - */ -public class SipPeersAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 921037572305993779L; - - /** - * Creates a new SipPeersAction. - */ - public SipPeersAction() - { - - } - - @Override - public String getAction() - { - return "SIPPeers"; - } - - public Class getActionCompleteEventClass() - { - return PeerlistCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SipShowPeerAction.java b/src/main/java/org/asteriskjava/manager/action/SipShowPeerAction.java deleted file mode 100644 index 2551937d0..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SipShowPeerAction.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.SipShowPeerResponse; - -/** - * Retrieves a the details about a given SIP peer.

- * The result is returned in the response received in reply to this action.

- * Use {@link org.asteriskjava.manager.response.ManagerResponse#getAttribute(String)} - * to retrieve the properties. Consider using {@link org.asteriskjava.manager.action.SipPeersAction} - * instead.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - * @see org.asteriskjava.manager.action.SipPeersAction - * @see org.asteriskjava.manager.response.SipShowPeerResponse - */ -@ExpectedResponse(SipShowPeerResponse.class) -public class SipShowPeerAction extends AbstractManagerAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String peer; - - /** - * Creates a new empty SipShowPeerAction. - */ - public SipShowPeerAction() - { - - } - - /** - * Creates a new SipShowPeerAction that requests the details about the given - * SIP peer. - *

- * This is just the peer name without the channel type prefix. For example - * if your channel is called "SIP/john", the peer name is just "john". - * - * @param peer the name of the SIP peer to retrieve details for. - * @since 0.2 - */ - public SipShowPeerAction(String peer) - { - this.peer = peer; - } - - @Override - public String getAction() - { - return "SIPShowPeer"; - } - - /** - * Returns the name of the peer to retrieve.

- * This parameter is mandatory. - * - * @return the name of the peer to retrieve without the channel type prefix. - */ - public String getPeer() - { - return peer; - } - - /** - * Sets the name of the peer to retrieve. - *

- * This is just the peer name without the channel type prefix. For example - * if your channel is called "SIP/john", the peer name is just "john". - *

- * This parameter is mandatory. - * - * @param peer the name of the peer to retrieve without the channel type prefix. - */ - public void setPeer(String peer) - { - this.peer = peer; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SipShowRegistryAction.java b/src/main/java/org/asteriskjava/manager/action/SipShowRegistryAction.java deleted file mode 100644 index 19ad7fa73..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SipShowRegistryAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.RegistrationsCompleteEvent; -import org.asteriskjava.manager.event.RegistryEntryEvent; -import org.asteriskjava.manager.event.ResponseEvent; - -/** - * Retrieves a list with the details about the SIP registrations.

- * For each registration that is found a RegistryEntryEvent is sent by Asterisk - * containing the details. When all the registrations have been reported a - * RegistrationsCompleteEvent is sent.

- * Available since Asterisk 1.6 - * - * @author Laureano - * @version $Id$ - * @see RegistrationsCompleteEvent - * @see RegistryEntryEvent - * @since 1.0.0 - */ -public class SipShowRegistryAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * - */ - private static final long serialVersionUID = -4501597578392156556L; - - /** - * Creates a new SipShowRegistryAction. - */ - public SipShowRegistryAction() - { - } - - @Override - public String getAction() - { - return "SipShowRegistry"; - } - - public Class getActionCompleteEventClass() - { - return RegistrationsCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeAccountPropertyAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeAccountPropertyAction.java deleted file mode 100644 index 53eef2ad2..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeAccountPropertyAction.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import java.util.HashMap; -import java.util.Map; - -/** - * The SkypeAccountPropertyAction sets properties for a Skype for Asterisk user.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeAccountPropertyAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - private String user; - private Map variables = new HashMap<>(); - - public static final String PROPERTY_SKYPENAME = "skypename"; - public static final String PROPERTY_TIMEZONE = "timezone"; - public static final String PROPERTY_AVAILABILITY = "availability"; - public static final String PROPERTY_FULLNAME = "fullname"; - public static final String PROPERTY_LANGUAGE = "language"; - public static final String PROPERTY_COUNTRY = "country"; - public static final String PROPERTY_PHONE_HOME = "phone_home"; - public static final String PROPERTY_PHONE_OFFICE = "phone_office"; - public static final String PROPERTY_PHONE_MOBILE = "phone_mobile"; - public static final String PROPERTY_ABOUT = "about"; - - /** - * Creates a new SkypeAccountPropertyAction. - */ - public SkypeAccountPropertyAction() - { - - } - - /** - * Creates a new SkypeAccountPropertyAction that sets the given properties for the given Skype for - * Asterisk user. - * - * @param user the Skype username of the user to add the buddy to. - * @param variables the properties to set. Must not be null - */ - public SkypeAccountPropertyAction(String user, Map variables) - { - this.user = user; - setVariables(variables); - } - - /** - * Returns the Skype username of the Skype for Asterisk user.

- * This property is mandatory. - * - * @return the Skype username of the Skype for Asterisk user. - */ - public String getUser() - { - return user; - } - - /** - * Sets the Skype username of the Skype for Asterisk user. - * - * @param user the Skype username of the Skype for Asterisk user. - */ - public void setUser(String user) - { - this.user = user; - } - - public Map getVariables() - { - return new HashMap<>(variables); - } - - public void setVariables(Map variables) - { - if (variables == null) - { - throw new IllegalArgumentException("Variables cannot be null"); - } - this.variables = new HashMap<>(variables); - } - - public void setTimezone(String timezone) - { - variables.put(PROPERTY_TIMEZONE, timezone); - } - - public void setSkypename(String skypename) - { - variables.put(PROPERTY_SKYPENAME, skypename); - } - - public void setAvailability(String availability) - { - variables.put(PROPERTY_AVAILABILITY, availability); - } - - public void setFullname(String fullname) - { - variables.put(PROPERTY_FULLNAME, fullname); - } - - /** - * Sets the ISO language code. - * - * @param language the ISO language code. - */ - public void setLanguage(String language) - { - variables.put(PROPERTY_LANGUAGE, language); - } - - /** - * Sets the country code. - * - * @param country the country code. - */ - public void setCountry(String country) - { - variables.put(PROPERTY_COUNTRY, country); - } - - public void setPhoneHome(String phoneHome) - { - variables.put(PROPERTY_PHONE_HOME, phoneHome); - } - - public void setPhoneOffice(String phoneOffice) - { - variables.put(PROPERTY_PHONE_OFFICE, phoneOffice); - } - - public void setPhoneMobile(String phoneMobile) - { - variables.put(PROPERTY_PHONE_MOBILE, phoneMobile); - } - - public void setAbout(String about) - { - variables.put(PROPERTY_ABOUT, about); - } - - /** - * Returns the name of this action, i.e. "SkypeAccountProperty". - */ - @Override - public String getAction() - { - return "SkypeAccountProperty"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeAddBuddyAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeAddBuddyAction.java deleted file mode 100644 index 5a9490323..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeAddBuddyAction.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The SkypeAddBuddyAction adds a buddy to the buddy list of a Skype for Asterisk user.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeAddBuddyAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - private String user; - private String buddy; - private String authMsg; - - /** - * Creates a new SkypeAddBuddyAction. - */ - public SkypeAddBuddyAction() - { - - } - - /** - * Creates a new SkypeAddBuddyAction that adds the given buddy to the given Skype for - * Asterisk user's buddy list. - * - * @param user the Skype username of the user to add the buddy to. - * @param buddy the Skype username of the buddy. - */ - public SkypeAddBuddyAction(String user, String buddy) - { - this.user = user; - this.buddy = buddy; - } - - /** - * Creates a new SkypeAddBuddyAction that adds the given buddy to the given Skype for - * Asterisk user's buddy list with a custom auth message. - * - * @param user the Skype username of the user to add the buddy to. - * @param buddy the Skype username of the buddy. - * @param authMsg the auth message. - */ - public SkypeAddBuddyAction(String user, String buddy, String authMsg) - { - this.user = user; - this.buddy = buddy; - this.authMsg = authMsg; - } - - /** - * Returns the Skype username of the Skype for Asterisk user.

- * This property is mandatory. - * - * @return the Skype username of the Skype for Asterisk user. - */ - public String getUser() - { - return user; - } - - /** - * Sets the Skype username of the Skype for Asterisk user. - * - * @param user the Skype username of the Skype for Asterisk user. - */ - public void setUser(String user) - { - this.user = user; - } - - /** - * Returns the Skype username of the buddy. - * - * @return the Skype username of the buddy. - */ - public String getBuddy() - { - return buddy; - } - - /** - * Sets the Skype username of the buddy.

- * This property is mandatory. - * - * @param buddy the Skype username of the buddy. - */ - public void setBuddy(String buddy) - { - this.buddy = buddy; - } - - /** - * Returns the auth message. - * - * @return the auth message. - */ - public String getAuthMsg() - { - return authMsg; - } - - /** - * Sets the auth message. - * - * @param authMsg the auth message. - */ - public void setAuthMsg(String authMsg) - { - this.authMsg = authMsg; - } - - /** - * Returns the name of this action, i.e. "SkypeAddBuddy". - */ - @Override - public String getAction() - { - return "SkypeAddBuddy"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeBuddiesAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeBuddiesAction.java deleted file mode 100644 index 60946992a..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeBuddiesAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.SkypeBuddyListCompleteEvent; - -/** - * The SkypeBuddiesAction retrieves the buddy list of a Skype for Asterisk user - * including the full name and status of each buddy.

- * For each agent a SkypeBuddyEntryEvent is generated. After the full buddy list has been - * reported a SkypeBuddyListCompleteEvent is generated.

- * Available with Skype for Asterisk. - * - * @see org.asteriskjava.manager.event.SkypeBuddyEntryEvent - * @see org.asteriskjava.manager.event.SkypeBuddyListCompleteEvent - * @since 1.0.0 - */ -public class SkypeBuddiesAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - private String user; - - /** - * Creates a new SkypeBuddiesAction. - */ - public SkypeBuddiesAction() - { - - } - - /** - * Creates a new SkypeBuddiesAction that retrieves the buddy list for the given user. - * - * @param user the Skype username of the user to retrieve the buddy list for. - */ - public SkypeBuddiesAction(String user) - { - this.user = user; - } - - /** - * Returns the Skype username of the user to retrieve the buddy list for.

- * This property is mandatory. - * - * @return the Skype username of the user to retrieve the buddy list for. - */ - public String getUser() - { - return user; - } - - /** - * Sets the Skype username of the user to retrieve the buddy list for. - * - * @param user the Skype username of the user to retrieve the buddy list for. - */ - public void setUser(String user) - { - this.user = user; - } - - /** - * Returns the name of this action, i.e. "SkypeBuddies". - */ - @Override - public String getAction() - { - return "SkypeBuddies"; - } - - public Class getActionCompleteEventClass() - { - return SkypeBuddyListCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeBuddyAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeBuddyAction.java deleted file mode 100644 index 738fc9019..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeBuddyAction.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.SkypeBuddyResponse; - -/** - * The SkypeBuddyAction retrieves the detais of a buddy for a Skype for Asterisk user.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -@ExpectedResponse(SkypeBuddyResponse.class) -public class SkypeBuddyAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - private String user; - private String buddy; - - /** - * Creates a new SkypeBuddiesAction. - */ - public SkypeBuddyAction() - { - - } - - /** - * Creates a new SkypeBuddiesAction that retrieves the details of the given buddy for the given user. - * - * @param user the Skype username of the user to retrieve the buddy details for. - * @param buddy the Skype username of the buddy. - */ - public SkypeBuddyAction(String user, String buddy) - { - this.user = user; - this.buddy = buddy; - } - - /** - * Returns the Skype username of the Skype for Asterisk user.

- * This property is mandatory. - * - * @return the Skype username of the Skype for Asterisk user. - */ - public String getUser() - { - return user; - } - - /** - * Sets the Skype username of the Skype for Asterisk user. - * - * @param user the Skype username of the Skype for Asterisk user. - */ - public void setUser(String user) - { - this.user = user; - } - - /** - * Returns the Skype username of the buddy. - * - * @return the Skype username of the buddy. - */ - public String getBuddy() - { - return buddy; - } - - /** - * Sets the Skype username of the buddy.

- * This property is mandatory. - * - * @param buddy the Skype username of the buddy. - */ - public void setBuddy(String buddy) - { - this.buddy = buddy; - } - - /** - * Returns the name of this action, i.e. "SkypeBuddy". - */ - @Override - public String getAction() - { - return "SkypeBuddy"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeChatSendAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeChatSendAction.java deleted file mode 100644 index 956b6bdd8..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeChatSendAction.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The SkypeChatSendAction sends a Skype Chat message to a buddy of a Skype for Asterisk user.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeChatSendAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - private String user; - private String skypename; - private String message; - - /** - * Creates a new SkypeAddBuddyAction. - */ - public SkypeChatSendAction() - { - - } - - /** - * Creates a new SkypeChatSendAction with the given parameters. - * - * @param user the Skype username of the sender of this chat message. - * @param skypename the Skype username of the recipient of this chat message. - * @param message the message to send. Must not contain newlines but you can use "\r". - */ - public SkypeChatSendAction(String user, String skypename, String message) - { - this.user = user; - this.skypename = skypename; - this.message = message; - } - - /** - * Returns the Skype username of the recipient of this chat message. - * - * @return the Skype username of the recipient of this chat message. - */ - public String getSkypename() - { - return skypename; - } - - /** - * Sets the Skype username of the recipient of this chat message. - * - * @param skypename the Skype username of the recipient of this chat message. - */ - public void setSkypename(String skypename) - { - this.skypename = skypename; - } - - /** - * Returns the Skype username of the sender of this chat message. - * - * @return the Skype username of the sender of this chat message. - */ - public String getUser() - { - return user; - } - - /** - * Sets the Skype username of the sender of this chat message. - * - * @param user the Skype username of the sender of this chat message. - */ - public void setUser(String user) - { - this.user = user; - } - - /** - * Returns the message to send. - * - * @return the message to send. - */ - public String getMessage() - { - return message; - } - - /** - * Sets the message to send. Must not contain newlines but you can use "\r". - * - * @param message the message to send. - */ - public void setMessage(String message) - { - this.message = message; - } - - /** - * Returns the name of this action, i.e. "SkypeChatSend". - */ - @Override - public String getAction() - { - return "SkypeChatSend"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeLicenseListAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeLicenseListAction.java deleted file mode 100644 index a81fca4b1..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeLicenseListAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.SkypeBuddyListCompleteEvent; - -/** - * The SkypeLicenseListAction lists all Skype for Asterisk licenses currently installed on - * the system.

- * For each license a SkypeLicenseEvent is generated. After all licenses have been - * reported a SkypeLicenseListCompleteEvent is generated.

- * Available with Skype for Asterisk. - * - * @see org.asteriskjava.manager.event.SkypeLicenseEvent - * @see org.asteriskjava.manager.event.SkypeLicenseListCompleteEvent - * @since 1.0.0 - */ -public class SkypeLicenseListAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - - /** - * Creates a new SkypeLicenseListAction. - */ - public SkypeLicenseListAction() - { - - } - - /** - * Returns the name of this action, i.e. "SkypeLicenseList". - */ - @Override - public String getAction() - { - return "SkypeLicenseList"; - } - - public Class getActionCompleteEventClass() - { - return SkypeBuddyListCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeLicenseStatusAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeLicenseStatusAction.java deleted file mode 100644 index 476d02948..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeLicenseStatusAction.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.response.SkypeLicenseStatusResponse; - -/** - * The SkypeLicenseStatusAction returns the total number of Skype calls licensed.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -@ExpectedResponse(SkypeLicenseStatusResponse.class) -public class SkypeLicenseStatusAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - - /** - * Creates a new SkypeLicenseStatusAction. - */ - public SkypeLicenseStatusAction() - { - - } - - /** - * Returns the name of this action, i.e. "SkypeLicenseStatus". - */ - @Override - public String getAction() - { - return "SkypeLicenseStatus"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/SkypeRemoveBuddyAction.java b/src/main/java/org/asteriskjava/manager/action/SkypeRemoveBuddyAction.java deleted file mode 100644 index 94e15d2b0..000000000 --- a/src/main/java/org/asteriskjava/manager/action/SkypeRemoveBuddyAction.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The SkypeRemoveBuddyAction removes a buddy from the buddy list of a Skype for Asterisk user.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeRemoveBuddyAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 1L; - private String user; - private String buddy; - - /** - * Creates a new SkypeRemoveBuddyAction. - */ - public SkypeRemoveBuddyAction() - { - - } - - /** - * Creates a new SkypeRemoveBuddyAction that removes the given buddy from the given Skype for - * Asterisk user's buddy list. - * - * @param user the Skype username of the user to add the buddy to. - * @param buddy the Skype username of the buddy. - */ - public SkypeRemoveBuddyAction(String user, String buddy) - { - this.user = user; - this.buddy = buddy; - } - - /** - * Returns the Skype username of the Skype for Asterisk user.

- * This property is mandatory. - * - * @return the Skype username of the Skype for Asterisk user. - */ - public String getUser() - { - return user; - } - - /** - * Sets the Skype username of the Skype for Asterisk user. - * - * @param user the Skype username of the Skype for Asterisk user. - */ - public void setUser(String user) - { - this.user = user; - } - - /** - * Returns the Skype username of the buddy. - * - * @return the Skype username of the buddy. - */ - public String getBuddy() - { - return buddy; - } - - /** - * Sets the Skype username of the buddy.

- * This property is mandatory. - * - * @param buddy the Skype username of the buddy. - */ - public void setBuddy(String buddy) - { - this.buddy = buddy; - } - - /** - * Returns the name of this action, i.e. "SkypeRemoveBuddy". - */ - @Override - public String getAction() - { - return "SkypeRemoveBuddy"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/StatusAction.java b/src/main/java/org/asteriskjava/manager/action/StatusAction.java deleted file mode 100644 index b32b85e9e..000000000 --- a/src/main/java/org/asteriskjava/manager/action/StatusAction.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import java.util.Iterator; -import java.util.List; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.StatusCompleteEvent; - -/** - * The StatusAction requests the state of all active channels. Alternativly (as of Asterisk 1.6) - * you can also pass a channel name to only retrive the status of one specific channel.

- * For each active channel a StatusEvent is generated. After the state of all - * channels has been reported a StatusCompleteEvent is generated. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.StatusEvent - * @see org.asteriskjava.manager.event.StatusCompleteEvent - */ -public class StatusAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private String channel; - private String variables; - - /** - * Creates a new StatusAction that retrieves the status of all channels. - */ - public StatusAction() - { - - } - - /** - * Creates a new StatusAction that retrieves the status of the given channel.

- * Available since Asterisk 1.6. - * - * @param channel name of the channel. - * @since 1.0.0 - */ - public StatusAction(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of this action, i.e. "Status". - */ - @Override - public String getAction() - { - return "Status"; - } - - public Class getActionCompleteEventClass() - { - return StatusCompleteEvent.class; - } - - /** - * Returns the name of the channel.

- * Available since Asterisk 1.6. - * - * @return the name of the channel or null for all channels. - * @since 1.0.0 - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel.

- * Available since Asterisk 1.6. - * - * @param channel the name of the channel or null for all channels. - * @since 1.0.0 - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getVariables() - { - return variables; - } - - /** - * Sets the names of the channel variables to return for each reported channel.

- * Available since Asterisk 1.6. - * - * @param variables comma separated list of variables to return for each reported channel. - * @see org.asteriskjava.manager.event.StatusEvent#getVariables() - * @since 1.0.0 - */ - public void setVariables(String variables) - { - this.variables = variables; - } - - /** - * Sets the names of the channel variables to return for each reported channel.

- * Available since Asterisk 1.6. - * - * @param variables list of variables to return for each reported channel. - * @see org.asteriskjava.manager.event.StatusEvent#getVariables() - * @since 1.0.0 - */ - public void setVariables(List variables) - { - if (variables == null || variables.isEmpty()) - { - this.variables = null; - return; - } - - Iterator iter = variables.iterator(); - StringBuilder buffer = new StringBuilder(iter.next()); - while (iter.hasNext()) - { - buffer.append(",").append(iter.next()); - } - this.variables = buffer.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/StopMonitorAction.java b/src/main/java/org/asteriskjava/manager/action/StopMonitorAction.java deleted file mode 100644 index cca664936..000000000 --- a/src/main/java/org/asteriskjava/manager/action/StopMonitorAction.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The StopMonitorAction ends monitoring (recording) a channel.

- * It is implemented in res/res_monitor.c - * - * @author srt - * @version $Id$ - */ -public class StopMonitorAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -6316010713240389305L; - - /** - * The name of the channel to end monitoring. - */ - private String channel; - - /** - * Creates a new empty StopMonitorAction. - */ - public StopMonitorAction() - { - - } - - /** - * Creates a new StopMonitorAction that ends monitoring of the given - * channel. - * - * @param channel the name of the channel to stop monitoring. - * @since 0.2 - */ - public StopMonitorAction(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of this action, i.e. "StopMonitor". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "StopMonitor"; - } - - /** - * Returns the name of the channel to end monitoring. - * - * @return the name of the channel to end monitoring. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to end monitoring.

- * This property is mandatory. - * - * @param channel the name of the channel to end monitoring. - */ - public void setChannel(String channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/UnpauseMonitorAction.java b/src/main/java/org/asteriskjava/manager/action/UnpauseMonitorAction.java deleted file mode 100644 index 964d1bf76..000000000 --- a/src/main/java/org/asteriskjava/manager/action/UnpauseMonitorAction.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The PauseMonitorAction re-enables monitoring (recording) of a channel after - * calling PauseMonitor. - *

- * It is implemented in res/res_monitor.c - *

- * Available since Asterisk 1.4. - * - * @see PauseMonitorAction - * @author srt - * @since 0.3 - * @version $Id$ - */ -public class UnpauseMonitorAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -6316010713240389305L; - - /** - * The name of the channel to re-enable monitoring. - */ - private String channel; - - /** - * Creates a new empty UnpauseMonitorAction. - */ - public UnpauseMonitorAction() - { - - } - - /** - * Creates a new UnpauseMonitorAction that re-enables monitoring the given - * channel. - * - * @param channel the name of the channel re-enable monitoring. - */ - public UnpauseMonitorAction(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of this action, i.e. "UnpauseMonitor". - * - * @return the name of this action. - */ - @Override - public String getAction() - { - return "UnpauseMonitor"; - } - - /** - * Returns the name of the channel to re-enable monitoring. - * - * @return the name of the channel to re-enable monitoring. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to re-enable monitoring. - *

- * This property is mandatory. - * - * @param channel the name of the channel to re-enable monitoring. - */ - public void setChannel(String channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/UpdateConfigAction.java b/src/main/java/org/asteriskjava/manager/action/UpdateConfigAction.java deleted file mode 100644 index 057eabd71..000000000 --- a/src/main/java/org/asteriskjava/manager/action/UpdateConfigAction.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import java.util.HashMap; -import java.util.Map; - -/** - * The UpdateConfigAction sends an UpdateConfig command to the asterisk server. - * Please take note that unlike the manager documentation, this command does not - * dump back the config file upon success -- it only tells you it succeeded. You - * should use the handy addCommand method this class provides for specifying - * what actions you would like to take on the configuration file. It will - * generate appropriate sequence numbers for the command. You may use the static - * ACTION_* fields provided by this action to specify what action you would like - * to take, while avoiding handling the strings required. Plain fields: - * SrcFilename: Configuration filename to read(e.g. foo.conf) DstFilename: - * Configuration filename to write(e.g. foo.conf) Reload: Whether or not a - * reload should take place (or name of specific module) Repeatable fields: - * Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append) - * Cat-XXXXXX: Category to operate on Var-XXXXXX: Variable to work on - * Value-XXXXXX: Value to work on Match-XXXXXX: Extra match required to match - * line - * - * @see org.asteriskjava.manager.response.GetConfigResponse - * @see org.asteriskjava.manager.action.UpdateConfigAction#addCommand - * @author martins - * @since 0.3 - */ -public class UpdateConfigAction extends AbstractManagerAction -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 4753117770471622025L; - - private static final String RELOAD_STRING_YES = "Yes"; - private static final String RELOAD_STRING_NO = "No"; - - /* Actions accepted by commands in the sequence */ - public static final String ACTION_NEWCAT = "NewCat"; - public static final String ACTION_RENAMECAT = "RenameCat"; - public static final String ACTION_DELCAT = "DelCat"; - public static final String ACTION_UPDATE = "Update"; - public static final String ACTION_DELETE = "Delete"; - public static final String ACTION_APPEND = "Append"; - - protected String srcFilename; - protected String dstFilename; - protected String reload; - - protected int actionCounter; - protected Map actions; - - /** - * Creates a new UpdateConfigAction. - */ - public UpdateConfigAction() - { - this.actionCounter = 0; - actions = new HashMap<>(); - } - - /** - * Creates a new UpdateConfigAction with the given parameters. - * - * @param srcFilename the name of the file to get. - */ - public UpdateConfigAction(String srcFilename, String dstFilename, boolean reload) - { - this.actionCounter = 0; - this.srcFilename = srcFilename; - this.dstFilename = dstFilename; - setReload(reload); - actions = new HashMap<>(); - } - - /** - * Adds a command to update a config file while sparing you the details of - * the Manager's required syntax. If you want to omit one of the command's - * sections, provide a null value to this method. The command index will be - * incremented even if you supply a null for all parameters, though the map - * will be unaffected. - * - * @param action Action to Take - * (NewCat,RenameCat,DelCat,Update,Delete,Append), see static - * fields - * @param cat Category to operate on - * @param var Variable to work on - * @param value Value to work on - * @param match Extra match required to match line - */ - public void addCommand(String action, String cat, String var, String value, String match) - { - // for convienence of reference, shorter! - final String stringCounter = String.format("%06d", this.actionCounter); - - if (action != null) - { - actions.put("Action-" + stringCounter, action); - } - - if (cat != null) - { - actions.put("Cat-" + stringCounter, cat); - } - - if (var != null) - { - actions.put("Var-" + stringCounter, var); - } - - if (value != null) - { - actions.put("Value-" + stringCounter, value); - } - - if (match != null) - { - actions.put("Match-" + stringCounter, match); - } - - this.actionCounter++; - } - - /** - * Returns the name of this action, i.e. "UpdateConfig". - */ - @Override - public String getAction() - { - return "UpdateConfig"; - } - - /** - * Returns the source filename. - */ - public String getSrcFilename() - { - return srcFilename; - } - - /** - * Sets the source filename. - */ - public void setSrcFilename(String filename) - { - this.srcFilename = filename; - } - - /** - * Returns the destination filename. - */ - public String getDstFilename() - { - return dstFilename; - } - - /** - * Sets the source filename. - */ - public void setDstFilename(String filename) - { - this.dstFilename = filename; - } - - /** - * @return should Asterisk reload, or the name of a specific module to - * reload - */ - public String getReload() - { - return reload; - } - - /** - * Sets the reload behavior of this action, or sets a specific module to be - * reloaded - * - * @param reload the reload parameter to set - * @see org.asteriskjava.manager.action.UpdateConfigAction#setReload(boolean) - */ - public void setReload(String reload) - { - this.reload = reload; - } - - /** - * Sets the reload behavior of this action. If you don't know what string to - * feed Asterisk, this method will provide the appropriate one. - * - * @param reload the reload parameter to set - * @see org.asteriskjava.manager.action.UpdateConfigAction#setReload(String) - */ - public void setReload(boolean reload) - { - this.reload = reload ? UpdateConfigAction.RELOAD_STRING_YES : UpdateConfigAction.RELOAD_STRING_NO; - } - - /** - * Returns Map of the action's desired operations where Map keys contain: - * action,cat,var,value,match pairs followed by -XXXXXX, and the Map values - * contain the values for those keys. This method will typically only be - * used by the ActionBuilder to generate the actual strings to be sent to - * the manager interface. - * - * @see org.asteriskjava.manager.action.UpdateConfigAction#addCommand - * @return a Map of the actions that should be taken - */ - public Map getAttributes() - { - return actions; - } - - /** - * You may use this field to directly, programmatically add your own Map of - * key,value pairs that you would like to send for this command. Setting - * your own map will reset the command index to the number of keys in the - * Map - * - * @see org.asteriskjava.manager.action.UpdateConfigAction#addCommand - * @param actions the actions to set - */ - public void setAttributes(Map actions) - { - this.actions = actions; - this.actionCounter = actions.keySet().size(); - } - -} diff --git a/src/main/java/org/asteriskjava/manager/action/UserEventAction.java b/src/main/java/org/asteriskjava/manager/action/UserEventAction.java deleted file mode 100644 index 52167a7fb..000000000 --- a/src/main/java/org/asteriskjava/manager/action/UserEventAction.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.UserEvent; - -/** - * The UserEventAction will send a custom user event to the Asterisk server. - * This is equivalent to using the UserEvent application in your - * dial plan. Before you send this event, you must register your - * event class with the registerUserEventClass method of the ManagerConnection. - * - * @see org.asteriskjava.manager.event.UserEvent - * @see org.asteriskjava.manager.ManagerConnection#registerUserEventClass(Class) - * @author Martin - */ -public class UserEventAction extends AbstractManagerAction -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 8696871424483458445L; - - /** - * The event this action will send - */ - private UserEvent userEvent; - - public UserEventAction() - { - super(); - } - - /** - * Create the userevent action with userEvent as the event it will send - * - * @param userEvent the subclass representing a custom event - */ - public UserEventAction(UserEvent userEvent) - { - this.userEvent = userEvent; - } - - /** - * Get the name of this action - */ - @Override - public String getAction() - { - return "UserEvent"; - } - - /** - * @return the userEvent - */ - public UserEvent getUserEvent() - { - return userEvent; - } - - /** - * @param userEvent the userEvent to set - * @see org.asteriskjava.manager.event.UserEvent - */ - public void setUserEvent(UserEvent userEvent) - { - this.userEvent = userEvent; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/VoicemailUsersListAction.java b/src/main/java/org/asteriskjava/manager/action/VoicemailUsersListAction.java deleted file mode 100644 index 1b896995e..000000000 --- a/src/main/java/org/asteriskjava/manager/action/VoicemailUsersListAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.VoicemailUserEntryCompleteEvent; - -/** - * Retrieves a list of all defined voicemail users.

- * For each user that is found a VoicemailUserEntryEvent event is sent by Asterisk containing - * the details. When all peers have been reported a VoicemailUserEntryCompleteEvent is - * sent.

- * It is implemented in apps/app_voicemail.c - *
- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.VoicemailUserEntryEvent - * @see org.asteriskjava.manager.event.VoicemailUserEntryCompleteEvent - * @since 1.0.0 - */ -public class VoicemailUsersListAction extends AbstractManagerAction implements EventGeneratingAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * Creates a new VoicemailUsersListAction. - */ - public VoicemailUsersListAction() - { - - } - - @Override - public String getAction() - { - return "VoicemailUsersList"; - } - - public Class getActionCompleteEventClass() - { - return VoicemailUserEntryCompleteEvent.class; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/action/ZapDialOffhookAction.java b/src/main/java/org/asteriskjava/manager/action/ZapDialOffhookAction.java deleted file mode 100644 index 961d54de3..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapDialOffhookAction.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ZapDialOffhookAction dials a number on a zap channel while offhook. - * - * @author srt - * @version $Id$ - */ -public class ZapDialOffhookAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -4708738122184810899L; - private Integer zapChannel; - private String number; - - /** - * Creates a new empty ZapDialOffhookAction. - */ - public ZapDialOffhookAction() - { - - } - - /** - * Creates a new ZapDialOffhookAction that dials the given number on the - * given zap channel. - * - * @param zapChannel the number of the zap channel - * @param number the number to dial - * @since 0.2 - */ - public ZapDialOffhookAction(Integer zapChannel, String number) - { - this.zapChannel = zapChannel; - this.number = number; - } - - /** - * Returns the name of this action, i.e. "ZapDialOffhook". - */ - @Override - public String getAction() - { - return "ZapDialOffhook"; - } - - /** - * Returns the number of the zap channel. - */ - public Integer getZapChannel() - { - return zapChannel; - } - - /** - * Sets the number of the zap channel.

- * This property is mandatory. - */ - public void setZapChannel(Integer channel) - { - this.zapChannel = channel; - } - - /** - * Returns the number to dial. - */ - public String getNumber() - { - return number; - } - - /** - * Sets the number to dial.

- * This property is mandatory. - */ - public void setNumber(String number) - { - this.number = number; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ZapDndOffAction.java b/src/main/java/org/asteriskjava/manager/action/ZapDndOffAction.java deleted file mode 100644 index 18e320f9c..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapDndOffAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ZapDNDOnAction switches a zap channel "Do Not Disturb" status off. - * - * @author srt - * @version $Id$ - */ -public class ZapDndOffAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 6596440995467988436L; - private Integer zapChannel; - - /** - * Creates a new empty ZapDndOffAction. - */ - public ZapDndOffAction() - { - - } - - /** - * Creates a new ZapDndOffAction that disables "Do Not Disturb" status for - * the given zap channel. - * - * @param zapChannel the number of the zap channel - * @since 0.2 - */ - public ZapDndOffAction(Integer zapChannel) - { - this.zapChannel = zapChannel; - } - - /** - * Returns the name of this action, i.e. "ZapDNDOff". - */ - @Override - public String getAction() - { - return "ZapDNDOff"; - } - - /** - * Returns the number of the zap channel to switch to dnd off. - */ - public Integer getZapChannel() - { - return zapChannel; - } - - /** - * Sets the number of the zap channel to switch to dnd off.

- * This property is mandatory. - */ - public void setZapChannel(Integer channel) - { - this.zapChannel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ZapDndOnAction.java b/src/main/java/org/asteriskjava/manager/action/ZapDndOnAction.java deleted file mode 100644 index f18beba34..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapDndOnAction.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ZapDNDOnAction switches a zap channel "Do Not Disturb" status on. - * - * @author srt - * @version $Id$ - */ -public class ZapDndOnAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -4669362344411680132L; - private Integer zapChannel; - - /** - * Creates a new empty ZapDndOnAction. - */ - public ZapDndOnAction() - { - - } - - /** - * Creates a new ZapDndOnAction that enables "Do Not Disturb" status for - * the given zap channel. - * - * @param zapChannel the number of the zap channel - * @since 0.2 - */ - public ZapDndOnAction(Integer zapChannel) - { - this.zapChannel = zapChannel; - } - - /** - * Returns the name of this action, i.e. "ZapDNDOn". - */ - @Override - public String getAction() - { - return "ZapDNDOn"; - } - - /** - * Returns the number of the zap channel to switch to dnd on. - */ - public Integer getZapChannel() - { - return zapChannel; - } - - /** - * Sets the number of the zap channel to switch to dnd on.

- * This property is mandatory. - */ - public void setZapChannel(Integer channel) - { - this.zapChannel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ZapHangupAction.java b/src/main/java/org/asteriskjava/manager/action/ZapHangupAction.java deleted file mode 100644 index 0d1484f5e..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapHangupAction.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ZapHangupAction hangs up a zap channel. - * - * @author srt - * @version $Id$ - */ -public class ZapHangupAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -4064616334146097495L; - private Integer zapChannel; - - /** - * Creates a new empty ZapHangupAction. - */ - public ZapHangupAction() - { - - } - - /** - * Creates a new ZapHangupAction that hangs up the given zap channel. - * - * @param zapChannel the number of the zap channel to hang up - * @since 0.2 - */ - public ZapHangupAction(Integer zapChannel) - { - this.zapChannel = zapChannel; - } - - /** - * Returns the name of this action, i.e. "ZapHangup". - */ - @Override - public String getAction() - { - return "ZapHangup"; - } - - /** - * Returns the number of the zap channel to hangup. - */ - public Integer getZapChannel() - { - return zapChannel; - } - - /** - * Sets the number of the zap channel to hangup.

- * This property is mandatory. - */ - public void setZapChannel(Integer channel) - { - this.zapChannel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ZapRestartAction.java b/src/main/java/org/asteriskjava/manager/action/ZapRestartAction.java deleted file mode 100644 index 395b88c6c..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapRestartAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.manager.action; - -/** - * Fully restarts all zaptel channels and terminates any calls on Zap - * interfaces. - *

- * Available since Asterisk 1.4. - * - * @author srt - * @since 0.3 - * @version $Id$ - */ -public class ZapRestartAction extends AbstractManagerAction -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 5899540386204706397L; - - /** - * Creates a new ZapRestartAction. - */ - public ZapRestartAction() - { - - } - - @Override - public String getAction() - { - return "ZapRestart"; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ZapShowChannelsAction.java b/src/main/java/org/asteriskjava/manager/action/ZapShowChannelsAction.java deleted file mode 100644 index 181513d28..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapShowChannelsAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.ZapShowChannelsCompleteEvent; - -/** - * The ZapShowChannelsAction requests the state of all zap channels.

- * For each zap channel a ZapShowChannelsEvent is generated. After all zap - * channels have been listed a ZapShowChannelsCompleteEvent is generated. - * - * @see org.asteriskjava.manager.event.ZapShowChannelsEvent - * @see org.asteriskjava.manager.event.ZapShowChannelsCompleteEvent - * @author srt - * @version $Id$ - */ -public class ZapShowChannelsAction extends AbstractManagerAction - implements - EventGeneratingAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 8697000330085766825L; - - /** - * Creates a new ZapShowChannelsAction. - */ - public ZapShowChannelsAction() - { - - } - - /** - * Returns the name of this action, i.e. "ZapShowChannels". - */ - @Override - public String getAction() - { - return "ZapShowChannels"; - } - - public Class getActionCompleteEventClass() - { - return ZapShowChannelsCompleteEvent.class; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/ZapTransferAction.java b/src/main/java/org/asteriskjava/manager/action/ZapTransferAction.java deleted file mode 100644 index 7286a0dd7..000000000 --- a/src/main/java/org/asteriskjava/manager/action/ZapTransferAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.action; - -/** - * The ZapTransferAction transfers a zap channel. - * - * @author srt - * @version $Id$ - */ -public class ZapTransferAction extends AbstractManagerAction -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2802091639000800786L; - private Integer zapChannel; - - /** - * Returns the name of this action, i.e. "ZapTransfer". - */ - @Override - public String getAction() - { - return "ZapTransfer"; - } - - /** - * Returns the number of the zap channel to transfer. - */ - public Integer getZapChannel() - { - return zapChannel; - } - - /** - * Sets the number of the zap channel to transfer.

- * This property is mandatory. - */ - public void setZapChannel(Integer channel) - { - this.zapChannel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/action/package.html b/src/main/java/org/asteriskjava/manager/action/package.html deleted file mode 100644 index fcaac1bb6..000000000 --- a/src/main/java/org/asteriskjava/manager/action/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides classes that represent the standard actions that can be sent - to an Asterisk server via the Manager API.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/.gitignore b/src/main/java/org/asteriskjava/manager/event/.gitignore deleted file mode 100644 index b1180ee41..000000000 --- a/src/main/java/org/asteriskjava/manager/event/.gitignore +++ /dev/null @@ -1,179 +0,0 @@ -/AbstractAgentEvent.class -/AbstractChannelEvent.class -/AbstractChannelStateEvent.class -/AbstractFaxEvent.class -/AbstractMeetMeEvent.class -/AbstractMonitorEvent.class -/AbstractParkedCallEvent.class -/AbstractQueueMemberEvent.class -/AbstractRtcpEvent.class -/AbstractRtpStatEvent.class -/AgentCallbackLoginEvent.class -/AgentCallbackLogoffEvent.class -/AgentCalledEvent.class -/AgentCompleteEvent.class -/AgentConnectEvent.class -/AgentDumpEvent.class -/AgentLoginEvent.class -/AgentLogoffEvent.class -/AgentRingNoAnswerEvent.class -/AgentsCompleteEvent.class -/AgentsEvent.class -/AgiExecEvent.class -/AlarmClearEvent.class -/AlarmEvent.class -/AsyncAgiEvent.class -/BridgeEvent.class -/BridgeExecEvent.class -/CdrEvent.class -/ChanSpyStartEvent.class -/ChanSpyStopEvent.class -/ChannelReloadEvent.class -/ChannelUpdateEvent.class -/ConfbridgeEndEvent.class -/ConfbridgeJoinEvent.class -/ConfbridgeLeaveEvent.class -/ConfbridgeListCompleteEvent.class -/ConfbridgeListEvent.class -/ConfbridgeListRoomsCompleteEvent.class -/ConfbridgeListRoomsEvent.class -/ConfbridgeStartEvent.class -/ConfbridgeTalkingEvent.class -/ConnectEvent.class -/CoreShowChannelEvent.class -/CoreShowChannelsCompleteEvent.class -/DAHDIChannelEvent.class -/DahdiShowChannelsCompleteEvent.class -/DahdiShowChannelsEvent.class -/DbGetResponseEvent.class -/DialEvent.class -/DisconnectEvent.class -/DndStateEvent.class -/DongleCENDEvent.class -/DongleCallStateChangeEvent.class -/DongleDeviceEntryEvent.class -/DongleNewCMGREvent.class -/DongleNewSMSBase64Event.class -/DongleNewSMSEvent.class -/DongleShowDevicesCompleteEvent.class -/DongleStatusEvent.class -/DtmfEvent.class -/ExtensionStatusEvent.class -/FaxDocumentStatusEvent.class -/FaxReceivedEvent.class -/FaxStatusEvent.class -/FullyBootedEvent.class -/HangupEvent.class -/HangupRequestEvent.class -/HoldEvent.class -/HoldedCallEvent.class -/JabberEventEvent.class -/JitterBufStatsEvent.class -/JoinEvent.class -/LeaveEvent.class -/LinkEvent.class -/ListDialplanEvent.class -/LogChannelEvent.class -/ManagerEvent.class -/MasqueradeEvent.class -/MeetMeEndEvent.class -/MeetMeJoinEvent.class -/MeetMeLeaveEvent.class -/MeetMeMuteEvent.class -/MeetMeStopTalkingEvent.class -/MeetMeTalkingEvent.class -/MeetMeTalkingRequestEvent.class -/MessageWaitingEvent.class -/ModuleLoadReportEvent.class -/MonitorStartEvent.class -/MonitorStopEvent.class -/MusicOnHoldEvent.class -/NewAccountCodeEvent.class -/NewCallerIdEvent.class -/NewChannelEvent.class -/NewExtenEvent.class -/NewStateEvent.class -/OriginateFailureEvent.class -/OriginateResponseEvent.class -/OriginateSuccessEvent.class -/ParkedCallEvent.class -/ParkedCallGiveUpEvent.class -/ParkedCallTimeOutEvent.class -/ParkedCallsCompleteEvent.class -/PeerEntryEvent.class -/PeerStatusEvent.class -/PeerlistCompleteEvent.class -/PriEventEvent.class -/ProtocolIdentifierReceivedEvent.class -/QueueCallerAbandonEvent.class -/QueueEntryEvent.class -/QueueEvent.class -/QueueMemberAddedEvent.class -/QueueMemberEvent.class -/QueueMemberPausedEvent.class -/QueueMemberPenaltyEvent.class -/QueueMemberRemovedEvent.class -/QueueMemberStatusEvent.class -/QueueParamsEvent.class -/QueueStatusCompleteEvent.class -/QueueSummaryCompleteEvent.class -/QueueSummaryEvent.class -/ReceiveFaxEvent.class -/RegistrationsCompleteEvent.class -/RegistryEntryEvent.class -/RegistryEvent.class -/ReloadEvent.class -/RenameEvent.class -/ResponseEvent.class -/RtcpReceivedEvent.class -/RtcpSentEvent.class -/RtpReceiverStatEvent.class -/RtpSenderStatEvent.class -/SendFaxEvent.class -/SendFaxStatusEvent.class -/ShowDialplanCompleteEvent.class -/ShutdownEvent.class -/SkypeAccountStatusEvent.class -/SkypeBuddyEntryEvent.class -/SkypeBuddyListCompleteEvent.class -/SkypeBuddyStatusEvent.class -/SkypeChatMessageEvent.class -/SkypeLicenseEvent.class -/SkypeLicenseListCompleteEvent.class -/SoftHangupRequestEvent.class -/StatusCompleteEvent.class -/StatusEvent.class -/T38FaxStatusEvent.class -/TransferEvent.class -/UnholdEvent.class -/UnlinkEvent.class -/UnparkedCallEvent.class -/UserEvent.class -/VarSetEvent.class -/VoicemailUserEntryCompleteEvent.class -/VoicemailUserEntryEvent.class -/ZapShowChannelsCompleteEvent.class -/ZapShowChannelsEvent.class -/AbstractBridgeEvent.class -/AgiExecEndEvent.class -/AgiExecStartEvent.class -/AsyncAgiEndEvent.class -/AsyncAgiExecEvent.class -/AsyncAgiStartEvent.class -/BlindTransferEvent.class -/BridgeCreateEvent.class -/BridgeDestroyEvent.class -/BridgeEnterEvent.class -/BridgeLeaveEvent.class -/ChallengeSentEvent.class -/DeviceStateChangeEvent.class -/DialBeginEvent.class -/DialEndEvent.class -/DtmfBeginEvent.class -/DtmfEndEvent.class -/InvalidPasswordEvent.class -/MusicOnHoldStartEvent.class -/MusicOnHoldStopEvent.class -/NewConnectedLineEvent.class -/SuccessfulAuthEvent.class -/ChallengeResponseFailedEvent.class diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractAgentEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractAgentEvent.java deleted file mode 100644 index 2d6a6a6b2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractAgentEvent.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.Map; - -/** - * Abstract base class for several agent related events. - * - * @author srt - * @author martins - * @version $Id$ - * @since 0.2 - */ -public abstract class AbstractAgentEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - private String channel; - private String uniqueId; - private String queue; - private String member; - private String memberName; - private Map variables; - - protected AbstractAgentEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the name of the queue. - * - * @return the name of the queue. - */ - public String getQueue() - { - return queue; - } - - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the name of the member's interface. - * - * @return the name of the member's interface. - */ - public String getMember() - { - return member; - } - - public void setMember(String member) - { - this.member = member; - } - - /** - * Returns the member name supplied for logging when the member is added. - *
- * Available since Asterisk 1.4. - * - * @return the member name supplied for logging when the member is added. - */ - public String getMemberName() - { - return memberName; - } - - public void setMemberName(String memberName) - { - this.memberName = memberName; - } - - /** - * Returns the channel variables if eventwhencalled is set to vars - * in queues.conf.

- * Available since Asterisk 1.6 - * - * @return the channel variables. - * @since 1.0.0 - */ - public Map getVariables() - { - return variables; - } - - /** - * Sets the channel variables.

- * Available since Asterisk 1.6 - * - * @param variables the channel variables. - * @since 1.0.0 - */ - public void setVariables(Map variables) - { - this.variables = variables; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractBridgeEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractBridgeEvent.java deleted file mode 100644 index 5219b63ad..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractBridgeEvent.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public abstract class AbstractBridgeEvent extends ManagerEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String bridgeUniqueId; - private String bridgeType; - private Integer bridgeNumChannels; - private String bridgeCreator; - private String bridgeName; - private String bridgeTechnology; - private String accountCode; - - AbstractBridgeEvent(Object source) - { - super(source); - } - - public String getBridgeUniqueId() - { - return bridgeUniqueId; - } - - public void setBridgeUniqueId(String bridgeUniqueId) - { - this.bridgeUniqueId = bridgeUniqueId; - } - - public String getBridgeType() - { - return bridgeType; - } - - public void setBridgeType(String bridgeType) - { - this.bridgeType = bridgeType; - } - - public Integer getBridgeNumChannels() - { - return bridgeNumChannels; - } - - public void setBridgeNumChannels(Integer bridgeNumChannels) - { - this.bridgeNumChannels = bridgeNumChannels; - } - - public String getBridgeCreator() - { - return bridgeCreator; - } - - public void setBridgeCreator(String bridgeCreator) - { - this.bridgeCreator = bridgeCreator; - } - - public String getBridgeName() - { - return bridgeName; - } - - public void setBridgeName(String bridgeName) - { - this.bridgeName = bridgeName; - } - - public String getBridgeTechnology() - { - return bridgeTechnology; - } - - public void setBridgeTechnology(String bridgeTechnology) - { - this.bridgeTechnology = bridgeTechnology; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractChannelEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractChannelEvent.java deleted file mode 100644 index 46b2517ac..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractChannelEvent.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class providing common properties channel related events. - * - * @author srt - * @version $Id$ - */ -public abstract class AbstractChannelEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 5906599407896179295L; - - private String accountCode; - - /** - * The name of the channel. - */ - private String channel; - - /** - * The unique id of the channel. - */ - protected String uniqueId; - - protected AbstractChannelEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - public final String getChannel() - { - return channel; - } - - public final void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public final String getUniqueId() - { - return uniqueId; - } - - public final void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the Caller*ID of the channel if set or null if none - * has been set. - * - * @return the Caller*ID - * @deprecated - * @see #getCallerIdNum() - */ - @Deprecated - public final String getCallerId() - { - return getCallerIdNum(); - } - - /** - * Sets the Caller*ID of the channel. - * - * @param callerId the Caller*ID of the channel. - * @deprecated - */ - @Deprecated - public final void setCallerId(String callerId) - { - setCallerIdNum(callerId); - } - - /** - * Returns the Caller*ID number of the channel if set or null - * if none has been set. - * - * @return the Caller*ID number - * @since 0.3 - */ - public final String getCallerIdNum() - { - return callerIdNum; - } - - public final void setCallerIdNum(String callerIdNum) - { - this.callerIdNum = callerIdNum; - } - - /** - * Returns the Caller*ID Name of the channel if set or null if - * none has been set. - * - * @return the Caller*ID Name of the channel. - */ - public final String getCallerIdName() - { - return callerIdName; - } - - public final void setCallerIdName(String callerIdName) - { - this.callerIdName = callerIdName; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractChannelStateEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractChannelStateEvent.java deleted file mode 100644 index abb46d710..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractChannelStateEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class providing common properties for HangupEvent, - * NewChannelEvent and NewStateEvent. - * - * @author srt - * @version $Id$ - */ -public abstract class AbstractChannelStateEvent extends AbstractChannelEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - protected AbstractChannelStateEvent(Object source) - { - super(source); - } - - /** - * Returns the new state of the channel as a descriptive text.
- * This is an alias for {@link #getChannelStateDesc()}. - * - * @return the new state of the channel as a descriptive text. - * @deprecated as of 1.0.0, use {@link #getChannelStateDesc()} instead or - * even better switch to numeric values as returned by - * {@link #getChannelState()}. - */ - @Deprecated - public String getState() - { - return getChannelStateDesc(); - } - - /** - * Sets the new state of the channel as a descriptive text. - *

- * The state property is used by Asterisk versions prior to 1.6. - * - * @param state the new state of the channel as a descriptive text. - */ - public void setState(String state) - { - setChannelStateDesc(state); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractConfbridgeEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractConfbridgeEvent.java deleted file mode 100644 index 944cc4b56..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractConfbridgeEvent.java +++ /dev/null @@ -1,153 +0,0 @@ -package org.asteriskjava.manager.event; - -public abstract class AbstractConfbridgeEvent extends AbstractChannelEvent -{ - private static final long serialVersionUID = 3893862793876858636L; - private String bridgeType; - private String bridgeNumChannels; - private String bridgeUniqueId; - private String bridgeTechnology; - private String bridgeName; - private String bridgeCreator; - private String conference; - - String admin; - - public AbstractConfbridgeEvent(Object source) - { - super(source); - } - - /** - * @return the admin - */ - public String getAdmin() - { - return admin; - } - - /** - * @param admin the admin to set - */ - public void setAdmin(String admin) - { - this.admin = admin; - } - - /** - * @return the bridgeType - */ - public String getBridgeType() - { - return bridgeType; - } - - /** - * @param bridgeType the bridgeType to set - */ - public void setBridgeType(String bridgeType) - { - this.bridgeType = bridgeType; - } - - /** - * @return the bridgeNumChannels - */ - public String getBridgeNumChannels() - { - return bridgeNumChannels; - } - - /** - * @param bridgeNumChannels the bridgeNumChannels to set - */ - public void setBridgeNumChannels(String bridgeNumChannels) - { - this.bridgeNumChannels = bridgeNumChannels; - } - - /** - * @return the bridgeUniqueId - */ - public String getBridgeUniqueId() - { - return bridgeUniqueId; - } - - /** - * @param bridgeUniqueId the bridgeUniqueId to set - */ - public void setBridgeUniqueId(String bridgeUniqueId) - { - this.bridgeUniqueId = bridgeUniqueId; - } - - /** - * @return the bridgeTechnology - */ - public String getBridgeTechnology() - { - return bridgeTechnology; - } - - /** - * @param bridgeTechnology the bridgeTechnology to set - */ - public void setBridgeTechnology(String bridgeTechnology) - { - this.bridgeTechnology = bridgeTechnology; - } - - /** - * @return the bridgeName - */ - public String getBridgeName() - { - return bridgeName; - } - - /** - * @param bridgeName the bridgeName to set - */ - public void setBridgeName(String bridgeName) - { - this.bridgeName = bridgeName; - } - - /** - * @return the bridgeCreator - */ - public String getBridgeCreator() - { - return bridgeCreator; - } - - /** - * @param bridgeCreator the bridgeCreator to set - */ - public void setBridgeCreator(String bridgeCreator) - { - this.bridgeCreator = bridgeCreator; - } - - /** - * Sets the id of the conference the participant left. - * - * @param conference the id of the conference the participant left. - */ - public final void setConference(String conference) - { - this.conference = conference; - } - - /** - * Returns the id of the conference the participant left. - * - * @return the id of the conference the participant left. - */ - public final String getConference() - { - return conference; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractFaxEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractFaxEvent.java deleted file mode 100644 index df89296ce..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractFaxEvent.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AbstractFaxEvent is a base class for fax related events - */ -public class AbstractFaxEvent extends ManagerEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1L; - private String channel; - private Integer faxSession; - - public AbstractFaxEvent(Object source) - { - super(source); - } - - - /** - * @return the channel - */ - public String getChannel() - { - return channel; - } - - - /** - * @param channel the channel to set - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - - /** - * @return the faxSession - */ - public Integer getFaxSession() - { - return faxSession; - } - - - /** - * @param faxSession the faxSession to set - */ - public void setFaxSession(Integer faxSession) - { - this.faxSession = faxSession; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractHoldEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractHoldEvent.java deleted file mode 100644 index 7b8b8c93a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractHoldEvent.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * A HoldEvent is triggered when a channel is put on hold (or no longer on - * hold). - *

- * It is implemented in channels/chan_sip.c. - *

- * Available since Asterisk 1.2 for SIP channels, as of Asterisk 1.6 this event - * is also supported for IAX2 channels. - *

- * To receive HoldEvents for SIP channels you must set - * callevents = yes in sip.conf. - * - * @author enro - * @version $Id$ - * @since 1.0.0.10 - */ -public class AbstractHoldEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - /** - * The name of the channel. - */ - private String channel; - - private String accountCode; - - /** - * The unique id of the channel. - */ - private String uniqueId; - - private Boolean status; - - private String linkedId; - private String language; - - - /** - * Creates a new HoldEvent. - * - * @param source - */ - public AbstractHoldEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return channel the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - * - * @param channel the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel. - * - * @param uniqueId the unique id of the channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns whether this is a hold or unhold event. - * - * @return true if this a hold event, false if - * it's an unhold event. - * @since 1.0.0 - */ - public Boolean getStatus() - { - return status; - } - - /** - * Returns whether this is a hold or unhold event. - * - * @param status true if this a hold event, false - * if it's an unhold event. - * @since 1.0.0 - */ - public void setStatus(Boolean status) - { - this.status = status; - } - - /** - * Returns whether this is a hold event. - * - * @return true if this a hold event, false if - * it's an unhold event. - * @since 1.0.0 - */ - public boolean isHold() - { - return status != null && status; - } - - /** - * Returns whether this is an unhold event. - * - * @return true if this an unhold event, false if - * it's a hold event. - * @since 1.0.0 - */ - public boolean isUnhold() - { - return status != null && !status; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractMeetMeEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractMeetMeEvent.java deleted file mode 100644 index 9a5efd0b6..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractMeetMeEvent.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class providing common properties for MeetMe (Asterisk's - * conference system) events. - *

- * MeetMe events are implemented in apps/app_meetme.c - * - * @author srt - * @version $Id$ - */ -public abstract class AbstractMeetMeEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - private String channel; - private String uniqueId; - private String meetMe; - private Integer user; - - /** - * @param source - */ - protected AbstractMeetMeEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - *

- * This property is available since Asterisk 1.4. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - *

- * This property is available since Asterisk 1.4. - * - * @param channel the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - *

- * This property is available since Asterisk 1.4. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel. - *

- * This property is available since Asterisk 1.4. - * - * @param uniqueId the unique id of the channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the conference number. - * - * @return the conference number. - */ - public String getMeetMe() - { - return meetMe; - } - - /** - * Sets the conference number. - * - * @param meetMe the conference number. - */ - public void setMeetMe(String meetMe) - { - this.meetMe = meetMe; - } - - /** - * Returns the index of the user in the conference. - *

- * This can be used for the "meetme (mute|unmute|kick)" commands. use - * getUser() instead - * - * @return the index of the user in the conference. - */ - @Deprecated - public Integer getUserNum() - { - return getUser(); - } - - /** - * Sets the index of the user in the conference. - * - * @param userNum the index of the user in the conference. - */ - @Deprecated - public void setUserNum(Integer userNum) - { - this.setUser(userNum); - } - - /** - * Returns the index of the user in the conference. - *

- * This can be used for the "meetme (mute|unmute|kick)" commands. - * - * @return the index of the user in the conference. - */ - public Integer getUser() - { - return user; - } - - /** - * Sets the index of the user in the conference. - * - * @param userNum the index of the user in the conference. - */ - public void setUser(Integer userNum) - { - this.user = userNum; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractMonitorEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractMonitorEvent.java deleted file mode 100644 index cb8cf6afc..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractMonitorEvent.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class for monitoring events.

- * Monitoring events are implemented in res/res_monitor.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public abstract class AbstractMonitorEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - private String channel; - private String uniqueId; - - /** - * @param source - */ - protected AbstractMonitorEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractParkedCallEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractParkedCallEvent.java deleted file mode 100644 index 5d27c2748..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractParkedCallEvent.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class for several call parking related events. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public abstract class AbstractParkedCallEvent extends ManagerEvent -{ - private static final long serialVersionUID = 0L; - private String uniqueId; - // Previously: Channel - private String parkeeChannel; - private Integer parkeeChannelState; - private String parkeeChannelStateDesc; - // previously CallerID - private String parkeeCallerIDNum; - // Previously CallerIDName - private String parkeeCallerIDName; - private Integer parkeeConnectedLineNum; - private String parkeeConnectedLineName; - private String parkeeLanguage; - private String parkeeAccountCode; - private String parkeeContext; - private String parkeeExten; - private Integer parkeePriority; - private String parkeeUniqueid; - // Previously: From - private String parkerDialString; - private String parkingLot; - // previously Exten - private String parkingSpace; - private Long parkingTimeout; - private Long parkingDuration; - - protected AbstractParkedCallEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel that parked the call. use - * getParkerDialString() instead - */ - @Deprecated - public String getFrom() - { - return getParkerDialString(); - } - - /** - * Sets the name of the channel that parked the call. - */ - @Deprecated - public void setFrom(String from) - { - this.setParkerDialString(from); - } - - /** - * Returns the parking lot. - *

- * Available since Asterisk 1.6. - * - * @return the parking lot. - * @since 1.0.0 - */ - public String getParkingLot() - { - return parkingLot; - } - - /** - * Sets the parking lot. - * - * @param parkingLot the parking lot. - */ - public void setParkingLot(String parkingLot) - { - this.parkingLot = parkingLot; - } - - /** - * Returns the unique id of the parked channel. - *

- * Note: This property is not set properly by all versions of Asterisk, see - * http://bugs.digium. - * com/ view.php?id=13323 and - * http://bugs.digium. - * com/view.php?id=13358 for more information. Use {@link #getChannel()} - * instead. - * - * @return the unique id of the parked channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - @Deprecated - public void setChannel(String channel) - { - this.setParkeeChannel(channel); - } - - /** - * use getParkeeChannel() instead - * - * @return - */ - @Deprecated - public String getChannel() - { - return this.getParkeeChannel(); - } - - public String getParkeeChannel() - { - return parkeeChannel; - } - - public void setParkeeChannel(String parkeeChannel) - { - this.parkeeChannel = parkeeChannel; - } - - public Integer getParkeeChannelState() - { - return parkeeChannelState; - } - - public void setParkeeChannelState(Integer parkeeChannelState) - { - this.parkeeChannelState = parkeeChannelState; - } - - public String getParkeeChannelStateDesc() - { - return parkeeChannelStateDesc; - } - - public void setParkeeChannelStateDesc(String parkeeChannelStateDesc) - { - this.parkeeChannelStateDesc = parkeeChannelStateDesc; - } - - public String getParkeeCallerIDNum() - { - return parkeeCallerIDNum; - } - - public void setParkeeCallerIDNum(String parkeeCallerIDNum) - { - this.parkeeCallerIDNum = parkeeCallerIDNum; - } - - public String getParkeeCallerIDName() - { - return parkeeCallerIDName; - } - - public void setParkeeCallerIDName(String parkeeCallerIDName) - { - this.parkeeCallerIDName = parkeeCallerIDName; - } - - public Integer getParkeeConnectedLineNum() - { - return parkeeConnectedLineNum; - } - - public void setParkeeConnectedLineNum(Integer parkeeConnectedLineNum) - { - this.parkeeConnectedLineNum = parkeeConnectedLineNum; - } - - public String getParkeeConnectedLineName() - { - return parkeeConnectedLineName; - } - - public void setParkeeConnectedLineName(String parkeeConnectedLineName) - { - this.parkeeConnectedLineName = parkeeConnectedLineName; - } - - public String getParkeeLanguage() - { - return parkeeLanguage; - } - - public void setParkeeLanguage(String parkeeLanguage) - { - this.parkeeLanguage = parkeeLanguage; - } - - public String getParkeeAccountCode() - { - return parkeeAccountCode; - } - - public void setParkeeAccountCode(String parkeeAccountCode) - { - this.parkeeAccountCode = parkeeAccountCode; - } - - public String getParkeeContext() - { - return parkeeContext; - } - - public void setParkeeContext(String parkeeContext) - { - this.parkeeContext = parkeeContext; - } - - public String getParkeeExten() - { - return parkeeExten; - } - - public void setParkeeExten(String parkeeExten) - { - this.parkeeExten = parkeeExten; - } - - public Integer getParkeePriority() - { - return parkeePriority; - } - - public void setParkeePriority(Integer parkeePriority) - { - this.parkeePriority = parkeePriority; - } - - public String getParkeeUniqueid() - { - return parkeeUniqueid; - } - - public void setParkeeUniqueid(String parkeeUniqueid) - { - this.parkeeUniqueid = parkeeUniqueid; - } - - public String getParkerDialString() - { - return parkerDialString; - } - - public void setParkerDialString(String parkerDialString) - { - this.parkerDialString = parkerDialString; - } - - public String getParkinglot() - { - return parkingLot; - } - - public void setParkinglot(String parkinglot) - { - this.parkingLot = parkinglot; - } - - public String getParkingSpace() - { - return parkingSpace; - } - - public void setParkingSpace(String parkingSpace) - { - this.parkingSpace = parkingSpace; - } - - public Long getParkingTimeout() - { - return parkingTimeout; - } - - public void setParkingTimeout(Long parkingTimeout) - { - this.parkingTimeout = parkingTimeout; - } - - public Long getParkingDuration() - { - return parkingDuration; - } - - public void setParkingDuration(Long parkingDuration) - { - this.parkingDuration = parkingDuration; - } - - @Deprecated - public String getCallerId() - { - return getParkeeCallerIDNum(); - } - - @Deprecated - public void setCallerId(String callerId) - { - setParkeeCallerIDNum(callerId); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractQueueMemberEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractQueueMemberEvent.java deleted file mode 100644 index 1ae38cfc1..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractQueueMemberEvent.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class for several queue member related events. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public abstract class AbstractQueueMemberEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -7437833328723536814L; - private String queue; - private String location; - private String memberName; - - /** - * @param source - */ - protected AbstractQueueMemberEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the queue. - * - * @return the name of the queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue. - * - * @param queue the name of the queue. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the name of the member's interface.

- * E.g. the channel name or agent group. - * - * @return the name of the member's interface. - */ - public String getLocation() - { - return location; - } - - /** - * Sets the name of the member's interface. - * - * @param member the name of the member's interface. - */ - public void setLocation(String member) - { - this.location = member; - } - - /** - * Retruns the name of the queue member. - *

- * Available since Asterisk 1.4 - * - * @return the name of the queue member. - * @since 0.3 - */ - public String getMemberName() - { - return memberName; - } - - /** - * Sets the name of the queue member. - *

- * Available since Asterisk 1.4 - * - * @param memberName the name of the queue member. - * @since 0.3 - */ - public void setMemberName(String memberName) - { - this.memberName = memberName; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractRtcpEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractRtcpEvent.java deleted file mode 100644 index 5b52b74da..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractRtcpEvent.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * Abstract base class for RTCP related events. - *

- * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public abstract class AbstractRtcpEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - private Long fractionLost; - private Double dlSr; - private Double iaJitter; - - public AbstractRtcpEvent(Object source) - { - super(source); - } - - /** - * Returns the short term loss ratio. This is the fraction of packets lost - * since the last RR or SR packet was sent. - * - * @return the short term loss ratio. - */ - public Long getFractionLost() - { - return fractionLost; - } - - public void setFractionLost(Long fractionLost) - { - this.fractionLost = fractionLost; - } - - /** - * Returns the interarrival jitter. - * - * @return the interarrival jitter. - */ - public Double getIaJitter() - { - return iaJitter; - } - - public void setIaJitter(Double iaJitter) - { - this.iaJitter = iaJitter; - } - - /** - * Returns the delay since the last SR. - * - * @return the delay since the last SR in seconds. - */ - public Double getDlSr() - { - return dlSr; - } - - public void setDlSr(String dlSrString) - { - this.dlSr = secStringToDouble(dlSrString); - } - - protected Long secStringToLong(String s) - { - if (s == null || s.length() == 0) - { - return null; - } - - if (s.endsWith("(sec)")) - { - return Long.parseLong(s.substring(0, s.length() - "(sec)".length())); - } - return Long.parseLong(s); - } - - protected Double secStringToDouble(String s) - { - if (s == null || s.length() == 0) - { - return null; - } - - if (s.endsWith("(sec)")) - { - return Double.parseDouble(s.substring(0, s.length() - "(sec)".length())); - } - return Double.parseDouble(s); - } - - protected InetAddress stringToAddress(String addressWithPort) - { - final String address; - - if (addressWithPort == null || addressWithPort.length() == 0) - { - return null; - } - - if (addressWithPort.lastIndexOf(':') > 0) - { - address = addressWithPort.substring(0, addressWithPort.lastIndexOf(':')); - } - else - { - address = addressWithPort; - } - - try - { - return InetAddress.getByName(address); - } - catch (UnknownHostException e) - { - // should not happen as we supply a textual IP address - throw new IllegalArgumentException("Unable to convert " + addressWithPort + " to InetAddress", e); - } - } - - protected Integer stringToPort(String addressWithPort) - { - final String port; - - if (addressWithPort == null || addressWithPort.length() == 0) - { - return null; - } - - if (addressWithPort.lastIndexOf(':') > 0) - { - port = addressWithPort.substring(addressWithPort.lastIndexOf(':') + 1); - } - else - { - return null; - } - - return Integer.parseInt(port); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractRtpStatEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractRtpStatEvent.java deleted file mode 100644 index 8987c3324..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractRtpStatEvent.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class for RTP statistics events.

- * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public abstract class AbstractRtpStatEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - private Long ssrc; - private Long lostPackets; - private Double jitter; - - public AbstractRtpStatEvent(Object source) - { - super(source); - } - - /** - * Returns the synchronization source identifier that uniquely identifies the source of a stream. - * - * @return the synchronization source identifier. - */ - public Long getSsrc() - { - return ssrc; - } - - public void setSsrc(Long ssrc) - { - this.ssrc = ssrc; - } - - /** - * Returns the number of lost packets. - * - * @return the number of lost packets. - */ - public Long getLostPackets() - { - return lostPackets; - } - - public void setLostPackets(Long lostPackets) - { - this.lostPackets = lostPackets; - } - - public Double getJitter() - { - return jitter; - } - - public void setJitter(Double jitter) - { - this.jitter = jitter; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractUnParkedEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractUnParkedEvent.java deleted file mode 100644 index d62a092b2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AbstractUnParkedEvent.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Enro 2015-03: Asterisk 13 Support - */ -public class AbstractUnParkedEvent extends AbstractParkedCallEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -7437833328723536814L; - - private String parkerChannel; - private Integer parkerChannelState; - private String parkerChannelStateDesc; - private String parkerCallerIDNum; - private String parkerCallerIDName; - private String parkerConnectedLineNum; - private String parkerConnectedLineName; - private String parkerAccountCode; - private String parkerContext; - private String parkerExten; - private String parkerPriority; - private String parkerUniqueid; - - /** - * @param source - */ - public AbstractUnParkedEvent(Object source) - { - super(source); - } - - public String getParkerChannel() - { - return parkerChannel; - } - - public void setParkerChannel(String parkerChannel) - { - this.parkerChannel = parkerChannel; - } - - public Integer getParkerChannelState() - { - return parkerChannelState; - } - - public void setParkerChannelState(Integer parkerChannelState) - { - this.parkerChannelState = parkerChannelState; - } - - public String getParkerChannelStateDesc() - { - return parkerChannelStateDesc; - } - - public void setParkerChannelStateDesc(String parkerChannelStateDesc) - { - this.parkerChannelStateDesc = parkerChannelStateDesc; - } - - public String getParkerCallerIDNum() - { - return parkerCallerIDNum; - } - - public void setParkerCallerIDNum(String parkerCallerIDNum) - { - this.parkerCallerIDNum = parkerCallerIDNum; - } - - public String getParkerCallerIDName() - { - return parkerCallerIDName; - } - - public void setParkerCallerIDName(String parkerCallerIDName) - { - this.parkerCallerIDName = parkerCallerIDName; - } - - public String getParkerConnectedLineNum() - { - return parkerConnectedLineNum; - } - - public void setParkerConnectedLineNum(String parkerConnectedLineNum) - { - this.parkerConnectedLineNum = parkerConnectedLineNum; - } - - public String getParkerConnectedLineName() - { - return parkerConnectedLineName; - } - - public void setParkerConnectedLineName(String parkerConnectedLineName) - { - this.parkerConnectedLineName = parkerConnectedLineName; - } - - public String getParkerAccountCode() - { - return parkerAccountCode; - } - - public void setParkerAccountCode(String parkerAccountCode) - { - this.parkerAccountCode = parkerAccountCode; - } - - public String getParkerContext() - { - return parkerContext; - } - - public void setParkerContext(String parkerContext) - { - this.parkerContext = parkerContext; - } - - public String getParkerExten() - { - return parkerExten; - } - - public void setParkerExten(String parkerExten) - { - this.parkerExten = parkerExten; - } - - public String getParkerPriority() - { - return parkerPriority; - } - - public void setParkerPriority(String parkerPriority) - { - this.parkerPriority = parkerPriority; - } - - public String getParkerUniqueid() - { - return parkerUniqueid; - } - - public void setParkerUniqueid(String parkerUniqueid) - { - this.parkerUniqueid = parkerUniqueid; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentCallbackLoginEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentCallbackLoginEvent.java deleted file mode 100644 index 08a27f6ec..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentCallbackLoginEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentCallbackLoginEvent is triggered when an agent is successfully logged in using - * AgentCallbackLogin.

- * It is implemented in channels/chan_agent.c - * - * @see org.asteriskjava.manager.event.AgentCallbackLogoffEvent - * @author srt - * @version $Id$ - */ -public class AgentCallbackLoginEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -3510642916347427230L; - private String agent; - private String loginChan; - private String uniqueId; - - /** - * @param source - */ - public AgentCallbackLoginEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the agent that logged in. - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the name of the agent that logged in. - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - public String getLoginChan() - { - return loginChan; - } - - public void setLoginChan(String loginChan) - { - this.loginChan = loginChan; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentCallbackLogoffEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentCallbackLogoffEvent.java deleted file mode 100644 index e95189a83..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentCallbackLogoffEvent.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using - * AgentCallbackLogin is logged of. - *

- * It is implemented in channels/chan_agent.c - * - * @see org.asteriskjava.manager.event.AgentCallbackLoginEvent - * @author srt - * @version $Id$ - */ -public class AgentCallbackLogoffEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 8458799161502800576L; - private String agent; - private String loginChan; - private Long loginTime; - private String reason; - private String uniqueId; - - /** - * @param source - */ - public AgentCallbackLogoffEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the agent that logged off. - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the name of the agent that logged off. - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - public String getLoginChan() - { - return loginChan; - } - - public void setLoginChan(String loginChan) - { - this.loginChan = loginChan; - } - - public Long getLoginTime() - { - return loginTime; - } - - public void setLoginTime(Long loginTime) - { - this.loginTime = loginTime; - } - - /** - * Returns the reason for the logoff. The reason is set to Autologoff if the agent has been - * logged off due to not answering the phone in time. Autologoff is configured by setting - * autologoff to the appropriate number of seconds in agents.conf. - */ - public String getReason() - { - return reason; - } - - /** - * Sets the reason for the logoff. - */ - public void setReason(String reason) - { - this.reason = reason; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentCalledEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentCalledEvent.java deleted file mode 100644 index 8b9fde797..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentCalledEvent.java +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.Map; - -/** - * An AgentCalledEvent is triggered when an agent is rung.
- * To enable AgentCalledEvents you have to set - * eventwhencalled = yes in queues.conf.
- * This event is implemented in apps/app_queue.c - * - * @author srt - * @version $Id$ - */ -public class AgentCalledEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 2L; - - private String queue; - private String agentCalled; - private String channelCalling; - private String destinationChannel; - private String uniqueId; - private String memberName; - - private Map variables; - - private String destExten; - private String destChannelStateDesc; - private String destUniqueId; - private String destConnectedLineNum; - private String destConnectedLineName; - private String destCallerIdName; - private String destCallerIdNum; - private String destContext; - private String destPriority; - private String destChannel; - private String destChannelState; - private String iface; - private String channel; - - private String destAccountCode; - private String language; - private String destLanguage; - private String linkedId; - private String destLinkedId; - - private String accountcode; - - - /** - * @param source - */ - public AgentCalledEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the queue. - *

- * Available since Asterisk 1.6. - * - * @return the name of the queue. - * @since 1.0.0 - */ - public String getQueue() - { - return queue; - } - - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the member interface of the agent that has been called. - * - * @return the member interface of the agent that has been called. - * @see QueueMemberEvent#getLocation() - */ - public String getAgentCalled() - { - return agentCalled; - } - - /** - * Sets the member interface of the agent that has been called. - * - * @param agentCalled the member interface of the agent that has been - * called. - */ - public void setAgentCalled(String agentCalled) - { - this.agentCalled = agentCalled; - } - - /** - * Returns the name of the agent that has been called. - *

- * Available since Asterisk 1.6. - * - * @return the name of the agent that has been called. - * @since 1.0.0 - * @deprecated use {@lkink #getMemberName()} instead (asterisk 13) - */ - @Deprecated - public String getAgentName() - { - return memberName; - } - - @Deprecated - public void setAgentName(String agentName) - { - this.memberName = agentName; - } - - /** - * Returns the name of the caller's channel that is about to be handled by - * the agent. - * - * @return the name of the caller's channel. - */ - public String getChannelCalling() - { - return channelCalling; - } - - /** - * Sets the name of the caller's channel. - * - * @param channelCalling the name of the caller's channel. - */ - public void setChannelCalling(String channelCalling) - { - this.channelCalling = channelCalling; - } - - /** - * Returns the name of the channel calling the agent. - *

- * Available since Asterisk 1.6 - * - * @return the name of the channel calling the agent. - * @since 1.0.0 - */ - public String getDestinationChannel() - { - return destinationChannel; - } - - public void setDestinationChannel(String destinationChannel) - { - this.destinationChannel = destinationChannel; - } - - /** - * Returns the Caller ID number of the caller's channel. - * - * @return the Caller ID number of the caller's channel. - * @deprecated as of 1.0.0, use {@link #getCallerIdNum()} instead. - */ - @Deprecated - public String getCallerId() - { - return callerIdNum; - } - - /** - * Sets the Caller ID number of the caller's channel. - * - * @param callerId the Caller ID number of the caller's channel. - */ - public void setCallerId(String callerId) - { - this.callerIdNum = callerId; - } - - public String getExtension() - { - return exten; - } - - public void setExtension(String extension) - { - this.exten = extension; - } - - /** - * Returns the unique id of the caller's channel that is about to be handled - * by the agent. This corresponds to {@link #getChannelCalling()}. - *

- * Available since Asterisk 1.6 - * - * @return the unique id of the caller's channel. - * @since 1.0.0 - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the Queue Member name. - *

- * Available since Asterisk 13 replace agentName - *

- */ - public String getMemberName() - { - return memberName; - } - - public void setMemberName(String memberName) - { - this.memberName = memberName; - } - - /** - * Returns the channel variables if eventwhencalled is set to - * vars in queues.conf. - *

- * Available since Asterisk 1.6 - * - * @return the channel variables. - * @since 1.0.0 - */ - public Map getVariables() - { - return variables; - } - - /** - * Sets the channel variables. - *

- * Available since Asterisk 1.6 - * - * @param variables the channel variables. - * @since 1.0.0 - */ - public void setVariables(Map variables) - { - this.variables = variables; - } - - /** - * @return the destExten - */ - public String getDestExten() - { - return destExten; - } - - /** - * @param destExten the destExten to set - */ - public void setDestExten(String destExten) - { - this.destExten = destExten; - } - - /** - * @return the destChannelStateDesc - */ - public String getDestChannelStateDesc() - { - return destChannelStateDesc; - } - - /** - * @param destChannelStateDesc the destChannelStateDesc to set - */ - public void setDestChannelStateDesc(String destChannelStateDesc) - { - this.destChannelStateDesc = destChannelStateDesc; - } - - /** - * @return the destUniqueId - */ - public String getDestUniqueId() - { - return destUniqueId; - } - - /** - * @param destUniqueId the destUniqueId to set - */ - public void setDestUniqueId(String destUniqueId) - { - this.destUniqueId = destUniqueId; - } - - /** - * @return the destConnectedLineNum - */ - public String getDestConnectedLineNum() - { - return destConnectedLineNum; - } - - /** - * @param destConnectedLineNum the destConnectedLineNum to set - */ - public void setDestConnectedLineNum(String destConnectedLineNum) - { - this.destConnectedLineNum = destConnectedLineNum; - } - - /** - * @return the destCallerIdName - */ - public String getDestCallerIdName() - { - return destCallerIdName; - } - - /** - * @param destCallerIdName the destCallerIdName to set - */ - public void setDestCallerIdName(String destCallerIdName) - { - this.destCallerIdName = destCallerIdName; - } - - /** - * @return the destCallerIdNum - */ - public String getDestCallerIdNum() - { - return destCallerIdNum; - } - - /** - * @param destCallerIdNum the destCallerIdNum to set - */ - public void setDestCallerIdNum(String destCallerIdNum) - { - this.destCallerIdNum = destCallerIdNum; - } - - /** - * @return the destContext - */ - public String getDestContext() - { - return destContext; - } - - /** - * @param destContext the destContext to set - */ - public void setDestContext(String destContext) - { - this.destContext = destContext; - } - - /** - * @return the destPriority - */ - public String getDestPriority() - { - return destPriority; - } - - /** - * @param destPriority the destPriority to set - */ - public void setDestPriority(String destPriority) - { - this.destPriority = destPriority; - } - - /** - * @return the destChannel - */ - public String getDestChannel() - { - return destChannel; - } - - /** - * @param destChannel the destChannel to set - */ - public void setDestChannel(String destChannel) - { - this.destChannel = destChannel; - } - - /** - * @return the destChannelState - */ - public String getDestChannelState() - { - return destChannelState; - } - - /** - * @param destChannelState the destChannelState to set - */ - public void setDestChannelState(String destChannelState) - { - this.destChannelState = destChannelState; - } - - /** - * @return the iface - */ - public String getInterface() - { - return iface; - } - - /** - * @param iface the iface to set - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * @return the channel - */ - public String getChannel() - { - return channel; - } - - /** - * @param channel the channel to set - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * @return the destConnectedLineName - */ - public String getDestConnectedLineName() - { - return destConnectedLineName; - } - - /** - * @param destConnectedLineName the destConnectedLineName to set - */ - public void setDestConnectedLineName(String destConnectedLineName) - { - this.destConnectedLineName = destConnectedLineName; - } - - public String getDestAccountCode() - { - return destAccountCode; - } - - public void setDestAccountCode(String destAccountCode) - { - this.destAccountCode = destAccountCode; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getDestLanguage() - { - return destLanguage; - } - - public void setDestLanguage(String destLanguage) - { - this.destLanguage = destLanguage; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getDestLinkedId() - { - return destLinkedId; - } - - public void setDestLinkedId(String destLinkedId) - { - this.destLinkedId = destLinkedId; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentCompleteEvent.java deleted file mode 100644 index 22b0c925e..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentCompleteEvent.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentCompleteEvent is triggered when at the end of a call if the caller - * was connected to an agent. - *

- * It is implemented in apps/app_queue.c. - *

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentCompleteEvent extends AbstractAgentEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 2108033737226142194L; - - private Long holdTime; - private Long talkTime; - private String reason; - - private String destExten; - private String destChannelStateDesc; - private String destUniqueId; - private String destConnectedLineNum; - private String destConnectedLineName; - private String destCallerIdName; - private String destCallerIdNum; - private String destContext; - private String destPriority; - private String destChannel; - private String destChannelState; - private String iface; - - private String destAccountCode; - private String language; - private String destLanguage; - private String linkedId; - private String destLinkedId; - private String accountCode; - - public AgentCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns the amount of time the caller was on hold. - * - * @return the amount of time the caller was on hold in seconds. - */ - public Long getHoldTime() - { - return holdTime; - } - - /** - * Sets the amount of time the caller was on hold. - * - * @param holdtime the amount of time the caller was on hold in seconds. - */ - public void setHoldTime(Long holdtime) - { - this.holdTime = holdtime; - } - - /** - * Returns the amount of time the caller talked to the agent. - * - * @return the amount of time the caller talked to the agent in seconds. - */ - public Long getTalkTime() - { - return talkTime; - } - - /** - * Sets the amount of time the caller talked to the agent. - * - * @param talkTime the amount of time the caller talked to the agent in - * seconds. - */ - public void setTalkTime(Long talkTime) - { - this.talkTime = talkTime; - } - - /** - * Returns if the agent or the caller terminated the call. - * - * @return "agent" if the agent terminated the call, "caller" if the caller - * terminated the call. - */ - public String getReason() - { - return reason; - } - - /** - * Sets if the agent or the caller terminated the call. - * - * @param reason "agent" if the agent terminated the call, "caller" if the - * caller terminated the call. - */ - public void setReason(String reason) - { - this.reason = reason; - } - - /** - * @return the destExten - */ - public String getDestExten() - { - return destExten; - } - - /** - * @param destExten the destExten to set - */ - public void setDestExten(String destExten) - { - this.destExten = destExten; - } - - /** - * @return the destChannelStateDesc - */ - public String getDestChannelStateDesc() - { - return destChannelStateDesc; - } - - /** - * @param destChannelStateDesc the destChannelStateDesc to set - */ - public void setDestChannelStateDesc(String destChannelStateDesc) - { - this.destChannelStateDesc = destChannelStateDesc; - } - - /** - * @return the destUniqueId - */ - public String getDestUniqueId() - { - return destUniqueId; - } - - /** - * @param destUniqueId the destUniqueId to set - */ - public void setDestUniqueId(String destUniqueId) - { - this.destUniqueId = destUniqueId; - } - - /** - * @return the destConnectedLineNum - */ - public String getDestConnectedLineNum() - { - return destConnectedLineNum; - } - - /** - * @param destConnectedLineNum the destConnectedLineNum to set - */ - public void setDestConnectedLineNum(String destConnectedLineNum) - { - this.destConnectedLineNum = destConnectedLineNum; - } - - /** - * @return the destConnectedLineName - */ - public String getDestConnectedLineName() - { - return destConnectedLineName; - } - - /** - * @param destConnectedLineName the destConnectedLineName to set - */ - public void setDestConnectedLineName(String destConnectedLineName) - { - this.destConnectedLineName = destConnectedLineName; - } - - /** - * @return the destCallerIdName - */ - public String getDestCallerIdName() - { - return destCallerIdName; - } - - /** - * @param destCallerIdName the destCallerIdName to set - */ - public void setDestCallerIdName(String destCallerIdName) - { - this.destCallerIdName = destCallerIdName; - } - - /** - * @return the destCallerIdNum - */ - public String getDestCallerIdNum() - { - return destCallerIdNum; - } - - /** - * @param destCallerIdNum the destCallerIdNum to set - */ - public void setDestCallerIdNum(String destCallerIdNum) - { - this.destCallerIdNum = destCallerIdNum; - } - - /** - * @return the destContext - */ - public String getDestContext() - { - return destContext; - } - - /** - * @param destContext the destContext to set - */ - public void setDestContext(String destContext) - { - this.destContext = destContext; - } - - /** - * @return the destPriority - */ - public String getDestPriority() - { - return destPriority; - } - - /** - * @param destPriority the destPriority to set - */ - public void setDestPriority(String destPriority) - { - this.destPriority = destPriority; - } - - /** - * @return the destChannel - */ - public String getDestChannel() - { - return destChannel; - } - - /** - * @param destChannel the destChannel to set - */ - public void setDestChannel(String destChannel) - { - this.destChannel = destChannel; - } - - /** - * @return the destChannelState - */ - public String getDestChannelState() - { - return destChannelState; - } - - /** - * @param destChannelState the destChannelState to set - */ - public void setDestChannelState(String destChannelState) - { - this.destChannelState = destChannelState; - } - - /** - * @return the iface - */ - public String getInterface() - { - return iface; - } - - /** - * @param iface the iface to set - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getDestAccountCode() - { - return destAccountCode; - } - - public void setDestAccountCode(String destAccountCode) - { - this.destAccountCode = destAccountCode; - } - - public String getDestLanguage() - { - return destLanguage; - } - - public void setDestLanguage(String destLanguage) - { - this.destLanguage = destLanguage; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getDestLinkedId() - { - return destLinkedId; - } - - public void setDestLinkedId(String destLinkedId) - { - this.destLinkedId = destLinkedId; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentConnectEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentConnectEvent.java deleted file mode 100644 index 7cb712b16..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentConnectEvent.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentConnectEvent is triggered when a caller is connected to an agent. - *

- * It is implemented in apps/app_queue.c. - *

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentConnectEvent extends AbstractAgentEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - private Long holdTime; - private String bridgedChannel; - private Long ringtime; - - private String destExten; - private String destChannelStateDesc; - private String destUniqueId; - private String destConnectedLineNum; - private String destConnectedLineName; - private String destCallerIdName; - private String destCallerIdNum; - private String destContext; - private String destPriority; - private String destChannel; - private String destChannelState; - private String iface; - private String destAccountCode; - private String linkedId; - private String destLinkedId; - private String destLanguage; - private String language; - - private String accountcode; - - public AgentConnectEvent(Object source) - { - super(source); - } - - /** - * Returns the amount of time the caller was on hold. - * - * @return the amount of time the caller was on hold in seconds. - */ - public Long getHoldTime() - { - return holdTime; - } - - /** - * Sets the amount of time the caller was on hold. - * - * @param holdtime the amount of time the caller was on hold in seconds. - */ - public void setHoldTime(Long holdtime) - { - this.holdTime = holdtime; - } - - /** - * Returns the unique ID of the queue member channel that is taking the - * call. This is useful when trying to link recording filenames back to a - * particular call from the queue. - *

- * Available since Asterisk 1.4. - * - * @return the unique ID of the queue member channel that is taking the - * call. - */ - public String getBridgedChannel() - { - return bridgedChannel; - } - - /** - * Sets the unique ID of the queue member channel that is taking the call. - * - * @param bridgedChannel the unique ID of the queue member channel that is - * taking the call. - */ - public void setBridgedChannel(String bridgedChannel) - { - this.bridgedChannel = bridgedChannel; - } - - /** - * Returns the amount of time the agent's channel was ringing before - * answered. - *

- * Available since Asterisk 1.6. - * - * @return the amount of time the agent's channel was ringing before - * answered in seconds. - * @since 1.0.0 - */ - public Long getRingtime() - { - return ringtime; - } - - public void setRingtime(Long ringtime) - { - this.ringtime = ringtime; - } - - /** - * @return the destExten - */ - public String getDestExten() - { - return destExten; - } - - /** - * @param destExten the destExten to set - */ - public void setDestExten(String destExten) - { - this.destExten = destExten; - } - - /** - * @return the destChannelStateDesc - */ - public String getDestChannelStateDesc() - { - return destChannelStateDesc; - } - - /** - * @param destChannelStateDesc the destChannelStateDesc to set - */ - public void setDestChannelStateDesc(String destChannelStateDesc) - { - this.destChannelStateDesc = destChannelStateDesc; - } - - /** - * @return the destUniqueId - */ - public String getDestUniqueId() - { - return destUniqueId; - } - - /** - * @param destUniqueId the destUniqueId to set - */ - public void setDestUniqueId(String destUniqueId) - { - this.destUniqueId = destUniqueId; - } - - /** - * @return the destConnectedLineNum - */ - public String getDestConnectedLineNum() - { - return destConnectedLineNum; - } - - /** - * @param destConnectedLineNum the destConnectedLineNum to set - */ - public void setDestConnectedLineNum(String destConnectedLineNum) - { - this.destConnectedLineNum = destConnectedLineNum; - } - - /** - * @return the destConnectedLineName - */ - public String getDestConnectedLineName() - { - return destConnectedLineName; - } - - /** - * @param destConnectedLineName the destConnectedLineName to set - */ - public void setDestConnectedLineName(String destConnectedLineName) - { - this.destConnectedLineName = destConnectedLineName; - } - - /** - * @return the destCallerIdName - */ - public String getDestCallerIdName() - { - return destCallerIdName; - } - - /** - * @param destCallerIdName the destCallerIdName to set - */ - public void setDestCallerIdName(String destCallerIdName) - { - this.destCallerIdName = destCallerIdName; - } - - /** - * @return the destCallerIdNum - */ - public String getDestCallerIdNum() - { - return destCallerIdNum; - } - - /** - * @param destCallerIdNum the destCallerIdNum to set - */ - public void setDestCallerIdNum(String destCallerIdNum) - { - this.destCallerIdNum = destCallerIdNum; - } - - /** - * @return the destContext - */ - public String getDestContext() - { - return destContext; - } - - /** - * @param destContext the destContext to set - */ - public void setDestContext(String destContext) - { - this.destContext = destContext; - } - - /** - * @return the destPriority - */ - public String getDestPriority() - { - return destPriority; - } - - /** - * @param destPriority the destPriority to set - */ - public void setDestPriority(String destPriority) - { - this.destPriority = destPriority; - } - - /** - * @return the destChannel - */ - public String getDestChannel() - { - return destChannel; - } - - /** - * @param destChannel the destChannel to set - */ - public void setDestChannel(String destChannel) - { - this.destChannel = destChannel; - } - - /** - * @return the destChannelState - */ - public String getDestChannelState() - { - return destChannelState; - } - - /** - * @param destChannelState the destChannelState to set - */ - public void setDestChannelState(String destChannelState) - { - this.destChannelState = destChannelState; - } - - /** - * @return the iface - */ - public String getInterface() - { - return iface; - } - - /** - * @param iface the iface to set - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - public String getDestAccountCode() - { - return destAccountCode; - } - - public void setDestAccountCode(String destAccountCode) - { - this.destAccountCode = destAccountCode; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getDestLinkedId() - { - return destLinkedId; - } - - public void setDestLinkedId(String destLinkedId) - { - this.destLinkedId = destLinkedId; - } - - public String getDestLanguage() - { - return destLanguage; - } - - public void setDestLanguage(String destLanguage) - { - this.destLanguage = destLanguage; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentDumpEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentDumpEvent.java deleted file mode 100644 index 11b075879..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentDumpEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentDumpEvent is triggered when an agent dumps the caller while listening - * to the queue announcement.

- * It is implemented in apps/app_queue.c.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentDumpEvent extends AbstractAgentEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 2108033737226142194L; - - public AgentDumpEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentLoginEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentLoginEvent.java deleted file mode 100644 index bbedc1e5e..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentLoginEvent.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentLoginEvent is triggered when an agent is successfully logged in using AgentLogin.

- * It is implemented in channels/chan_agent.c - * - * @see org.asteriskjava.manager.event.AgentLogoffEvent - * @author srt - * @version $Id$ - */ -public class AgentLoginEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 7125917930904957919L; - private String agent; - private String channel; - private String uniqueId; - - /** - * @param source - */ - public AgentLoginEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the agent that logged in. - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the name of the agent that logged in. - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - /** - * Returns the name of the channel associated with the logged in agent. - * - * @deprecated use {@link #getChannel()} instead. - */ - @Deprecated public String getLoginChan() - { - return channel; - } - - /** - * Returns the name of the channel associated with the logged in agent. - * - * @return the name of the channel associated with the logged in agent. - * @since 0.3 - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel associated with the logged in agent. - * - * @param channel the name of the channel associated with the logged in agent. - * @since 0.3 - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel associated with the logged in agent. - * - * @return the unique id of the channel associated with the logged in agent. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel associated with the logged in agent. - * - * @param uniqueId the unique id of the channel associated with the logged in agent. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentLogoffEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentLogoffEvent.java deleted file mode 100644 index 2c4b8dc8d..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentLogoffEvent.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using AgentLogin - * is logged of.

- * It is implemented in channels/chan_agent.c - * - * @see org.asteriskjava.manager.event.AgentLoginEvent - * @author srt - * @version $Id$ - */ -public class AgentLogoffEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -3482474719161350942L; - - /** - * The name of the agent that logged off. - */ - private String agent; - private String loginTime; - private String uniqueId; - - /** - * @param source - */ - public AgentLogoffEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the agent that logged off. - * - * @return the name of the agent that logged off. - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the name of the agent that logged off. - * - * @param agent the name of the agent that logged off. - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - public String getLoginTime() - { - return loginTime; - } - - public void setLoginTime(String loginTime) - { - this.loginTime = loginTime; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentRingNoAnswerEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentRingNoAnswerEvent.java deleted file mode 100644 index ca946236f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentRingNoAnswerEvent.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentRingNoAnswerEvent is triggered when a call is routed to an agent but - * the agent does not answer the call. - *

- * It is implemented in apps/app_queue.c. - *

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class AgentRingNoAnswerEvent extends AbstractAgentEvent -{ - private static final long serialVersionUID = 2L; - - private Long ringtime; - - private String destExten; - private String destChannelStateDesc; - private String destUniqueId; - private String destConnectedLineNum; - private String destConnectedLineName; - private String destCallerIdName; - private String destCallerIdNum; - private String destContext; - private String destPriority; - private String destChannel; - private String destChannelState; - private String iface; - - private String destAccountCode; - private String language; - private String destLanguage; - private String linkedId; - private String destLinkedId; - - private String accountcode; - - public AgentRingNoAnswerEvent(Object source) - { - super(source); - } - - /** - * Returns the amount of time the agent's channel was ringing. - * - * @return the amount of time the agent's channel was ringing in seconds. - */ - public Long getRingtime() - { - return ringtime; - } - - public void setRingtime(Long ringtime) - { - this.ringtime = ringtime; - } - - /** - * @return the destExten - */ - public String getDestExten() - { - return destExten; - } - - /** - * @param destExten the destExten to set - */ - public void setDestExten(String destExten) - { - this.destExten = destExten; - } - - /** - * @return the destChannelStateDesc - */ - public String getDestChannelStateDesc() - { - return destChannelStateDesc; - } - - /** - * @param destChannelStateDesc the destChannelStateDesc to set - */ - public void setDestChannelStateDesc(String destChannelStateDesc) - { - this.destChannelStateDesc = destChannelStateDesc; - } - - /** - * @return the destUniqueId - */ - public String getDestUniqueId() - { - return destUniqueId; - } - - /** - * @param destUniqueId the destUniqueId to set - */ - public void setDestUniqueId(String destUniqueId) - { - this.destUniqueId = destUniqueId; - } - - /** - * @return the destConnectedLineNum - */ - public String getDestConnectedLineNum() - { - return destConnectedLineNum; - } - - /** - * @param destConnectedLineNum the destConnectedLineNum to set - */ - public void setDestConnectedLineNum(String destConnectedLineNum) - { - this.destConnectedLineNum = destConnectedLineNum; - } - - /** - * @return the destConnectedLineName - */ - public String getDestConnectedLineName() - { - return destConnectedLineName; - } - - /** - * @param destConnectedLineName the destConnectedLineName to set - */ - public void setDestConnectedLineName(String destConnectedLineName) - { - this.destConnectedLineName = destConnectedLineName; - } - - /** - * @return the destCallerIdName - */ - public String getDestCallerIdName() - { - return destCallerIdName; - } - - /** - * @param destCallerIdName the destCallerIdName to set - */ - public void setDestCallerIdName(String destCallerIdName) - { - this.destCallerIdName = destCallerIdName; - } - - /** - * @return the destCallerIdNum - */ - public String getDestCallerIdNum() - { - return destCallerIdNum; - } - - /** - * @param destCallerIdNum the destCallerIdNum to set - */ - public void setDestCallerIdNum(String destCallerIdNum) - { - this.destCallerIdNum = destCallerIdNum; - } - - /** - * @return the destContext - */ - public String getDestContext() - { - return destContext; - } - - /** - * @param destContext the destContext to set - */ - public void setDestContext(String destContext) - { - this.destContext = destContext; - } - - /** - * @return the destPriority - */ - public String getDestPriority() - { - return destPriority; - } - - /** - * @param destPriority the destPriority to set - */ - public void setDestPriority(String destPriority) - { - this.destPriority = destPriority; - } - - /** - * @return the destChannel - */ - public String getDestChannel() - { - return destChannel; - } - - /** - * @param destChannel the destChannel to set - */ - public void setDestChannel(String destChannel) - { - this.destChannel = destChannel; - } - - /** - * @return the destChannelState - */ - public String getDestChannelState() - { - return destChannelState; - } - - /** - * @param destChannelState the destChannelState to set - */ - public void setDestChannelState(String destChannelState) - { - this.destChannelState = destChannelState; - } - - /** - * @return the iface - */ - public String getInterface() - { - return iface; - } - - /** - * @param iface the iface to set - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - public String getDestAccountCode() - { - return destAccountCode; - } - - public void setDestAccountCode(String destAccountCode) - { - this.destAccountCode = destAccountCode; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getDestLanguage() - { - return destLanguage; - } - - public void setDestLanguage(String destLanguage) - { - this.destLanguage = destLanguage; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getDestLinkedId() - { - return destLinkedId; - } - - public void setDestLinkedId(String destLinkedId) - { - this.destLinkedId = destLinkedId; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentsCompleteEvent.java deleted file mode 100644 index b48cde5bd..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentsCompleteEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentsCompleteEvent is triggered after the state of all agents has been - * reported in response to an AgentsAction.

- * Available since Asterisk 1.2 - * - * @see org.asteriskjava.manager.action.AgentsAction - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentsCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -1177773673509373296L; - - private Integer listItems; - private String eventList; - - /** - * @param source - */ - public AgentsCompleteEvent(Object source) - { - super(source); - } - - public Integer getListItems() - { - return listItems; - } - - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } - - public String getEventList() - { - return eventList; - } - - public void setEventList(String eventList) - { - this.eventList = eventList; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgentsEvent.java b/src/main/java/org/asteriskjava/manager/event/AgentsEvent.java deleted file mode 100644 index 1447be3ee..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgentsEvent.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AgentsEvent is triggered for each agent in response to an AgentsAction. - *

- * Available since Asterisk 1.2 - * - * @see org.asteriskjava.manager.action.AgentsAction - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class AgentsEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 0L; - - /** - * Agent isn't logged in. - */ - public static final String AGENT_STATUS_LOGGEDOFF = "AGENT_LOGGEDOFF"; - - /** - * Agent is logged in and waiting for call. - */ - public static final String AGENT_STATUS_IDLE = "AGENT_IDLE"; - - /** - * Agent is logged in and on a call. - */ - public static final String AGENT_STATUS_ONCALL = "AGENT_ONCALL"; - - /** - * Don't know anything about agent. Shouldn't ever get this. - */ - public static final String AGENT_STATUS_UNKNOWN = "AGENT_UNKNOWN"; - - private String agent; - private String name; - private String status; - private String loggedInChan; - private Long loggedInTime; - private String talkingTo; - private String talkingToChan; - - /** - * @param source - */ - public AgentsEvent(Object source) - { - super(source); - } - - /** - * Returns the agentid. - */ - public String getAgent() - { - return agent; - } - - /** - * Sets the agentid. - */ - public void setAgent(String agent) - { - this.agent = agent; - } - - /** - * Returns the name of this agent. - * - * @return the name of this agent - */ - public String getName() - { - return name; - } - - /** - * Sets the name of this agent. - * - * @param name the name of this agent - */ - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the status of this agent. - *

- * This is one of - *

- *
"AGENT_LOGGEDOFF"
- *
Agent isn't logged in
- *
"AGENT_IDLE"
- *
Agent is logged in and waiting for call
- *
"AGENT_ONCALL"
- *
Agent is logged in and on a call
- *
"AGENT_UNKNOWN"
- *
Don't know anything about agent. Shouldn't ever get this.
- *
- * - * @return the status of this agent - * @see #AGENT_STATUS_LOGGEDOFF - * @see #AGENT_STATUS_IDLE - * @see #AGENT_STATUS_ONCALL - * @see #AGENT_STATUS_UNKNOWN - */ - public String getStatus() - { - return status; - } - - /** - * Sets the status of this agent. - * - * @param status the status of this agent - */ - public void setStatus(String status) - { - this.status = status; - } - - /** - * Returns the name of channel this agent logged in from. - * - * @return the name of the channel this agent logged in from or "n/a" if the - * agent is not logged in. - */ - public String getLoggedInChan() - { - return loggedInChan; - } - - /** - * Sets the name of channel this agent logged in from. - * - * @param loggedInChan the name of channel this agent logged in from - */ - public void setLoggedInChan(String loggedInChan) - { - this.loggedInChan = loggedInChan; - } - - /** - * Returns the time (in seconds since 01/01/1970) when the agent logged in. - * - * @return the time when the agent logged in or 0 if the user is not logged - * in. - */ - public Long getLoggedInTime() - { - return loggedInTime; - } - - /** - * Sets the time when the agent logged in. - * - * @param loggedInTime the time when the agent logged in - */ - public void setLoggedInTime(Long loggedInTime) - { - this.loggedInTime = loggedInTime; - } - - /** - * Returns the numerical Caller*ID of the channel this agent is talking to. - * - * @return the numerical Caller*ID of the channel this agent is talking to - * or "n/a" if this agent is talking to nobody. - */ - public String getTalkingTo() - { - return talkingTo; - } - - /** - * Sets the numerical Caller*ID of the channel this agent is talking to. - * - * @param talkingTo the numerical Caller*ID of the channel this agent is - * talking to - */ - public void setTalkingTo(String talkingTo) - { - this.talkingTo = talkingTo; - } - - /** - * Returns the name of the channel this agent is talking to.

- * Available since Asterisk 1.6. - * - * @return the name of the channel this agent is talking to. - * @since 1.0.0 - */ - public String getTalkingToChan() - { - return talkingToChan; - } - - public void setTalkingToChan(String talkingToChan) - { - this.talkingToChan = talkingToChan; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgiExecEndEvent.java b/src/main/java/org/asteriskjava/manager/event/AgiExecEndEvent.java deleted file mode 100644 index 7d757b7b5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgiExecEndEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class AgiExecEndEvent extends AgiExecEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public AgiExecEndEvent(Object source) - { - super(source); - setSubEvent(SUB_EVENT_END); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgiExecEvent.java b/src/main/java/org/asteriskjava/manager/event/AgiExecEvent.java deleted file mode 100644 index 4fc78bf87..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgiExecEvent.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * AgiExecEvents are triggered when an AGI command is executed. For each command two events are triggered: - * one before excution ("Start") and one after execution ("End"). - *
- * The following sub events are reported: - *

    - *
  • Start: Execution of an AGI command has started.
  • - *
  • End: Execution of an AGI command has finished.
  • - *
- * It is implemented in res/res_agi.c. - *
- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class AgiExecEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - /** - * Execution of an AGI command has started. - */ - public static final String SUB_EVENT_START = "Start"; - - /** - * Execution of an AGI command has finished. - */ - public static final String SUB_EVENT_END = "End"; - - private String channel; - private String subEvent; - private String commandId; - private String command; - private Integer resultCode; - private String result; - private String accountCode; - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - private String uniqueId; - - /** - * Creates a new AgiExecEvent. - * - * @param source - */ - public AgiExecEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel this event occurred on. - * - * @return the name of the channel this event occurred on. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel this event occurred on. - * - * @param channel the name of the channel this event occurred on. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the sub event type. This is either "Start" or "End". - * - * @return the sub event type. - * @see #SUB_EVENT_START - * @see #SUB_EVENT_END - */ - public String getSubEvent() - { - return subEvent; - } - - /** - * Sets the sub event type. - * - * @param subEvent the sub event type. - */ - public void setSubEvent(String subEvent) - { - this.subEvent = subEvent; - } - - /** - * Returns the command id. The command is a random number generated by Asterisk that allows matching the "End" sub event with the corresponding "Start" sub event. - * - * @return the command id. - */ - public String getCommandId() - { - return commandId; - } - - /** - * Sets the command id. - * - * @param commandId the command id. - */ - public void setCommandId(String commandId) - { - this.commandId = commandId; - } - - /** - * Returns the AGI command. - * - * @return the AGI command. - */ - public String getCommand() - { - return command; - } - - /** - * Sets the AGI command. - * - * @param command the AGI command. - */ - public void setCommand(String command) - { - this.command = command; - } - - /** - * Returns the result code. - * - * @return the result code. - */ - public Integer getResultCode() - { - return resultCode; - } - - /** - * Sets the result code. - * - * @param resultCode the result code. - */ - public void setResultCode(Integer resultCode) - { - this.resultCode = resultCode; - } - - /** - * Returns the result as a string.

- * They correspond to the numeric values returned by {@link #getResultCode()}. Usually you will want to stick with the numeric values.

- * Possible values are: - *

    - *
  • Failure (corresponds to result code -1)
  • - *
  • Success (corresponds to result code 200)
  • - *
  • KeepAlive (corresponds to result code 210)
  • - *
  • Command not permitted on a dead channel (corresponds to result code 511)
  • - *
  • Usage (corresponds to result code 520)
  • - *
- * - * @return a string respresentation of the result. - */ - public String getResult() - { - return result; - } - - /** - * Sets the string respresentation of the result. - * - * @param result a string respresentation of the result. - */ - public void setResult(String result) - { - this.result = result; - } - - /** - * Returns the account code set for CDR. - * - * @return string - */ - public String getAccountCode() - { - return accountCode; - } - - /** - * Sets the account code used for billing in the CDR. - *
- * This will be the filename asterisk stores the billing informations in, so it should only use lowercase letters, numbers, hyphen and underscore. - * - * @param accountCode - */ - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - /** - * Checks is this a start sub event. - * - * @return true if this is a "Start" sub event, false otherwise. - */ - public boolean isStart() - { - return isSubEvent(SUB_EVENT_START); - } - - /** - * Checks is this an end sub event. - * - * @return true if this is an "End" sub event, false otherwise. - */ - public boolean isEnd() - { - return isSubEvent(SUB_EVENT_END); - } - - private boolean isSubEvent(String subEvent) - { - return this.subEvent != null && this.subEvent.equalsIgnoreCase(subEvent); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AgiExecStartEvent.java b/src/main/java/org/asteriskjava/manager/event/AgiExecStartEvent.java deleted file mode 100644 index a2d483cc3..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AgiExecStartEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class AgiExecStartEvent extends AgiExecEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public AgiExecStartEvent(Object source) - { - super(source); - setSubEvent(SUB_EVENT_START); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AlarmClearEvent.java b/src/main/java/org/asteriskjava/manager/event/AlarmClearEvent.java deleted file mode 100644 index a0be33356..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AlarmClearEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AlarmEvent is triggered when a Zap channel leaves alarm state.

- * It is implemented in channels/chan_zap.c - * - * @author srt - * @version $Id$ - */ -public class AlarmClearEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -3584791971422266558L; - - /** - * The number of the zap channel that left alarm state. - */ - private Integer channel; - - /** - * @param source - */ - public AlarmClearEvent(Object source) - { - super(source); - } - - /** - * Returns the number of the zap channel that left alarm state. - * - * @return the number of the zap channel that left alarm state. - */ - public Integer getChannel() - { - return channel; - } - - /** - * Sets the number of the zap channel that left alarm state. - * - * @param channel the number of the zap channel that left alarm state. - */ - public void setChannel(Integer channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AlarmEvent.java b/src/main/java/org/asteriskjava/manager/event/AlarmEvent.java deleted file mode 100644 index 1f490e9bc..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AlarmEvent.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An AlarmEvent is triggered when a Zap channel enters or changes alarm state.

- * It is implemented in channels/chan_zap.c - * - * @author srt - * @version $Id$ - */ -public class AlarmEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 5235245336934457877L; - private String alarm; - private Integer channel; - - /** - * @param source - */ - public AlarmEvent(Object source) - { - super(source); - } - - /** - * Returns the kind of alarm that happened.

- * This may be one of - *

    - *
  • Red Alarm
  • - *
  • Yellow Alarm
  • - *
  • Blue Alarm
  • - *
  • Recovering
  • - *
  • Loopback
  • - *
  • Not Open
  • - *
- */ - public String getAlarm() - { - return alarm; - } - - /** - * Sets the kind of alarm that happened. - */ - public void setAlarm(String alarm) - { - this.alarm = alarm; - } - - /** - * Returns the number of the channel the alarm occured on. - */ - public Integer getChannel() - { - return channel; - } - - /** - * Sets the number of the channel the alarm occured on. - */ - public void setChannel(Integer channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AntennaLevelEvent.java b/src/main/java/org/asteriskjava/manager/event/AntennaLevelEvent.java deleted file mode 100644 index bdf91332c..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AntennaLevelEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.asteriskjava.manager.event; - -public class AntennaLevelEvent extends AbstractChannelEvent { - - /** - * - */ - private static final long serialVersionUID = 7687745700915865011L; - - private String signal; - - public AntennaLevelEvent(Object source) { - super(source); - } - - public String getSignal() { - return signal; - } - - public void setSignal(String signal) { - this.signal = signal; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/AsyncAgiEndEvent.java b/src/main/java/org/asteriskjava/manager/event/AsyncAgiEndEvent.java deleted file mode 100644 index 944f79340..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AsyncAgiEndEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class AsyncAgiEndEvent extends AsyncAgiEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public AsyncAgiEndEvent(Object source) - { - super(source); - setSubEvent(SUB_EVENT_END); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AsyncAgiEvent.java b/src/main/java/org/asteriskjava/manager/event/AsyncAgiEvent.java deleted file mode 100644 index ac25a9be2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AsyncAgiEvent.java +++ /dev/null @@ -1,263 +0,0 @@ -package org.asteriskjava.manager.event; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * - * The following sub events are reported: - *
    - *
  • Start: A channel has started the AGI("agi:async") application and is awaiting Async AGI commands.
  • - *
  • Exec: Execution of an AGI command initiated through {@link org.asteriskjava.manager.action.AgiAction} - * has finished.
  • - *
  • End: A channel has left the AGI("agi:async") application.
  • - *
- * It is implemented in res/res_agi.c. - *
- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.AgiAction - * @since 1.0.0 - */ -public class AsyncAgiEvent extends ResponseEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - public static final String SUB_EVENT_START = "Start"; - public static final String SUB_EVENT_EXEC = "Exec"; - public static final String SUB_EVENT_END = "End"; - - private String channel; - private String subEvent; - private String commandId; - private String result; - private String env; - private String uniqueId; - - public String getUniqueId() { - return uniqueId; - } - - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; - } - - /** - * Creates a new AsyncAgiEvent. - * - * @param source - */ - public AsyncAgiEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel this event occurred on. - * - * @return the name of the channel this event occurred on. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel this event occurred on. - * - * @param channel the name of the channel this event occurred on. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the sub event type. This is either "Start", "Exec" or "End". - * - * @return the sub event type. - */ - public String getSubEvent() - { - return subEvent; - } - - /** - * Sets the sub event type. - * - * @param subEvent the sub event type. - */ - public void setSubEvent(String subEvent) - { - this.subEvent = subEvent; - } - - /** - * Returns the command id of the corresponding {@link org.asteriskjava.manager.action.AgiAction}.

- * This property is only available for the "Exec" sub event. - * - * @return the command id. - * @see org.asteriskjava.manager.action.AgiAction#setCommandId(String) - */ - public String getCommandId() - { - return commandId; - } - - /** - * Sets the command id. - * - * @param commandId the command id. - */ - public void setCommandId(String commandId) - { - this.commandId = commandId; - } - - /** - * Returns the raw result of a command execution in response to the corresponding - * {@link org.asteriskjava.manager.action.AgiAction}.

- * This property is only available for the "Exec" sub event.

- * The result is URL encoded and ends with a newline ("\n").

- * Example: - *

-     * 200%20result%3d0
-     * 
- * - * @return the URL encoded result. - */ - public String getResult() - { - return result; - } - - /** - * Decodes the result. - * - * @return the decoded result. - */ - public List decodeResult() - { - return decode(getResult()); - } - - /** - * Sets the raw result. - * - * @param result the URL encoded result. - */ - public void setResult(String result) - { - this.result = result; - } - - /** - * Returns the raw AGI environment similar to the AGI request for FastAGI.

- * This property is only available for the "Start" sub event.

- * The environment is passed in multiple lines (separated by "\n"). Each line is URL encoded - * and contains a key and a value. The environment ends with two newline characters ("\n\n").

- * Example: - *

-     * ...
-     * agi_channel%3a%20IAX2%2fpbx0-1
-     * agi_language%3a%20de
-     * agi_type%3a%20IAX2
-     * agi_uniqueid%3a%201201838738.19
-     * agi_version%3a%201.6.0-beta1
-     * ...
-     * 
- * - * @return the URL encoded AGI environment. - */ - public String getEnv() - { - return env; - } - - /** - * Decodes the AGI environment and returns a list of lines. - * - * @return The decoded AGI environment or an empty list if the environment is not available (that is - * if {@link #getEnv()} returns null). - * @see #getEnv() - */ - public List decodeEnv() - { - return decode(getEnv()); - } - - private List decode(String s) - { - final List result = new ArrayList<>(); - - if (s == null) - { - return result; - } - - try - { - final String decodedString = URLDecoder.decode(s, "UTF-8"); - result.addAll(Arrays.asList(decodedString.split("\n"))); - } - catch (UnsupportedEncodingException e) - { - throw new RuntimeException("This JDK does not support UTF-8 encoding", e); - } - - return result; - } - - /** - * Sets the AGI environment. - * - * @param env the URL encoded AGI environment. - */ - public void setEnv(String env) - { - this.env = env; - } - - /** - * Checks is this a start sub event. - * - * @return true if this is a "Start" sub event, false otherwise. - */ - public boolean isStart() - { - return isSubEvent(SUB_EVENT_START); - } - - /** - * Checks is this an exec sub event. - * - * @return true if this is an "Exec" sub event, false otherwise. - */ - public boolean isExec() - { - return isSubEvent(SUB_EVENT_EXEC); - } - - /** - * Checks is this an end sub event. - * - * @return true if this is an "End" sub event, false otherwise. - */ - public boolean isEnd() - { - return isSubEvent(SUB_EVENT_END); - } - - protected boolean isSubEvent(String subEvent) - { - return this.subEvent != null && this.subEvent.equalsIgnoreCase(subEvent); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AsyncAgiExecEvent.java b/src/main/java/org/asteriskjava/manager/event/AsyncAgiExecEvent.java deleted file mode 100644 index adde1cca7..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AsyncAgiExecEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class AsyncAgiExecEvent extends AsyncAgiEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public AsyncAgiExecEvent(Object source) - { - super(source); - setSubEvent(SUB_EVENT_EXEC); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AsyncAgiStartEvent.java b/src/main/java/org/asteriskjava/manager/event/AsyncAgiStartEvent.java deleted file mode 100644 index 1e924079a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AsyncAgiStartEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class AsyncAgiStartEvent extends AsyncAgiEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public AsyncAgiStartEvent(Object source) - { - super(source); - setSubEvent(SUB_EVENT_START); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/AttendedTransferEvent.java b/src/main/java/org/asteriskjava/manager/event/AttendedTransferEvent.java deleted file mode 100644 index 3795665e2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/AttendedTransferEvent.java +++ /dev/null @@ -1,940 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Raised when attended transfer is complete - * - * https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_AttendedTransfer - */ -public class AttendedTransferEvent extends AbstractBridgeEvent { - private static final long serialVersionUID = 1L; - - private String origTransfererChannel; - private String origTransfererChannelState; - private String origTransfererChannelStateDesc; - private String origTransfererCallerIDNum; - private String origTransfererCallerIDName; - private String origTransfererConnectedLineNum; - private String origTransfererConnectedLineName; - private String origTransfererAccountCode; - private String origTransfererContext; - private String origTransfererExten; - private String origTransfererPriority; - private String origTransfererUniqueid; - private String origBridgeUniqueid; - private String origBridgeType; - private String origBridgeTechnology; - private String origBridgeCreator; - private String origBridgeName; - private String origBridgeNumChannels; - private String secondTransfererChannel; - private String secondTransfererChannelState; - private String secondTransfererChannelStateDesc; - private String secondTransfererCallerIDNum; - private String secondTransfererCallerIDName; - private String secondTransfererConnectedLineNum; - private String secondTransfererConnectedLineName; - private String secondTransfererAccountCode; - private String secondTransfererContext; - private String secondTransfererExten; - private String secondTransfererPriority; - private String secondTransfererUniqueid; - private String secondBridgeUniqueid; - private String secondBridgeType; - private String secondBridgeTechnology; - private String secondBridgeCreator; - private String secondBridgeName; - private String secondBridgeNumChannels; - private String destType; - private String destBridgeUniqueid; - private String destApp; - private String localOneChannel; - private String localOneChannelState; - private String localOneChannelStateDesc; - private String localOneCallerIDNum; - private String localOneCallerIDName; - private String localOneConnectedLineNum; - private String localOneConnectedLineName; - private String localOneAccountCode; - private String localOneContext; - private String localOneExten; - private String localOnePriority; - private String localOneUniqueid; - private String localTwoChannel; - private String localTwoChannelState; - private String localTwoChannelStateDesc; - private String localTwoCallerIDNum; - private String localTwoCallerIDName; - private String localTwoConnectedLineNum; - private String localTwoConnectedLineName; - private String localTwoAccountCode; - private String localTwoContext; - private String localTwoExten; - private String localTwoPriority; - private String localTwoUniqueid; - private String destTransfererChannel; - private String transfereeChannel; - private String transfereeChannelState; - private String transfereeChannelStateDesc; - private String transfereeCallerIDNum; - private String transfereeCallerIDName; - private String transfereeConnectedLineNum; - private String transfereeConnectedLineName; - private String transfereeAccountCode; - private String transfereeContext; - private String transfereeExten; - private String transfereePriority; - private String transfereeUniqueid; - - private String transfereeLinkedId; - private String transfereeLanguage; - private String origTransfererLinkedId; - private String secondTransfererLanguage; - private String isexternal; - private String result; - private String secondTransfererLinkedId; - private String origTransfererLanguage; - - public AttendedTransferEvent(Object source) - { - super(source); - } - - public String getOrigTransfererChannel() - { - return origTransfererChannel; - } - - public void setOrigTransfererChannel(String origTransfererChannel) - { - this.origTransfererChannel = origTransfererChannel; - } - - public String getOrigTransfererChannelState() - { - return origTransfererChannelState; - } - - public void setOrigTransfererChannelState(String origTransfererChannelState) - { - this.origTransfererChannelState = origTransfererChannelState; - } - - public String getOrigTransfererChannelStateDesc() - { - return origTransfererChannelStateDesc; - } - - public void setOrigTransfererChannelStateDesc(String origTransfererChannelStateDesc) - { - this.origTransfererChannelStateDesc = origTransfererChannelStateDesc; - } - - public String getOrigTransfererCallerIDNum() - { - return origTransfererCallerIDNum; - } - - public void setOrigTransfererCallerIDNum(String origTransfererCallerIDNum) - { - this.origTransfererCallerIDNum = origTransfererCallerIDNum; - } - - public String getOrigTransfererCallerIDName() - { - return origTransfererCallerIDName; - } - - public void setOrigTransfererCallerIDName(String origTransfererCallerIDName) - { - this.origTransfererCallerIDName = origTransfererCallerIDName; - } - - public String getOrigTransfererConnectedLineNum() - { - return origTransfererConnectedLineNum; - } - - public void setOrigTransfererConnectedLineNum(String origTransfererConnectedLineNum) - { - this.origTransfererConnectedLineNum = origTransfererConnectedLineNum; - } - - public String getOrigTransfererConnectedLineName() - { - return origTransfererConnectedLineName; - } - - public void setOrigTransfererConnectedLineName(String origTransfererConnectedLineName) - { - this.origTransfererConnectedLineName = origTransfererConnectedLineName; - } - - public String getOrigTransfererAccountCode() - { - return origTransfererAccountCode; - } - - public void setOrigTransfererAccountCode(String origTransfererAccountCode) { - this.origTransfererAccountCode = origTransfererAccountCode; - } - - public String getOrigTransfererContext() - { - return origTransfererContext; - } - - public void setOrigTransfererContext(String origTransfererContext) - { - this.origTransfererContext = origTransfererContext; - } - - public String getOrigTransfererExten() - { - return origTransfererExten; - } - - public void setOrigTransfererExten(String origTransfererExten) - { - this.origTransfererExten = origTransfererExten; - } - - public String getOrigTransfererPriority() - { - return origTransfererPriority; - } - - public void setOrigTransfererPriority(String origTransfererPriority) - { - this.origTransfererPriority = origTransfererPriority; - } - - public String getOrigTransfererUniqueid() - { - return origTransfererUniqueid; - } - - public void setOrigTransfererUniqueid(String origTransfererUniqueid) - { - this.origTransfererUniqueid = origTransfererUniqueid; - } - - public String getOrigBridgeUniqueid() - { - return origBridgeUniqueid; - } - - public void setOrigBridgeUniqueid(String origBridgeUniqueid) - { - this.origBridgeUniqueid = origBridgeUniqueid; - } - - public String getOrigBridgeType() - { - return origBridgeType; - } - - public void setOrigBridgeType(String origBridgeType) - { - this.origBridgeType = origBridgeType; - } - - public String getOrigBridgeTechnology() - { - return origBridgeTechnology; - } - - public void setOrigBridgeTechnology(String origBridgeTechnology) - { - this.origBridgeTechnology = origBridgeTechnology; - } - - public String getOrigBridgeCreator() - { - return origBridgeCreator; - } - - public void setOrigBridgeCreator(String origBridgeCreator) - { - this.origBridgeCreator = origBridgeCreator; - } - - public String getOrigBridgeName() - { - return origBridgeName; - } - - public void setOrigBridgeName(String origBridgeName) - { - this.origBridgeName = origBridgeName; - } - - public String getOrigBridgeNumChannels() - { - return origBridgeNumChannels; - } - - public void setOrigBridgeNumChannels(String origBridgeNumChannels) - { - this.origBridgeNumChannels = origBridgeNumChannels; - } - - public String getSecondTransfererChannel() - { - return secondTransfererChannel; - } - - public void setSecondTransfererChannel(String secondTransfererChannel) - { - this.secondTransfererChannel = secondTransfererChannel; - } - - public String getSecondTransfererChannelState() - { - return secondTransfererChannelState; - } - - public void setSecondTransfererChannelState(String secondTransfererChannelState) - { - this.secondTransfererChannelState = secondTransfererChannelState; - } - - public String getSecondTransfererChannelStateDesc() - { - return secondTransfererChannelStateDesc; - } - - public void setSecondTransfererChannelStateDesc(String secondTransfererChannelStateDesc) - { - this.secondTransfererChannelStateDesc = secondTransfererChannelStateDesc; - } - - public String getSecondTransfererCallerIDNum() - { - return secondTransfererCallerIDNum; - } - - public void setSecondTransfererCallerIDNum(String secondTransfererCallerIDNum) - { - this.secondTransfererCallerIDNum = secondTransfererCallerIDNum; - } - - public String getSecondTransfererCallerIDName() - { - return secondTransfererCallerIDName; - } - - public void setSecondTransfererCallerIDName(String secondTransfererCallerIDName) - { - this.secondTransfererCallerIDName = secondTransfererCallerIDName; - } - - public String getSecondTransfererConnectedLineNum() { - return secondTransfererConnectedLineNum; - } - - public void setSecondTransfererConnectedLineNum(String secondTransfererConnectedLineNum) - { - this.secondTransfererConnectedLineNum = secondTransfererConnectedLineNum; - } - - public String getSecondTransfererConnectedLineName() - { - return secondTransfererConnectedLineName; - } - - public void setSecondTransfererConnectedLineName(String secondTransfererConnectedLineName) - { - this.secondTransfererConnectedLineName = secondTransfererConnectedLineName; - } - - public String getSecondTransfererAccountCode() - { - return secondTransfererAccountCode; - } - - public void setSecondTransfererAccountCode(String secondTransfererAccountCode) - { - this.secondTransfererAccountCode = secondTransfererAccountCode; - } - - public String getSecondTransfererContext() - { - return secondTransfererContext; - } - - public void setSecondTransfererContext(String secondTransfererContext) - { - this.secondTransfererContext = secondTransfererContext; - } - - public String getSecondTransfererExten() - { - return secondTransfererExten; - } - - public void setSecondTransfererExten(String secondTransfererExten) - { - this.secondTransfererExten = secondTransfererExten; - } - - public String getSecondTransfererPriority() - { - return secondTransfererPriority; - } - - public void setSecondTransfererPriority(String secondTransfererPriority) - { - this.secondTransfererPriority = secondTransfererPriority; - } - - public String getSecondTransfererUniqueid() - { - return secondTransfererUniqueid; - } - - public void setSecondTransfererUniqueid(String secondTransfererUniqueid) - { - this.secondTransfererUniqueid = secondTransfererUniqueid; - } - - public String getSecondBridgeUniqueid() - { - return secondBridgeUniqueid; - } - - public void setSecondBridgeUniqueid(String secondBridgeUniqueid) - { - this.secondBridgeUniqueid = secondBridgeUniqueid; - } - - public String getSecondBridgeType() - { - return secondBridgeType; - } - - public void setSecondBridgeType(String secondBridgeType) - { - this.secondBridgeType = secondBridgeType; - } - - public String getSecondBridgeTechnology() - { - return secondBridgeTechnology; - } - - public void setSecondBridgeTechnology(String secondBridgeTechnology) - { - this.secondBridgeTechnology = secondBridgeTechnology; - } - - public String getSecondBridgeCreator() - { - return secondBridgeCreator; - } - - public void setSecondBridgeCreator(String secondBridgeCreator) - { - this.secondBridgeCreator = secondBridgeCreator; - } - - public String getSecondBridgeName() - { - return secondBridgeName; - } - - public void setSecondBridgeName(String secondBridgeName) - { - this.secondBridgeName = secondBridgeName; - } - - public String getSecondBridgeNumChannels() - { - return secondBridgeNumChannels; - } - - public void setSecondBridgeNumChannels(String secondBridgeNumChannels) - { - this.secondBridgeNumChannels = secondBridgeNumChannels; - } - - public String getDestType() - { - return destType; - } - - public void setDestType(String destType) - { - this.destType = destType; - } - - public String getDestBridgeUniqueid() - { - return destBridgeUniqueid; - } - - public void setDestBridgeUniqueid(String destBridgeUniqueid) - { - this.destBridgeUniqueid = destBridgeUniqueid; - } - - public String getDestApp() - { - return destApp; - } - - public void setDestApp(String destApp) - { - this.destApp = destApp; - } - - public String getLocalOneChannel() - { - return localOneChannel; - } - - public void setLocalOneChannel(String localOneChannel) - { - this.localOneChannel = localOneChannel; - } - - public String getLocalOneChannelState() - { - return localOneChannelState; - } - - public void setLocalOneChannelState(String localOneChannelState) - { - this.localOneChannelState = localOneChannelState; - } - - public String getLocalOneChannelStateDesc() - { - return localOneChannelStateDesc; - } - - public void setLocalOneChannelStateDesc(String localOneChannelStateDesc) - { - this.localOneChannelStateDesc = localOneChannelStateDesc; - } - - public String getLocalOneCallerIDNum() - { - return localOneCallerIDNum; - } - - public void setLocalOneCallerIDNum(String localOneCallerIDNum) - { - this.localOneCallerIDNum = localOneCallerIDNum; - } - - public String getLocalOneCallerIDName() - { - return localOneCallerIDName; - } - - public void setLocalOneCallerIDName(String localOneCallerIDName) - { - this.localOneCallerIDName = localOneCallerIDName; - } - - public String getLocalOneConnectedLineNum() - { - return localOneConnectedLineNum; - } - - public void setLocalOneConnectedLineNum(String localOneConnectedLineNum) - { - this.localOneConnectedLineNum = localOneConnectedLineNum; - } - - public String getLocalOneConnectedLineName() - { - return localOneConnectedLineName; - } - - public void setLocalOneConnectedLineName(String localOneConnectedLineName) - { - this.localOneConnectedLineName = localOneConnectedLineName; - } - - public String getLocalOneAccountCode() - { - return localOneAccountCode; - } - - public void setLocalOneAccountCode(String localOneAccountCode) - { - this.localOneAccountCode = localOneAccountCode; - } - - public String getLocalOneContext() - { - return localOneContext; - } - - public void setLocalOneContext(String localOneContext) - { - this.localOneContext = localOneContext; - } - - public String getLocalOneExten() - { - return localOneExten; - } - - public void setLocalOneExten(String localOneExten) - { - this.localOneExten = localOneExten; - } - - public String getLocalOnePriority() - { - return localOnePriority; - } - - public void setLocalOnePriority(String localOnePriority) - { - this.localOnePriority = localOnePriority; - } - - public String getLocalOneUniqueid() - { - return localOneUniqueid; - } - - public void setLocalOneUniqueid(String localOneUniqueid) - { - this.localOneUniqueid = localOneUniqueid; - } - - public String getLocalTwoChannel() - { - return localTwoChannel; - } - - public void setLocalTwoChannel(String localTwoChannel) - { - this.localTwoChannel = localTwoChannel; - } - - public String getLocalTwoChannelState() - { - return localTwoChannelState; - } - - public void setLocalTwoChannelState(String localTwoChannelState) - { - this.localTwoChannelState = localTwoChannelState; - } - - public String getLocalTwoChannelStateDesc() - { - return localTwoChannelStateDesc; - } - - public void setLocalTwoChannelStateDesc(String localTwoChannelStateDesc) - { - this.localTwoChannelStateDesc = localTwoChannelStateDesc; - } - - public String getLocalTwoCallerIDNum() - { - return localTwoCallerIDNum; - } - - public void setLocalTwoCallerIDNum(String localTwoCallerIDNum) - { - this.localTwoCallerIDNum = localTwoCallerIDNum; - } - - public String getLocalTwoCallerIDName() - { - return localTwoCallerIDName; - } - - public void setLocalTwoCallerIDName(String localTwoCallerIDName) - { - this.localTwoCallerIDName = localTwoCallerIDName; - } - - public String getLocalTwoConnectedLineNum() - { - return localTwoConnectedLineNum; - } - - public void setLocalTwoConnectedLineNum(String localTwoConnectedLineNum) - { - this.localTwoConnectedLineNum = localTwoConnectedLineNum; - } - - public String getLocalTwoConnectedLineName() - { - return localTwoConnectedLineName; - } - - public void setLocalTwoConnectedLineName(String localTwoConnectedLineName) - { - this.localTwoConnectedLineName = localTwoConnectedLineName; - } - - public String getLocalTwoAccountCode() - { - return localTwoAccountCode; - } - - public void setLocalTwoAccountCode(String localTwoAccountCode) - { - this.localTwoAccountCode = localTwoAccountCode; - } - - public String getLocalTwoContext() - { - return localTwoContext; - } - - public void setLocalTwoContext(String localTwoContext) - { - this.localTwoContext = localTwoContext; - } - - public String getLocalTwoExten() - { - return localTwoExten; - } - - public void setLocalTwoExten(String localTwoExten) - { - this.localTwoExten = localTwoExten; - } - - public String getLocalTwoPriority() - { - return localTwoPriority; - } - - public void setLocalTwoPriority(String localTwoPriority) - { - this.localTwoPriority = localTwoPriority; - } - - public String getLocalTwoUniqueid() - { - return localTwoUniqueid; - } - - public void setLocalTwoUniqueid(String localTwoUniqueid) - { - this.localTwoUniqueid = localTwoUniqueid; - } - - public String getDestTransfererChannel() - { - return destTransfererChannel; - } - - public void setDestTransfererChannel(String destTransfererChannel) - { - this.destTransfererChannel = destTransfererChannel; - } - - public String getTransfereeChannel() - { - return transfereeChannel; - } - - public void setTransfereeChannel(String transfereeChannel) - { - this.transfereeChannel = transfereeChannel; - } - - public String getTransfereeChannelState() - { - return transfereeChannelState; - } - - public void setTransfereeChannelState(String transfereeChannelState) - { - this.transfereeChannelState = transfereeChannelState; - } - - public String getTransfereeChannelStateDesc() - { - return transfereeChannelStateDesc; - } - - public void setTransfereeChannelStateDesc(String transfereeChannelStateDesc) - { - this.transfereeChannelStateDesc = transfereeChannelStateDesc; - } - - public String getTransfereeCallerIDNum() - { - return transfereeCallerIDNum; - } - - public void setTransfereeCallerIDNum(String transfereeCallerIDNum) - { - this.transfereeCallerIDNum = transfereeCallerIDNum; - } - - public String getTransfereeCallerIDName() - { - return transfereeCallerIDName; - } - - public void setTransfereeCallerIDName(String transfereeCallerIDName) - { - this.transfereeCallerIDName = transfereeCallerIDName; - } - - public String getTransfereeConnectedLineNum() - { - return transfereeConnectedLineNum; - } - - public void setTransfereeConnectedLineNum(String transfereeConnectedLineNum) - { - this.transfereeConnectedLineNum = transfereeConnectedLineNum; - } - - public String getTransfereeConnectedLineName() - { - return transfereeConnectedLineName; - } - - public void setTransfereeConnectedLineName(String transfereeConnectedLineName) - { - this.transfereeConnectedLineName = transfereeConnectedLineName; - } - - public String getTransfereeAccountCode() - { - return transfereeAccountCode; - } - - public void setTransfereeAccountCode(String transfereeAccountCode) - { - this.transfereeAccountCode = transfereeAccountCode; - } - - public String getTransfereeContext() - { - return transfereeContext; - } - - public void setTransfereeContext(String transfereeContext) - { - this.transfereeContext = transfereeContext; - } - - public String getTransfereeExten() - { - return transfereeExten; - } - - public void setTransfereeExten(String transfereeExten) - { - this.transfereeExten = transfereeExten; - } - - public String getTransfereePriority() - { - return transfereePriority; - } - - public void setTransfereePriority(String transfereePriority) - { - this.transfereePriority = transfereePriority; - } - - public String getTransfereeUniqueid() - { - return transfereeUniqueid; - } - - public void setTransfereeUniqueid(String transfereeUniqueid) - { - this.transfereeUniqueid = transfereeUniqueid; - } - - public String getTransfereeLinkedId() - { - return transfereeLinkedId; - } - - public void setTransfereeLinkedId(String transfereeLinkedId) - { - this.transfereeLinkedId = transfereeLinkedId; - } - - public String getTransfereeLanguage() - { - return transfereeLanguage; - } - - public void setTransfereeLanguage(String transfereeLanguage) - { - this.transfereeLanguage = transfereeLanguage; - } - - public String getOrigTransfererLinkedId() - { - return origTransfererLinkedId; - } - - public void setOrigTransfererLinkedId(String origTransfererLinkedId) - { - this.origTransfererLinkedId = origTransfererLinkedId; - } - - public String getSecondTransfererLanguage() - { - return secondTransfererLanguage; - } - - public void setSecondTransfererLanguage(String secondTransfererLanguage) - { - this.secondTransfererLanguage = secondTransfererLanguage; - } - - public String getIsexternal() - { - return isexternal; - } - - public void setIsexternal(String isexternal) - { - this.isexternal = isexternal; - } - - public String getResult() - { - return result; - } - - public void setResult(String result) - { - this.result = result; - } - - public String getSecondTransfererLinkedId() - { - return secondTransfererLinkedId; - } - - public void setSecondTransfererLinkedId(String secondTransfererLinkedId) - { - this.secondTransfererLinkedId = secondTransfererLinkedId; - } - - public String getOrigTransfererLanguage() - { - return origTransfererLanguage; - } - - public void setOrigTransfererLanguage(String origTransfererLanguage) - { - this.origTransfererLanguage = origTransfererLanguage; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/BlindTransferEvent.java b/src/main/java/org/asteriskjava/manager/event/BlindTransferEvent.java deleted file mode 100644 index 91a2a6040..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BlindTransferEvent.java +++ /dev/null @@ -1,353 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class BlindTransferEvent extends AbstractBridgeEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String transfererUniqueId; - private String transfererConnectedLineNum; - private String transfererConnectedLineName; - private String transfererCallerIdName; - private String transfererCallerIdNum; - private String transfererChannel; - private String transfererChannelState; - private String transfererChannelStateDesc; - private Integer transfererPriority; - private String transfererContext; - - private String transfereeUniqueId; - private String transfereeConnectedLineNum; - private String transfereeConnectedLineName; - private String transfereeCallerIdName; - private String transfereeCallerIdNum; - private String transfereeChannel; - private String transfereeChannelState; - private String transfereeChannelStateDesc; - private Integer transfereePriority; - private String transfereeContext; - private String transfereeExten; - - private String extension; - private String isexternal; - private String result; - - private String transfereeLinkedId; - private String transfererAccountCode; - private String transfererExten; - private String transfererLanguage; - private String transfererLinkedId; - private String transfereeLanguage; - - - public BlindTransferEvent(Object source) - { - super(source); - } - - public String getTransfererUniqueId() - { - return transfererUniqueId; - } - - public void setTransfererUniqueId(String transfererUniqueId) - { - this.transfererUniqueId = transfererUniqueId; - } - - public String getTransfererConnectedLineNum() - { - return transfererConnectedLineNum; - } - - public void setTransfererConnectedLineNum(String transfererConnectedLineNum) - { - this.transfererConnectedLineNum = transfererConnectedLineNum; - } - - public String getTransfererConnectedLineName() - { - return transfererConnectedLineName; - } - - public void setTransfererConnectedLineName(String transfererConnectedLineName) - { - this.transfererConnectedLineName = transfererConnectedLineName; - } - - public String getTransfererCallerIdName() - { - return transfererCallerIdName; - } - - public void setTransfererCallerIdName(String transfererCallerIdName) - { - this.transfererCallerIdName = transfererCallerIdName; - } - - public String getTransfererCallerIdNum() - { - return transfererCallerIdNum; - } - - public void setTransfererCallerIdNum(String transfererCallerIdNum) - { - this.transfererCallerIdNum = transfererCallerIdNum; - } - - public String getTransfererChannel() - { - return transfererChannel; - } - - public void setTransfererChannel(String transfererChannel) - { - this.transfererChannel = transfererChannel; - } - - public String getTransfererChannelState() - { - return transfererChannelState; - } - - public void setTransfererChannelState(String transfererChannelState) - { - this.transfererChannelState = transfererChannelState; - } - - public String getTransfererChannelStateDesc() - { - return transfererChannelStateDesc; - } - - public void setTransfererChannelStateDesc(String transfererChannelStateDesc) - { - this.transfererChannelStateDesc = transfererChannelStateDesc; - } - - public Integer getTransfererPriority() - { - return transfererPriority; - } - - public void setTransfererPriority(Integer transfererPriority) - { - this.transfererPriority = transfererPriority; - } - - public String getTransfererContext() - { - return transfererContext; - } - - public void setTransfererContext(String transfererContext) - { - this.transfererContext = transfererContext; - } - - public String getTransfereeUniqueId() - { - return transfereeUniqueId; - } - - public void setTransfereeUniqueId(String transfereeUniqueId) - { - this.transfereeUniqueId = transfereeUniqueId; - } - - public String getTransfereeConnectedLineNum() - { - return transfereeConnectedLineNum; - } - - public void setTransfereeConnectedLineNum(String transfereeConnectedLineNum) - { - this.transfereeConnectedLineNum = transfereeConnectedLineNum; - } - - public String getTransfereeConnectedLineName() - { - return transfereeConnectedLineName; - } - - public void setTransfereeConnectedLineName(String transfereeConnectedLineName) - { - this.transfereeConnectedLineName = transfereeConnectedLineName; - } - - public String getTransfereeCallerIdName() - { - return transfereeCallerIdName; - } - - public void setTransfereeCallerIdName(String transfereeCallerIdName) - { - this.transfereeCallerIdName = transfereeCallerIdName; - } - - public String getTransfereeCallerIdNum() - { - return transfereeCallerIdNum; - } - - public void setTransfereeCallerIdNum(String transfereeCallerIdNum) - { - this.transfereeCallerIdNum = transfereeCallerIdNum; - } - - public String getTransfereeChannel() - { - return transfereeChannel; - } - - public void setTransfereeChannel(String transfereeChannel) - { - this.transfereeChannel = transfereeChannel; - } - - public String getTransfereeChannelState() - { - return transfereeChannelState; - } - - public void setTransfereeChannelState(String transfereeChannelState) - { - this.transfereeChannelState = transfereeChannelState; - } - - public String getTransfereeChannelStateDesc() - { - return transfereeChannelStateDesc; - } - - public void setTransfereeChannelStateDesc(String transfereeChannelStateDesc) - { - this.transfereeChannelStateDesc = transfereeChannelStateDesc; - } - - public Integer getTransfereePriority() - { - return transfereePriority; - } - - public void setTransfereePriority(Integer transfereePriority) - { - this.transfereePriority = transfereePriority; - } - - public String getTransfereeContext() - { - return transfereeContext; - } - - public void setTransfereeContext(String transfereeContext) - { - this.transfereeContext = transfereeContext; - } - - public String getExtension() - { - return extension; - } - - public void setExtension(String extension) - { - this.extension = extension; - } - - public String getIsexternal() - { - return isexternal; - } - - public void setIsexternal(String isexternal) - { - this.isexternal = isexternal; - } - - public String getResult() - { - return result; - } - - public void setResult(String result) - { - this.result = result; - } - - public String getTransfereeExten() - { - return transfereeExten; - } - - public void setTransfereeExten(String transfereeExten) - { - this.transfereeExten = transfereeExten; - } - - public String getTransfereeLinkedId() - { - return transfereeLinkedId; - } - - public void setTransfereeLinkedId(String transfereeLinkedId) - { - this.transfereeLinkedId = transfereeLinkedId; - } - - public String getTransfererAccountCode() - { - return transfererAccountCode; - } - - public void setTransfererAccountCode(String transfererAccountCode) - { - this.transfererAccountCode = transfererAccountCode; - } - - public String getTransfererExten() - { - return transfererExten; - } - - public void setTransfererExten(String transfererExten) - { - this.transfererExten = transfererExten; - } - - public String getTransfererLanguage() - { - return transfererLanguage; - } - - public void setTransfererLanguage(String transfererLanguage) - { - this.transfererLanguage = transfererLanguage; - } - - public String getTransfererLinkedId() - { - return transfererLinkedId; - } - - public void setTransfererLinkedId(String transfererLinkedId) - { - this.transfererLinkedId = transfererLinkedId; - } - - public String getTransfereeLanguage() - { - return transfereeLanguage; - } - - public void setTransfereeLanguage(String transfereeLanguage) - { - this.transfereeLanguage = transfereeLanguage; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeCreateEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeCreateEvent.java deleted file mode 100644 index 876c785b9..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeCreateEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class BridgeCreateEvent extends AbstractBridgeEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public BridgeCreateEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeDestroyEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeDestroyEvent.java deleted file mode 100644 index c7de172e2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeDestroyEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class BridgeDestroyEvent extends AbstractBridgeEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public BridgeDestroyEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeEnterEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeEnterEvent.java deleted file mode 100644 index 34c17d1fc..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeEnterEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class BridgeEnterEvent extends AbstractBridgeEvent -{ - /** - * - */ - private static final long serialVersionUID = 2L; - private String uniqueId; - private String channel; - private String language; - private String linkedId; - - public BridgeEnterEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeEvent.java deleted file mode 100644 index 46e203467..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeEvent.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A BridgeEvent is triggered when a link between two voice channels is established ("Link") or - * discontinued ("Unlink").

- * As of Asterisk 1.6 the Bridge event is reported directly by Asterisk. Asterisk versions up to - * 1.4 report individual events: {@link org.asteriskjava.manager.event.LinkEvent} and - * {@link org.asteriskjava.manager.event.UnlinkEvent}.For maximum compatibily do not use the Link and Unlink - * events in your code. Just use the Bridge event and check for {@link #isLink()} and {@link #isUnlink()}. - *
- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - */ -public class BridgeEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - public static final String BRIDGE_STATE_LINK = "Link"; - public static final String BRIDGE_STATE_UNLINK = "Unlink"; - - /** - * A channel.c bridge. - */ - public static final String BRIDGE_TYPE_CORE = "core"; - - /** - * An RTP native bridge. - */ - public static final String BRIDGE_TYPE_RTP_NATIVE = "rtp-native"; - - /** - * An RTP peer-2-peer bridge (NAT support only). - */ - public static final String BRIDGE_TYPE_RTP_DIRECT = "rtp-direct"; - - /** - * A remote (re-invite) bridge. - */ - public static final String BRIDGE_TYPE_RTP_REMOTE = "rtp-remote"; - - private String bridgeState; - private String bridgeType; - private String uniqueId1; - private String uniqueId2; - private String channel1; - private String channel2; - private String callerId1; - private String callerId2; - - public BridgeEvent(Object source) - { - super(source); - } - - /** - * Returns the bridge state. - * - * @return "Link" if the two channels have been linked, "Unlink" if they have been unlinked. - * @see #BRIDGE_STATE_LINK - * @see #BRIDGE_STATE_UNLINK - * @since 1.0.0 - */ - public String getBridgeState() - { - return bridgeState; - } - - /** - * Sets the bridge state. - * - * @param bridgeState "Link" if the two channels have been linked, "Unlink" if they have been unlinked. - * @since 1.0.0 - */ - public void setBridgeState(String bridgeState) - { - this.bridgeState = bridgeState; - } - - /** - * Returns the bridge type.

- * Available since Asterisk 1.6. - * - * @return the bridge type. - * @see #BRIDGE_TYPE_CORE - * @see #BRIDGE_TYPE_RTP_NATIVE - * @see #BRIDGE_TYPE_RTP_DIRECT - * @see #BRIDGE_TYPE_RTP_REMOTE - * @since 1.0.0 - */ - public String getBridgeType() - { - return bridgeType; - } - - /** - * Sets the bridge type. - * - * @param bridgeType the bridge type. - * @since 1.0.0 - */ - public void setBridgeType(String bridgeType) - { - this.bridgeType = bridgeType; - } - - /** - * Returns the unique id of the first channel. - * - * @return the unique id of the first channel. - */ - public String getUniqueId1() - { - return uniqueId1; - } - - /** - * Sets the unique id of the first channel. - * - * @param uniqueId1 the unique id of the first channel. - */ - public void setUniqueId1(String uniqueId1) - { - this.uniqueId1 = uniqueId1; - } - - /** - * Returns the unique id of the second channel. - * - * @return the unique id of the second channel. - */ - public String getUniqueId2() - { - return uniqueId2; - } - - /** - * Sets the unique id of the second channel. - * - * @param uniqueId2 the unique id of the second channel. - */ - public void setUniqueId2(String uniqueId2) - { - this.uniqueId2 = uniqueId2; - } - - /** - * Returns the name of the first channel. - * - * @return the name of the first channel. - */ - public String getChannel1() - { - return channel1; - } - - /** - * Sets the name of the first channel. - * - * @param channel1 the name of the first channel. - */ - public void setChannel1(String channel1) - { - this.channel1 = channel1; - } - - /** - * Returns the name of the second channel. - * - * @return the name of the second channel. - */ - public String getChannel2() - { - return channel2; - } - - /** - * Sets the name of the second channel. - * - * @param channel2 the name of the second channel. - */ - public void setChannel2(String channel2) - { - this.channel2 = channel2; - } - - /** - * Returns the Caller*Id number of the first channel. - * - * @return the Caller*Id number of the first channel. - * @since 0.2 - */ - public String getCallerId1() - { - return callerId1; - } - - /** - * Sets the Caller*Id number of the first channel. - * - * @param callerId1 the Caller*Id number of the first channel. - * @since 0.2 - */ - public void setCallerId1(String callerId1) - { - this.callerId1 = callerId1; - } - - /** - * Returns the Caller*Id number of the second channel. - * - * @return the Caller*Id number of the second channel. - * @since 0.2 - */ - public String getCallerId2() - { - return callerId2; - } - - /** - * Sets the Caller*Id number of the second channel. - * - * @param callerId2 the Caller*Id number of the second channel. - * @since 0.2 - */ - public void setCallerId2(String callerId2) - { - this.callerId2 = callerId2; - } - - /** - * Returns whether the two channels have been linked. - * - * @return true the two channels have been linked, false if they have been unlinked. - * @since 1.0.0 - */ - public boolean isLink() - { - return bridgeState != null && BRIDGE_STATE_LINK.equalsIgnoreCase(bridgeState); - } - - /** - * Returns whether the two channels have been unlinked. - * - * @return true the two channels have been unlinked, false if they have been linked. - * @since 1.0.0 - */ - public boolean isUnlink() - { - return bridgeState != null && BRIDGE_STATE_UNLINK.equalsIgnoreCase(bridgeState); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeExecEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeExecEvent.java deleted file mode 100644 index 2e1c1a1ba..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeExecEvent.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A BridgeExecEvent is triggered when two channels are bridged through a feature code or bridging the channels fails.

- * It is implemented in main/features.c

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class BridgeExecEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - public static final String RESPONSE_FAILED = "Failed"; - public static final String RESPONSE_SUCCESS = "Success"; - - private String response; - private String reason; - private String channel1; - private String channel2; - - public BridgeExecEvent(Object source) - { - super(source); - } - - /** - * Returns whether bridging succeeded or failed. Possible values are - *

    - *
  • Failed
  • - *
  • Success
  • - *
- * - * @return "Failed" if bridging failed, "Success" if it succeeded. - * @see #RESPONSE_FAILED - * @see #RESPONSE_SUCCESS - */ - public String getResponse() - { - return response; - } - - public void setResponse(String response) - { - this.response = response; - } - - /** - * Returns the reason for failure. Possible values are - *
    - *
  • Unable to bridge channel to itself
  • - *
  • Cannot grab end point
  • - *
  • cannot create placeholder
  • - *
  • Could not make channels compatible for bridge
  • - *
- * - * @return the reason for failure or null on success. - */ - public String getReason() - { - return reason; - } - - public void setReason(String reason) - { - this.reason = reason; - } - - /** - * The name of the first channel. - * - * @return name of the first channel. - */ - public String getChannel1() - { - return channel1; - } - - public void setChannel1(String channel1) - { - this.channel1 = channel1; - } - - /** - * The name of the second channel. - * - * @return name of the second channel. - */ - public String getChannel2() - { - return channel2; - } - - public void setChannel2(String channel2) - { - this.channel2 = channel2; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeLeaveEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeLeaveEvent.java deleted file mode 100644 index e03969b6c..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeLeaveEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class BridgeLeaveEvent extends AbstractBridgeEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String uniqueId; - private String channel; - private String language; - private String linkedId; - - public BridgeLeaveEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/BridgeMergeEvent.java b/src/main/java/org/asteriskjava/manager/event/BridgeMergeEvent.java deleted file mode 100644 index 6be462537..000000000 --- a/src/main/java/org/asteriskjava/manager/event/BridgeMergeEvent.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.asteriskjava.manager.event; - -public class BridgeMergeEvent extends ManagerEvent -{ - - private static final long serialVersionUID = 1L; - - public BridgeMergeEvent(Object source) - { - super(source); - } - - private Integer fromBridgeNumChannels; - private Integer toBridgeNumChannels; - private String fromBridgeName; - private String fromBridgeUniqueId; - private String fromBridgeCreator; - private String toBridgeName; - private String fromBridgeTechnology; - private String toBridgeUniqueId; - private String toBridgeTechnology; - private String fromBridgeType; - private String toBridgeType; - private String toBridgeCreator; - - public Integer getFromBridgeNumChannels() - { - return fromBridgeNumChannels; - } - public void setFromBridgeNumChannels(Integer fromBridgeNumChannels) - { - this.fromBridgeNumChannels = fromBridgeNumChannels; - } - public Integer getToBridgeNumChannels() - { - return toBridgeNumChannels; - } - public void setToBridgeNumChannels(Integer toBridgeNumChannels) - { - this.toBridgeNumChannels = toBridgeNumChannels; - } - public String getFromBridgeName() - { - return fromBridgeName; - } - public void setFromBridgeName(String fromBridgeName) - { - this.fromBridgeName = fromBridgeName; - } - public String getFromBridgeUniqueId() - { - return fromBridgeUniqueId; - } - public void setFromBridgeUniqueId(String fromBridgeUniqueId) - { - this.fromBridgeUniqueId = fromBridgeUniqueId; - } - public String getFromBridgeCreator() - { - return fromBridgeCreator; - } - public void setFromBridgeCreator(String fromBridgeCreator) - { - this.fromBridgeCreator = fromBridgeCreator; - } - public String getToBridgeName() - { - return toBridgeName; - } - public void setToBridgeName(String toBridgeName) - { - this.toBridgeName = toBridgeName; - } - public String getFromBridgeTechnology() - { - return fromBridgeTechnology; - } - public void setFromBridgeTechnology(String fromBridgeTechnology) - { - this.fromBridgeTechnology = fromBridgeTechnology; - } - public String getToBridgeUniqueId() - { - return toBridgeUniqueId; - } - public void setToBridgeUniqueId(String toBridgeUniqueId) - { - this.toBridgeUniqueId = toBridgeUniqueId; - } - public String getToBridgeTechnology() - { - return toBridgeTechnology; - } - public void setToBridgeTechnology(String toBridgeTechnology) - { - this.toBridgeTechnology = toBridgeTechnology; - } - public String getFromBridgeType() - { - return fromBridgeType; - } - public void setFromBridgeType(String fromBridgeType) - { - this.fromBridgeType = fromBridgeType; - } - public String getToBridgeType() - { - return toBridgeType; - } - public void setToBridgeType(String toBridgeType) - { - this.toBridgeType = toBridgeType; - } - public String getToBridgeCreator() - { - return toBridgeCreator; - } - public void setToBridgeCreator(String toBridgeCreator) - { - this.toBridgeCreator = toBridgeCreator; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/CdrEvent.java b/src/main/java/org/asteriskjava/manager/event/CdrEvent.java deleted file mode 100644 index 817a5aa47..000000000 --- a/src/main/java/org/asteriskjava/manager/event/CdrEvent.java +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.Date; -import java.util.TimeZone; - -import org.asteriskjava.util.DateUtil; - -/** - * A CdrEvent is triggered when a call detail record is generated, usually at the end of a call.

- * To enable CdrEvents you have to add enabled = yes to the general section in - * cdr_manager.conf.

- * This event is implemented in cdr/cdr_manager.c - * - * @author srt - * @version $Id$ - */ -public class CdrEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 2541424315212201670L; - - public static final String DISPOSITION_NO_ANSWER = "NO ANSWER"; - public static final String DISPOSITION_FAILED = "FAILED"; - public static final String DISPOSITION_BUSY = "BUSY"; - public static final String DISPOSITION_ANSWERED = "ANSWERED"; - public static final String DISPOSITION_UNKNOWN = "UNKNOWN"; - - public static final String AMA_FLAG_OMIT = "OMIT"; - public static final String AMA_FLAG_BILLING = "BILLING"; - public static final String AMA_FLAG_DOCUMENTATION = "DOCUMENTATION"; - public static final String AMA_FLAG_UNKNOWN = "Unknown"; - - private String accountCode; - private String src; - private String destination; - private String destinationContext; - private String callerId; - private String channel; - private String destinationChannel; - private String lastApplication; - private String lastData; - private String startTime; - private String answerTime; - private String endTime; - private Integer duration; - private Integer billableSeconds; - private String disposition; - private String amaFlags; - private String uniqueId; - private String userField; - - /** - * @param source - */ - public CdrEvent(Object source) - { - super(source); - } - - /** - * Returns the account number that is usually used to identify the party to bill for the call.

- * Corresponds to CDR field accountcode. - * - * @return the account number. - */ - public String getAccountCode() - { - return accountCode; - } - - /** - * Sets the account number. - * - * @param accountCode the account number. - */ - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - /** - * Returns the Caller*ID number.

- * Corresponds to CDR field src. - * - * @return the Caller*ID number. - */ - public String getSrc() - { - return src; - } - - /** - * Sets the Caller*ID number. - * - * @param source the Caller*ID number. - */ - public void setSrc(String source) - { - this.src = source; - } - - /** - * Returns the destination extension.

- * Corresponds to CDR field dst. - * - * @return the destination extension. - */ - public String getDestination() - { - return destination; - } - - /** - * Sets the destination extension. - * - * @param destination the destination extension. - */ - public void setDestination(String destination) - { - this.destination = destination; - } - - /** - * Returns the destination context.

- * Corresponds to CDR field dcontext. - * - * @return the destination context. - */ - public String getDestinationContext() - { - return destinationContext; - } - - /** - * Sets the destination context. - * - * @param destinationContext the destination context. - */ - public void setDestinationContext(String destinationContext) - { - this.destinationContext = destinationContext; - } - - /** - * Returns the Caller*ID with text.

- * Corresponds to CDR field clid. - * - * @return the Caller*ID with text - */ - public String getCallerId() - { - return callerId; - } - - /** - * Sets the Caller*ID with text. - * - * @param callerId the Caller*ID with text. - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - /** - * Returns the name of the channel, for example "SIP/1310-asfe".

- * Corresponds to CDR field channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - * - * @param channel the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the destination channel if appropriate.

- * Corresponds to CDR field dstchannel. - * - * @return the name of the destination channel or null if not available. - */ - public String getDestinationChannel() - { - return destinationChannel; - } - - /** - * Sets the name of the destination channel. - * - * @param destinationChannel the name of the destination channel. - */ - public void setDestinationChannel(String destinationChannel) - { - this.destinationChannel = destinationChannel; - } - - /** - * Returns the last application if appropriate, for example "VoiceMail".

- * Corresponds to CDR field lastapp. - * - * @return the last application or null if not avaialble. - */ - public String getLastApplication() - { - return lastApplication; - } - - /** - * Sets the last application. - * - * @param lastApplication the last application. - */ - public void setLastApplication(String lastApplication) - { - this.lastApplication = lastApplication; - } - - /** - * Returns the last application's data (arguments), for example "s1234".

- * Corresponds to CDR field lastdata. - * - * @return the last application's data or null if not avaialble. - */ - public String getLastData() - { - return lastData; - } - - /** - * Set the last application's data. - * - * @param lastData the last application's data. - */ - public void setLastData(String lastData) - { - this.lastData = lastData; - } - - /** - * Returns when the call has started.

- * This corresponds to CDR field start. - * - * @return A string of the format "%Y-%m-%d %T" (strftime(3)) representing the date/time the - * call has started, for example "2006-05-19 11:54:48". - */ - public String getStartTime() - { - return startTime; - } - - /** - * Returns the start time as Date object.

- * This method asumes that the Asterisk server's timezone equals the default - * timezone of your JVM. - * - * @return the start time as Date object. - * @since 0.3 - */ - public Date getStartTimeAsDate() - { - return DateUtil.parseDateTime(startTime); - } - - /** - * Returns the start time as Date object. - * - * @param tz the timezone of the Asterisk server. - * @return the start time as Date object. - * @since 0.3 - */ - public Date getStartTimeAsDate(TimeZone tz) - { - return DateUtil.parseDateTime(startTime, tz); - } - - /** - * Sets the date/time when the call has started. - * - * @param startTime the date/time when the call has started. - */ - public void setStartTime(String startTime) - { - this.startTime = startTime; - } - - /** - * Returns when the call was answered.

- * This corresponds to CDR field answered. - * - * @return A string of the format "%Y-%m-%d %T" (strftime(3)) representing the date/time the - * call was answered, for example "2006-05-19 11:55:01" - */ - public String getAnswerTime() - { - return answerTime; - } - - /** - * Returns the answer time as Date object.

- * This method asumes that the Asterisk server's timezone equals the default - * timezone of your JVM. - * - * @return the answer time as Date object. - * @since 0.3 - */ - public Date getAnswerTimeAsDate() - { - return DateUtil.parseDateTime(answerTime); - } - - /** - * Returns the answer time as Date object. - * - * @param tz the timezone of the Asterisk server. - * @return the answer time as Date object. - * @since 0.3 - */ - public Date getAnswerTimeAsDate(TimeZone tz) - { - return DateUtil.parseDateTime(answerTime, tz); - } - - /** - * Sets the date/time when the call was answered. - * - * @param answerTime the date/time when the call was answered. - */ - public void setAnswerTime(String answerTime) - { - this.answerTime = answerTime; - } - - /** - * Returns when the call has ended.

- * This corresponds to CDR field end. - * - * @return A string of the format "%Y-%m-%d %T" (strftime(3)) representing the date/time the - * call has ended, for example "2006-05-19 11:58:21" - */ - public String getEndTime() - { - return endTime; - } - - /** - * Returns the end time as Date object.

- * This method asumes that the Asterisk server's timezone equals the default - * timezone of your JVM. - * - * @return the end time as Date object. - * @since 0.3 - */ - public Date getEndTimeAsDate() - { - return DateUtil.parseDateTime(endTime); - } - - /** - * Returns the end time as Date object. - * - * @param tz the timezone of the Asterisk server. - * @return the end time as Date object. - * @since 0.3 - */ - public Date getEndTimeAsDate(TimeZone tz) - { - return DateUtil.parseDateTime(endTime, tz); - } - - /** - * Sets the date/time when the call has ended. - * - * @param endTime the date/time when the call has ended. - */ - public void setEndTime(String endTime) - { - this.endTime = endTime; - } - - /** - * Returns the total time (in seconds) the caller spent in the system from dial to hangup.

- * Corresponds to CDR field duration. - * - * @return the total time in system in seconds. - */ - public Integer getDuration() - { - return duration; - } - - /** - * Sets the total time in system. - * - * @param duration total time in system in seconds. - */ - public void setDuration(Integer duration) - { - this.duration = duration; - } - - /** - * Returns the total time (in seconds) the call was up from answer to hangup.

- * Corresponds to CDR field billsec. - * - * @return the total time in call in seconds. - */ - public Integer getBillableSeconds() - { - return billableSeconds; - } - - /** - * Sets the total time in call. - * - * @param billableSeconds the total time in call in seconds. - */ - public void setBillableSeconds(Integer billableSeconds) - { - this.billableSeconds = billableSeconds; - } - - /** - * Returns what happened to the call.

- * This is one of - *

    - *
  • {@link #DISPOSITION_NO_ANSWER} - *
  • {@link #DISPOSITION_FAILED} - *
  • {@link #DISPOSITION_BUSY} - *
  • {@link #DISPOSITION_ANSWERED} - *
  • {@link #DISPOSITION_UNKNOWN} - *
- * Corresponds to CDR field disposition. - * - * @return the disposition. - */ - public String getDisposition() - { - return disposition; - } - - /** - * Sets the disposition. - * - * @param disposition the disposition. - */ - public void setDisposition(String disposition) - { - this.disposition = disposition; - } - - /** - * Returns the AMA (Automated Message Accounting) flags.

- * This is one of - *

    - *
  • {@link #AMA_FLAG_OMIT} - *
  • {@link #AMA_FLAG_BILLING} - *
  • {@link #AMA_FLAG_DOCUMENTATION} - *
  • {@link #AMA_FLAG_UNKNOWN} - *
- * Corresponds to CDR field amaflags. - * - * @return the AMA flags. - */ - public String getAmaFlags() - { - return amaFlags; - } - - /** - * Sets the AMA (Automated Message Accounting) flags. - * - * @param amaFlags the AMA (Automated Message Accounting) flags. - */ - public void setAmaFlags(String amaFlags) - { - this.amaFlags = amaFlags; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel. - * - * @param uniqueId the unique id of the channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the user-defined field as set by Set(CDR(userfield)=Value).

- * Corresponds to CDR field userfield. - * - * @return the user-defined field. - */ - public String getUserField() - { - return userField; - } - - /** - * Sets the user-defined field. - * - * @param userField the user-defined field - */ - public void setUserField(String userField) - { - this.userField = userField; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/CelEvent.java b/src/main/java/org/asteriskjava/manager/event/CelEvent.java deleted file mode 100644 index 1c1873d45..000000000 --- a/src/main/java/org/asteriskjava/manager/event/CelEvent.java +++ /dev/null @@ -1,230 +0,0 @@ -package org.asteriskjava.manager.event; -/** - * Raised when a Channel Event Log is generated for a channel. - * https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_CEL - */ -public class CelEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - public static final String CEL_EVENT_CHAN_START = "CHAN_START"; - public static final String CEL_EVENT_CHAN_END = "CHAN_END"; - public static final String CEL_EVENT_ANSWER = "ANSWER"; - public static final String CEL_EVENT_HANGUP = "HANGUP"; - public static final String CEL_EVENT_BRIDGE_ENTER = "BRIDGE_ENTER"; - public static final String CEL_EVENT_BRIDGE_EXIT = "BRIDGE_EXIT"; - public static final String CEL_EVENT_APP_START = "APP_START"; - public static final String CEL_EVENT_APP_END = "APP_END"; - public static final String CEL_EVENT_PARK_START = "PARK_START"; - public static final String CEL_EVENT_PARK_END = "PARK_END"; - public static final String CEL_EVENT_BLINDTRANSFER = "BLINDTRANSFER"; - public static final String CEL_EVENT_ATTENDEDTRANSFER = "ATTENDEDTRANSFER"; - public static final String CEL_EVENT_PICKUP = "PICKUP"; - public static final String CEL_EVENT_FORWARD = "FORWARD"; - public static final String CEL_EVENT_LINKEDID_END = "LINKEDID_END"; - public static final String CEL_EVENT_LOCAL_OPTIMIZE = "LOCAL_OPTIMIZE"; - public static final String CEL_EVENT_USER_DEFINED = "USER_DEFINED"; - - private String eventName; - private String accountCode; - private String callerIDani; - private String callerIDrdnis; - private String callerIDdnid; - private String exten; - private String context; - private String application; - private String appData; - private String eventTime; - private String amaFlags; - private String uniqueID; - private String linkedID; - private String userField; - private String peer; - private String peerAccount; - private String extra; - private String channel; - - public CelEvent(Object source) - { - super(source); - } - - public String getEventName() - { - return eventName; - } - - public void setEventName(String eventName) - { - this.eventName = eventName; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getCallerIDani() - { - return callerIDani; - } - - public void setCallerIDani(String callerIDani) - { - this.callerIDani = callerIDani; - } - - public String getCallerIDrdnis() - { - return callerIDrdnis; - } - - public void setCallerIDrdnis(String callerIDrdnis) - { - this.callerIDrdnis = callerIDrdnis; - } - - public String getCallerIDdnid() - { - return callerIDdnid; - } - - public void setCallerIDdnid(String callerIDdnid) - { - this.callerIDdnid = callerIDdnid; - } - - public String getExten() - { - return exten; - } - - public void setExten(String exten) - { - this.exten = exten; - } - - public String getContext() - { - return context; - } - - public void setContext(String context) - { - this.context = context; - } - - public String getApplication() - { - return application; - } - - public void setApplication(String application) - { - this.application = application; - } - - public String getAppData() - { - return appData; - } - - public void setAppData(String appData) - { - this.appData = appData; - } - - public String getEventTime() - { - return eventTime; - } - - public void setEventTime(String eventTime) - { - this.eventTime = eventTime; - } - - public String getAmaFlags() - { - return amaFlags; - } - - public void setAmaFlags(String amaFlags) - { - this.amaFlags = amaFlags; - } - - public String getUniqueID() - { - return uniqueID; - } - - public void setUniqueID(String uniqueID) - { - this.uniqueID = uniqueID; - } - - public String getLinkedID() - { - return linkedID; - } - - public void setLinkedID(String linkedID) - { - this.linkedID = linkedID; - } - - public String getUserField() - { - return userField; - } - - public void setUserField(String userField) - { - this.userField = userField; - } - - public String getPeer() - { - return peer; - } - - public void setPeer(String peer) - { - this.peer = peer; - } - - public String getPeerAccount() - { - return peerAccount; - } - - public void setPeerAccount(String peerAccount) - { - this.peerAccount = peerAccount; - } - - public String getExtra() - { - return extra; - } - - public void setExtra(String extra) - { - this.extra = extra; - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ChallengeResponseFailedEvent.java b/src/main/java/org/asteriskjava/manager/event/ChallengeResponseFailedEvent.java deleted file mode 100644 index 96e13050a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ChallengeResponseFailedEvent.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.asteriskjava.manager.event; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -public class ChallengeResponseFailedEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - private String severity; - private String eventversion; - private String service; - private String remoteaddress; - private String localaddress; - - /** - * @param source - */ - public ChallengeResponseFailedEvent(Object source) { - super(source); - } - - public String getSeverity() - { - return severity; - } - public void setSeverity(String severity) - { - this.severity = severity; - } - - public String getEventversion() - { - return eventversion; - } - public void setEventversion(String eventversion) - { - this.eventversion = eventversion; - } - - - public String getService() - { - return service; - } - public void setService(String service) - { - this.service = service; - } - - public String getRemoteAddress() - { - return remoteaddress; - } - public void setRemoteAddress(String remoteaddress) - { - this.remoteaddress = remoteaddress; - } - - public String getLocalAddress() - { - return localaddress; - } - public void setLocalAddress(String localaddress) - { - this.localaddress = localaddress; - } - - public void setEventtv(String eventv) - { - DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - Long t = 0L; - try - { - Date date = format.parse(eventv); - t = date.getTime(); - } - catch (ParseException ex){} - finally - { - this.setTimestamp(t.doubleValue()); - } - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ChallengeSentEvent.java b/src/main/java/org/asteriskjava/manager/event/ChallengeSentEvent.java deleted file mode 100644 index 348e35923..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ChallengeSentEvent.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class ChallengeSentEvent extends ManagerEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String severity; - private Integer eventVersion; - private String accountId; - private String service; - private String eventtv; - private String remoteAddress; - private String localAddress; - private String challenge; - private String sessionId; - - public ChallengeSentEvent(Object source) - { - super(source); - } - - public String getSeverity() - { - return severity; - } - - public void setSeverity(String severity) - { - this.severity = severity; - } - - public Integer getEventVersion() - { - return eventVersion; - } - - public void setEventVersion(Integer eventVersion) - { - this.eventVersion = eventVersion; - } - - public String getAccountId() - { - return accountId; - } - - public void setAccountId(String accountId) - { - this.accountId = accountId; - } - - public String getService() - { - return service; - } - - public void setService(String service) - { - this.service = service; - } - - public String getEventtv() - { - return eventtv; - } - - public void setEventtv(String eventtv) - { - this.eventtv = eventtv; - } - - public String getRemoteAddress() - { - return remoteAddress; - } - - public void setRemoteAddress(String remoteAddress) - { - this.remoteAddress = remoteAddress; - } - - public String getLocalAddress() - { - return localAddress; - } - - public void setLocalAddress(String localAddress) - { - this.localAddress = localAddress; - } - - public String getChallenge() - { - return challenge; - } - - public void setChallenge(String challenge) - { - this.challenge = challenge; - } - - public String getSessionId() - { - return sessionId; - } - - public void setSessionId(String sessionId) - { - this.sessionId = sessionId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ChanSpyStartEvent.java b/src/main/java/org/asteriskjava/manager/event/ChanSpyStartEvent.java deleted file mode 100644 index 63bbcfd5f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ChanSpyStartEvent.java +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - - -public class ChanSpyStartEvent extends ManagerEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 3256725065466000696L; - - private String spyeeChannel; - private String spyerChannel; - - private Integer spyeeChannelState; - private String spyeeLinkedId; - private String spyeeUniqueId; - private String spyeeCallerIdNum; - private String spyeeConnectedLineName; - private String spyeeLanguage; - private String spyeeContext; - private String spyeeConnectedLineNum; - private String spyeeChannelStateDesc; - private String spyeeExten; - private Integer spyeeChannelstate; - private String spyeeAccountCode; - private Integer spyeePriority; - private String spyeeCallerIdName; - - - private String spyerUniqueId; - private String spyerLinkedId; - private Integer spyerChannelState; - private Integer spyerPriority; - private String spyerContext; - private String spyerLanguage; - private String spyerChannelStateDesc; - private String spyerExten; - private String spyerCallerIdNum; - private String spyerConnectedLineNum; - private String spyerConnectedLineName; - private String spyerCallerIdName; - - - - public ChanSpyStartEvent(Object source) - { - super(source); - } - - - - public String getSpyeeChannel() - { - return spyeeChannel; - } - - - - public void setSpyeeChannel(String spyeeChannel) - { - this.spyeeChannel = spyeeChannel; - } - - - - public String getSpyerChannel() - { - return spyerChannel; - } - - - - public void setSpyerChannel(String spyerChannel) - { - this.spyerChannel = spyerChannel; - } - - - - public Integer getSpyeeChannelState() - { - return spyeeChannelState; - } - - - - public void setSpyeeChannelState(Integer spyeeChannelState) - { - this.spyeeChannelState = spyeeChannelState; - } - - - - public String getSpyeeLinkedId() - { - return spyeeLinkedId; - } - - - - public void setSpyeeLinkedId(String spyeeLinkedId) - { - this.spyeeLinkedId = spyeeLinkedId; - } - - - - public String getSpyeeUniqueId() - { - return spyeeUniqueId; - } - - - - public void setSpyeeUniqueId(String spyeeUniqueId) - { - this.spyeeUniqueId = spyeeUniqueId; - } - - - - public String getSpyeeCallerIdNum() - { - return spyeeCallerIdNum; - } - - - - public void setSpyeeCallerIdNum(String spyeeCallerIdNum) - { - this.spyeeCallerIdNum = spyeeCallerIdNum; - } - - - - public String getSpyeeConnectedLineName() - { - return spyeeConnectedLineName; - } - - - - public void setSpyeeConnectedLineName(String spyeeConnectedLineName) - { - this.spyeeConnectedLineName = spyeeConnectedLineName; - } - - - - public String getSpyeeLanguage() - { - return spyeeLanguage; - } - - - - public void setSpyeeLanguage(String spyeeLanguage) - { - this.spyeeLanguage = spyeeLanguage; - } - - - - public String getSpyeeContext() - { - return spyeeContext; - } - - - - public void setSpyeeContext(String spyeeContext) - { - this.spyeeContext = spyeeContext; - } - - - - public String getSpyeeConnectedLineNum() - { - return spyeeConnectedLineNum; - } - - - - public void setSpyeeConnectedLineNum(String spyeeConnectedLineNum) - { - this.spyeeConnectedLineNum = spyeeConnectedLineNum; - } - - - - public String getSpyeeChannelStateDesc() - { - return spyeeChannelStateDesc; - } - - - - public void setSpyeeChannelStateDesc(String spyeeChannelStateDesc) - { - this.spyeeChannelStateDesc = spyeeChannelStateDesc; - } - - - - public String getSpyeeExten() - { - return spyeeExten; - } - - - - public void setSpyeeExten(String spyeeExten) - { - this.spyeeExten = spyeeExten; - } - - - - public Integer getSpyeeChannelstate() - { - return spyeeChannelstate; - } - - - - public void setSpyeeChannelstate(Integer spyeeChannelstate) - { - this.spyeeChannelstate = spyeeChannelstate; - } - - - - public String getSpyeeAccountCode() - { - return spyeeAccountCode; - } - - - - public void setSpyeeAccountCode(String spyeeAccountCode) - { - this.spyeeAccountCode = spyeeAccountCode; - } - - - - public Integer getSpyeePriority() - { - return spyeePriority; - } - - - - public void setSpyeePriority(Integer spyeePriority) - { - this.spyeePriority = spyeePriority; - } - - - - public String getSpyeeCallerIdName() - { - return spyeeCallerIdName; - } - - - - public void setSpyeeCallerIdName(String spyeeCallerIdName) - { - this.spyeeCallerIdName = spyeeCallerIdName; - } - - - - public String getSpyerUniqueId() - { - return spyerUniqueId; - } - - - - public void setSpyerUniqueId(String spyerUniqueId) - { - this.spyerUniqueId = spyerUniqueId; - } - - - - public String getSpyerLinkedId() - { - return spyerLinkedId; - } - - - - public void setSpyerLinkedId(String spyerLinkedId) - { - this.spyerLinkedId = spyerLinkedId; - } - - - - public Integer getSpyerChannelState() - { - return spyerChannelState; - } - - - - public void setSpyerChannelState(Integer spyerChannelState) - { - this.spyerChannelState = spyerChannelState; - } - - - - public Integer getSpyerPriority() - { - return spyerPriority; - } - - - - public void setSpyerPriority(Integer spyerPriority) - { - this.spyerPriority = spyerPriority; - } - - - - public String getSpyerContext() - { - return spyerContext; - } - - - - public void setSpyerContext(String spyerContext) - { - this.spyerContext = spyerContext; - } - - - - public String getSpyerLanguage() - { - return spyerLanguage; - } - - - - public void setSpyerLanguage(String spyerLanguage) - { - this.spyerLanguage = spyerLanguage; - } - - - - public String getSpyerChannelStateDesc() - { - return spyerChannelStateDesc; - } - - - - public void setSpyerChannelStateDesc(String spyerChannelStateDesc) - { - this.spyerChannelStateDesc = spyerChannelStateDesc; - } - - - - public String getSpyerExten() - { - return spyerExten; - } - - - - public void setSpyerExten(String spyerExten) - { - this.spyerExten = spyerExten; - } - - - - public String getSpyerCallerIdNum() - { - return spyerCallerIdNum; - } - - - - public void setSpyerCallerIdNum(String spyerCallerIdNum) - { - this.spyerCallerIdNum = spyerCallerIdNum; - } - - - - public String getSpyerConnectedLineNum() - { - return spyerConnectedLineNum; - } - - - - public void setSpyerConnectedLineNum(String spyerConnectedLineNum) - { - this.spyerConnectedLineNum = spyerConnectedLineNum; - } - - - - public String getSpyerConnectedLineName() - { - return spyerConnectedLineName; - } - - - - public void setSpyerConnectedLineName(String spyerConnectedLineName) - { - this.spyerConnectedLineName = spyerConnectedLineName; - } - - - - public String getSpyerCallerIdName() - { - return spyerCallerIdName; - } - - - - public void setSpyerCallerIdName(String spyerCallerIdName) - { - this.spyerCallerIdName = spyerCallerIdName; - } - - - - - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ChanSpyStopEvent.java b/src/main/java/org/asteriskjava/manager/event/ChanSpyStopEvent.java deleted file mode 100644 index 7b9e9a19b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ChanSpyStopEvent.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - - -public class ChanSpyStopEvent extends ManagerEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 3256725065466000696L; - - /** - * The name of the channel. - */ - private String spyeechannel; - - private String spyerUniqueId; - private String spyerLinkedId; - private Integer spyerChannelState; - private Integer spyerPriority; - private String spyerContext; - private String spyerLanguage; - private String spyerChannelStateDesc; - private String spyerExten; - private String spyerCallerIdNum; - private String spyerConnectedLineNum; - private String spyerConnectedLineName; - private String spyerCallerIdName; - private String spyerChannel; - - - public ChanSpyStopEvent(Object source) - { - super(source); - } - - - public String getSpyeeChannel() - { - return spyeechannel; - } - - public void setSpyeeChannel(String channel) - { - this.spyeechannel = channel; - } - - - public String getSpyeechannel() - { - return spyeechannel; - } - - - public void setSpyeechannel(String spyeechannel) - { - this.spyeechannel = spyeechannel; - } - - - public String getSpyerUniqueId() - { - return spyerUniqueId; - } - - - public void setSpyerUniqueId(String spyerUniqueId) - { - this.spyerUniqueId = spyerUniqueId; - } - - - public String getSpyerLinkedId() - { - return spyerLinkedId; - } - - - public void setSpyerLinkedId(String spyerLinkedId) - { - this.spyerLinkedId = spyerLinkedId; - } - - - public Integer getSpyerChannelState() - { - return spyerChannelState; - } - - - public void setSpyerChannelState(Integer spyerChannelState) - { - this.spyerChannelState = spyerChannelState; - } - - - public Integer getSpyerPriority() - { - return spyerPriority; - } - - - public void setSpyerPriority(Integer spyerPriority) - { - this.spyerPriority = spyerPriority; - } - - - public String getSpyerContext() - { - return spyerContext; - } - - - public void setSpyerContext(String spyerContext) - { - this.spyerContext = spyerContext; - } - - - public String getSpyerLanguage() - { - return spyerLanguage; - } - - - public void setSpyerLanguage(String spyerLanguage) - { - this.spyerLanguage = spyerLanguage; - } - - - public String getSpyerChannelStateDesc() - { - return spyerChannelStateDesc; - } - - - public void setSpyerChannelStateDesc(String spyerChannelStateDesc) - { - this.spyerChannelStateDesc = spyerChannelStateDesc; - } - - - public String getSpyerExten() - { - return spyerExten; - } - - - public void setSpyerExten(String spyerExten) - { - this.spyerExten = spyerExten; - } - - - public String getSpyerCallerIdNum() - { - return spyerCallerIdNum; - } - - - public void setSpyerCallerIdNum(String spyerCallerIdNum) - { - this.spyerCallerIdNum = spyerCallerIdNum; - } - - - public String getSpyerConnectedLineNum() - { - return spyerConnectedLineNum; - } - - - public void setSpyerConnectedLineNum(String spyerConnectedLineNum) - { - this.spyerConnectedLineNum = spyerConnectedLineNum; - } - - - public String getSpyerConnectedLineName() - { - return spyerConnectedLineName; - } - - - public void setSpyerConnectedLineName(String spyerConnectedLineName) - { - this.spyerConnectedLineName = spyerConnectedLineName; - } - - - public String getSpyerCallerIdName() - { - return spyerCallerIdName; - } - - - public void setSpyerCallerIdName(String spyerCallerIdName) - { - this.spyerCallerIdName = spyerCallerIdName; - } - - - public String getSpyerChannel() - { - return spyerChannel; - } - - - public void setSpyerChannel(String spyerChannel) - { - this.spyerChannel = spyerChannel; - } - - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ChannelReloadEvent.java b/src/main/java/org/asteriskjava/manager/event/ChannelReloadEvent.java deleted file mode 100644 index fc5cab85d..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ChannelReloadEvent.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * A ChannelReloadEvent is when a channel driver is reloaded, either on startup - * or by request. - *
- * For example, channels/chan_sip.c triggers the channel reload - * event when the SIP configuration is reloaded from sip.conf because the 'sip - * reload' command was issued at the Manager interface, the CLI, or for another - * reason. - *
- * Available since Asterisk 1.4. - *
- * It is implemented in channels/chan_sip.c - * - * @author martins - */ -public class ChannelReloadEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - /** - * The channel module has been loaded for the first time. - */ - public static final String REASON_LOAD = "LOAD"; - - /** - * The channel module has been reloaded. - */ - public static final String REASON_RELOAD = "RELOAD"; - - /** - * The channel module has been reloaded from the command line. - */ - public static final String REASON_CLI_RELOAD = "CLIRELOAD"; - - /** - * The channel module has been reloaded due to a manager action. - */ - public static final String REASON_MANAGER_RELOAD = "MANAGERRELOAD"; - - private static final Pattern REASON_PATTERN = Pattern.compile("^([A-Z]+) \\((.*)\\)$"); - - /** - * The type of channel that got reloaded (i.e. SIP) - */ - private String channelType; - - private String reloadReason; - - /** - * The reason for the reload. - * - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_CLI_RELOAD - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_LOAD - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_RELOAD - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_MANAGER_RELOAD - */ - private String reloadReasonCode; - private String reloadReasonDescription; - - /** - * The number of registrations with other channels (e.g. registrations with - * other sip proxies) - */ - private Integer registryCount; - - /** - * The number of peers defined during the configuration of this channel - * (e.g. sip peer definitions) - */ - private Integer peerCount; - - /** - * The number of users defined during the configuration of this channel - * (e.g. sip user definitions) - */ - private Integer userCount; - - /** - * @param source - */ - public ChannelReloadEvent(Object source) - { - super(source); - } - - /** - * Returns the type of channel that was reloaded. For channels/chan_sip.c, this would be "SIP". - * - * @return the type of channel that was reloaded (e.g. SIP) - * @since 1.0.0 - */ - public String getChannelType() - { - return channelType; - } - - public void setChannelType(String channelType) - { - this.channelType = channelType; - } - - /** - * Returns the channel that was reloaded. For - * channels/chan_sip.c, this would be "SIP" - * - * @return the type of channel that was reloaded (e.g. SIP) - * @deprecated use {@link #getChannelType()} instead. - */ - @Deprecated public String getChannel() - { - return channelType; - } - - public void setChannel(String channel) - { - this.channelType = channel; - } - - /** - * Returns the number of peers defined during the configuration of this - * channel (e.g. sip peer definitions). - * - * @return the number of peers defined during the configuration of this - * channel (e.g. sip peer definitions) - */ - public Integer getPeerCount() - { - return peerCount; - } - - /** - * @param peerCount the number of peers defined during the configuration of - * this channel (e.g. sip peer definitions) - */ - public void setPeerCount(Integer peerCount) - { - this.peerCount = peerCount; - } - - /** - * @return the number of registrations with other channels (e.g. - * registrations with other sip proxies) - */ - public Integer getRegistryCount() - { - return registryCount; - } - - /** - * @param registryCount the number of registrations with other channels - * (e.g. registrations with other sip proxies) - */ - public void setRegistryCount(Integer registryCount) - { - this.registryCount = registryCount; - } - - /** - * Returns the reason that this channel was reloaded as received from Asterisk, for - * example "CLIRELOAD (Channel module reload by CLI command)". - *
- * Usually you don't want to use this method directly. - * - * @return the reason for the reload as received from Asterisk. - * @see #getReloadReasonCode() - * @see #getReloadReasonDescription() - */ - public String getReloadReason() - { - return reloadReason; - } - - /** - * Sets the reason that this channel was reloaded, for - * example "CLIRELOAD (Channel module reload by CLI command)". - * - * @param reloadReason the reason that this channel was reloaded - */ - public void setReloadReason(String reloadReason) - { - Matcher matcher; - - this.reloadReason = reloadReason; - if (reloadReason == null) - { - return; - } - - matcher = REASON_PATTERN.matcher(reloadReason); - if (matcher.matches()) - { - reloadReasonCode = matcher.group(1); - reloadReasonDescription = matcher.group(2); - } - } - - /** - * Returns the reason that this channel was reloaded.

- * Only the code part of the reason is returned. This is one of - *

    - *
  • LOAD
  • - *
  • RELOAD
  • - *
  • CLIRELOAD
  • - *
  • MANAGERRELOAD
  • - *
- * - * @return the code of the reason for the reload - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_CLI_RELOAD - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_LOAD - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_RELOAD - * @see org.asteriskjava.manager.event.ChannelReloadEvent#REASON_MANAGER_RELOAD - */ - public String getReloadReasonCode() - { - return reloadReasonCode; - } - - /** - * Returns the reason that this channel was reloaded as a human readable descriptive - * string, for example "Channel module reload by CLI command". - * - * @return the descriptive version of the reason for the reload. - */ - public String getReloadReasonDescription() - { - return reloadReasonDescription; - } - - /** - * @return the number of users defined during the configuration of this - * channel (e.g. sip user definitions) - */ - public Integer getUserCount() - { - return userCount; - } - - /** - * @param userCount the number of users defined during the configuration of - * this channel (e.g. sip user definitions) - */ - public void setUserCount(Integer userCount) - { - this.userCount = userCount; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ChannelUpdateEvent.java b/src/main/java/org/asteriskjava/manager/event/ChannelUpdateEvent.java deleted file mode 100644 index 15d250d74..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ChannelUpdateEvent.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ChannelUpdateEvent provides additional channel type specific information like - * the SIP call id or IAX2 call numbers about a channel.

- * Available since Asterisk 1.6.

- * It is implemented in channels/chan_sip.c, channels/chan_iax2.c and - * channels/chan_gtalk.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class ChannelUpdateEvent extends ManagerEvent -{ - private static final long serialVersionUID = 3141630567125429466L; - private String channelType; - private String channel; - private String uniqueId; - // SIP - private String sipCallId; - private String sipFullContact; - private String peerName; - // Gtalk - private String gtalkSid; - // IAX2 - private String iax2CallNoLocal; - private String iax2CallNoRemote; - private String iax2Peer; - - /** - * @param source - */ - public ChannelUpdateEvent(Object source) - { - super(source); - } - - - /** - * Returns the type of channel, that is "IAX2" for an IAX2 - * channel or "SIP" for a SIP channel.
- * For Google Talk it is either "GTALK" or "Gtalk". - * - * @return the type of channel that is registered. - */ - public String getChannelType() - { - return channelType; - } - - public void setChannelType(String channelType) - { - this.channelType = channelType; - } - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - public String getSipCallId() - { - return sipCallId; - } - - public void setSipCallId(String sipCallId) - { - this.sipCallId = sipCallId; - } - - public String getSipFullContact() - { - return sipFullContact; - } - - public void setSipFullContact(String sipFullContact) - { - this.sipFullContact = sipFullContact; - } - - public String getPeerName() - { - return peerName; - } - - public void setPeerName(String peerName) - { - this.peerName = peerName; - } - - public String getGtalkSid() - { - return gtalkSid; - } - - public void setGtalkSid(String gtalkSid) - { - this.gtalkSid = gtalkSid; - } - - public String getIax2CallNoLocal() - { - return iax2CallNoLocal; - } - - public void setIax2CallNoLocal(String iax2CallNoLocal) - { - this.iax2CallNoLocal = iax2CallNoLocal; - } - - public String getIax2CallNoRemote() - { - return iax2CallNoRemote; - } - - public void setIax2CallNoRemote(String iax2CallNoRemote) - { - this.iax2CallNoRemote = iax2CallNoRemote; - } - - public String getIax2Peer() - { - return iax2Peer; - } - - public void setIax2Peer(String iax2Peer) - { - this.iax2Peer = iax2Peer; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeEndEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeEndEvent.java deleted file mode 100644 index 16b97b27d..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeEndEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * This event is sent when the last user leaves a conference and it is torn - * down. - * - * @since 1.0.0 - */ -public class ConfbridgeEndEvent extends AbstractConfbridgeEvent -{ - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -8973512592594074108L; - - public ConfbridgeEndEvent(Object source) - { - super(source); - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeJoinEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeJoinEvent.java deleted file mode 100644 index 2405f369e..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeJoinEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * This event is sent when a user joins a conference - either one already in - * progress or as the first user to join a newly instantiated bridge. - * - * @since 1.0.0 - */ -public class ConfbridgeJoinEvent extends AbstractConfbridgeEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - public ConfbridgeJoinEvent(Object source) - { - super(source); - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeLeaveEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeLeaveEvent.java deleted file mode 100644 index 2116a5a5f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeLeaveEvent.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * This event is sent when a user leaves a conference. - * - * @since 1.0.0 - */ -public class ConfbridgeLeaveEvent extends AbstractConfbridgeEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - public ConfbridgeLeaveEvent(Object source) - { - super(source); - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeListCompleteEvent.java deleted file mode 100644 index e446f617b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListCompleteEvent.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.asteriskjava.manager.event; - -public class ConfbridgeListCompleteEvent extends ResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - private String eventList; - private String listItems; - - /** - * @param source - */ - public ConfbridgeListCompleteEvent(Object source) - { - super(source); - } - - /** - * Sets the status of the list e.g. complete. - */ - public void setEventList(String eventList) - { - this.eventList = eventList; - } - - /** - * Returns the status of the list e.g. complete. - */ - public String getEventList() - { - return eventList; - } - - /** - * Sets the number listitems. - */ - public void setListItems(String listItems) - { - this.listItems = listItems; - } - - /** - * Returns the number listitems. - */ - public String getListItems() - { - return listItems; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeListEvent.java deleted file mode 100644 index 4046c17bd..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListEvent.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Response to a {@link org.asteriskjava.manager.action.ConfbridgeListAction}. - * - * @see org.asteriskjava.manager.action.ConfbridgeListAction - * @since 1.0.0 - */ -public class ConfbridgeListEvent extends ResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - private String conference; - private Boolean admin; - private Boolean markedUser; - private String channel; - - public ConfbridgeListEvent(Object source) - { - super(source); - } - - /** - * Sets the id of the conference to be listed. - * - * @param conference the id of the conference to be listed. - */ - public void setConference(String conference) - { - this.conference = conference; - } - - /** - * Returns the id of the conference to be listed. - * - * @return the id of the conference to be listed. - */ - public String getConference() - { - return conference; - } - - /** - * Sets the role of the caller in the list admin = yes or no of the conference. - * - * @param admin = yes or no the role of the caller in the list of the conference. - */ - public void setAdmin(Boolean admin) - { - this.admin = admin; - } - - /** - * Returns the role of the caller in the list admin = yes or no of the conference. - * - * @return the role of the caller in the list admin = yes or no of the conference. - */ - public Boolean getAdmin() - { - return admin; - } - - public void setMarkedUser(Boolean markedUser) - { - this.markedUser = markedUser; - } - - public Boolean getMarkedUser() - { - return markedUser; - } - - /** - * Sets the name of the channel in the list. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the channel in the list. - */ - public String getChannel() - { - return channel; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListRoomsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeListRoomsCompleteEvent.java deleted file mode 100644 index 62c863a8d..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListRoomsCompleteEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.asteriskjava.manager.event; - -public class ConfbridgeListRoomsCompleteEvent extends ResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - private String eventList; - private String listItems; - - public ConfbridgeListRoomsCompleteEvent(Object source) - { - super(source); - } - - /** - * Sets the status of the list that is always "Complete". - */ - public void setEventList(String eventList) - { - this.eventList = eventList; - } - - /** - * Returns the status of the list that is always "Complete". - */ - public String getEventList() - { - return eventList; - } - - /** - * Sets the number items returned. - * - * @param listItems the number items returned. - */ - public void setListItems(String listItems) - { - this.listItems = listItems; - } - - /** - * Returns the number listitems. - * - * @return the number items returned. - */ - public String getListItems() - { - return listItems; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListRoomsEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeListRoomsEvent.java deleted file mode 100644 index 342ab684a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeListRoomsEvent.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.asteriskjava.manager.event; - -public class ConfbridgeListRoomsEvent extends ResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - private String conference; - private Integer parties; - private Integer marked; - private Boolean locked; - - public ConfbridgeListRoomsEvent(Object source) - { - super(source); - } - - /** - * Sets the id of the conference to be listed. - */ - public void setConference(String conference) - { - this.conference = conference; - } - - /** - * Returns the id of the conference to be listed. - */ - public String getConference() - { - return conference; - } - - /** - * Sets the number of participants in this conference. - * - * @param parties the number of participants in this conference. - */ - public void setParties(Integer parties) - { - this.parties = parties; - } - - /** - * Returns the number of participants in this conference. - * - * @return the number of participants in this conference. - */ - public Integer getParties() - { - return parties; - } - - /** - * Sets the number of marked participants in this conference. - * - * @param marked the number of marked participants in this conference. - */ - public void setMarked(Integer marked) - { - this.marked = marked; - } - - /** - * Returns the number of marked participants in this conference. - * - * @return the number of marked participants in this conference. - */ - public Integer getMarked() - { - return marked; - } - - public void setLocked(Boolean locked) - { - this.locked = locked; - } - - public Boolean getLocked() - { - return locked; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeStartEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeStartEvent.java deleted file mode 100644 index bd001c754..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeStartEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * This event is sent when the first user requests a conference and it is - * instantiated. - * - * @since 1.0.0 - */ -public class ConfbridgeStartEvent extends AbstractConfbridgeEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private String conference; - - public ConfbridgeStartEvent(Object source) - { - super(source); - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConfbridgeTalkingEvent.java b/src/main/java/org/asteriskjava/manager/event/ConfbridgeTalkingEvent.java deleted file mode 100644 index 4ce4fba72..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConfbridgeTalkingEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * This event is sent when the conference detects that a user has either begin - * or stopped talking. - * - * @since 1.0.0 - */ -public class ConfbridgeTalkingEvent extends AbstractConfbridgeEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - - private Boolean talkingStatus; - - public ConfbridgeTalkingEvent(Object source) - { - super(source); - } - - /** - * Sets the talking status on or off. - * - * @param talkingStatus the talking status - */ - public void setTalkingStatus(Boolean talkingStatus) - { - this.talkingStatus = talkingStatus; - } - - /** - * Returns the talking status. - * - * @return true if the participant started talking, - * false if the participant stopped talking. - */ - public Boolean getTalkingStatus() - { - return talkingStatus; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ConnectEvent.java b/src/main/java/org/asteriskjava/manager/event/ConnectEvent.java deleted file mode 100644 index a1cbd0593..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ConnectEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ConnectEvent is triggered after successful login to the Asterisk server.

- * It is a pseudo event not directly related to an Asterisk generated event. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.DisconnectEvent - */ -public class ConnectEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 3257845467831284784L; - - /** - * The version of the manager protocol. - */ - private String protocolIdentifier; - - /** - * @param source - */ - public ConnectEvent(Object source) - { - super(source); - } - - public ConnectEvent(Object source, String protocolIdentifier) - { - this(source); - this.protocolIdentifier = protocolIdentifier; - } - - /** - * Returns the version of the protocol. For example "Asterisk Call Manager/1.0" for Asterisk up to 1.4 and - * "Asterisk Call Manager/1.1" for Asterisk 1.6. - * - * @return the version of the protocol. - */ - public String getProtocolIdentifier() - { - return protocolIdentifier; - } - - /** - * Sets the version of the protocol. - * - * @param protocolIdentifier the version of the protocol. - */ - public void setProtocolIdentifier(String protocolIdentifier) - { - this.protocolIdentifier = protocolIdentifier; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/CoreShowChannelEvent.java b/src/main/java/org/asteriskjava/manager/event/CoreShowChannelEvent.java deleted file mode 100644 index c401b272f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/CoreShowChannelEvent.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 2009 Sebastian. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * under the License. - */ -package org.asteriskjava.manager.event; - -/** - * A CoreShowChannelEvent is triggered for each active channel in response to a - * CoreShowChannelsAction. - * - * @author sebastian gutierrez - * @version $Id$ - * @see org.asteriskjava.manager.action.CoreShowChannelsAction - * @since 1.0.0 - */ -public class CoreShowChannelEvent extends ResponseEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private String uniqueid; - private String channel; - private String extension; - private String application; - private String applicationdata; - private String duration; - private String accountcode; - private String bridgedChannel; - private String bridgeid; - private String linkedid; - private String language; - - - public CoreShowChannelEvent(Object source) - { - super(source); - } - - /** - * Returns the channel state - * - * @return channel state - */ - - /** - * Returns the Account code - * - * @return accountcode - */ - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } - - /** - * Returns the Aplication is runnning that channel at that time - * - * @return aplication name - */ - public String getApplication() - { - return application; - } - - public void setApplication(String application) - { - this.application = application; - } - - /** - * Returns the Aplication Data is runnning that channel at that time this is - * the parameters passed to that dialplan application - * - * @return aplication data - */ - public String getApplicationdata() - { - return applicationdata; - } - - public void setApplicationdata(String applicationdata) - { - this.applicationdata = applicationdata; - } - - /** - * Returns the Bridged Channel if is bridged to one - * - * @return Channel name - */ - public String getBridgedChannel() - { - return bridgedChannel; - } - - public void setBridgedChannel(String bridgedChannel) - { - this.bridgedChannel = bridgedChannel; - } - - /** - * Returns the Bridged UniqueID - * - * @return uniqueid - */ - @Deprecated - public String getBridgeduniqueid() - { - return bridgeid; - } - - @Deprecated - public void setBridgeduniqueid(String bridgeduniqueid) - { - this.bridgeid = bridgeduniqueid; - } - - /** - * Returns the Bridged UniqueID Case params name return "bridgeid" - * - * @return uniqueid - */ - public String getBridgeid() - { - return bridgeid; - } - - public void setBridgeid(String bridgeid) - { - this.bridgeid = bridgeid; - } - - /** - * Returns the Originate Channel name - * - * @return Channel name - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the duration of the call - * - * @return duration - */ - public String getDuration() - { - return duration; - } - - public void setDuration(String duration) - { - this.duration = duration; - } - - /** - * Returns the Extension dialed - * - * @return extension - */ - public String getExtension() - { - return extension; - } - - public void setExtension(String extension) - { - this.extension = extension; - } - - /** - * Returns the Uniqueid - * - * @return uniqueid - */ - public String getUniqueid() - { - return uniqueid; - } - - public void setUniqueid(String uniqueid) - { - this.uniqueid = uniqueid; - } - - - /** - * Returns the Channel LinkedID - * - * @return linkedid - */ - public String getLinkedid() { - return linkedid; - } - - public void setLinkedid(String linkedid) { - this.linkedid = linkedid; - } - - - /** - * Returns the Channel Language - * - * @return language - */ - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/CoreShowChannelsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/CoreShowChannelsCompleteEvent.java deleted file mode 100644 index 8bab60ebe..000000000 --- a/src/main/java/org/asteriskjava/manager/event/CoreShowChannelsCompleteEvent.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2009 Sebastian. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * under the License. - */ - -package org.asteriskjava.manager.event; - -/** - * A CoreShowChannelsCompleteEvent is triggered after the state of all channels has been reported in response - * to a CoreShowChannelsAction. - * - * @author sebastian gutierrez - * @see org.asteriskjava.manager.action.CoreShowChannelsAction - * @see org.asteriskjava.manager.event.CoreShowChannelEvent - * @since 1.0.0 - */ -public class CoreShowChannelsCompleteEvent extends ResponseEvent -{ - - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - private Integer listitems; - private String eventlist; - - public CoreShowChannelsCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns if the status of the eventlist (should be Complete).

- * - * @return the status of the list. - * @since 1.0.0 - */ - public String getEventlist() - { - return eventlist; - } - - public void setEventlist(String eventlist) - { - this.eventlist = eventlist; - } - - /** - * Returns the number of channels reported.

- * - * @return the number of channels reported. - */ - public Integer getListitems() - { - return listitems; - } - - /** - * Sets the number of channels reported.

- * - * @param listitems the number of channels reported. - */ - public void setListitems(Integer listitems) - { - this.listitems = listitems; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DAHDIChannelEvent.java b/src/main/java/org/asteriskjava/manager/event/DAHDIChannelEvent.java deleted file mode 100644 index 2c8a139f4..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DAHDIChannelEvent.java +++ /dev/null @@ -1,64 +0,0 @@ - -package org.asteriskjava.manager.event; - -/** - * @author Sebastian - */ -public class DAHDIChannelEvent extends ManagerEvent -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - private String dahdichannel; - private String dahdispan; - private String uniqueid; - private String channel; - - public String getDahdichannel() - { - return dahdichannel; - } - - public void setDahdichannel(String dahdichannel) - { - this.dahdichannel = dahdichannel; - } - - public String getDahdispan() - { - return dahdispan; - } - - public void setDahdispan(String dahdispan) - { - this.dahdispan = dahdispan; - } - - public String getUniqueid() - { - return uniqueid; - } - - public void setUniqueid(String uniqueid) - { - this.uniqueid = uniqueid; - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public DAHDIChannelEvent(Object source) - { - super(source); - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DahdiShowChannelsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/DahdiShowChannelsCompleteEvent.java deleted file mode 100644 index 5945f2fed..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DahdiShowChannelsCompleteEvent.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DahdiShowChannelsCompleteEvent is triggered after the state of all Dahdi channels has been reported - * in response to a DahdiShowChannelsAction. - * - * @see org.asteriskjava.manager.action.DahdiShowChannelsAction - * @see org.asteriskjava.manager.event.DahdiShowChannelsEvent - * - * @author srt - * @version $Id$ - */ -public class DahdiShowChannelsCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 6323249250335885462L; - - private Integer listitems; - private String eventlist; - private Integer items; - - public Integer getItems() { - return items; - } - - public void setItems(Integer items) { - this.items = items; - } - - /** - * @param source - */ - public DahdiShowChannelsCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns if the status of the eventlist (should be Complete).

- * - * @return the status of the list. - * @since 1.0.0 - */ - public String getEventlist() - { - return eventlist; - } - - public void setEventlist(String eventlist) - { - this.eventlist = eventlist; - } - - /** - * Returns the number of channels reported.

- * - * @return the number of channels reported. - */ - public Integer getListitems() - { - return listitems; - } - - /** - * Sets the number of channels reported.

- * - * @param listitems the number of channels reported. - */ - public void setListitems(Integer listitems) - { - this.listitems = listitems; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DahdiShowChannelsEvent.java b/src/main/java/org/asteriskjava/manager/event/DahdiShowChannelsEvent.java deleted file mode 100644 index e878df7b6..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DahdiShowChannelsEvent.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DahdiShowChannelsEvent is triggered in response to a DahdiShowChannelsAction and shows the state of - * a Dahdi channel. - * - * @see org.asteriskjava.manager.action.DahdiShowChannelsAction - * - * @author srt - * @version $Id$ - */ -public class DahdiShowChannelsEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -3613642267527361400L; - private Integer Dahdichannel; - private String signalling; - private String signallingcode; - private Boolean dnd; - private String alarm; - private String uniqueid; - private String accountcode; - private String channel; - - public String getAccountcode() { - return accountcode; - } - - public void setAccountcode(String accountcode) { - this.accountcode = accountcode; - } - - public String getChannel() { - return channel; - } - - public void setChannel(String channel) { - this.channel = channel; - } - - public Integer getDahdichannel() { - return Dahdichannel; - } - - public void setDahdichannel(Integer Dahdichannel) { - this.Dahdichannel = Dahdichannel; - } - - public String getSignallingcode() { - return signallingcode; - } - - public void setSignallingcode(String signallingcode) { - this.signallingcode = signallingcode; - } - - public String getUniqueid() { - return uniqueid; - } - - public void setUniqueid(String uniqueid) { - this.uniqueid = uniqueid; - } - - - - - /** - * @param source - */ - public DahdiShowChannelsEvent(Object source) - { - super(source); - } - - - /** - * Returns the signalling of this Dahdi channel.

- * Possible values are: - *

    - *
  • E & M Immediate
  • - *
  • E & M Wink
  • - *
  • E & M E1
  • - *
  • Feature Group D (DTMF)
  • - *
  • Feature Group D (MF)
  • - *
  • Feature Group B (MF)
  • - *
  • E911 (MF)
  • - *
  • FXS Loopstart
  • - *
  • FXS Groundstart
  • - *
  • FXS Kewlstart
  • - *
  • FXO Loopstart
  • - *
  • FXO Groundstart
  • - *
  • FXO Kewlstart
  • - *
  • PRI Signalling
  • - *
  • R2 Signalling
  • - *
  • SF (Tone) Signalling Immediate
  • - *
  • SF (Tone) Signalling Wink
  • - *
  • SF (Tone) Signalling with Feature Group D (DTMF)
  • - *
  • SF (Tone) Signalling with Feature Group D (MF)
  • - *
  • SF (Tone) Signalling with Feature Group B (MF)
  • - *
  • GR-303 Signalling with FXOKS
  • - *
  • GR-303 Signalling with FXSKS
  • - *
  • Pseudo Signalling
  • - *
- */ - public String getSignalling() - { - return signalling; - } - - /** - * Sets the signalling of this Dahdi channel. - */ - public void setSignalling(String signalling) - { - this.signalling = signalling; - } - - /** - * Returns whether dnd (do not disturb) is enabled for this Dahdi channel. - * - * @return Boolean.TRUE if dnd is enabled, Boolean.FALSE if it is disabled, - * null if not set. - * @since 0.3 - */ - public Boolean getDnd() - { - return dnd; - } - - /** - * Sets whether dnd (do not disturb) is enabled for this Dahdi channel. - * - * @param dnd Boolean.TRUE if dnd is enabled, Boolean.FALSE if it is disabled. - * @since 0.3 - */ - public void setDnd(Boolean dnd) - { - this.dnd = dnd; - } - - /** - * Returns the alarm state of this Dahdi channel.

- * This may be one of - *

    - *
  • Red Alarm
  • - *
  • Yellow Alarm
  • - *
  • Blue Alarm
  • - *
  • Recovering
  • - *
  • Loopback
  • - *
  • Not Open
  • - *
  • No Alarm
  • - *
- */ - public String getAlarm() - { - return alarm; - } - - /** - * Sets the alarm state of this Dahdi channel. - */ - public void setAlarm(String alarm) - { - this.alarm = alarm; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DbGetResponseEvent.java b/src/main/java/org/asteriskjava/manager/event/DbGetResponseEvent.java deleted file mode 100644 index b1fdbb3c9..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DbGetResponseEvent.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DBGetResponseEvent is sent in response to a DBGetAction and contains the - * entry that was queried.

- * Available since Asterisk 1.2 - * - * @see org.asteriskjava.manager.action.DbGetAction - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class DbGetResponseEvent extends ResponseEvent -{ - private String family; - private String key; - private String val; - - /** - * Serial version identifier - */ - private static final long serialVersionUID = -1177773673509373296L; - - /** - * @param source - */ - public DbGetResponseEvent(Object source) - { - super(source); - } - - /** - * Returns the family of the database entry that was queried. - * - * @return the family of the database entry that was queried. - */ - public String getFamily() - { - return family; - } - - /** - * Sets the family of the database entry that was queried. - * - * @param family the family of the database entry that was queried. - */ - public void setFamily(String family) - { - this.family = family; - } - - /** - * Returns the key of the database entry that was queried. - * - * @return the key of the database entry that was queried. - */ - public String getKey() - { - return key; - } - - /** - * Sets the key of the database entry that was queried. - * - * @param key the key of the database entry that was queried. - */ - public void setKey(String key) - { - this.key = key; - } - - /** - * Returns the value of the database entry that was queried. - * - * @return the value of the database entry that was queried. - */ - public String getVal() - { - return val; - } - - /** - * Sets the value of the database entry that was queried. - * - * @param val the value of the database entry that was queried. - */ - public void setVal(String val) - { - this.val = val; - } - - /** - * Sets the value of the database entry that was queried. - * It seems that in ast 1.2 ( 1.2.9 +BRIStuff ? ) at least the key is - * not val anymore but value. - * - * @param val the value of the database entry that was queried. - */ - public void setValue(String val) - { - this.val = val; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DeviceStateChangeEvent.java b/src/main/java/org/asteriskjava/manager/event/DeviceStateChangeEvent.java deleted file mode 100644 index b4d31d8f9..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DeviceStateChangeEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DeviceStateChangeEvent extends ManagerEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String state; - private String device; - - public String getState() - { - return state; - } - - public void setState(String state) - { - this.state = state; - } - - public String getDevice() - { - return device; - } - - public void setDevice(String device) - { - this.device = device; - } - - public DeviceStateChangeEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DialBeginEvent.java b/src/main/java/org/asteriskjava/manager/event/DialBeginEvent.java deleted file mode 100644 index f4f3601be..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DialBeginEvent.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DialBeginEvent extends DialEvent -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - private String language; - private String destlanguage; - private String destAccountCode; - private String linkedId; - private String destLinkedId; - - private String accountcode; - - public DialBeginEvent(Object source) - { - super(source); - setSubEvent(SUBEVENT_BEGIN); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getDestLanguage() - { - return destlanguage; - } - - public void setDestLanguage(String destlanguage) - { - this.destlanguage = destlanguage; - } - - public String getDestAccountCode() - { - return destAccountCode; - } - - public void setDestAccountCode(String destAccountCode) - { - this.destAccountCode = destAccountCode; - } - - public String getDestlanguage() - { - return destlanguage; - } - - public void setDestlanguage(String destlanguage) - { - this.destlanguage = destlanguage; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getDestLinkedId() - { - return destLinkedId; - } - - public void setDestLinkedId(String destLinkedId) - { - this.destLinkedId = destLinkedId; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DialEndEvent.java b/src/main/java/org/asteriskjava/manager/event/DialEndEvent.java deleted file mode 100644 index 256302652..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DialEndEvent.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DialEndEvent extends DialEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String language; - private String destLanguage; - private String accountCode; - private String destAccountCode; - private String destLinkedId; - private String linkedId; - - public DialEndEvent(Object source) - { - super(source); - setSubEvent(SUBEVENT_END); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getDestLanguage() - { - return destLanguage; - } - - public void setDestLanguage(String destLanguage) - { - this.destLanguage = destLanguage; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getDestAccountCode() - { - return destAccountCode; - } - - public void setDestAccountCode(String destAccountCode) - { - this.destAccountCode = destAccountCode; - } - - public String getDestLinkedId() - { - return destLinkedId; - } - - public void setDestLinkedId(String destLinkedId) - { - this.destLinkedId = destLinkedId; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DialEvent.java b/src/main/java/org/asteriskjava/manager/event/DialEvent.java deleted file mode 100644 index 7c1c7f0b6..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DialEvent.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A dial event is triggered whenever a phone attempts to dial someone. - *

- * This event is implemented in apps/app_dial.c. - *

- * Available since Asterisk 1.2. - * - * @author Asteria Solutions Group, Inc. http://www.asteriasgi.com/ - * @version $Id$ - * @since 0.2 - */ -public class DialEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - public static final String SUBEVENT_BEGIN = "Begin"; - public static final String SUBEVENT_END = "End"; - - public static final String DIALSTATUS_CHANUNAVAIL = "CHANUNAVAIL"; - public static final String DIALSTATUS_CONGESTION = "CONGESTION"; - public static final String DIALSTATUS_NOANSWER = "NOANSWER"; - public static final String DIALSTATUS_BUSY = "BUSY"; - public static final String DIALSTATUS_ANSWER = "ANSWER"; - public static final String DIALSTATUS_CANCEL = "CANCEL"; - public static final String DIALSTATUS_DONTCALL = "DONTCALL"; - public static final String DIALSTATUS_TORTURE = "TORTURE"; - public static final String DIALSTATUS_INVALIDARGS = "INVALIDARGS"; - - private String subEvent = SUBEVENT_BEGIN; - - /** - * The name of the source channel. - */ - private String channel; - - /** - * The name of the destination channel. - */ - private String destination; - - /** - * Destination channel state - */ - private Integer destChannelState; - private String destChannelStateDesc; - - private String destContext; - - private Integer destPriority; - - private String destExten; - - private String destConnectedLineName; - private String destConnectedLineNum; - - private String destCallerIdName; - private String destCallerIdNum; - - /** - * The unique id of the source channel. - */ - private String uniqueId; - - /** - * The unique id of the destination channel. - */ - private String destUniqueId; - - private String dialString; - private String dialStatus; - - public DialEvent(Object source) - { - super(source); - } - - /** - * Enro 2015-03 Workaround to build legacy DialEvent (unsupported in - * Asterisk 13) from new DialBeginEvent Asterisk 13. - */ - public DialEvent(DialBeginEvent dialBeginEvent) - { - this(dialBeginEvent.getSource()); - setDateReceived(dialBeginEvent.getDateReceived()); - setTimestamp(dialBeginEvent.getTimestamp()); - setPrivilege(dialBeginEvent.getPrivilege()); - setCallerId(dialBeginEvent.getCallerIdNum()); - setCallerIdName(dialBeginEvent.getCallerIdName()); - setSrc(dialBeginEvent.getChannel()); - setUniqueId(dialBeginEvent.getSrcUniqueId()); - setDestUniqueId(dialBeginEvent.getDestUniqueId()); - setDestination(dialBeginEvent.getDestChannel()); - setDialStatus(dialBeginEvent.getDialStatus()); - } - - /** - * Since Asterisk 1.6 the begin and the end of a dial command generate a - * Dial event. The subEvent property returns whether the dial started - * execution ("Begin") or completed ("End"). As Asterisk prior to 1.6 only - * sends one event per Dial command this always returns "Begin" for Asterisk - * prior to 1.6.
- * For an "End" sub event only the properies channel, unqiue id and dial - * status are available, for a "Begin" sub event all properties are - * available except for the dial status. - * - * @return "Begin" or "End" for Asterisk since 1.6, "Begin" for Asterisk - * prior to 1.6. - * @since 1.0.0 - */ - public String getSubEvent() - { - return subEvent; - } - - public void setSubEvent(String subEvent) - { - this.subEvent = subEvent; - } - - /** - * Returns the name of the source channel. - * - * @return the name of the source channel. - * @since 1.0.0 - */ - public String getChannel() - { - return channel; - } - - /** - * Returns the name of the source channel. - * - * @param channel the name of the source channel. - * @since 1.0.0 - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the name of the source channel. - * - * @return the name of the source channel. - * @deprecated as of 1.0.0, use {@link #getChannel()} instead. - */ - @Deprecated - public String getSrc() - { - return channel; - } - - /** - * Sets the name of the source channel. - *

- * Asterisk versions up to 1.4 use the "Source" property instead of - * "Channel". - * - * @param src the name of the source channel. - */ - public void setSrc(String src) - { - this.channel = src; - } - - /** - * Returns the name of the destination channel. - * - * @return the name of the destination channel. - */ - public String getDestination() - { - return destination; - } - - public String getDestChannel() - { - return getDestination(); - } - - /** - * Sets the name of the destination channel. - * - * @param destination the name of the destination channel. - */ - public void setDestination(String destination) - { - this.destination = destination; - } - - public void setDestChannel(String destination) - { - setDestination(destination); - } - - /** - * Returns the Caller*ID. - * - * @return the Caller*ID or "<unknown>" if none has been set. - * @deprecated as of 1.0.0, use {@link #getCallerIdNum()} instead. - */ - @Deprecated - public String getCallerId() - { - return getCallerIdNum(); - } - - /** - * Sets the caller*ID. - * - * @param callerId the caller*ID. - * @deprecated as of 1.0.0, use {@link #setCallerIdNum()} instead. - */ - @Deprecated - public void setCallerId(String callerId) - { - setCallerIdNum(callerId); - } - - /** - * Returns the unique ID of the source channel. - * - * @return the unique ID of the source channel. - * @since 1.0.0 - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique ID of the source channel. - * - * @param srcUniqueId the unique ID of the source channel. - * @since 1.0.0 - */ - public void setUniqueId(String srcUniqueId) - { - this.uniqueId = srcUniqueId; - } - - /** - * Returns the unique ID of the source channel. - * - * @return the unique ID of the source channel. - * @deprecated as of 1.0.0, use {@link #getUniqueId()} instead. - */ - @Deprecated - public String getSrcUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique ID of the source channel. - *

- * Asterisk versions up to 1.4 use the "SrcUniqueId" property instead of - * "UniqueId". - * - * @param srcUniqueId the unique ID of the source channel. - */ - public void setSrcUniqueId(String srcUniqueId) - { - this.uniqueId = srcUniqueId; - } - - /** - * Returns the unique ID of the destination channel. - * - * @return the unique ID of the destination channel. - */ - public String getDestUniqueId() - { - return destUniqueId; - } - - /** - * Sets the unique ID of the destination channel. - * - * @param destUniqueId the unique ID of the destination channel. - */ - public void setDestUniqueId(String destUniqueId) - { - this.destUniqueId = destUniqueId; - } - - /** - * Returns the dial string passed to the Dial application. - *

- * Available since Asterisk 1.6. - * - * @return the dial string passed to the Dial application. - * @since 1.0.0 - */ - public String getDialString() - { - return dialString; - } - - /** - * Sets the dial string passed to the Dial application. - * - * @param dialString the dial string passed to the Dial application. - * @since 1.0.0 - */ - public void setDialString(String dialString) - { - this.dialString = dialString; - } - - /** - * For end subevents this returns whether the completion status of the dial - * application.
- * Possible values are: - *

    - *
  • CHANUNAVAIL
  • - *
  • CONGESTION
  • - *
  • NOANSWER
  • - *
  • BUSY
  • - *
  • ANSWER
  • - *
  • CANCEL
  • - *
  • DONTCALL
  • - *
  • TORTURE
  • - *
  • INVALIDARGS
  • - *
- * It corresponds the the DIALSTATUS variable used in the dialplan. - *

- * Available since Asterisk 1.6. - * - * @return the completion status of the dial application. - * @since 1.0.0 - */ - public String getDialStatus() - { - return dialStatus; - } - - public void setDialStatus(String dialStatus) - { - this.dialStatus = dialStatus; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("DialEvent [subEvent="); - builder.append(subEvent); - builder.append(", channel="); - builder.append(channel); - builder.append(", destination="); - builder.append(destination); - builder.append(", callerIdNum="); - builder.append(callerIdNum); - builder.append(", callerIdName="); - builder.append(callerIdName); - builder.append(", uniqueId="); - builder.append(uniqueId); - builder.append(", destUniqueId="); - builder.append(destUniqueId); - builder.append(", dialString="); - builder.append(dialString); - builder.append(", dialStatus="); - builder.append(dialStatus); - builder.append(", connectedLineNum="); - builder.append(connectedLineNum); - builder.append(", connectedLineName="); - builder.append(connectedLineName); - builder.append("]"); - return builder.toString(); - } - - public Integer getDestChannelState() - { - return destChannelState; - } - - public void setDestChannelState(Integer destChannelState) - { - this.destChannelState = destChannelState; - } - - public String getDestContext() - { - return destContext; - } - - public void setDestContext(String destContext) - { - this.destContext = destContext; - } - - public Integer getDestPriority() - { - return destPriority; - } - - public void setDestPriority(Integer destPriority) - { - this.destPriority = destPriority; - } - - public String getDestChannelStateDesc() - { - return destChannelStateDesc; - } - - public void setDestChannelStateDesc(String destChannelStateDesc) - { - this.destChannelStateDesc = destChannelStateDesc; - } - - public String getDestExten() - { - return destExten; - } - - public void setDestExten(String destExten) - { - this.destExten = destExten; - } - - public String getDestConnectedLineName() - { - return destConnectedLineName; - } - - public void setDestConnectedLineName(String destConnectedLineName) - { - this.destConnectedLineName = destConnectedLineName; - } - - public String getDestConnectedLineNum() - { - return destConnectedLineNum; - } - - public void setDestConnectedLineNum(String destConnectedLineNum) - { - this.destConnectedLineNum = destConnectedLineNum; - } - - public String getDestCallerIdName() - { - return destCallerIdName; - } - - public void setDestCallerIdName(String destCallerIdName) - { - this.destCallerIdName = destCallerIdName; - } - - public String getDestCallerIdNum() - { - return destCallerIdNum; - } - - public void setDestCallerIdNum(String destCallerIdNum) - { - this.destCallerIdNum = destCallerIdNum; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DisconnectEvent.java b/src/main/java/org/asteriskjava/manager/event/DisconnectEvent.java deleted file mode 100644 index 129490d26..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DisconnectEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DisconnectEvent is triggered when the connection to the asterisk server is lost.

- * It is a pseudo event not directly related to an Asterisk generated event. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.ConnectEvent - */ -public class DisconnectEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 3689355411862206518L; - - /** - * @param source - */ - public DisconnectEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DndStateEvent.java b/src/main/java/org/asteriskjava/manager/event/DndStateEvent.java deleted file mode 100644 index 7af8b31e2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DndStateEvent.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DNDStateEvent is triggered by the Zap channel driver when a channel enters - * or leaves DND (do not disturb) state.

- * It is implemented in channels/chan_zap.c.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class DndStateEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 5906599407896179295L; - - /** - * The name of the channel. - */ - private String channel; - - /** - * The DND state of the channel. - */ - private Boolean state; - - /** - * Creates a new DNDStateEvent. - * - * @param source - */ - public DndStateEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. The channel name is of the form - * "Zap/<channel number>". - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns DND state of the channel. - * - * @return Boolean.TRUE if do not disturb is on, Boolean.FALSE if it is off. - */ - public Boolean getState() - { - return state; - } - - /** - * Sets the DND state of the channel. - */ - public void setState(Boolean state) - { - this.state = state; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DongleCENDEvent.java b/src/main/java/org/asteriskjava/manager/event/DongleCENDEvent.java deleted file mode 100644 index 6d8382908..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleCENDEvent.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleCENDEvent extends ManagerEvent -{ - private static final long serialVersionUID = 3257845467831284784L; - private String device; - private String endstatus; - private String cccause; - private String duration; - private String callidx; - - - - public DongleCENDEvent(Object source) - { - super(source); - } - - public String getDevice() { - return this.device; - } - - public void setDevice(String device) { - this.device = device; - } - - public String getCallidx() { - return callidx; - } - - public void setCallidx(String callidx) { - this.callidx = callidx; - } - - public String getCccause() { - return cccause; - } - - public void setCccause(String cccause) { - this.cccause = cccause; - } - - public String getDuration() { - return duration; - } - - public void setDuration(String duration) { - this.duration = duration; - } - - public String getEndstatus() { - return endstatus; - } - - public void setEndstatus(String endstatus) { - this.endstatus = endstatus; - } - - - - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/DongleCallStateChangeEvent.java b/src/main/java/org/asteriskjava/manager/event/DongleCallStateChangeEvent.java deleted file mode 100644 index 59e16e263..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleCallStateChangeEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleCallStateChangeEvent extends ManagerEvent -{ - private static final long serialVersionUID = 3257845467831284784L; - private String device; - private String callidx; - private String newstate; - - public DongleCallStateChangeEvent(Object source) - { - super(source); - } - - public String getDevice() { - return this.device; - } - - public void setDevice(String device) { - this.device = device; - } - - public String getCallidx() { - return callidx; - } - - public void setCallidx(String callidx) { - this.callidx = callidx; - } - - public String getNewstate() { - return newstate; - } - - public void setNewstate(String newstate) { - this.newstate = newstate; - } - - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/DongleDeviceEntryEvent.java b/src/main/java/org/asteriskjava/manager/event/DongleDeviceEntryEvent.java deleted file mode 100644 index 1ef740d86..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleDeviceEntryEvent.java +++ /dev/null @@ -1,633 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleDeviceEntryEvent extends ResponseEvent -{ - - /** - * - */ - private static final long serialVersionUID = 1L; - private String Device; - private String AudioSetting; - private String DataSetting; - private String IMEISetting; - private String IMSISetting; - private String ChannelLanguage; - private String Group; - private String RXGain; - private String TXGain; - private String U2DIAG; - private String UseCallingPres; - private String DefaultCallingPres; - private String AutoDeleteSMS; - private String DisableSMS; - private String ResetDongle; - private String SMSPDU; - private String CallWaitingSetting; - private String DTMF; - private String MinimalDTMFGap; - private String MinimalDTMFDuration; - private String MinimalDTMFInterval; - - private String State; - private String AudioState; - private String DataState; - private String Voice; - private String SMS; - private String Manufacturer; - private String Model; - private String Firmware; - private String IMEIState; - private String GSMRegistrationStatus; - private String RSSI; - private String Mode; - private String Submode; - private String ProviderName; - private String LocationAreaCode; - private String CellID; - private String SubscriberNumber; - private String SMSServiceCenter; - private String UseUCS2Encoding; - private String USSDUse7BitEncoding; - private String USSDUseUCS2Decoding; - private String TasksInQueue; - private String CommandsInQueue; - private String CallWaitingState; - private String CurrentDeviceState; - private String DesiredDeviceState; - private String CallsChannels; - private String Active; - private String Held; - private String Dialing; - private String Alerting; - private String Incoming; - private String Waiting; - private String Releasing; - private String Initializing; - - public DongleDeviceEntryEvent(Object source) - { - super(source); - } - - public String getDevice() - { - return Device; - } - - public void setDevice(String Device) - { - this.Device = Device; - } - - public String getAudioSetting() - { - return AudioSetting; - } - - public void setAudioSetting(String AudioSetting) - { - this.AudioSetting = AudioSetting; - } - - public String getDataSetting() - { - return DataSetting; - } - - public void setDataSetting(String DataSetting) - { - this.DataSetting = DataSetting; - } - - public String getIMEISetting() - { - return IMEISetting; - } - - public void setIMEISetting(String IMEISetting) - { - this.IMEISetting = IMEISetting; - } - - public String getIMSISetting() - { - return IMSISetting; - } - - public void setIMSISetting(String IMSISetting) - { - this.IMSISetting = IMSISetting; - } - - public String getChannelLanguage() - { - return ChannelLanguage; - } - - public void setChannelLanguage(String ChannelLanguage) - { - this.ChannelLanguage = ChannelLanguage; - } - - public String getGroup() - { - return Group; - } - - public void setGroup(String Group) - { - this.Group = Group; - } - - public String getRXGain() - { - return RXGain; - } - - public void setRXGain(String RXGain) - { - this.RXGain = RXGain; - } - - public String getTXGain() - { - return TXGain; - } - - public void setTXGain(String TXGain) - { - this.TXGain = TXGain; - } - - public String getU2DIAG() - { - return U2DIAG; - } - - public void setU2DIAG(String U2DIAG) - { - this.U2DIAG = U2DIAG; - } - - public String getUseCallingPres() - { - return UseCallingPres; - } - - public void setUseCallingPres(String UseCallingPres) - { - this.UseCallingPres = UseCallingPres; - } - - public String getDefaultCallingPres() - { - return DefaultCallingPres; - } - - public void setDefaultCallingPres(String DefaultCallingPres) - { - this.DefaultCallingPres = DefaultCallingPres; - } - - public String getAutoDeleteSMS() - { - return AutoDeleteSMS; - } - - public void setAutoDeleteSMS(String AutoDeleteSMS) - { - this.AutoDeleteSMS = AutoDeleteSMS; - } - - public String getDisableSMS() - { - return DisableSMS; - } - - public void setDisableSMS(String DisableSMS) - { - this.DisableSMS = DisableSMS; - } - - public String getResetDongle() - { - return ResetDongle; - } - - public void setResetDongle(String ResetDongle) - { - this.ResetDongle = ResetDongle; - } - - public String getSMSPDU() - { - return SMSPDU; - } - - public void setSMSPDU(String SMSPDU) - { - this.SMSPDU = SMSPDU; - } - - public String getCallWaitingSetting() - { - return CallWaitingSetting; - } - - public void setCallWaitingSetting(String CallWaitingSetting) - { - this.CallWaitingSetting = CallWaitingSetting; - } - - public String getDTMF() - { - return DTMF; - } - - public void setDTMF(String DTMF) - { - this.DTMF = DTMF; - } - - public String getMinimalDTMFGap() - { - return MinimalDTMFGap; - } - - public void setMinimalDTMFGap(String MinimalDTMFGap) - { - this.MinimalDTMFGap = MinimalDTMFGap; - } - - public String getMinimalDTMFDuration() - { - return MinimalDTMFDuration; - } - - public void setMinimalDTMFDuration(String MinimalDTMFDuration) - { - this.MinimalDTMFDuration = MinimalDTMFDuration; - } - - public String getMinimalDTMFInterval() - { - return MinimalDTMFInterval; - } - - public void setMinimalDTMFInterval(String MinimalDTMFInterval) - { - this.MinimalDTMFInterval = MinimalDTMFInterval; - } - - public String getState() - { - return State; - } - - public void setState(String State) - { - this.State = State; - } - - public String getAudioState() - { - return AudioState; - } - - public void setAudioState(String AudioState) - { - this.AudioState = AudioState; - } - - public String getDataState() - { - return DataState; - } - - public void setDataState(String DataState) - { - this.DataState = DataState; - } - - public String getVoice() - { - return Voice; - } - - public void setVoice(String Voice) - { - this.Voice = Voice; - } - - public String getSMS() - { - return SMS; - } - - public void setSMS(String SMS) - { - this.SMS = SMS; - } - - public String getManufacturer() - { - return Manufacturer; - } - - public void setManufacturer(String Manufacturer) - { - this.Manufacturer = Manufacturer; - } - - public String getModel() - { - return Model; - } - - public void setModel(String Model) - { - this.Model = Model; - } - - public String getFirmware() - { - return Firmware; - } - - public void setFirmware(String Firmware) - { - this.Firmware = Firmware; - } - - public String getIMEIState() - { - return IMEIState; - } - - public void setIMEIState(String IMEIState) - { - this.IMEIState = IMEIState; - } - - public String getGSMRegistrationStatus() - { - return GSMRegistrationStatus; - } - - public void setGSMRegistrationStatus(String GSMRegistrationStatus) - { - this.GSMRegistrationStatus = GSMRegistrationStatus; - } - - public String getRSSI() - { - return RSSI; - } - - public void setRSSI(String RSSI) - { - this.RSSI = RSSI; - } - - public String getMode() - { - return Mode; - } - - public void setMode(String Mode) - { - this.Mode = Mode; - } - - public String getSubmode() - { - return Submode; - } - - public void setSubmode(String Submode) - { - this.Submode = Submode; - } - - public String getProviderName() - { - return ProviderName; - } - - public void setProviderName(String ProviderName) - { - this.ProviderName = ProviderName; - } - - public String getLocationAreaCode() - { - return LocationAreaCode; - } - - public void setLocationAreaCode(String LocationAreaCode) - { - this.LocationAreaCode = LocationAreaCode; - } - - public String getCellID() - { - return CellID; - } - - public void setCellID(String CellID) - { - this.CellID = CellID; - } - - public String getSubscriberNumber() - { - return SubscriberNumber; - } - - public void setSubscriberNumber(String SubscriberNumber) - { - this.SubscriberNumber = SubscriberNumber; - } - - public String getSMSServiceCenter() - { - return SMSServiceCenter; - } - - public void setSMSServiceCenter(String SMSServiceCenter) - { - this.SMSServiceCenter = SMSServiceCenter; - } - - public String getUseUCS2Encoding() - { - return UseUCS2Encoding; - } - - public void setUseUCS2Encoding(String UseUCS2Encoding) - { - this.UseUCS2Encoding = UseUCS2Encoding; - } - - public String getUSSDUse7BitEncoding() - { - return USSDUse7BitEncoding; - } - - public void setUSSDUse7BitEncoding(String USSDUse7BitEncoding) - { - this.USSDUse7BitEncoding = USSDUse7BitEncoding; - } - - public String getUSSDUseUCS2Decoding() - { - return USSDUseUCS2Decoding; - } - - public void setUSSDUseUCS2Decoding(String USSDUseUCS2Decoding) - { - this.USSDUseUCS2Decoding = USSDUseUCS2Decoding; - } - - public String getTasksInQueue() - { - return TasksInQueue; - } - - public void setTasksInQueue(String TasksInQueue) - { - this.TasksInQueue = TasksInQueue; - } - - public String getCommandsInQueue() - { - return CommandsInQueue; - } - - public void setCommandsInQueue(String CommandsInQueue) - { - this.CommandsInQueue = CommandsInQueue; - } - - public String getCallWaitingState() - { - return CallWaitingState; - } - - public void setCallWaitingState(String CallWaitingState) - { - this.CallWaitingState = CallWaitingState; - } - - public String getCurrentDeviceState() - { - return CurrentDeviceState; - } - - public void setCurrentDeviceState(String CurrentDeviceState) - { - this.CurrentDeviceState = CurrentDeviceState; - } - - public String getDesiredDeviceState() - { - return DesiredDeviceState; - } - - public void setDesiredDeviceState(String DesiredDeviceState) - { - this.DesiredDeviceState = DesiredDeviceState; - } - - public String getCallsChannels() - { - return CallsChannels; - } - - public void setCallsChannels(String CallsChannels) - { - this.CallsChannels = CallsChannels; - } - - public String getActive() - { - return Active; - } - - public void setActive(String Active) - { - this.Active = Active; - } - - public String getHeld() - { - return Held; - } - - public void setHeld(String Held) - { - this.Held = Held; - } - - public String getDialing() - { - return Dialing; - } - - public void setDialing(String Dialing) - { - this.Dialing = Dialing; - } - - public String getAlerting() - { - return Alerting; - } - - public void setAlerting(String Alerting) - { - this.Alerting = Alerting; - } - - public String getIncoming() - { - return Incoming; - } - - public void setIncoming(String Incoming) - { - this.Incoming = Incoming; - } - - public String getWaiting() - { - return Waiting; - } - - public void setWaiting(String Waiting) - { - this.Waiting = Waiting; - } - - public String getReleasing() - { - return Releasing; - } - - public void setReleasing(String Releasing) - { - this.Releasing = Releasing; - } - - public String getInitializing() - { - return Initializing; - } - - public void setInitializing(String Initializing) - { - this.Initializing = Initializing; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DongleNewCMGREvent.java b/src/main/java/org/asteriskjava/manager/event/DongleNewCMGREvent.java deleted file mode 100644 index 6f58b2d70..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleNewCMGREvent.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleNewCMGREvent extends ManagerEvent -{ - private static final long serialVersionUID = 3257845467831284784L; - private String device; - - public DongleNewCMGREvent(Object source) - { - super(source); - } - - public String getDevice() - { - return this.device; - } - - public void setDevice(String device) - { - this.device = device; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DongleNewSMSBase64Event.java b/src/main/java/org/asteriskjava/manager/event/DongleNewSMSBase64Event.java deleted file mode 100644 index 9f1535cdb..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleNewSMSBase64Event.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleNewSMSBase64Event extends ManagerEvent -{ - private static final long serialVersionUID = 3257845467831284784L; - private String from; - private String message; - private String device; - - public DongleNewSMSBase64Event(Object source) - { - super(source); - } - - public String getDevice() { - return this.device; - } - - public void setDevice(String device) { - this.device = device; - } - - public String getFrom() { - return this.from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/DongleNewSMSEvent.java b/src/main/java/org/asteriskjava/manager/event/DongleNewSMSEvent.java deleted file mode 100644 index 81fce3390..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleNewSMSEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleNewSMSEvent extends ManagerEvent -{ - private static final long serialVersionUID = 3257845467831284784L; - private String from; - private String messageline0; - private String device; - private String linecount; - - - public DongleNewSMSEvent(Object source) - { - super(source); - } - - public String getDevice() { - return this.device; - } - - public void setDevice(String device) { - this.device = device; - } - - public String getFrom() { - return this.from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getLinecount() { - return linecount; - } - - public void setLinecount(String linecount) { - this.linecount = linecount; - } - - public String getMessageline0() { - return messageline0; - } - - public void setMessageline0(String messageline0) { - this.messageline0 = messageline0; - } - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/DongleShowDevicesCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/DongleShowDevicesCompleteEvent.java deleted file mode 100644 index 45b3f0de1..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleShowDevicesCompleteEvent.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DahdiShowChannelsCompleteEvent is triggered after the state of all Dahdi channels has been reported - * in response to a DahdiShowChannelsAction. - * - * @see org.asteriskjava.manager.action.DahdiShowChannelsAction - * @see org.asteriskjava.manager.event.DahdiShowChannelsEvent - * - * @author srt - * @version $Id$ - */ -public class DongleShowDevicesCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 6323249250335885462L; - - private Integer listitems; - private String eventlist; - private Integer items; - - public Integer getItems() { - return items; - } - - public void setItems(Integer items) { - this.items = items; - } - - /** - * @param source - */ - public DongleShowDevicesCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns if the status of the eventlist (should be Complete).

- * - * @return the status of the list. - * @since 1.0.0 - */ - public String getEventlist() - { - return eventlist; - } - - public void setEventlist(String eventlist) - { - this.eventlist = eventlist; - } - - /** - * Returns the number of channels reported.

- * - * @return the number of channels reported. - */ - public Integer getListitems() - { - return listitems; - } - - /** - * Sets the number of channels reported.

- * - * @param listitems the number of channels reported. - */ - public void setListitems(Integer listitems) - { - this.listitems = listitems; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/DongleStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/DongleStatusEvent.java deleted file mode 100644 index 622087aea..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DongleStatusEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.manager.event; - -public class DongleStatusEvent extends ManagerEvent -{ - private static final long serialVersionUID = 3257845467831284784L; - private String device; - private String status; - - public DongleStatusEvent(Object source) - { - super(source); - } - - public String getDevice() { - return this.device; - } - - public void setDevice(String device) { - this.device = device; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/DtmfBeginEvent.java b/src/main/java/org/asteriskjava/manager/event/DtmfBeginEvent.java deleted file mode 100644 index 31808823b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DtmfBeginEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class DtmfBeginEvent extends DtmfEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public DtmfBeginEvent(Object source) - { - super(source); - setBegin(true); - setEnd(false); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DtmfEndEvent.java b/src/main/java/org/asteriskjava/manager/event/DtmfEndEvent.java deleted file mode 100644 index a92633dfc..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DtmfEndEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class DtmfEndEvent extends DtmfEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private Integer durationMs; - - public DtmfEndEvent(Object source) - { - super(source); - setBegin(false); - setEnd(true); - } - - public Integer getDurationMs() - { - return durationMs; - } - - public void setDurationMs(Integer durationMs) - { - this.durationMs = durationMs; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/DtmfEvent.java b/src/main/java/org/asteriskjava/manager/event/DtmfEvent.java deleted file mode 100644 index 6740c6d36..000000000 --- a/src/main/java/org/asteriskjava/manager/event/DtmfEvent.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A DtmfEvent is triggered each time a DTMF digit is sent or received on a - * channel.

- * To support variable-length DTMF Asterisk (since 1.4.0) interally uses two different frames - * for DTMF releated events (AST_FRAME_DTMF_BEGIN and AST_FRAME_DTMF_END). - * Before 1.4.0 Asterisk only used one frame (AST_FRAME_DTMF) which is now an alias for - * AST_FRAME_DTMF_END.
- * Many other systems and devices (like mobile phone providers) do not support variable-length DTMF. - * In these cases you will only see AST_FRAME_DTMF_END frames in Asterisk.
- * When building DTMF aware applications you should not rely on AST_FRAME_DTMF_BEGIN. - * Generally it is safe to just ignore them and only react on AST_FRAME_DTMF_END frames.
- * To check whether an DtmfEvent represents an AST_FRAME_DTMF_BEGIN or - * AST_FRAME_DTMF_END frame use the {@link #isBegin()} and {@link #isEnd()} methods. - *
- * You can find more information on how Asterisk handles DTMF in the - * DTMF article at voip-info.org

- * It is implemented in main/channel.c.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class DtmfEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 1L; - - public static final String DIRECTION_RECEIVED = "Received"; - public static final String DIRECTION_SENT = "Sent"; - - private String channel; - private String uniqueId; - private String digit; - private String direction; - private Boolean begin; - private Boolean end; - - private String language; - private String linkedId; - private String accountCode; - - /** - * Creates a new DtmfEvent. - * - * @param source - */ - public DtmfEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel the DTMF digit was sent or received on. - * The channel name is of the form "Zap/<channel number>". - * - * @return the channel name. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - * - * @param channel the channel name. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the the channel the DTMF digit was sent or received on. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the the channel. - * - * @param uniqueId the unique id of the the channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the DTMF digit that was sent or received. - * - * @return the DTMF digit that was sent or received. - */ - public String getDigit() - { - return digit; - } - - /** - * Sets the DTMF digit that was sent or received. - * - * @param digit the DTMF digit that was sent or received. - */ - public void setDigit(String digit) - { - this.digit = digit; - } - - /** - * Returns whether the DTMF digit was sent or received.

- * Possible values are: - *

    - *
  • Received
  • - *
  • Sent
  • - *
- * - * @return "Reveived" if the DTMF was received (sent from the device to Asterisk) or "Sent" if the DTMF - * digit was sent (sent from Asterisk to the device). - * @see #DIRECTION_RECEIVED - * @see #DIRECTION_SENT - */ - public String getDirection() - { - return direction; - } - - /** - * Sets whether the DTMF digit was sent or received. - * - * @param direction "Received" or "Sent". - */ - public void setDirection(String direction) - { - this.direction = direction; - } - - /** - * Returns whether this event represents an AST_FRAME_DTMF_BEGIN frame.

- * Gerally your application will want to ignore begin events. You will only need - * them if you want to make use of the duration a DTMF key was pressed.

- * Note that there will be DTMF end events without a corresponding begin event - * as not all systems (including Asterisk prior to 1.4.0) support variable-length - * DTMF. - * - * @return true if this is a DTMF begin event (key pressed), - * false otherwise. - */ - public Boolean isBegin() - { - return begin != null && begin; - } - - /** - * Sets whether this event represents an AST_FRAME_DTMF_BEGIN frame. - * - * @param begin true if this is a DTMF begin event (key pressed), - * false otherwise. - */ - public void setBegin(Boolean begin) - { - this.begin = begin; - } - - /** - * Returns whether this event represents an AST_FRAME_DTMF_END frame.

- * DTMF information received from systems that do not support variable-length - * DTMF you will only see DTMF end events. - * - * @return true if this is a DTMF end event (key released), - * false otherwise. - */ - public boolean isEnd() - { - return end != null && end; - } - - /** - * Sets whether this event represents an AST_FRAME_DTMF_END frame. - * - * @param end true if this is a DTMF end event (key released), - * false otherwise. - */ - public void setEnd(Boolean end) - { - this.end = end; - } - - /** - * Returns whether the DTMF digit was received by Asterisk (sent from the device to Asterisk). - * - * @return true if the DTMF digit was received by Asterisk, - * false otherwise. - * @see #getDirection() - */ - public boolean isReceived() - { - return direction != null && DIRECTION_RECEIVED.equalsIgnoreCase(direction); - } - - /** - * Returns whether the DTMF digit was sent from Asterisk to the device. - * - * @return true if the DTMF digit was sent from Asterisk to the device, - * false otherwise. - * @see #getDirection() - */ - public boolean isSent() - { - return direction != null && DIRECTION_SENT.equalsIgnoreCase(direction); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/ExtensionStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/ExtensionStatusEvent.java deleted file mode 100644 index 185760c2a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ExtensionStatusEvent.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An ExtensionStatusEvent is triggered when the state of an extension changes.

- * For this to work for you must provide appropriate hints in your dialplan to - * map channels to extensions. - *
- * Example: - *

exten => 1234,1,Dial(SIP/myuser)
- * exten => 1234,hint,SIP/myuser
- * Hints can also be used to map the state of multiple channels to an extension: - *
exten => 6789,hint,SIP/user1&SIP/user2
- *
- * It is implemented in manager.c, values for state are defined in - * include/asterisk/pbx.h. - * - * @author srt - * @version $Id$ - */ -public class ExtensionStatusEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * No device INUSE or BUSY. - */ - public static final int NOT_INUSE = 0; - - /** - * One or more devices INUSE. - */ - public static final int INUSE = 1; - - /** - * All devices BUSY. - */ - public static final int BUSY = 1 << 1; - - /** - * All devices UNAVAILABLE/UNREGISTERED. - */ - public static final int UNAVAILABLE = 1 << 2; - - /** - * One or more devices RINGING. - */ - public static final int RINGING = 1 << 3; - - private String hint; - private Integer status; - private String callerId; - private String statustext; - - - public ExtensionStatusEvent(Object source) - { - super(source); - } - - /** - * Returns the hint assigned to the extension. The hint is used to map a channel (e.g. "SIP/123") to an - * extension (e.g. "123").

- * Available since Asterisk 1.6. - * - * @return the hint (channel name) assigned to the extension. - * @since 1.0.0 - */ - public String getHint() - { - return hint; - } - - public void setHint(String hint) - { - this.hint = hint; - } - - /** - * Returns the state of the extension.

- * Possible values are: - *

    - *
  • RINGING
  • - *
  • INUSE | RINGING
  • - *
  • INUSE
  • - *
  • NOT_INUSE
  • - *
  • BUSY
  • - *
  • UNAVAILABLE
  • - *
- */ - public Integer getStatus() - { - return status; - } - - /** - * Sets the state of the extension. - */ - public void setStatus(Integer status) - { - this.status = status; - } - - /** - * Returns the Caller*ID in the form "Some Name" <1234>. - *
- * This property is only available on BRIstuffed Asterisk servers. - * - * @return the Caller*ID. - * @since 0.3 - */ - public String getCallerId() - { - return callerId; - } - - /** - * Sets the Caller*ID. - * - * @param callerId the Caller*ID. - * @since 0.3 - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - public String getStatustext() - { - return statustext; - } - - public void setStatustext(String statustext) - { - this.statustext = statustext; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/FaxDocumentStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/FaxDocumentStatusEvent.java deleted file mode 100644 index 74754b27c..000000000 --- a/src/main/java/org/asteriskjava/manager/event/FaxDocumentStatusEvent.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A FaxDocumentStatusEvent is an event of Digium's Fax For Asterisk add-on. - */ -public class FaxDocumentStatusEvent extends AbstractFaxEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1L; - private Integer documentNumber; - private Integer lastError; - private Integer pageCount; - private Integer startPage; - private Integer lastPageProcessed; - private Integer retransmitCount; - private Integer transferPels; - private Integer transferRate; - private String transferDuration; - private Integer badLineCount; - private String processedStatus; - private String documentTime; - private String localSid; - private String localDis; - private String remoteSid; - private String remoteDis; - - - public FaxDocumentStatusEvent(Object source) - { - super(source); - } - - - /** - * @return the documentNumber - */ - public Integer getDocumentNumber() - { - return documentNumber; - } - - - /** - * @param documentNumber the documentNumber to set - */ - public void setDocumentNumber(Integer documentNumber) - { - this.documentNumber = documentNumber; - } - - - /** - * @return the lastError - */ - public Integer getLastError() - { - return lastError; - } - - - /** - * @param lastError the lastError to set - */ - public void setLastError(Integer lastError) - { - this.lastError = lastError; - } - - - /** - * @return the pageCount - */ - public Integer getPageCount() - { - return pageCount; - } - - - /** - * @param pageCount the pageCount to set - */ - public void setPageCount(Integer pageCount) - { - this.pageCount = pageCount; - } - - - /** - * @return the startPage - */ - public Integer getStartPage() - { - return startPage; - } - - - /** - * @param startPage the startPage to set - */ - public void setStartPage(Integer startPage) - { - this.startPage = startPage; - } - - - /** - * @return the lastPageProcessed - */ - public Integer getLastPageProcessed() - { - return lastPageProcessed; - } - - - /** - * @param lastPageProcessed the lastPageProcessed to set - */ - public void setLastPageProcessed(Integer lastPageProcessed) - { - this.lastPageProcessed = lastPageProcessed; - } - - - /** - * @return the retransmitCount - */ - public Integer getRetransmitCount() - { - return retransmitCount; - } - - - /** - * @param retransmitCount the retransmitCount to set - */ - public void setRetransmitCount(Integer retransmitCount) - { - this.retransmitCount = retransmitCount; - } - - - /** - * @return the transferPels - */ - public Integer getTransferPels() - { - return transferPels; - } - - - /** - * @param transferPels the transferPels to set - */ - public void setTransferPels(Integer transferPels) - { - this.transferPels = transferPels; - } - - - /** - * @return the transferRate - */ - public Integer getTransferRate() - { - return transferRate; - } - - - /** - * @param transferRate the transferRate to set - */ - public void setTransferRate(Integer transferRate) - { - this.transferRate = transferRate; - } - - - /** - * @return the transferDuration - */ - public String getTransferDuration() - { - return transferDuration; - } - - - /** - * @param transferDuration the transferDuration to set - */ - public void setTransferDuration(String transferDuration) - { - this.transferDuration = transferDuration; - } - - - /** - * @return the badLineCount - */ - public Integer getBadLineCount() - { - return badLineCount; - } - - - /** - * @param badLineCount the badLineCount to set - */ - public void setBadLineCount(Integer badLineCount) - { - this.badLineCount = badLineCount; - } - - - /** - * @return the processedStatus - */ - public String getProcessedStatus() - { - return processedStatus; - } - - - /** - * @param processedStatus the processedStatus to set - */ - public void setProcessedStatus(String processedStatus) - { - this.processedStatus = processedStatus; - } - - - /** - * @return the documentTime - */ - public String getDocumentTime() - { - return documentTime; - } - - - /** - * @param documentTime the documentTime to set - */ - public void setDocumentTime(String documentTime) - { - this.documentTime = documentTime; - } - - - /** - * @return the localSid - */ - public String getLocalSid() - { - return localSid; - } - - - /** - * @param localSid the localSid to set - */ - public void setLocalSid(String localSid) - { - this.localSid = localSid; - } - - - /** - * @return the localDis - */ - public String getLocalDis() - { - return localDis; - } - - - /** - * @param localDis the localDis to set - */ - public void setLocalDis(String localDis) - { - this.localDis = localDis; - } - - - /** - * @return the remoteSid - */ - public String getRemoteSid() - { - return remoteSid; - } - - - /** - * @param remoteSid the remoteSid to set - */ - public void setRemoteSid(String remoteSid) - { - this.remoteSid = remoteSid; - } - - - /** - * @return the remoteDis - */ - public String getRemoteDis() - { - return remoteDis; - } - - - /** - * @param remoteDis the remoteDis to set - */ - public void setRemoteDis(String remoteDis) - { - this.remoteDis = remoteDis; - } - - -} - diff --git a/src/main/java/org/asteriskjava/manager/event/FaxReceivedEvent.java b/src/main/java/org/asteriskjava/manager/event/FaxReceivedEvent.java deleted file mode 100644 index 4d3ae442e..000000000 --- a/src/main/java/org/asteriskjava/manager/event/FaxReceivedEvent.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A FaxReceivedEvent is triggered by spandsp after a new fax has been received. - *

- * It is only available if you installed the spandsp patches to Asterisk. - *

- * See http://soft-switch.org/installing-spandsp.html for details. - *

- * Implemented in apps/app_rxfax.c. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class FaxReceivedEvent extends AbstractFaxEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - private String callerId; - private String remoteStationId; - private String localStationId; - private Integer pagesTransferred; - private Integer resolution; - private Integer transferRate; - private String filename; - - public FaxReceivedEvent(Object source) - { - super(source); - } - - /** - * Returns the Caller*ID of the calling party or an empty string if none is - * available. - * - * @return the Caller*ID of the calling party. - */ - public String getCallerId() - { - return callerId; - } - - /** - * Sets the Caller*ID of the calling party. - * - * @param callerId the Caller*ID of the calling party. - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - /** - * Retruns the identifier of the remote fax station. - * - * @return the identifier of the remote fax station. - */ - public String getRemoteStationId() - { - return remoteStationId; - } - - /** - * Sets the identifier of the remote fax station. - * - * @param remoteStationId the identifier of the remote fax station. - */ - public void setRemoteStationId(String remoteStationId) - { - this.remoteStationId = remoteStationId; - } - - /** - * Returns the identifier of the local fax station. - * - * @return the identifier of the local fax station. - */ - public String getLocalStationId() - { - return localStationId; - } - - /** - * Sets the identifier of the local fax station. - * - * @param localStationId the identifier of the local fax station. - */ - public void setLocalStationId(String localStationId) - { - this.localStationId = localStationId; - } - - /** - * Returns the number of pages transferred. - * - * @return the number of pages transferred. - */ - public Integer getPagesTransferred() - { - return pagesTransferred; - } - - /** - * Sets the number of pages transferred. - * - * @param pagesTransferred the number of pages transferred. - */ - public void setPagesTransferred(Integer pagesTransferred) - { - this.pagesTransferred = pagesTransferred; - } - - /** - * Returns the row resolution of the received fax. - * - * @return the row resolution of the received fax. - */ - public Integer getResolution() - { - return resolution; - } - - /** - * Sets the row resolution of the received fax. - * - * @param resolution the row resolution of the received fax. - */ - public void setResolution(Integer resolution) - { - this.resolution = resolution; - } - - /** - * Returns the transfer rate in bits/s. - * - * @return the transfer rate in bits/s. - */ - public Integer getTransferRate() - { - return transferRate; - } - - /** - * Sets the transfer rate in bits/s. - * - * @param transferRate the transfer rate in bits/s. - */ - public void setTransferRate(Integer transferRate) - { - this.transferRate = transferRate; - } - - /** - * Returns the filename of the received fax including its full path on the - * Asterisk server. - * - * @return the filename of the received fax - */ - public String getFilename() - { - return filename; - } - - /** - * Sets the filename of the received fax. - * - * @param filename the filename of the received fax - */ - public void setFilename(String filename) - { - this.filename = filename; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/FaxStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/FaxStatusEvent.java deleted file mode 100644 index d80a6f2ab..000000000 --- a/src/main/java/org/asteriskjava/manager/event/FaxStatusEvent.java +++ /dev/null @@ -1,562 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A FaxDocumentStatusEvent is an event of Digium's Fax For Asterisk add-on. - */ -public class FaxStatusEvent extends AbstractFaxEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1L; - private String operatingMode; - private String result; - private String error; - private Double callDuration; - private String ecmMode; - private Integer dataRate; - private String imageResolution; - private String imageEncoding; - private String pageSize; - private Integer documentNumber; - private Integer pageNumber; - private String fileName; - private Integer txPages; - private Integer txBytes; - private Integer totalTxLines; - private Integer rxPages; - private Integer rxBytes; - private Integer totalRxLines; - private Integer totalBadLines; - private Integer disDcsDtcCtcCount; - private Integer cfrCount; - private Integer fttCount; - private Integer mcfCount; - private Integer pprCount; - private Integer rtnCount; - private Integer dcnCount; - private String remoteStationId; - private String localStationId; - private String callerId; - private String status; - private String operation; - - public FaxStatusEvent(Object source) - { - super(source); - } - - - /** - * @return the operatingMode - */ - public String getOperatingMode() - { - return operatingMode; - } - - /** - * @param operatingMode the operatingMode to set - */ - public void setOperatingMode(String operatingMode) - { - this.operatingMode = operatingMode; - } - - /** - * @return the result - */ - public String getResult() - { - return result; - } - - /** - * @param result the result to set - */ - public void setResult(String result) - { - this.result = result; - } - - /** - * @return the error - */ - public String getError() - { - return error; - } - - /** - * @param error the error to set - */ - public void setError(String error) - { - this.error = error; - } - - /** - * @return the callDuration - */ - public Double getCallDuration() - { - return callDuration; - } - - /** - * @param callDuration the callDuration to set - */ - public void setCallDuration(Double callDuration) - { - this.callDuration = callDuration; - } - - /** - * @return the ecmMode - */ - public String getEcmMode() - { - return ecmMode; - } - - /** - * @param ecmMode the ecmMode to set - */ - public void setEcmMode(String ecmMode) - { - this.ecmMode = ecmMode; - } - - /** - * @return the dataRate - */ - public Integer getDataRate() - { - return dataRate; - } - - /** - * @param dataRate the dataRate to set - */ - public void setDataRate(Integer dataRate) - { - this.dataRate = dataRate; - } - - /** - * @return the imageResolution - */ - public String getImageResolution() - { - return imageResolution; - } - - /** - * @param imageResolution the imageResolution to set - */ - public void setImageResolution(String imageResolution) - { - this.imageResolution = imageResolution; - } - - /** - * @return the imageEncoding - */ - public String getImageEncoding() - { - return imageEncoding; - } - - /** - * @param imageEncoding the imageEncoding to set - */ - public void setImageEncoding(String imageEncoding) - { - this.imageEncoding = imageEncoding; - } - - /** - * @return the pageSize - */ - public String getPageSize() - { - return pageSize; - } - - /** - * @param pageSize the pageSize to set - */ - public void setPageSize(String pageSize) - { - this.pageSize = pageSize; - } - - /** - * @return the documentNumber - */ - public Integer getDocumentNumber() - { - return documentNumber; - } - - /** - * @param documentNumber the documentNumber to set - */ - public void setDocumentNumber(Integer documentNumber) - { - this.documentNumber = documentNumber; - } - - /** - * @return the pageNumber - */ - public Integer getPageNumber() - { - return pageNumber; - } - - /** - * @param pageNumber the pageNumber to set - */ - public void setPageNumber(Integer pageNumber) - { - this.pageNumber = pageNumber; - } - - /** - * @return the fileName - */ - public String getFileName() - { - return fileName; - } - - /** - * @param fileName the fileName to set - */ - public void setFileName(String fileName) - { - this.fileName = fileName; - } - - /** - * @return the txPages - */ - public Integer getTxPages() - { - return txPages; - } - - /** - * @param txPages the txPages to set - */ - public void setTxPages(Integer txPages) - { - this.txPages = txPages; - } - - /** - * @return the txBytes - */ - public Integer getTxBytes() - { - return txBytes; - } - - /** - * @param txBytes the txBytes to set - */ - public void setTxBytes(Integer txBytes) - { - this.txBytes = txBytes; - } - - /** - * @return the totalTxLines - */ - public Integer getTotalTxLines() - { - return totalTxLines; - } - - /** - * @param totalTxLines the totalTxLines to set - */ - public void setTotalTxLines(Integer totalTxLines) - { - this.totalTxLines = totalTxLines; - } - - /** - * @return the rxPages - */ - public Integer getRxPages() - { - return rxPages; - } - - /** - * @param rxPages the rxPages to set - */ - public void setRxPages(Integer rxPages) - { - this.rxPages = rxPages; - } - - /** - * @return the rxBytes - */ - public Integer getRxBytes() - { - return rxBytes; - } - - /** - * @param rxBytes the rxBytes to set - */ - public void setRxBytes(Integer rxBytes) - { - this.rxBytes = rxBytes; - } - - /** - * @return the totalRxLines - */ - public Integer getTotalRxLines() - { - return totalRxLines; - } - - /** - * @param totalRxLines the totalRxLines to set - */ - public void setTotalRxLines(Integer totalRxLines) - { - this.totalRxLines = totalRxLines; - } - - /** - * @return the totalBadLines - */ - public Integer getTotalBadLines() - { - return totalBadLines; - } - - /** - * @param totalBadLines the totalBadLines to set - */ - public void setTotalBadLines(Integer totalBadLines) - { - this.totalBadLines = totalBadLines; - } - - /** - * @return the disDcsDtcCtcCount - */ - public Integer getDisDcsDtcCtcCount() - { - return disDcsDtcCtcCount; - } - - /** - * @param disDcsDtcCtcCount the disDcsDtcCtcCount to set - */ - public void setDisDcsDtcCtcCount(Integer disDcsDtcCtcCount) - { - this.disDcsDtcCtcCount = disDcsDtcCtcCount; - } - - /** - * @return the cfrCount - */ - public Integer getCfrCount() - { - return cfrCount; - } - - /** - * @param cfrCount the cfrCount to set - */ - public void setCfrCount(Integer cfrCount) - { - this.cfrCount = cfrCount; - } - - /** - * @return the fttCount - */ - public Integer getFttCount() - { - return fttCount; - } - - /** - * @param fttCount the fttCount to set - */ - public void setFttCount(Integer fttCount) - { - this.fttCount = fttCount; - } - - /** - * @return the mcfCount - */ - public Integer getMcfCount() - { - return mcfCount; - } - - /** - * @param mcfCount the mcfCount to set - */ - public void setMcfCount(Integer mcfCount) - { - this.mcfCount = mcfCount; - } - - /** - * @return the pprCount - */ - public Integer getPprCount() - { - return pprCount; - } - - /** - * @param pprCount the pprCount to set - */ - public void setPprCount(Integer pprCount) - { - this.pprCount = pprCount; - } - - /** - * @return the rtnCount - */ - public Integer getRtnCount() - { - return rtnCount; - } - - /** - * @param rtnCount the rtnCount to set - */ - public void setRtnCount(Integer rtnCount) - { - this.rtnCount = rtnCount; - } - - /** - * @return the dcnCount - */ - public Integer getDcnCount() - { - return dcnCount; - } - - /** - * @param dcnCount the dcnCount to set - */ - public void setDcnCount(Integer dcnCount) - { - this.dcnCount = dcnCount; - } - - /** - * @return the remoteStationId - */ - public String getRemoteStationId() - { - return remoteStationId; - } - - /** - * @param remoteStationId the remoteStationId to set - */ - public void setRemoteStationId(String remoteStationId) - { - this.remoteStationId = remoteStationId; - } - - /** - * @return the localStationId - */ - public String getLocalStationId() - { - return localStationId; - } - - /** - * @param localStationId the localStationId to set - */ - public void setLocalStationId(String localStationId) - { - this.localStationId = localStationId; - } - - /** - * @return the callerId - */ - public String getCallerId() - { - return callerId; - } - - /** - * @param callerId the callerId to set - */ - public void setCallerId(String callerid) - { - this.callerId = callerid; - } - - /** - * @return the status - */ - public String getStatus() - { - return status; - } - - /** - * @param status the status to set - */ - public void setStatus(String status) - { - this.status = status; - } - - /** - * @return the operation - */ - public String getOperation() - { - return operation; - } - - /** - * @param context the context to set - */ - public void setOperation(String operation) - { - this.operation = operation; - } -} - diff --git a/src/main/java/org/asteriskjava/manager/event/FullyBootedEvent.java b/src/main/java/org/asteriskjava/manager/event/FullyBootedEvent.java deleted file mode 100644 index 84e220f45..000000000 --- a/src/main/java/org/asteriskjava/manager/event/FullyBootedEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Indicates that Asterisk has loaded all its modules and finished booting.
- * It is handy to have a single event notification for when all Asterisk - * modules have been loaded - especially for situations like running - * automated tests. This event will fire 1) immediately upon all modules - * loading or 2) upon connection to the AMI interface if the modules have - * already finished loading before the connection was made. This ensures - * that a user will never miss getting a FullyBooted event. In vary rare - * circumstances, it might be possible to get two copies of the message - * if the AMI connection is made right as the modules finish loading. - *
- * It is implemented in main/asterisk.c and manager.c.
- * Available since Asterisk 1.8 - */ -public class FullyBootedEvent extends ManagerEvent -{ - private static final long serialVersionUID = 0L; - private String status; - private String lastreload; - private Integer uptime; - - public FullyBootedEvent(Object source) - { - super(source); - } - - /** - * Returns the status. Currently this is always "Fully Booted". - * - * @return the status. - */ - public String getStatus() - { - return status; - } - - /** - * Sets the status. - * - * @param status the status. - */ - public void setStatus(String status) - { - this.status = status; - } - - public String getLastreload() { - return lastreload; - } - - public void setLastreload(String lastreload) { - this.lastreload = lastreload; - } - - public Integer getUptime() { - return uptime; - } - - public void setUptime(Integer uptime) { - this.uptime = uptime; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/HangupEvent.java b/src/main/java/org/asteriskjava/manager/event/HangupEvent.java deleted file mode 100644 index 9d842526d..000000000 --- a/src/main/java/org/asteriskjava/manager/event/HangupEvent.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A HangupEvent is triggered when a channel is hung up.

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - */ -public class HangupEvent extends AbstractChannelStateEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private Integer cause; - private String causeTxt; - private String language; - private String linkedId; - private String connectedlinenum; - - private String accountCode; - - public HangupEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - /** - * Returns the cause of the hangup. - * - * @return the hangup cause. - * @see org.asteriskjava.live.HangupCause - */ - public Integer getCause() - { - return cause; - } - - /** - * Sets the cause of the hangup. - * - * @param cause the hangup cause. - */ - public void setCause(Integer cause) - { - this.cause = cause; - } - - /** - * Returns the textual representation of the hangup cause. - * - * @return the textual representation of the hangup cause. - * @since 0.2 - */ - public String getCauseTxt() - { - return causeTxt; - } - - /** - * Sets the textual representation of the hangup cause. - * - * @param causeTxt the textual representation of the hangup cause. - * @since 0.2 - */ - public void setCauseTxt(String causeTxt) - { - this.causeTxt = causeTxt; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("HangupEvent [cause="); - builder.append(cause); - builder.append(", causeTxt="); - builder.append(causeTxt); - builder.append(", language="); - builder.append(language); - builder.append(", linkedId="); - builder.append(linkedId); - builder.append(", accountCode="); - builder.append(accountCode); - builder.append("]"); - return builder.toString(); - } - - public String getConnectedlinenum() - { - return connectedlinenum; - } - - public void setConnectedlinenum(String connectedlinenum) - { - this.connectedlinenum = connectedlinenum; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/HangupRequestEvent.java b/src/main/java/org/asteriskjava/manager/event/HangupRequestEvent.java deleted file mode 100644 index 3852045be..000000000 --- a/src/main/java/org/asteriskjava/manager/event/HangupRequestEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A HangupEvent is triggered when a channel is requested hung up. - *

- * It is implemented in channel.c - */ -public class HangupRequestEvent extends AbstractChannelEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private Integer cause; - private String language; - private String linkedId; - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public HangupRequestEvent(Object source) - { - super(source); - } - - /** - * Returns the cause of the hangup. - * - * @return the hangup cause. - * @see org.asteriskjava.live.HangupCause - */ - public Integer getCause() - { - return cause; - } - - /** - * Sets the cause of the hangup. - * - * @param cause the hangup cause. - */ - public void setCause(Integer cause) - { - this.cause = cause; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/HoldEvent.java b/src/main/java/org/asteriskjava/manager/event/HoldEvent.java deleted file mode 100644 index 6c2b40435..000000000 --- a/src/main/java/org/asteriskjava/manager/event/HoldEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A HoldEvent is triggered when a channel is put on hold (or no longer on - * hold). - *

- * It is implemented in channels/chan_sip.c. - *

- * Available since Asterisk 1.2 for SIP channels, as of Asterisk 1.6 this event - * is also supported for IAX2 channels. - *

- * To receive HoldEvents for SIP channels you must set - * callevents = yes in sip.conf. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class HoldEvent extends AbstractHoldEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - private String musicClass; - - /** - * Creates a new HoldEvent. - * - * @param source - */ - public HoldEvent(Object source) - { - super(source); - /* - * Asterisk prior to 1.6 and after 11 uses Hold and Unhold events - * instead of the status So we set the status to true in the Hold event - * and to false in Unhold. For Asterisk 1.6-11 this is overridden by the - * status property received with the hold event. - */ - setStatus(true); - } - - public String getMusicClass() - { - return musicClass; - } - - public void setMusicClass(String musicClass) - { - this.musicClass = musicClass; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/HoldedCallEvent.java b/src/main/java/org/asteriskjava/manager/event/HoldedCallEvent.java deleted file mode 100644 index 53e904019..000000000 --- a/src/main/java/org/asteriskjava/manager/event/HoldedCallEvent.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A HoldedCallEvent is triggered when a channel is put on hold.

- * It is implemented in res/res_features.c - * - * @author srt - * @version $Id$ - */ -public class HoldedCallEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 7384290590382334480L; - private String uniqueId1; - private String uniqueId2; - private String channel1; - private String channel2; - - /** - * @param source - */ - public HoldedCallEvent(Object source) - { - super(source); - } - - /** - * Returns the unique id of the channel that put the other channel on hold. - */ - public String getUniqueId1() - { - return uniqueId1; - } - - /** - * Sets the unique id of the channel that put the other channel on hold. - */ - public void setUniqueId1(String uniqueId1) - { - this.uniqueId1 = uniqueId1; - } - - /** - * Returns the unique id of the channel that has been put on hold. - */ - public String getUniqueId2() - { - return uniqueId2; - } - - /** - * Sets the unique id of the channel that has been put on hold. - */ - public void setUniqueId2(String uniqueId2) - { - this.uniqueId2 = uniqueId2; - } - - /** - * Returns the name of the channel that put the other channel on hold. - */ - public String getChannel1() - { - return channel1; - } - - /** - * Sets the name of the channel that put the other channel on hold. - */ - public void setChannel1(String channel1) - { - this.channel1 = channel1; - } - - /** - * Returns the name of the channel that has been put on hold. - */ - public String getChannel2() - { - return channel2; - } - - /** - * Sets the name of the channel that has been put on hold. - */ - public void setChannel2(String channel2) - { - this.channel2 = channel2; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/InvalidPasswordEvent.java b/src/main/java/org/asteriskjava/manager/event/InvalidPasswordEvent.java deleted file mode 100644 index e478e3544..000000000 --- a/src/main/java/org/asteriskjava/manager/event/InvalidPasswordEvent.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/23/15. - */ -public class InvalidPasswordEvent extends ManagerEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String severity; - private Integer eventVersion; - private String eventtv; - private String sessionid; - private String receivedHash; - private String localaddress; - private String accountId; - private String receivedChallenge; - private String service; - private String remoteAddress; - private String challenge; - - public InvalidPasswordEvent(Object source) - { - super(source); - } - - public String getSeverity() - { - return severity; - } - - public void setSeverity(String severity) - { - this.severity = severity; - } - - public Integer getEventVersion() - { - return eventVersion; - } - - public void setEventVersion(Integer eventVersion) - { - this.eventVersion = eventVersion; - } - - public String getEventtv() - { - return eventtv; - } - - public void setEventtv(String eventtv) - { - this.eventtv = eventtv; - } - - public String getSessionid() - { - return sessionid; - } - - public void setSessionid(String sessionid) - { - this.sessionid = sessionid; - } - - public String getReceivedHash() - { - return receivedHash; - } - - public void setReceivedHash(String receivedHash) - { - this.receivedHash = receivedHash; - } - - public String getLocaladdress() - { - return localaddress; - } - - public void setLocaladdress(String localaddress) - { - this.localaddress = localaddress; - } - - public String getAccountId() - { - return accountId; - } - - public void setAccountId(String accountId) - { - this.accountId = accountId; - } - - public String getReceivedChallenge() - { - return receivedChallenge; - } - - public void setReceivedChallenge(String receivedChallenge) - { - this.receivedChallenge = receivedChallenge; - } - - public String getService() - { - return service; - } - - public void setService(String service) - { - this.service = service; - } - - public String getRemoteAddress() - { - return remoteAddress; - } - - public void setRemoteAddress(String remoteAddress) - { - this.remoteAddress = remoteAddress; - } - - public String getChallenge() - { - return challenge; - } - - public void setChallenge(String challenge) - { - this.challenge = challenge; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/JabberEventEvent.java b/src/main/java/org/asteriskjava/manager/event/JabberEventEvent.java deleted file mode 100644 index 0daf07591..000000000 --- a/src/main/java/org/asteriskjava/manager/event/JabberEventEvent.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A JabberEventEvent is triggered when Asterisk receives a Jabber (XMPP) message.

- * It is implemented in res/res_jabber.c

- * Available since Asterisk 1.4 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class JabberEventEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - private String account; - private String packet; - - public JabberEventEvent(Object source) - { - super(source); - } - - public String getAccount() - { - return account; - } - - public void setAccount(String account) - { - this.account = account; - } - - public String getPacket() - { - return packet; - } - - public void setPacket(String packet) - { - this.packet = packet; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/JitterBufStatsEvent.java b/src/main/java/org/asteriskjava/manager/event/JitterBufStatsEvent.java deleted file mode 100644 index f321811b8..000000000 --- a/src/main/java/org/asteriskjava/manager/event/JitterBufStatsEvent.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A JitterBufStatsEvent is triggered at the end of IAX2 calls and reports - * jitter statistics.

- * It is implemented in channels/chan_iax2.c.

- * Available since Asterisk 1.6. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class JitterBufStatsEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - private String owner; - private Integer ping; - private Integer localJitter; - private Integer localJbDelay; - private Integer localTotalLost; - private Integer localLossPercent; - private Integer localDropped; - private Integer localooo; - private Integer localReceived; - private Integer remoteJitter; - private Integer remoteJbDelay; - private Integer remoteTotalLost; - private Integer remoteLossPercent; - private Integer remoteDropped; - private Integer remoteooo; - private Integer remoteReceived; - - public JitterBufStatsEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return channel the name of the channel. - */ - public String getOwner() - { - return owner; - } - - public void setOwner(String owner) - { - this.owner = owner; - } - - public Integer getPing() - { - return ping; - } - - public void setPing(Integer ping) - { - this.ping = ping; - } - - public Integer getLocalJitter() - { - return localJitter; - } - - public void setLocalJitter(Integer localJitter) - { - this.localJitter = localJitter; - } - - public Integer getLocalJbDelay() - { - return localJbDelay; - } - - public void setLocalJbDelay(Integer localJbDelay) - { - this.localJbDelay = localJbDelay; - } - - public Integer getLocalTotalLost() - { - return localTotalLost; - } - - public void setLocalTotalLost(Integer localTotalLost) - { - this.localTotalLost = localTotalLost; - } - - public Integer getLocalLossPercent() - { - return localLossPercent; - } - - public void setLocalLossPercent(Integer localLossPercent) - { - this.localLossPercent = localLossPercent; - } - - public Integer getLocalDropped() - { - return localDropped; - } - - public void setLocalDropped(Integer localDropped) - { - this.localDropped = localDropped; - } - - public Integer getLocalooo() - { - return localooo; - } - - public void setLocalooo(Integer localooo) - { - this.localooo = localooo; - } - - public Integer getLocalReceived() - { - return localReceived; - } - - public void setLocalReceived(Integer localReceived) - { - this.localReceived = localReceived; - } - - public Integer getRemoteJitter() - { - return remoteJitter; - } - - public void setRemoteJitter(Integer remoteJitter) - { - this.remoteJitter = remoteJitter; - } - - public Integer getRemoteJbDelay() - { - return remoteJbDelay; - } - - public void setRemoteJbDelay(Integer remoteJbDelay) - { - this.remoteJbDelay = remoteJbDelay; - } - - public Integer getRemoteTotalLost() - { - return remoteTotalLost; - } - - public void setRemoteTotalLost(Integer remoteTotalLost) - { - this.remoteTotalLost = remoteTotalLost; - } - - public Integer getRemoteLossPercent() - { - return remoteLossPercent; - } - - public void setRemoteLossPercent(Integer remoteLossPercent) - { - this.remoteLossPercent = remoteLossPercent; - } - - public Integer getRemoteDropped() - { - return remoteDropped; - } - - public void setRemoteDropped(Integer remoteDropped) - { - this.remoteDropped = remoteDropped; - } - - public Integer getRemoteooo() - { - return remoteooo; - } - - public void setRemoteooo(Integer remoteooo) - { - this.remoteooo = remoteooo; - } - - public Integer getRemoteReceived() - { - return remoteReceived; - } - - public void setRemoteReceived(Integer remoteReceived) - { - this.remoteReceived = remoteReceived; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/JoinEvent.java b/src/main/java/org/asteriskjava/manager/event/JoinEvent.java deleted file mode 100644 index b9fef7d76..000000000 --- a/src/main/java/org/asteriskjava/manager/event/JoinEvent.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A JoinEvent is triggered when a channel joines a queue.

- * It is implemented in apps/app_queue.c - * - * @author srt - */ -public class JoinEvent extends QueueEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - protected String callerIdNum; - protected String callerIdName; - protected Integer position; - - public JoinEvent(Object source) - { - super(source); - } - - /** - * Returns the Caller*ID number of the channel that joined the queue if set. - * If the channel has no caller id set "unknown" is returned. - * - * @return the Caller*ID number of the channel that joined the queue - * @deprecated since 1.0.0, use {@link #getCallerIdNum()} instead. - */ - @Deprecated public String getCallerId() - { - return callerIdNum; - } - - /** - * Sets the Caller*ID number of the channel that joined the queue. - * - * @param callerId the Caller*ID number of the channel that joined the queue. - */ - public void setCallerId(String callerId) - { - this.callerIdNum = callerId; - } - - /** - * Returns the position of the joined channel in the queue. - */ - public Integer getPosition() - { - return position; - } - - /** - * Sets the position of the joined channel in the queue. - */ - public void setPosition(Integer position) - { - this.position = position; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/LeaveEvent.java b/src/main/java/org/asteriskjava/manager/event/LeaveEvent.java deleted file mode 100644 index ac069e286..000000000 --- a/src/main/java/org/asteriskjava/manager/event/LeaveEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A LeaveEvent is triggered when a channel leaves a queue.

- * It is implemented in apps/app_queue.c - * - * @author srt - */ -public class LeaveEvent extends QueueEvent -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = -7450401017732634240L; - - private Integer position; - - /** - * @param source - */ - public LeaveEvent(Object source) - { - super(source); - } - - /** - * @return the position of the caller at the time they leave the queue - */ - public Integer getPosition() - { - return position; - } - - public void setPosition(Integer position) - { - this.position = position; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/LinkEvent.java b/src/main/java/org/asteriskjava/manager/event/LinkEvent.java deleted file mode 100644 index c0614ed57..000000000 --- a/src/main/java/org/asteriskjava/manager/event/LinkEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A LinkEvent is triggered when two voice channels are linked together and voice data exchange - * commences.

- * Several Link events may be seen for a single call. This can occur when Asterisk fails to setup a - * native bridge for the call.This is when Asterisk must sit between two telephones and perform - * CODEC conversion on their behalf.

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - * @deprecated as of 1.0.0, use {@link org.asteriskjava.manager.event.BridgeEvent} and - * {@link BridgeEvent#isLink()} instead - */ -@Deprecated public class LinkEvent extends BridgeEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = -4023240534975776225L; - - public LinkEvent(Object source) - { - super(source); - setBridgeState(BRIDGE_STATE_LINK); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ListDialplanEvent.java b/src/main/java/org/asteriskjava/manager/event/ListDialplanEvent.java deleted file mode 100644 index 1f8ceea49..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ListDialplanEvent.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * A ShowDialplanCompleteEvent is triggered for each priority in the dialplan - * in response to a ShowDialplanAction.

- * Available since Asterisk 1.6

- * It is implemented in main/pbx.c - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ShowDialplanAction - * @see ShowDialplanCompleteEvent - * @since 1.0.0 - */ -public class ListDialplanEvent extends ResponseEvent -{ - private static final long serialVersionUID = 1L; - - private static final String PRIORITY_HINT = "hint"; - - private String extension; - private String extensionLabel; - private boolean hint = false; - private String application; - private String appData; - private String registrar; - - public ListDialplanEvent(Object source) - { - super(source); - } - - /** - * Returns the extension or extension pattern. - * - * @return the extension or extension pattern. - */ - public String getExtension() - { - return extension; - } - - public void setExtension(String extension) - { - this.extension = extension; - } - - /** - * Returns the extension label. - * @return the extension label or null if none. - */ - public String getExtensionLabel() - { - return extensionLabel; - } - - public void setExtensionLabel(String extensionLabel) - { - this.extensionLabel = extensionLabel; - } - - /** - * Checks whether this is a hint. - * @return true if this is a hint, false otherwise. - */ - public boolean isHint() - { - return hint; - } - - public void setPriority(String priorityString) - { - if (priorityString == null) - { - this.priority = null; - return; - } - - if (PRIORITY_HINT.equals(priorityString)) - { - hint = true; - this.priority = null; - } - else - { - this.priority = Integer.parseInt(priorityString); - } - } - - /** - * Returns the application configured to handle this priority. - * - * @return the application configured to handle this priority. - */ - public String getApplication() - { - return application; - } - - public void setApplication(String application) - { - this.application = application; - } - - /** - * Returns the parameters of the application configured to handle this priority. - * - * @return the parameters of the application configured to handle this priority - * or null if none. - */ - public String getAppData() - { - return appData; - } - - public void setAppData(String appData) - { - this.appData = appData; - } - - /** - * Returns the registrar that registered this priority.

- * Typical values are "features" for the parkedcalls context, "pbx_config" for priorities - * defined in extensions.conf or "app_dial" for the - * app_dial_gosub_virtual_context context. - * - * @return the registrar that registered this priority. - */ - public String getRegistrar() - { - return registrar; - } - - public void setRegistrar(String registrar) - { - this.registrar = registrar; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/LocalBridgeEvent.java b/src/main/java/org/asteriskjava/manager/event/LocalBridgeEvent.java deleted file mode 100644 index 51e0cc9d3..000000000 --- a/src/main/java/org/asteriskjava/manager/event/LocalBridgeEvent.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerEvent_LocalBridge - * Triggered when 2 halves of a local channels are bridged - * - * It is implemented in channels/chan_local.c - * - * @author jylebleu - * @version $Id$ - */ -public class LocalBridgeEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private String uniqueId1; - private String uniqueId2; - private String channel1; - private String channel2; - private String callerId1; - private String callerId2; - private String localOptimization; - private String localOneCalleridName; - private String localTwoChannel; - private String localTwoLanguage; - private String localTwoExten; - private String localOneChannel; - private String localOneContext; - private String localOneConnectedLineNum; - private String localOneConnectedLineName; - private String localOneChannelStateDesc; - private String localOneChannelState; - private String localOneExten; - private String localOneLanguage; - private String localOnePriority; - private String localOneUniqueId; - private String localTwochannelState; - private String localTwoChannelStateDesc; - private String localTwoPriority; - private String localTwoContext; - private String localTwoCalleridNum; - private String localTwoCalleridName; - private String localTwoUniqueid; - private String localOneCalleridNum; - private String localTwoConnectedLineName; - private String localTwoConnectedLineNum; - - private String localTwoLinkedid; - private String localOneLinkedid; - private String localOneAccountCode; - private String localTwoAccountCode; - - public LocalBridgeEvent(Object source) - { - super(source); - } - - public String getUniqueId1() { - return uniqueId1; - } - - public void setUniqueId1(String uniqueId1) { - this.uniqueId1 = uniqueId1; - } - - public String getUniqueId2() { - return uniqueId2; - } - - public void setUniqueId2(String uniqueId2) { - this.uniqueId2 = uniqueId2; - } - - /** - * The name of the Local Channel half that bridges to another channel. - * - * @return The name of the Local Channel half that bridges to another channel. - */ - public String getChannel1() { - return channel1; - } - - public void setChannel1(String channel1) { - this.channel1 = channel1; - } - - /** - * The name of the Local Channel half that executes the dialplan. - * - * @return The name of the Local Channel half that executes the dialplan. - */ - public String getChannel2() { - return channel2; - } - - public void setChannel2(String channel2) { - this.channel2 = channel2; - } - - public String getCallerId1() { - return callerId1; - } - - public void setCallerId1(String callerId1) { - this.callerId1 = callerId1; - } - - public String getCallerId2() { - return callerId2; - } - - public void setCallerId2(String callerId2) { - this.callerId2 = callerId2; - } - - /** - * Local optimization values - * - * Yes - * No - * - * @return Local optimization - */ - - public String getLocalOptimization() { - return localOptimization; - } - - public void setLocalOptimization(String localOptimization) { - this.localOptimization = localOptimization; - } - - public String getLocalOneCalleridName() - { - return localOneCalleridName; - } - - public void setLocalOneCalleridName(String localOneCalleridName) - { - this.localOneCalleridName = localOneCalleridName; - } - - public String getLocalTwoChannel() - { - return localTwoChannel; - } - - public void setLocalTwoChannel(String localTwoChannel) - { - this.localTwoChannel = localTwoChannel; - } - - public String getLocalTwoLanguage() - { - return localTwoLanguage; - } - - public void setLocalTwoLanguage(String localTwoLanguage) - { - this.localTwoLanguage = localTwoLanguage; - } - - public String getLocalTwoExten() - { - return localTwoExten; - } - - public void setLocalTwoExten(String localTwoExten) - { - this.localTwoExten = localTwoExten; - } - - public String getLocalOneChannel() - { - return localOneChannel; - } - - public void setLocalOneChannel(String localOneChannel) - { - this.localOneChannel = localOneChannel; - } - - public String getLocalOneContext() - { - return localOneContext; - } - - public void setLocalOneContext(String localOneContext) - { - this.localOneContext = localOneContext; - } - - public String getLocalOneConnectedLineNum() - { - return localOneConnectedLineNum; - } - - public void setLocalOneConnectedLineNum(String localOneConnectedLineNum) - { - this.localOneConnectedLineNum = localOneConnectedLineNum; - } - - public String getLocalOneConnectedLineName() - { - return localOneConnectedLineName; - } - - public void setLocalOneConnectedLineName(String localOneConnectedLineName) - { - this.localOneConnectedLineName = localOneConnectedLineName; - } - - public String getLocalOneChannelStateDesc() - { - return localOneChannelStateDesc; - } - - public void setLocalOneChannelStateDesc(String localOneChannelStateDesc) - { - this.localOneChannelStateDesc = localOneChannelStateDesc; - } - - public String getLocalOneChannelState() - { - return localOneChannelState; - } - - public void setLocalOneChannelState(String localOneChannelState) - { - this.localOneChannelState = localOneChannelState; - } - - public String getLocalOneExten() - { - return localOneExten; - } - - public void setLocalOneExten(String localOneExten) - { - this.localOneExten = localOneExten; - } - - public String getLocalOneLanguage() - { - return localOneLanguage; - } - - public void setLocalOneLanguage(String localOneLanguage) - { - this.localOneLanguage = localOneLanguage; - } - - public String getLocalOnePriority() - { - return localOnePriority; - } - - public void setLocalOnePriority(String localOnePriority) - { - this.localOnePriority = localOnePriority; - } - - public String getLocalOneUniqueId() - { - return localOneUniqueId; - } - - public void setLocalOneUniqueId(String localOneUniqueId) - { - this.localOneUniqueId = localOneUniqueId; - } - - public String getLocalTwochannelState() - { - return localTwochannelState; - } - - public void setLocalTwochannelState(String localTwochannelState) - { - this.localTwochannelState = localTwochannelState; - } - - public String getLocalTwoChannelStateDesc() - { - return localTwoChannelStateDesc; - } - - public void setLocalTwoChannelStateDesc(String localTwoChannelStateDesc) - { - this.localTwoChannelStateDesc = localTwoChannelStateDesc; - } - - public String getLocalTwoPriority() - { - return localTwoPriority; - } - - public void setLocalTwoPriority(String localTwoPriority) - { - this.localTwoPriority = localTwoPriority; - } - - public String getLocalTwoContext() - { - return localTwoContext; - } - - public void setLocalTwoContext(String localTwoContext) - { - this.localTwoContext = localTwoContext; - } - - public String getLocalTwoCalleridNum() - { - return localTwoCalleridNum; - } - - public void setLocalTwoCalleridNum(String localTwoCalleridNum) - { - this.localTwoCalleridNum = localTwoCalleridNum; - } - - public String getLocalTwoCalleridName() - { - return localTwoCalleridName; - } - - public void setLocalTwoCalleridName(String localTwoCalleridName) - { - this.localTwoCalleridName = localTwoCalleridName; - } - - public String getLocalTwoUniqueid() - { - return localTwoUniqueid; - } - - public void setLocalTwoUniqueid(String localTwoUniqueid) - { - this.localTwoUniqueid = localTwoUniqueid; - } - - public String getLocalOneCalleridNum() - { - return localOneCalleridNum; - } - - public void setLocalOneCalleridNum(String localOneCalleridNum) - { - this.localOneCalleridNum = localOneCalleridNum; - } - - public String getLocalTwoConnectedLineName() - { - return localTwoConnectedLineName; - } - - public void setLocalTwoConnectedLineName(String localTwoConnectedLineName) - { - this.localTwoConnectedLineName = localTwoConnectedLineName; - } - - public String getLocalTwoConnectedLineNum() - { - return localTwoConnectedLineNum; - } - - public void setLocalTwoConnectedLineNum(String localTwoConnectedLineNum) - { - this.localTwoConnectedLineNum = localTwoConnectedLineNum; - } - - public String getLocalTwoLinkedid() - { - return localTwoLinkedid; - } - - public void setLocalTwoLinkedid(String localTwoLinkedid) - { - this.localTwoLinkedid = localTwoLinkedid; - } - - public String getLocalOneLinkedid() - { - return localOneLinkedid; - } - - public void setLocalOneLinkedid(String localOneLinkedid) - { - this.localOneLinkedid = localOneLinkedid; - } - - public String getLocalOneAccountCode() - { - return localOneAccountCode; - } - - public void setLocalOneAccountCode(String localOneAccountCode) - { - this.localOneAccountCode = localOneAccountCode; - } - - public String getLocalTwoAccountCode() - { - return localTwoAccountCode; - } - - public void setLocalTwoAccountCode(String localTwoAccountCode) - { - this.localTwoAccountCode = localTwoAccountCode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/LogChannelEvent.java b/src/main/java/org/asteriskjava/manager/event/LogChannelEvent.java deleted file mode 100644 index f2c3a7ad1..000000000 --- a/src/main/java/org/asteriskjava/manager/event/LogChannelEvent.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A LogChannelEvent is triggered when logging is turned on or off.

- * It is implemented in logger.c

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class LogChannelEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = 650153034857116588L; - - private String channel; - private Boolean enabled; - private Integer reason; - private String reasonTxt; - - /** - * @param source - */ - public LogChannelEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the log channel. - * - * @return the name of the log channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the log channel. - * - * @param channel the name of the log channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns if logging has been enabled or disabled. - * - * @return Boolean.TRUE if logging has been enabled, Boolean.FALSE if it has - * been disabled. - */ - public Boolean getEnabled() - { - return enabled; - } - - /** - * Sets if logging has been enabled or disabled. - * - * @param enabled Boolean.TRUE if logging has been enabled, Boolean.FALSE if - * it has been disabled. - */ - public void setEnabled(Boolean enabled) - { - this.enabled = enabled; - } - - /** - * Returns the reason code for disabling logging. - * - * @return the reason code for disabling logging. - */ - public Integer getReason() - { - return reason; - } - - /** - * Returns the textual representation of the reason for disabling logging. - * - * @return the textual representation of the reason for disabling logging. - */ - public String getReasonTxt() - { - return reasonTxt; - } - - /** - * Sets the reason for disabling logging. - * - * @param s the reason in the form "%d - %s". - */ - public void setReason(String s) - { - int spaceIdx; - - if (s == null) - { - return; - } - - spaceIdx = s.indexOf(' '); - if (spaceIdx <= 0) - { - spaceIdx = s.length(); - } - - try - { - this.reason = Integer.valueOf(s.substring(0, spaceIdx)); - } - catch (NumberFormatException e) - { - return; - } - - if (s.length() > spaceIdx + 3) - { - this.reasonTxt = s.substring(spaceIdx + 3, s.length()); - } - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ManagerEvent.java b/src/main/java/org/asteriskjava/manager/event/ManagerEvent.java deleted file mode 100644 index 3fa1af486..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ManagerEvent.java +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Date; -import java.util.EventObject; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.util.AstState; -import org.asteriskjava.util.ReflectionUtil; - -/** - * Abstract base class for all Events that can be received from the Asterisk - * server.
- * Events contain data pertaining to an event generated from within the Asterisk - * core or an extension module.
- * There is one conrete subclass of ManagerEvent per each supported Asterisk - * Event. - * - * @author srt - * @version $Id$ - */ -public abstract class ManagerEvent extends EventObject -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 2L; - protected String connectedLineNum; - protected String connectedLineName; - protected Integer priority; - protected Integer channelState; - protected String channelStateDesc; - protected String exten; - protected String callerIdNum; - protected String callerIdName; - - /** - * Returns the Caller ID name of the caller's channel. - * - * @return the Caller ID name of the caller's channel or "unknown" if none - * has been set. - * @since 0.2 - */ - - public String getCallerIdName() - { - return callerIdName; - } - - public void setCallerIdName(String callerIdName) - { - this.callerIdName = callerIdName; - } - - public String getConnectedLineNum() - { - return connectedLineNum; - } - - public void setConnectedLineNum(String connectedLineNum) - { - this.connectedLineNum = connectedLineNum; - } - - public String getConnectedLineName() - { - return connectedLineName; - } - - public void setConnectedLineName(String connectedLineName) - { - this.connectedLineName = connectedLineName; - } - - public Integer getPriority() - { - return priority; - } - - public void setPriority(Integer priority) - { - this.priority = priority; - } - - public Integer getChannelState() - { - return channelState == null ? AstState.str2state(channelStateDesc) : channelState; - } - - public void setChannelState(Integer channelState) - { - this.channelState = channelState; - } - - public String getChannelStateDesc() - { - return channelStateDesc; - } - - public void setChannelStateDesc(String channelStateDesc) - { - this.channelStateDesc = channelStateDesc; - } - - public String getExten() - { - return exten; - } - - public void setExten(String exten) - { - this.exten = exten; - } - - public String getCallerIdNum() - { - return callerIdNum; - } - - public void setCallerIdNum(String callerIdNum) - { - this.callerIdNum = callerIdNum; - } - - public String getContext() - { - return context; - } - - public void setContext(String context) - { - this.context = context; - } - - protected String context; - - /** - * AMI authorization class. - */ - private String privilege; - - /** - * The point in time this event has been received from the Asterisk server. - */ - private Date dateReceived; - - private Double timestamp; - - /** - * The server from which this event has been received (only used with - * AstManProxy). - */ - private String server; - - private String systemName; - - // AJ-213 only used when debugging is turned on - private String file; - private Integer line; - private String func; - private Integer sequenceNumber; - - public ManagerEvent(Object source) - { - super(source); - - } - - /** - * Returns the point in time this event was received from the Asterisk - * server.
- * Pseudo events that are not directly received from the asterisk server - * (for example ConnectEvent and DisconnectEvent) may return - * null. - */ - public Date getDateReceived() - { - return dateReceived; - } - - /** - * Sets the point in time this event was received from the asterisk server. - */ - public void setDateReceived(Date dateReceived) - { - this.dateReceived = dateReceived; - } - - /** - * Returns the AMI authorization class of this event.
- * This is one or more of system, call, log, verbose, command, agent or - * user. Multiple privileges are separated by comma.
- * Note: This property is not available from Asterisk 1.0 servers. - * - * @since 0.2 - */ - public String getPrivilege() - { - return privilege; - } - - /** - * Sets the AMI authorization class of this event. - * - * @since 0.2 - */ - public void setPrivilege(String privilege) - { - this.privilege = privilege; - } - - /** - * Returns the timestamp for this event.
- * The timestamp property is available in Asterisk since 1.4 if enabled in - * manager.conf by setting timestampevents = yes. - *
- * In contains the time the event was generated in seconds since the epoch. - *
- * Example: 1159310429.569108 - * - * @return the timestamp for this event. - * @since 0.3 - */ - public final Double getTimestamp() - { - return timestamp; - } - - /** - * Sets the timestamp for this event. - * - * @param timestamp the timestamp to set. - * @since 0.3 - */ - public final void setTimestamp(Double timestamp) - { - this.timestamp = timestamp; - } - - /** - * Returns the name of the Asterisk server from which this event has been - * received.
- * This property is only available when using to AstManProxy. - * - * @return the name of the Asterisk server from which this event has been - * received or null when directly connected to an - * Asterisk server instead of AstManProxy. - * @since 1.0.0 - */ - public final String getServer() - { - return server; - } - - /** - * Sets the name of the Asterisk server from which this event has been - * received. - * - * @param server the name of the Asterisk server from which this event has - * been received. - * @since 1.0.0 - */ - public final void setServer(String server) - { - this.server = server; - } - - public String getSystemName() - { - return systemName; - } - - public void setSystemName(String systemName) - { - this.systemName = systemName; - } - - /** - * Returns the name of the file in Asterisk's source code that triggered - * this event. For example pbx.c. - *

- * This property is only available if debugging for the Manager API has been - * turned on in Asterisk. This can be done by calling - * manager debug on on Asterisk's command line interface or by - * adding debug=on to Asterisk's manager.conf. - * This feature is availble in Asterisk since 1.6.0. - * - * @return the name of the file in that triggered this event or - * null if debgging is turned off. - * @see #getFunc() - * @see #getLine() - * @since 1.0.0 - */ - public String getFile() - { - return file; - } - - public void setFile(String file) - { - this.file = file; - } - - /** - * Returns the line number in Asterisk's source code where this event was - * triggered. - *

- * This property is only available if debugging for the Manager API has been - * turned on in Asterisk. This can be done by calling - * manager debug on on Asterisk's command line interface or by - * adding debug=on to Asterisk's manager.conf. - * This feature is availble in Asterisk since 1.6.0. - * - * @return the line number where this event was triggered or - * null if debgging is turned off. - * @see #getFile() - * @see #getFunc() - * @since 1.0.0 - */ - public Integer getLine() - { - return line; - } - - public void setLine(Integer line) - { - this.line = line; - } - - /** - * Returns the name of the C function in Asterisk's source code that - * triggered this event. For example pbx_builtin_setvar_helper - *

- * This property is only available if debugging for the Manager API has been - * turned on in Asterisk. This can be done by calling - * manager debug on on Asterisk's command line interface or by - * adding debug=on to Asterisk's manager.conf. - * This feature is availble in Asterisk since 1.6.0. - * - * @return the name of the C function that triggered this event or - * null if debgging is turned off. - * @see #getFile() - * @see #getLine() - * @since 1.0.0 - */ - public String getFunc() - { - return func; - } - - public void setFunc(String func) - { - this.func = func; - } - - /** - * Returns the sequence numbers of this event. Sequence numbers are only - * incremented while debugging is enabled. - *

- * This property is only available if debugging for the Manager API has been - * turned on in Asterisk. This can be done by calling - * manager debug on on Asterisk's command line interface or by - * adding debug=on to Asterisk's manager.conf. - * This feature is availble in Asterisk since 1.6.0. - * - * @return the sequence number of this event or null if - * debgging is turned off. - * @see #getFile() - * @see #getLine() - * @since 1.0.0 - */ - public Integer getSequenceNumber() - { - return sequenceNumber; - } - - public void setSequenceNumber(Integer sequenceNumber) - { - this.sequenceNumber = sequenceNumber; - } - - @Override - public String toString() - { - final List ignoredProperties = Arrays.asList("file", "func", "line", "sequenceNumber", "datereceived", - "privilege", "source", "class"); - final StringBuilder sb = new StringBuilder(getClass().getName() + "["); - appendPropertyIfNotNull(sb, "file", getFile()); - appendPropertyIfNotNull(sb, "func", getFunc()); - appendPropertyIfNotNull(sb, "line", getLine()); - appendPropertyIfNotNull(sb, "sequenceNumber", getSequenceNumber()); - appendPropertyIfNotNull(sb, "dateReceived", getDateReceived()); - appendPropertyIfNotNull(sb, "privilege", getPrivilege()); - - final Map getters = ReflectionUtil.getGetters(getClass()); - for (Map.Entry entry : getters.entrySet()) - { - final String property = entry.getKey(); - if (ignoredProperties.contains(property)) - { - continue; - } - - try - { - final Object value = entry.getValue().invoke(this); - appendProperty(sb, property, value); - } - catch (Exception e) // NOPMD - { - // swallow - } - } - sb.append("systemHashcode=").append(System.identityHashCode(this)); - sb.append("]"); - - return sb.toString(); - } - - protected void appendPropertyIfNotNull(StringBuilder sb, String property, Object value) - { - if (value != null) - { - appendProperty(sb, property, value); - } - } - - private void appendProperty(StringBuilder sb, String property, Object value) - { - sb.append(property).append("="); - if (value == null) - { - sb.append("null"); - } - else - { - sb.append("'").append(value).append("'"); - } - sb.append(","); - - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MasqueradeEvent.java b/src/main/java/org/asteriskjava/manager/event/MasqueradeEvent.java deleted file mode 100644 index 264fcec49..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MasqueradeEvent.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import org.asteriskjava.util.AstState; - -/** - * A MasqueradeEvent is triggered when Asterisk masquerades a channel.

- * Available since Asterisk 1.6

- * It is implemented in main/channel.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class MasqueradeEvent extends ManagerEvent -{ - static final long serialVersionUID = 1L; - - private String clone; - private String cloneStateDesc; - private String original; - private String originalStateDesc; - - public MasqueradeEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the clone channel. - * - * @return the name of the clone channel. - */ - public String getClone() - { - return clone; - } - - public void setClone(String clone) - { - this.clone = clone; - } - - /** - * Returns the state of the clone channel. - * - * @return the state of the clone channel. - * @see org.asteriskjava.util.AstState - */ - public Integer getCloneState() - { - return AstState.str2state(cloneStateDesc); - } - - /** - * Returns the state of the clone channel as a descriptive text. - * - * @return the state of the clone channel as a descriptive text. - */ - public String getCloneStateDesc() - { - return cloneStateDesc; - } - - public void setCloneState(String cloneState) - { - this.cloneStateDesc = cloneState; - } - - /** - * Returns the name of the original channel. - * - * @return the name of the original channel. - */ - public String getOriginal() - { - return original; - } - - public void setOriginal(String original) - { - this.original = original; - } - - /** - * Returns the state of the original channel. - * - * @return the state of the original channel. - * @see org.asteriskjava.util.AstState - */ - public Integer getOriginalState() - { - return AstState.str2state(originalStateDesc); - } - - /** - * Returns the state of the original channel as a descriptive text. - * - * @return the state of the original channel as a descriptive text. - */ - public String getOriginalStateDesc() - { - return originalStateDesc; - } - - public void setOriginalState(String originalState) - { - this.originalStateDesc = originalState; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeEndEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeEndEvent.java deleted file mode 100644 index a305b4f7c..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeEndEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeEnd event indicates that a conference room was disposed.

- * Available since Asterisk 1.6.

- * It is defined in apps/app_meetme.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class MeetMeEndEvent extends ManagerEvent -{ - private static final long serialVersionUID = 510266716726148586L; - private String meetMe; - - /** - * @param source - */ - public MeetMeEndEvent(Object source) - { - super(source); - } - - /** - * Returns the conference number. - * - * @return the conference number. - */ - public String getMeetMe() - { - return meetMe; - } - - public void setMeetMe(String meetMe) - { - this.meetMe = meetMe; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeJoinEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeJoinEvent.java deleted file mode 100644 index 5b7f16815..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeJoinEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeJoinEvent is triggered if a channel joins a MeetMe conference. - *

- * Channel and unqiueId properties for this event are available since Asterisk - * 1.0. - *

- * It is implemented in apps/app_meetme.c - * - * @author srt - * @version $Id$ - */ -public class MeetMeJoinEvent extends AbstractMeetMeEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * @param source - */ - public MeetMeJoinEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeLeaveEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeLeaveEvent.java deleted file mode 100644 index 517a21cb1..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeLeaveEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeLeaveEvent is triggered if a channel leaves a MeetMe conference. - *

- * Channel and unqiueId properties for this event are available since Asterisk - * 1.0. - *

- * It is implemented in apps/app_meetme.c - * - * @author srt - * @version $Id$ - */ -public class MeetMeLeaveEvent extends AbstractMeetMeEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 7692361610793036224L; - - private Long duration; - - /** - * @param source - */ - public MeetMeLeaveEvent(Object source) - { - super(source); - } - - /** - * Returns how long the user spent in the conference. - *

- * This property is available since Asterisk 1.4. - * - * @return the duration in seconds the user spent in the conference. - */ - public Long getDuration() - { - return duration; - } - - /** - * Sets how long the user spent in the conference. - * - * @param duration the duration in seconds the user spent in the conference. - */ - public void setDuration(Long duration) - { - this.duration = duration; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeMuteEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeMuteEvent.java deleted file mode 100644 index 9c723b45f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeMuteEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeMuteEvent is triggered when a user in a MeetMe room is muted or - * unmuted.

- * It is implemented in apps/app_meetme.c

- * Available since Asterisk 1.4. - * - * @author srt - * @version $Id$ - */ -public class MeetMeMuteEvent extends AbstractMeetMeEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = -8554403451985143184L; - - private Boolean status; - - /** - * @param source - */ - public MeetMeMuteEvent(Object source) - { - super(source); - } - - /** - * Returns whether the user was muted or unmuted. - * - * @return true if ther user was muted, - * false if the user was unmuted. - */ - public Boolean getStatus() - { - return status; - } - - /** - * Sets whether the user was muted or unmuted. - * - * @param status true if ther user was muted, - * false if the user was unmuted. - */ - public void setStatus(Boolean status) - { - this.status = status; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeStopTalkingEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeStopTalkingEvent.java deleted file mode 100644 index 448b30622..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeStopTalkingEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeStopTalkingEvent is triggered when a user ends talking in a meet me - * conference.

- * To enable talker detection you must pass the option 'T' to the MeetMe application.

- * It is implemented in apps/app_meetme.c

- * Available only in Asterisk 1.2. Asterisk 1.4 sends a - * {@link org.asteriskjava.manager.event.MeetMeTalkingEvent} with status set to - * false instead. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.MeetMeTalkingEvent - * @since 0.2 - * @deprecated as of 1.0.0, use {@link org.asteriskjava.manager.event.MeetMeTalkingEvent} instead and check for - * {@link MeetMeTalkingEvent#getStatus()}. - */ -@Deprecated public class MeetMeStopTalkingEvent extends MeetMeTalkingEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - public MeetMeStopTalkingEvent(Object source) - { - super(source); - this.status = Boolean.FALSE; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeTalkingEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeTalkingEvent.java deleted file mode 100644 index e6080190d..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeTalkingEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeTalkingEvent is triggered when a user starts talking in a meet me - * conference.

- * To enable talker detection you must pass the option 'T' to the MeetMe application.

- * It is implemented in apps/app_meetme.c

- * Available since Asterisk 1.2 - * - * @see org.asteriskjava.manager.event.MeetMeStopTalkingEvent - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class MeetMeTalkingEvent extends AbstractMeetMeEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = -8554403451985143184L; - - protected Boolean status = Boolean.TRUE; - - public MeetMeTalkingEvent(Object source) - { - super(source); - } - - /** - * Returns whether the user has started or stopped talking.

- * Until Asterisk 1.2 Asterisk used different events to indicate start - * and stop: This MeetMeTalkingEvent when the user started talking and the - * {@link MeetMeStopTalkingEvent} when he stopped. With Asterisk 1.2 - * only this MeetMeTalkingEvent is used with the status property indicating - * start and stop. For backwards compatibility this property defaults to - * true so when used with version 1.2 of Asterisk you get - * true. - * - * @return true if ther user has started talking, - * false if the user has stopped talking. - * @since 0.3 - */ - public Boolean getStatus() - { - return status; - } - - public void setStatus(Boolean status) - { - this.status = status; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MeetMeTalkingRequestEvent.java b/src/main/java/org/asteriskjava/manager/event/MeetMeTalkingRequestEvent.java deleted file mode 100644 index 4a968b3d2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MeetMeTalkingRequestEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MeetMeTalkingEvent is triggered when a muted user requests talking in a meet me - * conference.

- * To enable talker detection you must pass the option 'T' to the MeetMe application.

- * It is implemented in apps/app_meetme.c

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class MeetMeTalkingRequestEvent extends AbstractMeetMeEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - private Boolean status; - - /** - * @param source - */ - public MeetMeTalkingRequestEvent(Object source) - { - super(source); - } - - // see http://bugs.digium.com/view.php?id=9418 - - /** - * Returns whether the user has started or stopped requesting talking. - * - * @return true if ther user has started requesting talking, - * false if the user has stopped requesting talking. - */ - public Boolean getStatus() - { - return status; - } - - public void setStatus(Boolean status) - { - this.status = status; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/MessageWaitingEvent.java b/src/main/java/org/asteriskjava/manager/event/MessageWaitingEvent.java deleted file mode 100644 index 2e8910722..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MessageWaitingEvent.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MessageWaitingEvent is triggered when someone leaves voicemail.

- * It is implemented in apps/app_voicemail.c - * - * @author srt - * @version $Id$ - */ -public class MessageWaitingEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 7014587245968686266L; - private String mailbox; - private Integer waiting; - private Integer newMessages; - private Integer oldMessages; - - /** - * @param source - */ - public MessageWaitingEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the mailbox that has waiting messages.

- * The name of the mailbox is of the form numberOfMailbox@context, e.g. - * 1234@default. - * - * @return the name of the mailbox that has waiting messages - */ - public String getMailbox() - { - return mailbox; - } - - /** - * Sets the name of the mailbox that has waiting messages. - * - * @param mailbox the name of the mailbox that has waiting messages - */ - public void setMailbox(String mailbox) - { - this.mailbox = mailbox; - } - - /** - * Returns the number of new messages in the mailbox. - * - * @return the number of new messages in the mailbox - */ - public Integer getWaiting() - { - return waiting; - } - - /** - * Sets the number of new messages in the mailbox. - * - * @param waiting the number of new messages in the mailbox - */ - public void setWaiting(Integer waiting) - { - this.waiting = waiting; - } - - /** - * Returns the number of new messages in this mailbox. - * @return the number of new messages in this mailbox. - * @since 0.2 - */ - public Integer getNew() - { - return newMessages; - } - - /** - * Sets the number of new messages in this mailbox. - * @param newMessages the number of new messages in this mailbox. - * @since 0.2 - */ - public void setNew(Integer newMessages) - { - this.newMessages = newMessages; - } - - /** - * Returns the number of old messages in this mailbox. - * @return the number of old messages in this mailbox. - * @since 0.2 - */ - public Integer getOld() - { - return oldMessages; - } - - /** - * Sets the number of old messages in this mailbox. - * @param oldMessages the number of old messages in this mailbox. - * @since 0.2 - */ - public void setOld(Integer oldMessages) - { - this.oldMessages = oldMessages; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ModuleLoadReportEvent.java b/src/main/java/org/asteriskjava/manager/event/ModuleLoadReportEvent.java deleted file mode 100644 index 9dfe7e87b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ModuleLoadReportEvent.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ModuleLoadReportEvent is triggerd when Asterisk has completed loading its modules.

- * It is implemented in main/loader.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class ModuleLoadReportEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - public static final String MODULE_SELECTION_PRELOAD = "Preload"; - public static final String MODULE_SELECTION_ALL = "All"; - - public static final String MODULE_LOAD_STATUS_DONE = "Done"; - - private String moduleLoadStatus; - private String moduleSelection; - private Integer moduleCount; - - public ModuleLoadReportEvent(Object source) - { - super(source); - } - - /** - * Returns the load status. Currently this is always "Done". - * - * @return the load status. - * @see #MODULE_LOAD_STATUS_DONE - */ - public String getModuleLoadStatus() - { - return moduleLoadStatus; - } - - public void setModuleLoadStatus(String moduleLoadStatus) - { - this.moduleLoadStatus = moduleLoadStatus; - } - - /** - * Returns whether loading the pre-load modules has been completed or all modules - * have been loaded. - * - * @return "Preload" or "All" - * @see #MODULE_SELECTION_PRELOAD - * @see #MODULE_SELECTION_ALL - */ - public String getModuleSelection() - { - return moduleSelection; - } - - public boolean isPreload() - { - return MODULE_SELECTION_PRELOAD.equals(moduleSelection); - } - - public boolean isAll() - { - return MODULE_SELECTION_ALL.equals(moduleSelection); - } - - public void setModuleSelection(String moduleSelection) - { - this.moduleSelection = moduleSelection; - } - - /** - * Returns the number of modules that have been loaded. - * - * @return the number of modules that have been loaded. - */ - public Integer getModuleCount() - { - return moduleCount; - } - - public void setModuleCount(Integer moduleCount) - { - this.moduleCount = moduleCount; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/MonitorStartEvent.java b/src/main/java/org/asteriskjava/manager/event/MonitorStartEvent.java deleted file mode 100644 index 60ca3aefe..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MonitorStartEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MonitorStartEvent indicates that monitoring was started on a channel.

- * Available since Asterisk 1.6.

- * It is implemented in res/res_monitor.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - * @see org.asteriskjava.manager.event.MonitorStopEvent - */ -public class MonitorStartEvent extends AbstractMonitorEvent -{ - private static final long serialVersionUID = 253533286571341499L; - public MonitorStartEvent(Object source) - { - super(source); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/MonitorStopEvent.java b/src/main/java/org/asteriskjava/manager/event/MonitorStopEvent.java deleted file mode 100644 index 61cbfd846..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MonitorStopEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MonitorStopEvent indicates that monitoring was stopped on a channel.

- * Available since Asterisk 1.6.

- * It is implemented in res/res_monitor.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - * @see org.asteriskjava.manager.event.MonitorStartEvent - */ -public class MonitorStopEvent extends AbstractMonitorEvent -{ - private static final long serialVersionUID = -2605389608972504362L; - public MonitorStopEvent(Object source) - { - super(source); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/MusicOnHoldEvent.java b/src/main/java/org/asteriskjava/manager/event/MusicOnHoldEvent.java deleted file mode 100644 index a4ac71629..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MusicOnHoldEvent.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A MusicOnHoldEvent is triggered when music on hold starts or stops on a - * channel. - *

- * It is implemented in res/res_musiconhold.c. - *

- * Available since Asterisk 1.6 - * - * @author srt - * @since 1.0.0 - */ -public class MusicOnHoldEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - public static final String STATE_START = "Start"; - public static final String STATE_STOP = "Stop"; - - private String channel; - private String className; - private String uniqueId; - private String state; - private String accountCode; - private String linkedId; - private String language; - - public MusicOnHoldEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return channel the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - * - * @param channel the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getClassName() - { - return this.className; - } - - public void setClazz(String className) - { - this.className = className; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel. - * - * @param uniqueId the unique id of the channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the state. This is either "Start" or "Stop" depending on whether - * music on hold started or stopped on the channel. - * - * @return "Start" if music on hold started or "Stop" if music on hold - * stopped on the channel. - * @see #STATE_START - * @see #STATE_STOP - * @see #isStart() - * @see #isStop() - */ - public String getState() - { - return state; - } - - public void setState(String state) - { - this.state = state; - } - - /** - * Returns whether this is a start event. - * - * @return true if this a start event, false - * otherwise. - */ - public boolean isStart() - { - return STATE_START.equals(state); - } - - /** - * Returns whether this is a stop event. - * - * @return true if this an stop event, false - * otherwise. - */ - public boolean isStop() - { - return STATE_STOP.equals(state); - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/MusicOnHoldStartEvent.java b/src/main/java/org/asteriskjava/manager/event/MusicOnHoldStartEvent.java deleted file mode 100644 index 68e0e002a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MusicOnHoldStartEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class MusicOnHoldStartEvent extends MusicOnHoldEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public MusicOnHoldStartEvent(Object source) - { - super(source); - setState(STATE_START); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/MusicOnHoldStopEvent.java b/src/main/java/org/asteriskjava/manager/event/MusicOnHoldStopEvent.java deleted file mode 100644 index f25f9d4a5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/MusicOnHoldStopEvent.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by Alexander Polakov on 1/26/15. - */ -public class MusicOnHoldStopEvent extends MusicOnHoldEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - - public MusicOnHoldStopEvent(Object source) - { - super(source); - setState(STATE_STOP); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/NewAccountCodeEvent.java b/src/main/java/org/asteriskjava/manager/event/NewAccountCodeEvent.java deleted file mode 100644 index cb6e80aee..000000000 --- a/src/main/java/org/asteriskjava/manager/event/NewAccountCodeEvent.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A NewAccountCodeEvent indicates that the account code used for CDR has - * changed.

- * Available since Asterisk 1.6.

- * It is implemented in main/cdr.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class NewAccountCodeEvent extends ManagerEvent -{ - private static final long serialVersionUID = -1786512014173534223L; - private String channel; - private String uniqueId; - private String accountCode; - private String oldAccountCode; - private String language; - private String linkedId; - - /** - * @param source - */ - public NewAccountCodeEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel. - * - * @return the name of the channel. - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the new account code. - * - * @return the new account code. - */ - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - /** - * Returns the old account code. - * - * @return the old account code. - */ - public String getOldAccountCode() - { - return oldAccountCode; - } - - public void setOldAccountCode(String oldAccountCode) - { - this.oldAccountCode = oldAccountCode; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/NewCallerIdEvent.java b/src/main/java/org/asteriskjava/manager/event/NewCallerIdEvent.java deleted file mode 100644 index a840dce92..000000000 --- a/src/main/java/org/asteriskjava/manager/event/NewCallerIdEvent.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - - -/** - * A NewCallerIdEvent is triggered when the caller id of a channel changes.

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - */ -public class NewCallerIdEvent extends AbstractChannelEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 6639570533512201213L; - - /** - * Callerid presentation/screening. - */ - private Integer cidCallingPres; - private String cidCallingPresTxt; - private String language; - private String linkedId; - - public NewCallerIdEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - /** - * Returns the CallerId presentation/screening. - * - * @return the CallerId presentation/screening. - * @since 0.2 - */ - public Integer getCidCallingPres() - { - return cidCallingPres; - } - - /** - * Returns the textual respresentation of the CallerId presentation/screening. - * - * @return the textual respresentation of the CallerId presentation/screening. - * @since 0.2 - */ - public String getCidCallingPresTxt() - { - return cidCallingPresTxt; - } - - /** - * Sets the CallerId presentation/screening in the form "%d (%s)". - * - * @param s the CallerId presentation/screening in the form "%d (%s)". - * @since 0.2 - */ - public void setCidCallingPres(String s) - { - int spaceIdx; - - if (s == null) - { - return; - } - - spaceIdx = s.indexOf(' '); - if (spaceIdx <= 0) - { - spaceIdx = s.length(); - } - - try - { - this.cidCallingPres = Integer.valueOf(s.substring(0, spaceIdx)); - } - catch (NumberFormatException e) - { - return; - } - - if (s.length() > spaceIdx + 3) - { - this.cidCallingPresTxt = s.substring(spaceIdx + 2, s.length() - 1); - } - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/NewChannelEvent.java b/src/main/java/org/asteriskjava/manager/event/NewChannelEvent.java deleted file mode 100644 index f7983206b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/NewChannelEvent.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A NewChannelEvent is triggered when a new channel is created. - *

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - */ -public class NewChannelEvent extends AbstractChannelStateEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 1L; - - private String accountCode; - private String language; - private String linkedid; - - public NewChannelEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - /** - * Returns the account code of the new channel. - *

- * This property is available since Asterisk 1.6. - * - * @return the account code of the new channel. - * @since 1.0.0 - */ - public String getAccountCode() - { - return accountCode; - } - - /** - * Sets the account code of the new channel. - * - * @param accountCode the account code of the new channel. - * @since 1.0.0 - */ - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getLinkedid() - { - return linkedid; - } - - public void setLinkedid(String linkedid) - { - this.linkedid = linkedid; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/NewConnectedLineEvent.java b/src/main/java/org/asteriskjava/manager/event/NewConnectedLineEvent.java deleted file mode 100644 index 4274e2d33..000000000 --- a/src/main/java/org/asteriskjava/manager/event/NewConnectedLineEvent.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class NewConnectedLineEvent extends ManagerEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String channel; - private String uniqueId; - private String language; - private String accountCode; - private String linkedId; - - public NewConnectedLineEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/NewExtenEvent.java b/src/main/java/org/asteriskjava/manager/event/NewExtenEvent.java deleted file mode 100644 index 9997b9152..000000000 --- a/src/main/java/org/asteriskjava/manager/event/NewExtenEvent.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A NewExtenEvent is triggered when a channel is connected to a new extension. - *

- * It is implemented in pbx.c - * - * @author srt - * @version $Id$ - */ -public class NewExtenEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = -467486409866099387L; - - private String uniqueId; - private String extension; - private String application; - private String appData; - private String channel; - private String language; - private String accountCode; - private String linkedId; - - /** - * @param source - */ - public NewExtenEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - /** - * Returns the unique id of the channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the name of the application that is executed. - */ - public String getApplication() - { - return application; - } - - /** - * Sets the name of the application that is executed. - */ - public void setApplication(String application) - { - this.application = application; - } - - /** - * Returns the parameters passed to the application that is executed. The - * parameters are separated by a '|' character. - */ - public String getAppData() - { - return appData; - } - - /** - * Sets the parameters passed to the application that is executed. - */ - public void setAppData(String appData) - { - this.appData = appData; - } - - /** - * Returns the name of the channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the extension. - */ - public String getExtension() - { - return extension; - } - - /** - * Sets the extension. - */ - public void setExtension(String extension) - { - this.extension = extension; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/NewStateEvent.java b/src/main/java/org/asteriskjava/manager/event/NewStateEvent.java deleted file mode 100644 index 275146b31..000000000 --- a/src/main/java/org/asteriskjava/manager/event/NewStateEvent.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A NewStateEvent is triggered when the state of a channel has changed.

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - */ -public class NewStateEvent extends AbstractChannelStateEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = -0L; - private String language; - private String linkedId; - - public NewStateEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/OriginateFailureEvent.java b/src/main/java/org/asteriskjava/manager/event/OriginateFailureEvent.java deleted file mode 100644 index f18af74c5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/OriginateFailureEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An OriginateFailureEvent is triggered when the execution of an - * OriginateAction failed.

- * Deprecated since Asterisk 1.4. - * - * @see org.asteriskjava.manager.action.OriginateAction - * @see OriginateResponseEvent - * @deprecated - * @author srt - * @version $Id$ - */ -@Deprecated public class OriginateFailureEvent extends OriginateResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -6812199688948480631L; - - /** - * @param source - */ - public OriginateFailureEvent(Object source) - { - super(source); - setResponse("Failure"); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/OriginateResponseEvent.java b/src/main/java/org/asteriskjava/manager/event/OriginateResponseEvent.java deleted file mode 100644 index 33ce8cb00..000000000 --- a/src/main/java/org/asteriskjava/manager/event/OriginateResponseEvent.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Response to an OriginateAction. - * - * @see org.asteriskjava.manager.action.OriginateAction - * @author srt - * @version $Id$ - */ -public class OriginateResponseEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 910724860608259687L; - private String response; - private String channel; - private String uniqueId; - private Integer reason; - private String data; - private String application; - - /** - * @param source - */ - public OriginateResponseEvent(Object source) - { - super(source); - } - - /** - * Returns the result of the corresponding Originate action. - * - * @return "Success" or "Failure" - */ - public String getResponse() - { - return response; - } - - /** - * Sets the result of the corresponding Originate action. - * - * @param response "Success" or "Failure" - */ - public void setResponse(String response) - { - this.response = response; - } - - public boolean isSuccess() - { - return "Success".equalsIgnoreCase(response); - } - - /** - * Returns the name of the channel to connect to the outgoing call. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel to connect to the outgoing call. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - public Integer getReason() - { - return reason; - } - - public void setReason(Integer reason) - { - this.reason = reason; - } - - /** - * Returns the unique id of the originated channel. - * - * @return the unique id of the originated channel or "<null>" if none - * is available. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - // for backward compatibility only - public void setCallerId(String callerId) - { - if (getCallerIdNum() == null) - { - setCallerIdNum(callerId); - } - } - - public String getData() - { - return data; - } - - public void setData(String data) - { - this.data = data; - } - - public String getApplication() - { - return application; - } - - public void setApplication(String application) - { - this.application = application; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/OriginateSuccessEvent.java b/src/main/java/org/asteriskjava/manager/event/OriginateSuccessEvent.java deleted file mode 100644 index d3f92c4aa..000000000 --- a/src/main/java/org/asteriskjava/manager/event/OriginateSuccessEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An OriginateSuccessEvent is triggered when the execution of an - * OriginateAction succeeded.

- * Deprecated since Asterisk 1.4. - * - * @see org.asteriskjava.manager.action.OriginateAction - * @see OriginateResponseEvent - * @deprecated - * @author srt - * @version $Id$ - */ -@Deprecated public class OriginateSuccessEvent extends OriginateResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -5086668438614692086L; - - /** - * @param source - */ - public OriginateSuccessEvent(Object source) - { - super(source); - setResponse("Success"); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ParkedCallEvent.java b/src/main/java/org/asteriskjava/manager/event/ParkedCallEvent.java deleted file mode 100644 index 9c6311988..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ParkedCallEvent.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ParkedCallEvent is triggered when a channel is parked (in this case no - * action id is set) and in response to a ParkedCallsAction. - *

- * It is implemented in res/res_features.c - * - * @see org.asteriskjava.manager.action.ParkedCallsAction - * @author srt - * @version $Id$ - */ -public class ParkedCallEvent extends AbstractParkedCallEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 0L; - - private Integer timeout; - private String connectedlinenum; - private String connectedlinename; - - /** - * @param source - */ - public ParkedCallEvent(Object source) - { - super(source); - } - - /** - * Returns the number of seconds this call will be parked. - *

- * This corresponds to the parkingtime option in - * features.conf. - */ - public Integer getTimeout() - { - return timeout; - } - - /** - * Sets the number of seconds this call will be parked. - */ - public void setTimeout(Integer timeout) - { - this.timeout = timeout; - } - - /** - * Sets the unique id of the parked channel as a workaround for a typo in - * asterisk manager event. - */ - public void setUnqiueId(String unqiueId) - { - setUniqueId(unqiueId); - } - - - public String getConnectedLinenum() - { - return connectedlinenum; - } - - - public void setConnectedLinenum(String connectedlinenum) - { - this.connectedlinenum = connectedlinenum; - } - - public String getConnectedLinename() - { - return connectedlinename; - } - - - public void setConnectedLinename(String connectedlinename) - { - this.connectedlinename = connectedlinename; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ParkedCallGiveUpEvent.java b/src/main/java/org/asteriskjava/manager/event/ParkedCallGiveUpEvent.java deleted file mode 100644 index 1c4a456e5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ParkedCallGiveUpEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ParkedCallGiveUpEvent is triggered when a channel that has been parked is - * hung up. - *

- * It is implemented in res/res_features.c - *

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class ParkedCallGiveUpEvent extends AbstractUnParkedEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -7437833328723536814L; - - /** - * @param source - */ - public ParkedCallGiveUpEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ParkedCallTimeOutEvent.java b/src/main/java/org/asteriskjava/manager/event/ParkedCallTimeOutEvent.java deleted file mode 100644 index c258ba4af..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ParkedCallTimeOutEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ParkedCallTimeOutEvent is triggered when call parking times out for a given - * channel. - *

- * It is implemented in res/res_features.c - *

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class ParkedCallTimeOutEvent extends AbstractUnParkedEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -7437833328723536814L; - - /** - * @param source - */ - public ParkedCallTimeOutEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ParkedCallsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/ParkedCallsCompleteEvent.java deleted file mode 100644 index 263df0c59..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ParkedCallsCompleteEvent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ParkedCallsCompleteEvent is triggered after all parked calls have been - * reported in response to a ParkedCallsAction. - * - * @see org.asteriskjava.manager.action.ParkedCallsAction - * @see org.asteriskjava.manager.event.ParkedCallEvent - * @author srt - * @version $Id$ - */ -public class ParkedCallsCompleteEvent extends ResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2736388036245367249L; - - /** - * @param source - */ - public ParkedCallsCompleteEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/PausedEvent.java b/src/main/java/org/asteriskjava/manager/event/PausedEvent.java deleted file mode 100644 index efa0dbe83..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PausedEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.manager.event; - -public class PausedEvent extends UserEvent { - - public PausedEvent(Object source) { - super(source); - } - - /** - * - */ - private static final long serialVersionUID = 7181269530090027203L; - - private String header; - - private String extension; - - public String getHeader() { - return header; - } - - public void setHeader(String header) { - this.header = header; - } - - public String getExtension() { - return extension; - } - - public void setExtension(String extension) { - this.extension = extension; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/PeerEntryEvent.java b/src/main/java/org/asteriskjava/manager/event/PeerEntryEvent.java deleted file mode 100644 index 0e8b9b64e..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PeerEntryEvent.java +++ /dev/null @@ -1,435 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A PeerEntryEvent is triggered in response to a - * {@link org.asteriskjava.manager.action.SipPeersAction}, - * {@link org.asteriskjava.manager.action.SipShowPeerAction} or - * {@link org.asteriskjava.manager.action.IaxPeerListAction} and contains - * information about a SIP or IAX peer. - *

- * It is implemented in channels/chan_sip.c and - * channels/chan_iax.c - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class PeerEntryEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - public static final String CHANNEL_TYPE_SIP = "SIP"; - public static final String CHANNEL_TYPE_IAX = "IAX"; - - private String channelType; - private String objectName; - private String objectUserName; - private String chanObjectType; - private String ipAddress; - private Integer port; - private Boolean dynamic; - private Boolean natSupport; - private Boolean forceRport; - private Boolean videoSupport; - private Boolean textSupport; - private Boolean acl; - private String status; - private String realtimeDevice; - private Boolean trunk; - private String encryption; - private String autoComedia; - private String autoForcerport; - private String comedia; - private String description; - private String accountcode; - - /** - * Creates a new instance. - * - * @param source - */ - public PeerEntryEvent(Object source) - { - super(source); - } - - /** - * Returns whether this event represents a SIP or an IAX peer. - * - * @return "SIP" or "IAX". - * @see #CHANNEL_TYPE_SIP - * @see #CHANNEL_TYPE_IAX - */ - public String getChannelType() - { - return channelType; - } - - public void setChannelType(String channelType) - { - this.channelType = channelType; - } - - public String getObjectName() - { - return objectName; - } - - public void setObjectName(String objectName) - { - this.objectName = objectName; - } - - /** - * @return - * @since 1.0.0 - */ - public String getObjectUserName() - { - return objectUserName; - } - - public void setObjectUserName(String objectUserName) - { - this.objectUserName = objectUserName; - } - - /** - * For SIP peers this is either "peer" or "user". - * - * @return "peer" or "user". - */ - public String getChanObjectType() - { - return chanObjectType; - } - - public void setChanObjectType(String chanObjectType) - { - this.chanObjectType = chanObjectType; - } - - /** - * Returns the IP address of the peer. - * - * @return the IP address of the peer or "-none-" if none is available. - */ - public String getIpAddress() - { - return ipAddress; - } - - /** - * Sets the IP address of the peer. - * - * @param ipAddress the IP address of the peer. - */ - public void setIpAddress(String ipAddress) - { - this.ipAddress = ipAddress; - } - - /** - * Returns the port of the peer. - * - * @return the port of the peer. - * @deprecated since 1.0.0, use {@link #getPort()} instead. - */ - @Deprecated - public Integer getIpPort() - { - return port; - } - - public void setIpPort(Integer ipPort) - { - this.port = ipPort; - } - - /** - * Returns the port of the peer. - * - * @return the port of the peer. - * @since 1.0.0 - */ - public Integer getPort() - { - return port; - } - - public void setPort(Integer port) - { - this.port = port; - } - - public Boolean getDynamic() - { - return dynamic; - } - - public void setDynamic(Boolean dynamic) - { - this.dynamic = dynamic; - } - - public Boolean getNatSupport() - { - return natSupport; - } - - public void setNatSupport(Boolean natSupport) - { - this.natSupport = natSupport; - } - - /** - * Returns whether the nat option is set to force_rport.
- * Available since Asterisk 1.8 - * - * @return true if the nat option is set to - * force_rport, false otherwise or - * null if not supported by Asterisk. - */ - public Boolean getForceRport() - { - return forceRport; - } - - public void setForceRport(Boolean forceRport) - { - this.forceRport = forceRport; - } - - /** - * Available since Asterisk 1.4. - * - * @since 0.3 - */ - public Boolean getVideoSupport() - { - return videoSupport; - } - - /** - * Available since Asterisk 1.4. - * - * @since 0.3 - */ - public void setVideoSupport(Boolean videoSupport) - { - this.videoSupport = videoSupport; - } - - /** - * Returns whether the peer supports text messages. - *

- * Available since Asterisk 1.6. - * - * @return true if the peer supports text messages, - * false otherwise or null if the property - * is not set (i.e. for Asterisk prior to 1.6). - * @since 1.0.0 - */ - public Boolean getTextSupport() - { - return textSupport; - } - - public void setTextSupport(Boolean textSupport) - { - this.textSupport = textSupport; - } - - public Boolean getAcl() - { - return acl; - } - - public void setAcl(Boolean acl) - { - this.acl = acl; - } - - /** - * Returns the status of this peer. - *

- * For SIP peers this is one of: - *

- *
"UNREACHABLE"
- *
- *
"LAGGED (%d ms)"
- *
- *
"OK (%d ms)"
- *
- *
"UNKNOWN"
- *
- *
"Unmonitored"
- *
- *
- * - * @return the status of this peer. - */ - public String getStatus() - { - return status; - } - - /** - * Sets the status of this peer. - * - * @param status the status of this peer. - */ - public void setStatus(String status) - { - this.status = status; - } - - /** - * Available since Asterisk 1.4. - * - * @since 0.3 - */ - public String getRealtimeDevice() - { - return realtimeDevice; - } - - /** - * Available since Asterisk 1.4. - * - * @since 0.3 - */ - public void setRealtimeDevice(String realtimeDevice) - { - this.realtimeDevice = realtimeDevice; - } - - /** - * Returns whether to use IAX2 trunking with this peer. - *

- * Available since Asterisk 1.6. - * - * @return true if trunking is used, false if not - * or null if not set. - * @since 1.0.0 - */ - public Boolean getTrunk() - { - return trunk; - } - - public void setTrunk(Boolean trunk) - { - this.trunk = trunk; - } - - public String getEncryption() - { - return encryption; - } - - public void setEncryption(String encryption) - { - this.encryption = encryption; - } - - /** - * @return the autoComedia - */ - public String getAutoComedia() - { - return autoComedia; - } - - /** - * @param autoComedia the autoComedia to set - */ - public void setAutoComedia(String autoComedia) - { - this.autoComedia = autoComedia; - } - - /** - * @return the autoForcerport - */ - public String getAutoForcerport() - { - return autoForcerport; - } - - /** - * @param autoForcerport the autoForcerport to set - */ - public void setAutoForcerport(String autoForcerport) - { - this.autoForcerport = autoForcerport; - } - - /** - * @return the comedia - */ - public String getComedia() - { - return comedia; - } - - /** - * @param comedia the comedia to set - */ - public void setComedia(String comedia) - { - this.comedia = comedia; - } - - /** - * @return the description - */ - public String getDescription() - { - return description; - } - - /** - * @param the description to set - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @return the accountcode - */ - public String getAccountcode() - { - return accountcode; - } - - /** - * @param the accountcode to set - */ - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/PeerStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/PeerStatusEvent.java deleted file mode 100644 index 200de7a54..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PeerStatusEvent.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A PeerStatusEvent is triggered when a SIP or IAX client attempts to registrer at this asterisk - * server.

- * This event is implemented in channels/chan_iax2.c and - * channels/chan_sip.c - * - * @author srt - * @version $Id$ - */ -public class PeerStatusEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - public static final String STATUS_REGISTERED = "Registered"; - public static final String STATUS_UNREGISTERED = "Unregistered"; - public static final String STATUS_REACHABLE = "Reachable"; - public static final String STATUS_LAGGED = "Lagged"; - public static final String STATUS_UNREACHABLE = "Unreachable"; - public static final String STATUS_REJECTED = "Rejected"; - - private String channelType; - private String peer; - private String peerStatus; - private String cause; - private Integer time; - private String address; - private Integer port; - - /** - * @param source - */ - public PeerStatusEvent(Object source) - { - super(source); - } - - /** - * Returns the type of channel that registers, that is "IAX2" for an IAX2 - * channel or "SIP" for a SIP channel.

- * Available since Asterisk 1.6. - * - * @return the type of channel that registers. - * @since 1.0.0 - */ - public String getChannelType() - { - return channelType; - } - - /** - * Sets the type of channel that registers. - * - * @param channelType the type of channel that registers - * @since 1.0.0 - */ - public void setChannelType(String channelType) - { - this.channelType = channelType; - } - - /** - * Returns the name of the peer that registered.

- * The peer name includes the channel type prefix. So if you receive a PeerStatusEvent for a - * SIP peer defined as "john" in sip.conf this method returns "SIP/john". - *
- * Peer names for IAX clients start with "IAX2/", peer names for SIP clients start with "SIP/". - * - * @return the peer's name including the channel type. - */ - public String getPeer() - { - return peer; - } - - /** - * Sets the name of the peer that registered. - */ - public void setPeer(String peer) - { - this.peer = peer; - } - - /** - * Returns the registration state.

- * This may be one of - *

    - *
  • Registered
  • - *
  • Unregistered
  • - *
  • Reachable
  • - *
  • Lagged
  • - *
  • Unreachable
  • - *
  • Rejected (IAX only)
  • - *
- */ - public String getPeerStatus() - { - return peerStatus; - } - - /** - * Sets the registration state. - */ - public void setPeerStatus(String peerStatus) - { - this.peerStatus = peerStatus; - } - - /** - * Returns the cause of a rejection or unregistration.

- * For IAX peers this is set only if the status equals "Rejected".

- * For SIP peers this is set if the status equals "Unregistered" and the peer was unregistered - * due to an expiration. In that case the cause is set to "Expired". - * - * @return the cause of a rejection or unregistration. - */ - public String getCause() - { - return cause; - } - - /** - * Sets the cause of the rejection or unregistration. - */ - public void setCause(String cause) - { - this.cause = cause; - } - - /** - * Returns the ping time of the client if status equals "Reachable" or "Lagged"; if the status - * equals "Unreachable" it returns how long the last response took (in ms) for IAX peers or -1 - * for SIP peers. - */ - public Integer getTime() - { - return time; - } - - public void setTime(Integer time) - { - this.time = time; - } - - /** - * Returns the IP address of the peer that registered. Only available for SIP channels.

- * Available since Asterisk 1.6. - * - * @return the IP address of the peer that registered or null if not available. - * @since 1.0.0 - */ - public String getAddress() - { - return address; - } - - public void setAddress(String address) - { - this.address = address; - } - - /** - * Returns the port of the peer that registered. Only available for SIP channels.

- * Available since Asterisk 1.6. - * - * @return the port of the peer that registered or null if not available. - * @since 1.0.0 - */ - public Integer getPort() - { - return port; - } - - public void setPort(Integer port) - { - this.port = port; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/PeerlistCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/PeerlistCompleteEvent.java deleted file mode 100644 index c98e42ace..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PeerlistCompleteEvent.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A PeerlistCompleteEvent is triggered after the details of all peers has been reported in response - * to an SIPPeersAction or SIPShowPeerAction.

- * Available since Asterisk 1.2 - * - * @see org.asteriskjava.manager.event.PeerEntryEvent - * @see org.asteriskjava.manager.action.SipPeersAction - * @see org.asteriskjava.manager.action.SipShowPeerAction - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class PeerlistCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1177773673509373296L; - private Integer listItems; - private String eventList; - - /** - * Creates a new instance. - * - * @param source - */ - public PeerlistCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns the number of PeerEvents that have been reported. - * - * @return the number of PeerEvents that have been reported. - */ - public Integer getListItems() - { - return listItems; - } - - /** - * Sets the number of PeerEvents that have been reported. - * - * @param listItems the number of PeerEvents that have been reported. - */ - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } - - /** - * Returns always "Complete".

- * Available since Asterisk 1.6. - * - * @return always returns "Complete" confirming that all PeerEntry events have been sent. - * @since 1.0.0 - */ - public String getEventList() - { - return eventList; - } - - public void setEventList(String eventList) - { - this.eventList = eventList; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/PeersEvent.java b/src/main/java/org/asteriskjava/manager/event/PeersEvent.java deleted file mode 100644 index 2e1692d9c..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PeersEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.List; - -/** - * A PeersEvent is triggered in response to a {@link org.asteriskjava.manager.action.SipPeersAction}, - * {@link org.asteriskjava.manager.action.SipShowPeerAction} or {@link org.asteriskjava.manager.action.IaxPeerListAction} - * and contains information about a SIP or IAX peers.

- * It is implemented in channels/chan_sip.c and channels/chan_iax.c - * - * @author ddpaul - * @version $Id$ - * @since 0.2 - */ -public class PeersEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * This field holds actual information about SIP/IAX peers - */ - private List childEvents; - - /** - * Creates a new instance. - * - * @param source - */ - public PeersEvent( Object source ) - { - super(source); - } - - public List getChildEvents() - { - return childEvents; - } - - public void setChildEvents( List childEvents ) - { - this.childEvents = childEvents; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/PickupEvent.java b/src/main/java/org/asteriskjava/manager/event/PickupEvent.java deleted file mode 100644 index b7c829cda..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PickupEvent.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asteriskjava.manager.event; - -public class PickupEvent extends ManagerEvent -{ - private String channel; - private String targetchannel; - - public PickupEvent(Object source) - { - super(source); - } - - /** - * - */ - private static final long serialVersionUID = 1L; - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getTargetchannel() - { - return targetchannel; - } - - public void setTargetchannel(String targetchannel) - { - this.targetchannel = targetchannel; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/PriEventEvent.java b/src/main/java/org/asteriskjava/manager/event/PriEventEvent.java deleted file mode 100644 index 3b82cc4ba..000000000 --- a/src/main/java/org/asteriskjava/manager/event/PriEventEvent.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * This event is implemented in channels/chan_dahdi.c.

- * Available since Asterisk 1.6.1 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class PriEventEvent extends ManagerEvent -{ - private static final long serialVersionUID = 3257069450639290810L; - private String priEvent; - private Integer priEventCode; - private String dChannel; - private Integer span; - - public PriEventEvent(Object source) - { - super(source); - } - - /** - * Returns the textual representation of the event code.

- * This is one of - *

    - *
  • "On hook" - *
  • "Ring/Answered" - *
  • "Wink/Flash" - *
  • "Alarm" - *
  • "No more alarm" - *
  • "HDLC Abort" - *
  • "HDLC Overrun" - *
  • "HDLC Bad FCS" - *
  • "Dial Complete" - *
  • "Ringer On" - *
  • "Ringer Off" - *
  • "Hook Transition Complete" - *
  • "Bits Changed" - *
  • "Pulse Start" - *
  • "Timer Expired" - *
  • "Timer Ping" - *
  • "Polarity Reversal" - *
  • "Ring Begin" - *
- * - * @return the textual representation of the event code. - * @see #getPriEventCode() - */ - public String getPriEvent() - { - return priEvent; - } - - public void setPriEvent(String priEvent) - { - this.priEvent = priEvent; - } - - /** - * Returns the numerical pri event code. - * - * @return the numerical pri event code. - * @see #getPriEvent() - */ - public Integer getPriEventCode() - { - return priEventCode; - } - - public void setPriEventCode(Integer priEventCode) - { - this.priEventCode = priEventCode; - } - - /** - * Returns the D-Channel the event occurred on. - * - * @return the D-Channel the event occurred on. - */ - public String getDChannel() - { - return dChannel; - } - - public void setDChannel(String dChannel) - { - this.dChannel = dChannel; - } - - /** - * Returns the span the event occurred on. - * - * @return the span the event occurred on. - */ - public Integer getSpan() - { - return span; - } - - public void setSpan(Integer span) - { - this.span = span; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ProtocolIdentifierReceivedEvent.java b/src/main/java/org/asteriskjava/manager/event/ProtocolIdentifierReceivedEvent.java deleted file mode 100644 index fa45bf69f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ProtocolIdentifierReceivedEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ProtocolIdentifierReceivedEvent is triggered when the network connection to the Asterisk - * server has been established and the protocol identifier has been sent.

- * It is a pseudo event not directly related to an Asterisk generated event.

- * The ProtocolIdentifierReceivedEvent is not dispatched to clients so you will - * probably never see it. - * - * @author srt - * @version $Id$ - */ -public class ProtocolIdentifierReceivedEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 3257845467831284784L; - - /** - * The version of the manager protocol. - */ - private String protocolIdentifier; - - /** - * @param source - */ - public ProtocolIdentifierReceivedEvent(Object source) - { - super(source); - } - - /** - * Returns the version of the protocol. - * - * @return the version of the protocol. - */ - public String getProtocolIdentifier() - { - return protocolIdentifier; - } - - /** - * Sets the version of the protocol. - * - * @param protocolIdentifier the version of the protocol. - */ - public void setProtocolIdentifier(String protocolIdentifier) - { - this.protocolIdentifier = protocolIdentifier; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueCallerAbandonEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueCallerAbandonEvent.java deleted file mode 100644 index 58d189a73..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueCallerAbandonEvent.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueCallerAbandonEvent is triggered when a caller abandons a queue before - * getting connected with an agent. - *

- * It is implemented in apps/app_queue.c - *

- * Available since Asterisk 1.4. - * - * @author martins - */ -public class QueueCallerAbandonEvent extends QueueEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 812069706662063871L; - - private Integer position; - private Integer originalPosition; - private Integer holdTime; - private String linkedId; - private String language; - - private String accountcode; - - /** - * @param source - */ - public QueueCallerAbandonEvent(Object source) - { - super(source); - } - - /** - * @return the amount of time in seconds the caller was on hold - */ - public Integer getHoldTime() - { - return holdTime; - } - - /** - * @param holdTime the amount of time in seconds the caller was on hold - */ - public void setHoldTime(Integer holdTime) - { - this.holdTime = holdTime; - } - - /** - * @return the original position of the caller in the queue - */ - public Integer getOriginalPosition() - { - return originalPosition; - } - - /** - * @param originalPosition the original position of the caller in the queue - */ - public void setOriginalPosition(Integer originalPosition) - { - this.originalPosition = originalPosition; - } - - /** - * @return the position of the caller at the time they abandoned the queue - */ - public Integer getPosition() - { - return position; - } - - /** - * @param position the position of the caller at the time they abandoned the - * queue - */ - public void setPosition(Integer position) - { - this.position = position; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueCallerJoinEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueCallerJoinEvent.java deleted file mode 100644 index 204390119..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueCallerJoinEvent.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueCallerJoinEvent is triggered when a caller join a queue before - * getting connected with an agent. - *

- * It is implemented in apps/app_queue.c - *

- * Available since Asterisk 1.4. - * - * @author Leonardo de Souza - */ -public class QueueCallerJoinEvent extends QueueEvent -{ - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 812069706662063872L; - - private Integer position; - private String linkedId; - private String language; - private String accountcode; - - /** - * @param source - */ - public QueueCallerJoinEvent(Object source) - { - super(source); - } - - /** - * @return the position of the caller at the time they abandoned the queue - */ - public Integer getPosition() - { - return position; - } - - /** - * @param position the position of the caller at the time they abandoned the - * queue - */ - public void setPosition(Integer position) - { - this.position = position; - } - - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueCallerLeaveEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueCallerLeaveEvent.java deleted file mode 100644 index 77538b0d5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueCallerLeaveEvent.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueCallerLeaveEvent is triggered when a caller leave a queue before - * getting connected with an agent. - *

- * It is implemented in apps/app_queue.c - *

- * Available since Asterisk 1.4. - * - * @author Leonardo de Souza - */ -public class QueueCallerLeaveEvent extends QueueEvent -{ - - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 812069706662063871L; - - private Integer position; - private String language; - private String linkedId; - - private String accountcode; - - /** - * @param source - */ - public QueueCallerLeaveEvent(Object source) - { - super(source); - } - - /** - * @return the position of the caller at the time they abandoned the queue - */ - public Integer getPosition() - { - return position; - } - - /** - * @param position the position of the caller at the time they abandoned the - * queue - */ - public void setPosition(Integer position) - { - this.position = position; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getAccountcode() - { - return accountcode; - } - - public void setAccountcode(String accountcode) - { - this.accountcode = accountcode; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueEntryEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueEntryEvent.java deleted file mode 100644 index 840e105ed..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueEntryEvent.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueEntryEvent is triggered in response to a QueueStatusAction and - * contains information about an entry in a queue. - *

- * It is implemented in apps/app_queue.c - * - * @author srt - * @version $Id: QueueEntryEvent.java 1360 2009-09-04 01:08:57Z srt $ - * @see org.asteriskjava.manager.action.QueueStatusAction - */ -public class QueueEntryEvent extends ResponseEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = 1L; - private String queue; - private Integer position; - private String uniqueId; - private String channel; - private String callerId; - private Long wait; - - /** - * @param source - */ - public QueueEntryEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the queue that contains this entry. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue that contains this entry. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the position of this entry in the queue. - */ - public Integer getPosition() - { - return position; - } - - /** - * Sets the position of this entry in the queue. - */ - public void setPosition(Integer position) - { - this.position = position; - } - - /** - * Returns the name of the channel of this entry. - */ - public String getChannel() - { - return channel; - } - - /** - * Returns the unique id of the channel of this entry. - *

- * Available since Asterisk 1.6. - * - * @return the unique id of the channel of this entry. - * @since 1.0.0 - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Sets the name of the channel of this entry. - * - * @param channel the name of the channel of this entry. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the the Caller*ID number of this entry. - * - * @return the the Caller*ID number of this entry. - */ - public String getCallerId() - { - return callerId; - } - - /** - * Sets the the Caller*ID number of this entry. - * - * @param callerId the the Caller*ID number of this entry. - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - /** - * Returns the number of seconds this entry has spent in the queue. - */ - public Long getWait() - { - return wait; - } - - /** - * Sets the number of seconds this entry has spent in the queue. - */ - public void setWait(Long wait) - { - this.wait = wait; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueEvent.java deleted file mode 100644 index 862c6ca1a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueEvent.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class providing common properties for JoinEvent and LeaveEvent. - * - * @author srt - * @version $Id$ - */ -public abstract class QueueEvent extends ManagerEvent -{ - /** - * Serializable version identifier - */ - static final long serialVersionUID = -8554382298783676181L; - - private String uniqueId; - private String channel; - private String queue; - private Integer count; - - /** - * @param source - */ - public QueueEvent(Object source) - { - super(source); - } - - /** - * Returns the unique id of the channel that joines or leaves the queue.

- * This property is only available since Asterisk 1.4. Up to Asterisk 1.2 - * this method always returns null.

- * See Asterisk issues 6458 and 7002. - * - * @return the unique id of the channel that joines or leaves the queue or - * null if not supported by your Asterisk server. - * @since 0.3 - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel that joines or leaves the queue. - * - * @param uniqueId the unique id of the channel that joines or leaves the queue. - * @since 0.3 - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the name of the channel that joines or leaves the queue. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel that joines or leaves the queue. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the number of elements in the queue, i.e. the number of calls waiting to be answered - * by an agent. - */ - public Integer getCount() - { - return count; - } - - /** - * Sets the number of elements in the queue. - */ - public void setCount(Integer count) - { - this.count = count; - } - - /** - * Returns the name of the queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue. - */ - public void setQueue(String queue) - { - this.queue = queue; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberAddedEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberAddedEvent.java deleted file mode 100644 index 0dca02434..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberAddedEvent.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueMemberAddedEvent is triggered when a queue member is added to a queue.

- * It is implemented in apps/app_queue.c.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class QueueMemberAddedEvent extends AbstractQueueMemberEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 2108033737226142194L; - - private String membership; - private Integer penalty; - private Integer callsTaken; - private Long lastCall; - private Integer status; - private Boolean paused; - - private String stateinterface; - private String _interface; - private Boolean ringinuse; - - public QueueMemberAddedEvent(Object source) - { - super(source); - } - - /** - * Returns if the added member is a dynamic or static queue member. - * - * @return "dynamic" if the added member is a dynamic queue member, "static" - * if the added member is a static queue member. - */ - public String getMembership() - { - return membership; - } - - /** - * Sets if the added member is a dynamic or static queue member. - * - * @param membership "dynamic" if the added member is a dynamic queue - * member, "static" if the added member is a static queue member. - */ - public void setMembership(String membership) - { - this.membership = membership; - } - - /** - * Returns the penalty for the added member. When calls are distributed - * members with higher penalties are considered last. - * - * @return the penalty for the added member. - */ - public Integer getPenalty() - { - return penalty; - } - - /** - * Sets the penalty for this member. - * - * @param penalty the penalty for this member. - */ - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } - - /** - * Returns the number of calls answered by the member. - * - * @return the number of calls answered by the member. - */ - public Integer getCallsTaken() - { - return callsTaken; - } - - /** - * Sets the number of calls answered by the added member. - * - * @param callsTaken the number of calls answered by the added member. - */ - public void setCallsTaken(Integer callsTaken) - { - this.callsTaken = callsTaken; - } - - /** - * Returns the time the last successful call answered by the added member - * was hungup. - * - * @return the time (in seconds since 01/01/1970) the last successful call - * answered by the added member was hungup. - */ - public Long getLastCall() - { - return lastCall; - } - - /** - * Sets the time the last successful call answered by this member was - * hungup. - * - * @param lastCall the time (in seconds since 01/01/1970) the last - * successful call answered by the added member was hungup. - */ - public void setLastCall(Long lastCall) - { - this.lastCall = lastCall; - } - - /** - * Returns the status of this queue member.

- * Valid status codes are: - *

- *
AST_DEVICE_UNKNOWN (0)
- *
Queue member is available
- *
AST_DEVICE_NOT_INUSE (1)
- *
?
- *
AST_DEVICE_INUSE (2)
- *
?
- *
AST_DEVICE_BUSY (3)
- *
?
- *
AST_DEVICE_INVALID (4)
- *
?
- *
AST_DEVICE_UNAVAILABLE (5)
- *
?
- *
- * - * @return the status of this queue member. - */ - public Integer getStatus() - { - return status; - } - - /** - * Sets the status of this queue member. - * - * @param status the status of this queue member - */ - public void setStatus(Integer status) - { - this.status = status; - } - - /** - * Returns if this queue member is paused (not accepting calls).

- * - * @return Boolean.TRUE if this member has been paused or - * Boolean.FALSE if not. - */ - public Boolean getPaused() - { - return paused; - } - - /** - * Sets if this member is paused. - * - * @param paused Boolean.TRUE if this member has been paused - * or Boolean.FALSE if not. - */ - public void setPaused(Boolean paused) - { - this.paused = paused; - } - - public String getStateinterface() - { - return stateinterface; - } - - public void setStateinterface(String stateinterface) - { - this.stateinterface = stateinterface; - } - - public String getInterface() - { - return _interface; - } - - public void setInterface(String _interface) - { - this._interface = _interface; - } - - public Boolean getRinginuse() - { - return ringinuse; - } - - public void setRinginuse(Boolean ringinuse) - { - this.ringinuse = ringinuse; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberEvent.java deleted file mode 100644 index a5ade6482..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberEvent.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueMemberEvent is triggered in response to a QueueStatusAction and - * contains information about a member of a queue. - *

- * It is implemented in apps/app_queue.c - * - * @see org.asteriskjava.manager.action.QueueStatusAction - * @author srt - * @version $Id$ - */ -public class QueueMemberEvent extends ResponseEvent -{ - public static final int AST_DEVICE_UNKNOWN = 0; - - /** - * Queue member is available. - */ - public static final int AST_DEVICE_NOT_INUSE = 1; - public static final int AST_DEVICE_INUSE = 2; - public static final int AST_DEVICE_BUSY = 3; - public static final int AST_DEVICE_INVALID = 4; - public static final int AST_DEVICE_UNAVAILABLE = 5; - public static final int AST_DEVICE_RINGING = 6; - public static final int AST_DEVICE_RINGINUSE = 7; - public static final int AST_DEVICE_ONHOLD = 8; - - public static final String MEMBERSHIP_STATIC = "static"; - public static final String MEMBERSHIP_DYNAMIC = "dynamic"; - - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - private String queue; - private String location; - private String membership; - private String name; - private Integer penalty; - private Integer callsTaken; - private Long lastCall; - private Integer status; - private Boolean paused; - private String stateinterface; - private Integer incall; - private String pausedreason; - - - - /** - * @param source - */ - public QueueMemberEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the queue. - * - * @return the name of the queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue. - * - * @param queue the name of the queue. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the name of the member's interface. - *

- * E.g. the channel name or agent group (for example "Agent/@1"). - * - * @return the name of the member's interface. - */ - public String getLocation() - { - return location; - } - - /** - * Sets the name of the member's interface. - * - * @param location the name of the member's interface. - */ - public void setLocation(String location) - { - this.location = location; - } - - /** - * Returns if this member has been dynamically added by the QueueAdd command - * (in the dialplan or via the Manager API) or if this member is has been - * statically defined in queues.conf. - * - * @return "dynamic" if the added member is a dynamic queue member, "static" - * if the added member is a static queue member. - */ - public String getMembership() - { - return membership; - } - - /** - * Convenience method that checks whether this member has been statically - * defined in queues.conf. - * - * @return true if this member has been statically defined in - * queues.conf, false otherwise. - * @since 0.3 - */ - public boolean isStatic() - { - return MEMBERSHIP_STATIC.equals(membership); - } - - /** - * Convenience method that checks whether this member has been dynamically - * added by the QueueAdd command. - * - * @return true if this member has been dynamically added by - * the QueueAdd command, false otherwise. - * @since 0.3 - */ - public boolean isDynamic() - { - return MEMBERSHIP_DYNAMIC.equals(membership); - } - - /** - * Sets if this member has been dynamically or statically added. - * - * @param membership "dynamic" if the added member is a dynamic queue - * member, "static" if the added member is a static queue member. - */ - public void setMembership(String membership) - { - this.membership = membership; - } - - /** - * Returns the penalty for the added member. When calls are distributed - * members with higher penalties are considered last. - * - * @return the penalty for the added member. - */ - public Integer getPenalty() - { - return penalty; - } - - /** - * Sets the penalty for this member. - * - * @param penalty the penalty for this member. - */ - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } - - /** - * Returns the number of calls answered by the member. - * - * @return the number of calls answered by the member. - */ - public Integer getCallsTaken() - { - return callsTaken; - } - - /** - * Sets the number of calls answered by the added member. - * - * @param callsTaken the number of calls answered by the added member. - */ - public void setCallsTaken(Integer callsTaken) - { - this.callsTaken = callsTaken; - } - - /** - * Returns the time the last successful call answered by the added member - * was hungup. - * - * @return the time (in seconds since 01/01/1970) the last successful call - * answered by the added member was hungup. - */ - public Long getLastCall() - { - return lastCall; - } - - /** - * Sets the time the last successful call answered by this member was - * hungup. - * - * @param lastCall the time (in seconds since 01/01/1970) the last - * successful call answered by the added member was hungup. - */ - public void setLastCall(Long lastCall) - { - this.lastCall = lastCall; - } - - /** - * Returns the status of this queue member. - *

- * Available since Asterisk 1.2 - *

- * Valid status codes are: - *

- *
AST_DEVICE_UNKNOWN (0)
- *
Device valid but unknown channel state
- *
AST_DEVICE_NOT_INUSE (1)
- *
Device is not used
- *
AST_DEVICE_INUSE (2)
- *
Device is in use
- *
AST_DEVICE_BUSY (3)
- *
Device is Busy
- *
AST_DEVICE_INVALID (4)
- *
Device is invalid
- *
AST_DEVICE_UNAVAILABLE (5)
- *
Device is unavaiable
- *
AST_DEVICE_RINGING (6)
- *
Device is ringing
- *
AST_DEVICE_RINGINUSE (7)
- *
Device is ringing and in use
- *
AST_DEVICE_ONHOLD (8)
- *
Device is on hold
- - *
- * - * @return the status of this queue member or null if this - * attribute is not supported by your version of Asterisk. - * @since 0.2 - */ - public Integer getStatus() - { - return status; - } - - /** - * Sets the status of this queue member. - * - * @param status the status of this queue member - * @since 0.2 - */ - public void setStatus(Integer status) - { - this.status = status; - } - - /** - * Is this queue member paused (not accepting calls)? - *

- * Available since Asterisk 1.2. - * - * @return Boolean.TRUE if this member has been paused, - * Boolean.FALSE if not or null if - * pausing is not supported by your version of Asterisk. - * @since 0.2 - */ - public Boolean getPaused() - { - return paused; - } - - /** - * Sets if this member has been paused. - * - * @since 0.2 - */ - public void setPaused(Boolean paused) - { - this.paused = paused; - } - - /** - * Returns the name of the member. - * - * @return the name of the member supplied for logging when the member is added - * @since 1.0.0 - */ - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - /** - * Returns the name of the member. - * - * @return the name of the member supplied for logging when the member is added - * @deprecated since 1.0.0. Use {@link #getName()} instead. - */ - @Deprecated public String getMemberName() - { - return name; - } - - // Renamed to "name" in Asterisk 1.6 - public void setMemberName(String memberName) - { - this.name = memberName; - } - - /** - * @return Name of the interface where device state is taken from. - */ - public String getStateinterface() - { - return stateinterface; - } - - public void setStateinterface(String stateinterface) - { - this.stateinterface = stateinterface; - } - - /** - * @return 1 if is incall 0 if not - */ - public Integer getIncall() - { - return incall; - } - - public void setIncall(Integer incall) - { - this.incall = incall; - } - - - public String getPausedreason() - { - return pausedreason; - } - - public void setPausedreason(String pausedreason) - { - this.pausedreason = pausedreason; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberPauseEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberPauseEvent.java deleted file mode 100644 index 3b44bd2e1..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberPauseEvent.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.asteriskjava.manager.event; - -public class QueueMemberPauseEvent extends QueueMemberPausedEvent -{ - private static final long serialVersionUID = 58564514209197321L; - - // Logger logger = LogManager.getLogger(); - String membership; - Long lastcall; - Integer callsTaken; - Integer penalty; - Integer status; - Boolean ringinuse; - String iface; - String stateInterface; - Integer incall; - String pausedreason; - - public QueueMemberPauseEvent(Object source) - { - super(source); - // TODO Auto-generated constructor stub - } - - /** - * @return the membership - */ - public String getMembership() - { - return membership; - } - - /** - * @param membership the membership to set - */ - public void setMembership(String membership) - { - this.membership = membership; - } - - /** - * @return the lastcall - */ - public Long getLastcall() - { - return lastcall; - } - - /** - * @param lastcall the lastcall to set - */ - public void setLastcall(Long lastcall) - { - this.lastcall = lastcall; - } - - /** - * @return the callsTaken - */ - public Integer getCallsTaken() - { - return callsTaken; - } - - /** - * @param callsTaken the callsTaken to set - */ - public void setCallsTaken(Integer callsTaken) - { - this.callsTaken = callsTaken; - } - - /** - * @return the penalty - */ - public Integer getPenalty() - { - return penalty; - } - - /** - * @param penalty the penalty to set - */ - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } - - /** - * @return the status - */ - public Integer getStatus() - { - return status; - } - - /** - * @param status the status to set - */ - public void setStatus(Integer status) - { - this.status = status; - } - - /** - * @return the ringinuse - */ - public Boolean getRinginuse() - { - return ringinuse; - } - - /** - * @param ringinuse the ringinuse to set - */ - public void setRinginuse(Boolean ringinuse) - { - this.ringinuse = ringinuse; - } - - /** - * @return the iface - */ - public String getInterface() - { - return iface; - } - - /** - * @param iface the iface to set - */ - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * @return the stateInterface - */ - public String getStateInterface() - { - return stateInterface; - } - - /** - * @param stateInterface the stateInterface to set - */ - public void setStateInterface(String stateInterface) - { - this.stateInterface = stateInterface; - } - - /** - * @return get Incall - */ - public Integer getIncall() - { - return incall; - } - - /** - * @param setIncall the incall to set - */ - public void setIncall(Integer incall) - { - this.incall = incall; - } - - public String getPausedreason() - { - return pausedreason; - } - - public void setPausedreason(String pausedreason) - { - this.pausedreason = pausedreason; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberPausedEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberPausedEvent.java deleted file mode 100644 index 66b0e5ec3..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberPausedEvent.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueMemberPausedEvent is triggered when a queue member is paused or - * unpaused.

- * It is implemented in apps/app_queue.c.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class QueueMemberPausedEvent extends AbstractQueueMemberEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - private Boolean paused; - - /** - * The reason why the queue member has been paused (optional). - */ - private String reason; - - public QueueMemberPausedEvent(Object source) - { - super(source); - } - - /** - * Returns if this queue member is paused (not accepting calls).

- * - * @return Boolean.TRUE if this member has been paused or - * Boolean.FALSE if not. - */ - public Boolean getPaused() - { - return paused; - } - - /** - * Sets if this member is paused. - * - * @param paused Boolean.TRUE if this member has been paused - * or Boolean.FALSE if not. - */ - public void setPaused(Boolean paused) - { - this.paused = paused; - } - - /** - * Returns the reason why the queue member has been paused. Will be set to - * Auto-Pause for the case that the queue member has been - * paused for not answering the call. - * - * @return the reason specified for the pause. - */ - public String getReason() - { - return reason; - } - - /** - * Sets the reason why the queue member has been paused. - * - * @param reason the reason why the queue member has been paused. - */ - public void setReason(String reason) - { - this.reason = reason; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberPenaltyEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberPenaltyEvent.java deleted file mode 100644 index d16723dca..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberPenaltyEvent.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueMemberPenaltyEvent is triggered when a queue member is assigned a - * new penalty.

- * It is implemented in apps/app_queue.c.

- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class QueueMemberPenaltyEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - private String queue; - private String location; - private Integer penalty; - - /** - * Creates a new instance. - * - * @param source - */ - public QueueMemberPenaltyEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the queue. - * - * @return the name of the queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue. - * - * @param queue the name of the queue. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the name of the member's interface.

- * E.g. the channel name or agent group. - * - * @return the name of the member's interface. - */ - public String getLocation() - { - return location; - } - - /** - * Sets the name of the member's interface. - * - * @param member the name of the member's interface. - */ - public void setLocation(String member) - { - this.location = member; - } - - /** - * Returns the new penalty. - * - * @return the new penalty. - */ - public Integer getPenalty() - { - return penalty; - } - - /** - * Sets the new penalty. - * - * @param penalty the new penalty. - */ - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberRemovedEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberRemovedEvent.java deleted file mode 100644 index cb3b90728..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberRemovedEvent.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueMemberRemovedEvent is triggered when a queue member is removed from a - * queue.

- * It is implemented in apps/app_queue.c.

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class QueueMemberRemovedEvent extends AbstractQueueMemberEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 2108033737226142194L; - - Boolean paused; - Integer penalty; - String stateinterface; - String membership; - String _interface; - Long callstaken; - Boolean ringinuse; - Long lastcall; - Integer status; - - - public QueueMemberRemovedEvent(Object source) - { - super(source); - } - - - public Boolean getPaused() - { - return paused; - } - - - public void setPaused(Boolean paused) - { - this.paused = paused; - } - - - public Integer getPenalty() - { - return penalty; - } - - - public void setPenalty(Integer penalty) - { - this.penalty = penalty; - } - - - public String getStateinterface() - { - return stateinterface; - } - - - public void setStateinterface(String stateinterface) - { - this.stateinterface = stateinterface; - } - - - public String getMembership() - { - return membership; - } - - - public void setMembership(String membership) - { - this.membership = membership; - } - - - public String getInterface() - { - return _interface; - } - - - public void setInterface(String _interface) - { - this._interface = _interface; - } - - - public Long getCallstaken() - { - return callstaken; - } - - - public void setCallstaken(Long callstaken) - { - this.callstaken = callstaken; - } - - - public Boolean getRinginuse() - { - return ringinuse; - } - - - public void setRinginuse(Boolean ringinuse) - { - this.ringinuse = ringinuse; - } - - - public Long getLastcall() - { - return lastcall; - } - - - public void setLastcall(Long lastcall) - { - this.lastcall = lastcall; - } - - - public Integer getStatus() - { - return status; - } - - - public void setStatus(Integer status) - { - this.status = status; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueMemberStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueMemberStatusEvent.java deleted file mode 100644 index 4619cd2b6..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueMemberStatusEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueMemberStatusEvent shows the status of a QueueMemberEvent - * - * @author Asteria Solutions Group, Inc. http://www.asteriasgi.com/ - * @version $Id$ - */ -public class QueueMemberStatusEvent extends QueueMemberEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -2293926744791895763L; - - private String ringinuse; - private String iface; - private Integer incall; - - /** - * @param source - */ - public QueueMemberStatusEvent(Object source) - { - super(source); - } - - public String getInterface() - { - return iface; - } - - public void setInterface(String iface) - { - this.iface = iface; - } - - /** - * @return the ringinuse - */ - public String getRinginuse() - { - return ringinuse; - } - - /** - * @param ringinuse the ringinuse to set - */ - public void setRinginuse(String ringinuse) - { - this.ringinuse = ringinuse; - } - - public Integer getIncall() - { - return incall; - } - - public void setIncall(Integer incall) - { - this.incall = incall; - } - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueParamsEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueParamsEvent.java deleted file mode 100644 index 504dc3e83..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueParamsEvent.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueParamsEvent is triggered in response to a QueueStatusAction and contains the parameters of - * a queue.

- * It is implemented in apps/app_queue.c - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.QueueStatusAction - */ -public class QueueParamsEvent extends ResponseEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = -170511596914604717L; - private String queue; - private Integer max; - private String strategy; - private Integer calls; - private Integer holdTime; - private Integer talkTime; - private Integer completed; - private Integer abandoned; - private Integer serviceLevel; - private Double serviceLevelPerf; - private Double serviceLevelPerf2; - private Integer weight; - - public QueueParamsEvent(Object source) - { - super(source); - } - - - /** - * Returns the name of the queue. - * - * @return the name of the queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of the queue. - * - * @param queue the name of the queue. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the maximum number of people waiting in the queue or 0 for unlimited.

- * This corresponds to the maxlen setting in queues.conf. - * - * @return the maximum number of people waiting in the queue or 0 for unlimited. - */ - public Integer getMax() - { - return max; - } - - /** - * Sets the maximum number of people waiting in the queue. - * - * @param max the maximum number of people waiting in the queue or 0 for unlimited. - */ - public void setMax(Integer max) - { - this.max = max; - } - - /** - * Returns the strategy used for this queue.

- * Possible values are:

- *

    - *
  • ringall
  • - *
  • roundrobin
  • - *
  • leastrecent
  • - *
  • fewestcalls
  • - *
  • random
  • - *
  • rrmemory
  • - *
- * Available since Asterisk 1.6 - * - * @return the strategy used for this queue. - * @since 1.0.0 - */ - public String getStrategy() - { - return strategy; - } - - /** - * Sets the strategy used for this queue. - * - * @param strategy the strategy used for this queue. - * @since 1.0.0 - */ - public void setStrategy(String strategy) - { - this.strategy = strategy; - } - - /** - * Returns the number of calls currently waiting in the queue. - * - * @return the number of calls currently waiting in the queue. - */ - public Integer getCalls() - { - return calls; - } - - /** - * Sets the number of calls currently waiting in the queue. - * - * @param calls the number of calls currently waiting in the queue. - */ - public void setCalls(Integer calls) - { - this.calls = calls; - } - - /** - * Returns the current average holdtime for this queue (in seconds). - * - * @return the current average holdtime for this queue (in seconds). - */ - public Integer getHoldTime() - { - return holdTime; - } - - /** - * Sets the current average holdtime for this queue. - * - * @param holdTime the current average holdtime for this queue (in seconds). - */ - public void setHoldTime(Integer holdTime) - { - this.holdTime = holdTime; - } - - /** - * Returns the current avarage talk time for this queue based on an exponential average. - * - * @return the current avarage talk time for this queue. - * @since 1.0.0 - */ - public Integer getTalkTime() - { - return talkTime; - } - - /** - * Sets the current avarage talk time for this queue based on an exponential average. - * - * @param talkTime the current avarage talk time for this queue. - * @since 1.0.0 - */ - public void setTalkTime(Integer talkTime) - { - this.talkTime = talkTime; - } - - /** - * Returns the number of completed calls. - * - * @return the number of completed calls. - */ - public Integer getCompleted() - { - return completed; - } - - /** - * Sets the number of completed calls. - * - * @param complete the number of completed calls. - */ - public void setCompleted(Integer complete) - { - this.completed = complete; - } - - /** - * Returns the number of abandoned calls. - * - * @return the number of abandoned calls. - */ - public Integer getAbandoned() - { - return abandoned; - } - - /** - * Sets the number of abandoned calls. - * - * @param abandoned the number of abandoned calls. - */ - public void setAbandoned(Integer abandoned) - { - this.abandoned = abandoned; - } - - /** - * Returns the service level (in seconds) as defined by the servicelevel setting - * in queues.conf. - * - * @return the service level (in seconds). - */ - public Integer getServiceLevel() - { - return serviceLevel; - } - - /** - * Sets the service level. - * - * @param serviceLevel the service level (in seconds). - */ - public void setServiceLevel(Integer serviceLevel) - { - this.serviceLevel = serviceLevel; - } - - /** - * Returns the ratio of calls answered within the specified service level per total completed - * calls (in percent). - * - * @return the ratio of calls answered within the specified service level per total completed - * calls (in percent). - */ - public Double getServiceLevelPerf() - { - return serviceLevelPerf; - } - - /** - * Sets the ratio of calls answered within the specified service level per total completed - * calls. - * - * @param serviceLevelPerf the ratio of calls answered within the specified service level per total completed - * calls (in percent). - */ - public void setServiceLevelPerf(Double serviceLevelPerf) - { - this.serviceLevelPerf = serviceLevelPerf; - } - - /** - * Returns the weight of this queue.

- * A queue can be assigned a 'weight' to ensure calls waiting in a - * higher priority queue will deliver its calls first. Only delays - * the lower weight queue's call if the member is also in the - * higher weight queue.

- * Available since Asterisk 1.2 - * - * @return the weight of this queue or null if not - * supported by your version of Asterisk - * @since 0.2 - */ - public Integer getWeight() - { - return weight; - } - - /** - * Sets the weight of this queue. - * - * @param weight the weight of this queue - * @since 0.2 - */ - public void setWeight(Integer weight) - { - this.weight = weight; - } - - public Double getServiceLevelPerf2() { - return serviceLevelPerf2; - } - - public void setServiceLevelPerf2(Double serviceLevelPerf2) { - this.serviceLevelPerf2 = serviceLevelPerf2; - } - - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueStatusCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueStatusCompleteEvent.java deleted file mode 100644 index 5783bc7a1..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueStatusCompleteEvent.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A QueueStatusCompleteEvent is triggered after the state of all queues has been reported in response - * to a QueueStatusAction.

- * Since Asterisk 1.2 - * - * @see org.asteriskjava.manager.action.QueueStatusAction - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class QueueStatusCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -1177773673509373297L; - - private Integer listItems; - private String eventList; - - /** - * @param source - */ - public QueueStatusCompleteEvent(Object source) - { - super(source); - } - - public Integer getListItems() - { - return listItems; - } - - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } - - public String getEventList() - { - return eventList; - } - - public void setEventList(String eventList) - { - this.eventList = eventList; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueSummaryCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueSummaryCompleteEvent.java deleted file mode 100644 index ed1dd6843..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueSummaryCompleteEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.asteriskjava.manager.event; - -import org.asteriskjava.manager.action.QueueSummaryAction; - -/** - * A QueueSummaryCompleteEvent is triggered after the summary for all requested - * queues has been reported in response to a QueueSummaryAction. - * - * @see QueueSummaryAction - * @see QueueSummaryEvent - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class QueueSummaryCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -5044247858568827143L; - - public QueueSummaryCompleteEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/QueueSummaryEvent.java b/src/main/java/org/asteriskjava/manager/event/QueueSummaryEvent.java deleted file mode 100644 index dad4cab15..000000000 --- a/src/main/java/org/asteriskjava/manager/event/QueueSummaryEvent.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.asteriskjava.manager.event; - -import org.asteriskjava.manager.action.QueueSummaryAction; - -/** - * A QueueSummaryEvent is triggered in response to a QueueSummaryAction and - * contains a summary of the current state of a queue. - *
- * Available in Asterisk post-1.4. - *
- * It is implemented in apps/app_queue.c - * - * @author srt - * @version $Id$ - * @see QueueSummaryCompleteEvent - * @see QueueSummaryAction - * @since 0.3 - */ -public class QueueSummaryEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 2596498558463681457L; - private String queue; - private Integer loggedIn; - private Integer available; - private Integer callers; - private Integer holdTime; - private Integer talkTime; - private Integer longestHoldTime; - - public QueueSummaryEvent(Object source) - { - super(source); - } - - /** - * Returns the name of queue. - * - * @return the name of queue. - */ - public String getQueue() - { - return queue; - } - - /** - * Sets the name of queue. - * - * @param queue the name of queue. - */ - public void setQueue(String queue) - { - this.queue = queue; - } - - /** - * Returns the number of members logged in. - * - * @return the number of members logged in. - */ - public Integer getLoggedIn() - { - return loggedIn; - } - - /** - * Sets the number of members logged in. - * - * @param loggedIn the number of members logged in. - */ - public void setLoggedIn(Integer loggedIn) - { - this.loggedIn = loggedIn; - } - - /** - * Returns the number of members logged in and not in a call. - *
- * This is the number of queue members currently available for calls. - * - * @return the number of members logged in and not in a call. - */ - public Integer getAvailable() - { - return available; - } - - /** - * Sets the number of members logged in and not in a call. - * - * @param available the number of members logged in and not in a call. - */ - public void setAvailable(Integer available) - { - this.available = available; - } - - /** - * Returns the number of callers currently waiting in the queue. - * - * @return the number of callers currently waiting in the queue. - */ - public Integer getCallers() - { - return callers; - } - - /** - * Sets the number of callers currently waiting in the queue. - * - * @param callers the number of callers currently waiting in the queue. - */ - public void setCallers(Integer callers) - { - this.callers = callers; - } - - /** - * Returns the current avarage hold time for this queue based on an exponential average. - * - * @return the current avarage hold time for this queue. - */ - public Integer getHoldTime() - { - return holdTime; - } - - /** - * Sets the current avarage hold time for this queue based on an exponential average. - * - * @param holdTime the current avarage hold time for this queue. - */ - public void setHoldTime(Integer holdTime) - { - this.holdTime = holdTime; - } - - /** - * Returns the current avarage talk time for this queue based on an exponential average. - * - * @return the current avarage talk time for this queue. - * @since 1.0.0 - */ - public Integer getTalkTime() - { - return talkTime; - } - - /** - * Sets the current avarage talk time for this queue based on an exponential average. - * - * @param talkTime the current avarage talk time for this queue. - * @since 1.0.0 - */ - public void setTalkTime(Integer talkTime) - { - this.talkTime = talkTime; - } - - /** - * Returns the longest hold time of the a queue entry currently in the queue. - * - * @return the longest hold time of the a queue entry currently in the queue. - * @since 1.0.0 - */ - public Integer getLongestHoldTime() - { - return longestHoldTime; - } - - /** - * Sets the longest hold time of the a queue entry currently in the queue. - * - * @param longestHoldTime the longest hold time of the a queue entry currently in the queue. - * @since 1.0.0 - */ - public void setLongestHoldTime(Integer longestHoldTime) - { - this.longestHoldTime = longestHoldTime; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ReceiveFaxEvent.java b/src/main/java/org/asteriskjava/manager/event/ReceiveFaxEvent.java deleted file mode 100644 index 5dfb41444..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ReceiveFaxEvent.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * A ReceiveFaxEvent is an event of Digium's Fax For Asterisk add-on. - */ -public class ReceiveFaxEvent extends ManagerEvent -{ - private static final long serialVersionUID = 0L; - private String channel; - private String callerId; - private String remoteStationId; - private String localStationId; - private Integer pagesTransferred; - private String resolution; - private Integer transferRate; - private String fileName; - - public ReceiveFaxEvent(Object source) - { - super(source); - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getCallerId() - { - return callerId; - } - - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - public String getRemoteStationId() - { - return remoteStationId; - } - - public void setRemoteStationId(String remoteStationId) - { - this.remoteStationId = remoteStationId; - } - - public String getLocalStationId() - { - return localStationId; - } - - public void setLocalStationId(String localStationId) - { - this.localStationId = localStationId; - } - - public Integer getPagesTransferred() - { - return pagesTransferred; - } - - public void setPagesTransferred(Integer pagesTransferred) - { - this.pagesTransferred = pagesTransferred; - } - - public String getResolution() - { - return resolution; - } - - public void setResolution(String resolution) - { - this.resolution = resolution; - } - - public Integer getTransferRate() - { - return transferRate; - } - - public void setTransferRate(Integer transferRate) - { - this.transferRate = transferRate; - } - - public String getFileName() - { - return fileName; - } - - public void setFileName(String fileName) - { - this.fileName = fileName; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/RegistrationsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/RegistrationsCompleteEvent.java deleted file mode 100644 index f13f2d951..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RegistrationsCompleteEvent.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A RegistrationsCompleteEvent is triggered after the details of all SIP - * registrations has been reported in response to an SipShowRegistryAction.

- * Available since Asterisk 1.6 - * - * @author Laureano - * @version $Id$ - * @see RegistryEntryEvent - * @see org.asteriskjava.manager.action.SipShowRegistryAction - * @since 1.0.0 - */ -public class RegistrationsCompleteEvent extends ResponseEvent -{ - - /** - * - */ - private static final long serialVersionUID = 6269829662009989518L; - private Integer listItems; - private String eventList; - - /** - * Creates a new RegistrationsCompleteEvent. - */ - public RegistrationsCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns the number of SIP registrations that have been reported. - * - * @return the number of SIP registrations that have been reported. - */ - public Integer getListItems() - { - return listItems; - } - - /** - * Sets the number of SIP registrations that have been reported. - * - * @param listItems the number of SIP registrations that have been reported. - */ - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } - - /** - * Returns always "Complete". - * - * @return always returns "Complete" confirming that all RegistryEntry events have been sent. - */ - public String getEventList() - { - return eventList; - } - - - public void setEventList(String eventList) - { - this.eventList = eventList; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/RegistryEntryEvent.java b/src/main/java/org/asteriskjava/manager/event/RegistryEntryEvent.java deleted file mode 100644 index 94d956f58..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RegistryEntryEvent.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2004-2008 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A RegistryEntry is triggered in response to a SipShowRegistryAction and contains - * information about a SIP registration.

- * It is implemented in channels/chan_sip.c - * - * @author Laureano - * @version $Id$ - * @since 1.0.0 - */ -public class RegistryEntryEvent extends ResponseEvent -{ - /** - * - */ - private static final long serialVersionUID = -7158046719541054868L; - private Integer port; - private String username; - private String state; - private Integer refresh; - private String host; - private Long registrationTime; - - /** - * Creates a new instance. - * - * @param source - */ - public RegistryEntryEvent(Object source) - { - super(source); - } - - /** - * Returns the epoch since the last registration. - * - * @return epoch since the last registration. - */ - public Long getRegistrationTime() - { - return registrationTime; - } - - /** - * Sets the epoch (unix Timestamp) of the last registration. - * Will be casted to Long. - * - * @param registrationTime the epoch of the last registration. - */ - public void setRegistrationTime(String registrationTime) - { - this.registrationTime = Long.valueOf(registrationTime); - } - - /** - * Returns the port number used for the registration. - * - * @return the port number. - */ - public Integer getPort() - { - return port; - } - - /** - * Sets the port number used for the registration. - * - * @param port the port number. - */ - public void setPort(Integer port) - { - this.port = port; - } - - /** - * Returns the username used for the registration. - * - * @return the username. - */ - public String getUsername() - { - return username; - } - - /** - * Sets the username used for the registration. - * - * @param username the username. - */ - public void setUsername(String username) - { - this.username = username; - } - - /** - * Returns the IP address or hostname used for the registration. - * - * @return the IP address or the hostname. - */ - public String getHost() - { - return host; - } - - /** - * Set the IP address or hostname used for the registration. - * - * @param host IP address or hostname. - */ - public void setHost(String host) - { - this.host = host; - } - - /** - * Returns the value of state. - * - * @return the value of state - */ - public String getState() - { - return state; - } - - /** - * Set the value of state. - * - * @param state new value of state - */ - public void setState(String state) - { - this.state = state; - } - - /** - * Returns the value of refresh. - * - * @return the value of refresh. - */ - public Integer getRefresh() - { - return refresh; - } - - /** - * Set the value of refresh. - * - * @param refresh new value of refresh - */ - public void setRefresh(Integer refresh) - { - this.refresh = refresh; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/RegistryEvent.java b/src/main/java/org/asteriskjava/manager/event/RegistryEvent.java deleted file mode 100644 index 2f5e86063..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RegistryEvent.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A RegistryEvent is triggered when this asterisk server attempts to register - * as a client at another SIP or IAX server.

- * This event is implemented in channels/chan_iax2.c and - * channels/chan_sip.c - * - * @author srt - * @version $Id$ - */ -public class RegistryEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - public static final String STATUS_REGISTERED = "Registered"; - public static final String STATUS_UNREGISTERED = "Registered"; - public static final String STATUS_REQUEST_SENT = "Request Sent"; - public static final String STATUS_AUTH_SENT = "Auth. Sent"; - public static final String STATUS_REJECTED = "Rejected"; - public static final String STATUS_TIMEOUT = "Timeout"; - public static final String STATUS_NO_AUTHENTICATION = "No Authentication"; - public static final String STATUS_UNREACHABLE = "Unreachable"; - - private String channelType; - private String domain; - private String username; - private String status; - private String cause; - - /** - * @param source - */ - public RegistryEvent(Object source) - { - super(source); - } - - /** - * Returns the type of channel that is registered, that is "IAX2" for an IAX2 - * channel or "SIP" for a SIP channel. - * - * @return the type of channel that is registered. - * @since 1.0.0 - */ - public String getChannelType() - { - return channelType; - } - - /** - * Sets the type of channel that is registered. - * - * @param channelType the type of channel that is registered. - * @since 1.0.0 - */ - public void setChannelType(String channelType) - { - this.channelType = channelType; - } - - /** - * Returns the type of channel that is registered, that is "IAX2" for an IAX2 - * channel or "SIP" for a SIP channel. - * - * @see #getChannelType() - * @since 0.3 - * @deprecated - */ - @Deprecated public String getChannelDriver() - { - return channelType; - } - - /** - * Sets the type of channel that is registered. - * - * @see #setChannelType(String) - * @since 0.3 - * @deprecated - */ - @Deprecated public void setChannelDriver(String channelDriver) - { - this.channelType = channelDriver; - } - - /** - * Returns the type of channel that is registered, that is "IAX2" for an IAX2 - * channel or "SIP" for a SIP channel. - * - * @see #getChannelType() - * @deprecated - */ - @Deprecated public String getChannel() - { - return channelType; - } - - /** - * Sets the type of channel that is registered. - * - * @see #setChannelType(String) - * @deprecated - */ - @Deprecated public void setChannel(String channel) - { - this.channelType = channel; - } - - /** - * Returns the domain or host name of the SIP or IAX2 server.

- * This is the host part used in the register lines in - * iax.conf and sip.conf. - * - * @return the domain or host name of the SIP or IAX2 server. - */ - public String getDomain() - { - return domain; - } - - /** - * Sets the domain or host name of the SIP or IAX2 server. - * - * @param domain the domain or host name of the SIP or IAX2 server. - */ - public void setDomain(String domain) - { - this.domain = domain; - } - - /** - * Returns the username used for registration.

- * SIP send the username in case of a registration timeout, IAX2 in case of - * a registration failure. Otherwise the username is null. - * - * @return the username used for registration. - */ - public String getUsername() - { - return username; - } - - /** - * Sets the username used for registration. - * - * @param username the username used for registration. - */ - public void setUsername(String username) - { - this.username = username; - } - - /** - * Sets the username used for registration. - * - * @see #setUsername(String) - * @deprecated Please do not use this method it is a workaround for Asterisk - * 1.0.x servers. See Asterisk bug 4916. - */ - @Deprecated public void setUser(String username) - { - this.username = username; - } - - /** - * Returns the registration state.

- * For sip this may be one of (not sure if all of these are exposed via the - * manager api, at least "Registered" and "Timeout" are used though) - *

    - *
  • Registered
  • - *
  • Unregistered
  • - *
  • Request Sent
  • - *
  • Auth. Sent
  • - *
  • Rejected
  • - *
  • Timeout
  • - *
  • No Authentication
  • - *
  • Unreachable
  • - *
- * IAX2 only uses - *
    - *
  • Rejected
  • - *
- * Successful IAX2 registrations do not use the this property at all. - * - * @return the registration state. - */ - public String getStatus() - { - return status; - } - - /** - * Sets the registration state. - * - * @param status the registration state. - */ - public void setStatus(String status) - { - this.status = status; - } - - /** - * Returns the cause of a rejected registration. - * - * @return the cause of a rejected registration or null if the cause is unknown. - * @since 0.2 - */ - public String getCause() - { - return cause; - } - - /** - * Sets the cause of a rejected registration. - * - * @param cause the cause of a rejected registration. - * @since 0.2 - */ - public void setCause(String cause) - { - this.cause = cause; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/ReloadEvent.java b/src/main/java/org/asteriskjava/manager/event/ReloadEvent.java deleted file mode 100644 index 087ece01f..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ReloadEvent.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ReloadEvent is triggerd when the reload console command is executed or the - * Asterisk server is started.

- * It is implemented in manager.c - * - * @author srt - * @version $Id$ - */ -public class ReloadEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 0L; - - public static final String MODULE_MANAGER = "Manager"; - public static final String MODULE_CDR = "CDR"; - public static final String MODULE_DNS_MGR = "DNSmgr"; - public static final String MODULE_RTP = "RTP"; - public static final String MODULE_ENUM = "ENUM"; - - public static final String STATUS_ENABLED = "Enabled"; - public static final String STATUS_DISABLED = "Disabled"; - - private String module; - private String status; - private String message; - - public ReloadEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the module that has been reloaded.

- * Available since Asterisk 1.6. - * - * @return the name of the module that has been reloaded. - * @since 1.0.0 - */ - public String getModule() - { - return module; - } - - /** - * Sets the name of the module that has been reloaded. - * - * @param module the name of the module that has been reloaded. - * @since 1.0.0 - */ - public void setModule(String module) - { - this.module = module; - } - - /** - * Returns the new status of the module.

- * Available since Asterisk 1.6. - * - * @return "Enabled" if the module is endabled, "Disabled" if it is disabled. - * @since 1.0.0 - * @see #STATUS_ENABLED - * @see #STATUS_DISABLED - * @see #isEnabled() - * @see #isDisabled() - */ - public String getStatus() - { - return status; - } - - /** - * Sets the new status of the module. - * - * @param status "Enabled" if the module is endabled, "Disabled" if it is disabled. - * @since 1.0.0 - */ - public void setStatus(String status) - { - this.status = status; - } - - public String getMessage() - { - return message; - } - - public void setMessage(String message) - { - this.message = message; - } - - /** - * Returns whether the module is now enabled.

- * Available since Asterisk 1.6. - * - * @return true the module is now enabled, false if it is disabled. - * For Asterisk versions up to 1.4 that do not support the "Status" property false is returned. - * @see #getStatus() - * @since 1.0.0 - */ - public boolean isEnabled() - { - return status != null && STATUS_ENABLED.equalsIgnoreCase(status); - } - - /** - * Returns whether the module is now disabled.

- * Available since Asterisk 1.6. - * - * @return true the module is now disabled, false if it is enabled. - * For Asterisk versions up to 1.4 that do not support the "Status" property false is returned. - * @see #getStatus() - * @since 1.0.0 - */ - public boolean isDisabled() - { - return status != null && STATUS_DISABLED.equalsIgnoreCase(status); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/RenameEvent.java b/src/main/java/org/asteriskjava/manager/event/RenameEvent.java deleted file mode 100644 index 9ea5c8cec..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RenameEvent.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A RenameEvent is triggered when the name of a channel is changed. - *

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - */ -public class RenameEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 3400165738000349767L; - - /** - * Old name of the channel before renaming occured. - */ - protected String channel; - - /** - * New name of the channel after renaming occured. - */ - protected String newname; - - /** - * New unique id. - */ - protected String newUniqueId; - - /** - * Unique id of the channel. - */ - protected String uniqueId; - - public RenameEvent(Object source) - { - super(source); - } - - /** - * Returns the new name of the channel. - * - * @return the new name of the channel. - */ - public final String getNewname() - { - return newname; - } - - /** - * Sets the new name of the channel. - * - * @param newname the new name of the channel. - */ - public final void setNewname(final String newname) - { - this.newname = newname; - } - - /** - * Returns the old name of the channel. - * - * @return the old name of the channel. - * @since 1.0.0 - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the old name of the channel.

- * The "Oldchannel" property has been renamed to "Channel" as of Asterisk 1.6. - * - * @param channel the old name of the channel. - * @since 1.0.0 - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the old name of the channel. - * - * @return the old name of the channel. - * @deprecated use {@link #getChannel} instead. - */ - @Deprecated public final String getOldname() - { - return channel; - } - - /** - * Sets the old name of the channel.

- * The "Oldchannel" property is used by Asterisk up to 1.4 and has been renamed to "Channel" - * as of Asterisk 1.6. - * - * @param oldname the old name of the channel. - */ - public final void setOldname(final String oldname) - { - this.channel = oldname; - } - - /** - * Returns the unique id of the channel. - * - * @return the unique id of the channel. - */ - public final String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of the channel. - * - * @param uniqueId the unique id of the channel. - */ - public final void setUniqueId(final String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the new unique id of the channel. - *

- * This property is only available on BRIstuffed Asterisk servers. - *

- * The purpose of this property is unclear as the unique id is supposed to - * never change. - * - * @return the new unique id of the channel. - * @since 0.3 - */ - public final String getNewUniqueId() - { - return newUniqueId; - } - - /** - * Sets the new unique id of the channel. - *

- * This property is only available on BRIstuffed Asterisk servers. - *

- * The purpose of this property is unclear as the unique id is supposed to - * never change. - * - * @param newUniqueId the new unique id of the channel. - * @since 0.3 - */ - public final void setNewUniqueId(final String newUniqueId) - { - this.newUniqueId = newUniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ResponseEvent.java b/src/main/java/org/asteriskjava/manager/event/ResponseEvent.java deleted file mode 100644 index f979e0d61..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ResponseEvent.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class for events triggered in response to a ManagerAction.

- * All ResponseEvents contain an additional action id property that links the - * event to the action that caused it. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ManagerAction - */ -public abstract class ResponseEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - private String actionId; - private String internalActionId; - - public ResponseEvent(Object source) - { - super(source); - } - - /** - * Returns the user provided action id of the ManagerAction that caused - * this event. If the application did not set an action id this method - * returns null. - * - * @return the action id of the ManagerAction that caused this event or - * null if none was set. - * @see org.asteriskjava.manager.action.ManagerAction#setActionId(String) - */ - public final String getActionId() - { - return actionId; - } - - /** - * Sets the action id of the ManagerAction that caused this event. - * - * @param actionId the action id of the ManagerAction that caused this - * event. - */ - public final void setActionId(String actionId) - { - this.actionId = actionId; - } - - /** - * Returns the internal action id of the ManagerAction that caused this - * event.

- * Warning: This method is internal to Asterisk-Java and should never be - * used in application code. - * - * @return the internal action id of the ManagerAction that caused this - * event. - * @since 0.2 - */ - public final String getInternalActionId() - { - return internalActionId; - } - - /** - * Sets the internal action id of the ManagerAction that caused this event. - * - * @param internalActionId the internal action id of the ManagerAction that - * caused this event. - * @since 0.2 - */ - public final void setInternalActionId(String internalActionId) - { - this.internalActionId = internalActionId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/RtcpReceivedEvent.java b/src/main/java/org/asteriskjava/manager/event/RtcpReceivedEvent.java deleted file mode 100644 index 1c50c2a98..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RtcpReceivedEvent.java +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.net.InetAddress; - -/** - * An RTCPReceivedEvent is triggered when Asterisk receives an RTCP message.

- * Available since Asterisk 1.6

- * It is implemented in main/rtp.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class RtcpReceivedEvent extends AbstractRtcpEvent -{ - private static final long serialVersionUID = 2L; - - /** - * Payload identifier for a sender report. - */ - public static final int PT_SENDER_REPORT = 200; - - /** - * Payload identifier for a receiver report. - */ - public static final int PT_RECEIVER_REPORT = 201; - public static final int PT_H261_FUR = 192; - - private InetAddress fromAddress; - private Integer fromPort; - private Long pt; - private Long receptionReports; - private Long senderSsrc; - private Long packetsLost; - private Long highestSequence; - private Long sequenceNumberCycles; - private Double lastSr; - private Double rtt; - - private String channel; - private String language; - private String report0SequenceNumberCycles; - private String ssrc; - private String linkedId; - private String report0lsr; - private Long sentOctets; - private String report0Sourcessrc; - private Double report0dlsr; - private String uniqueid; - private Integer reportCount; - private Integer report0CumulativeLost; - private Integer report0FractionLost; - private Integer report0iaJitter; - private Integer report0HighestSequence; - private InetAddress toAddress; - private Integer toPort; - private String sentntp; - private Integer sentPackets; - private Long sentrtp; - private String accountCode; - - - public RtcpReceivedEvent(Object source) - { - super(source); - } - - /** - * Returns the IP address the RTCP message has been received from. - * - * @return the IP address the RTCP message has been received from. - */ - public InetAddress getFromAddress() - { - return fromAddress; - } - - /** - * Returns the port of the RTCP message has been received from. - * - * @return the port of the RTCP message has been received from. - */ - public Integer getFromPort() - { - return fromPort; - } - - public void setFrom(String from) - { - // Format is "%s:%d" - this.fromAddress = stringToAddress(from); - this.fromPort = stringToPort(from); - } - - /** - * Returns the port the RTCP message has been sent to. - * - * @return the port the RTCP message has been sent to. - */ - public Integer getToPort() - { - return toPort; - } - - public void setTo(String to) - { - // Format is "%s:%d" - this.toAddress = stringToAddress(to); - this.toPort = stringToPort(to); - } - - /** - * Indicates the format of the payload, typical values are 200 for sender reports and - * 201 for receiver reports. - * - * @return the format of the payload. - * @see #PT_SENDER_REPORT - * @see #PT_RECEIVER_REPORT - */ - public Long getPt() - { - return pt; - } - - public void setPt(String ptString) - { - // Format is "PT: %d(%s)" - if (ptString == null || ptString.length() == 0) - { - this.pt = null; - return; - } - - try - { - if (ptString.indexOf('(') > 0) - { - this.pt = Long.parseLong(ptString.substring(0, ptString.indexOf('('))); - } - else - { - this.pt = Long.parseLong(ptString); - } - - } catch (NumberFormatException e) - { - throw new NumberFormatException(String.format("Input string [%s] is not a parsable long", ptString)); - } - } - - public Long getReceptionReports() - { - return receptionReports; - } - - public void setReceptionReports(Long receptionReports) - { - this.receptionReports = receptionReports; - } - - /** - * Returns the synchronization source identifier of the sender. - * - * @return the synchronization source identifier of the sender. - */ - public Long getSenderSsrc() - { - return senderSsrc; - } - - public void setSenderSsrc(Long senderSsrc) - { - this.senderSsrc = senderSsrc; - } - - /** - * Returns the number of packets lost so far. - * - * @return the number of packets lost. - */ - public Long getPacketsLost() - { - return packetsLost; - } - - public void setPacketsLost(Long packetsLost) - { - this.packetsLost = packetsLost; - } - - public Long getHighestSequence() - { - return highestSequence; - } - - public void setHighestSequence(Long highestSequence) - { - this.highestSequence = highestSequence; - } - - public Long getSequenceNumberCycles() - { - return sequenceNumberCycles; - } - - public void setSequenceNumberCycles(Long sequenceNumberCycles) - { - this.sequenceNumberCycles = sequenceNumberCycles; - } - - public Double getLastSr() - { - return lastSr; - } - - public void setLastSr(Double lastSr) - { - this.lastSr = lastSr; - } - - /** - * Returns the round trip time. - * - * @return the round trip time in seconds, may be null. - */ - public Double getRtt() - { - return rtt; - } - - public void setRtt(String rttString) - { - this.rtt = secStringToDouble(rttString); - } - - public Long getRttAsMillseconds() - { - return (long) (rtt * 1000); - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getReport0SequenceNumberCycles() - { - return report0SequenceNumberCycles; - } - - public void setReport0SequenceNumberCycles(String report0SequenceNumberCycles) - { - this.report0SequenceNumberCycles = report0SequenceNumberCycles; - } - - public String getSsrc() - { - return ssrc; - } - - public void setSsrc(String ssrc) - { - this.ssrc = ssrc; - } - - public String getReport0lsr() - { - return report0lsr; - } - - public void setReport0lsr(String report0lsr) - { - this.report0lsr = report0lsr; - } - - public Long getSentOctets() - { - return sentOctets; - } - - public void setSentOctets(Long sentOctets) - { - this.sentOctets = sentOctets; - } - - public String getReport0Sourcessrc() - { - return report0Sourcessrc; - } - - public void setReport0Sourcessrc(String report0Sourcessrc) - { - this.report0Sourcessrc = report0Sourcessrc; - } - - public Double getReport0dlsr() - { - return report0dlsr; - } - - public void setReport0dlsr(Double report0dlsr) - { - this.report0dlsr = report0dlsr; - } - - public String getUniqueid() - { - return uniqueid; - } - - public void setUniqueid(String uniqueid) - { - this.uniqueid = uniqueid; - } - - public Integer getReport0CumulativeLost() - { - return report0CumulativeLost; - } - - public void setReport0CumulativeLost(Integer report0CumulativeLost) - { - this.report0CumulativeLost = report0CumulativeLost; - } - - public Integer getReport0FractionLost() - { - return report0FractionLost; - } - - public void setReport0FractionLost(Integer report0FractionLost) - { - this.report0FractionLost = report0FractionLost; - } - - public Integer getReport0iaJitter() - { - return report0iaJitter; - } - - public void setReport0iaJitter(Integer report0iaJitter) - { - this.report0iaJitter = report0iaJitter; - } - - public InetAddress getToAddress() - { - return toAddress; - } - - public String getSentntp() - { - return sentntp; - } - - public void setSentntp(String sentntp) - { - this.sentntp = sentntp; - } - - public Long getSentrtp() - { - return sentrtp; - } - - public void setSentrtp(Long sentrtp) - { - this.sentrtp = sentrtp; - } - - public Integer getReportCount() - { - return reportCount; - } - - public void setReportCount(Integer reportCount) - { - this.reportCount = reportCount; - } - - public Integer getReport0HighestSequence() - { - return report0HighestSequence; - } - - public void setReport0HighestSequence(Integer report0HighestSequence) - { - this.report0HighestSequence = report0HighestSequence; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public Integer getSentPackets() - { - return sentPackets; - } - - public void setSentPackets(Integer sentPackets) - { - this.sentPackets = sentPackets; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - - -} diff --git a/src/main/java/org/asteriskjava/manager/event/RtcpSentEvent.java b/src/main/java/org/asteriskjava/manager/event/RtcpSentEvent.java deleted file mode 100644 index e556ce733..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RtcpSentEvent.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.net.InetAddress; - -/** - * An RtcpSentEvent is triggered when Asterisk sends an RTCP message.

- * Available since Asterisk 1.6

- * It is implemented in main/rtp.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class RtcpSentEvent extends AbstractRtcpEvent -{ - private static final long serialVersionUID = 1L; - - private InetAddress fromAddress; - private Integer fromPort; - private Long pt; - private InetAddress toAddress; - private Integer toPort; - private Long ourSsrc; - private Double sentNtp; - private Long sentRtp; - private Long sentPackets; - private Long sentOctets; - private Long cumulativeLoss; - private Long theirLastSr; - - private String channel; - private String language; - private String report0SequenceNumberCycles; - private String ssrc; - private String linkedId; - private String report0lsr; - private String report0Sourcessrc; - private Double report0dlsr; - private String uniqueid; - private Integer reportCount; - private Integer report0CumulativeLost; - private Integer report0FractionLost; - private Integer report0iaJitter; - private Integer report0HighestSequence; - private String accountCode; - - public RtcpSentEvent(Object source) - { - super(source); - } - - /** - * Returns the IP address the RTCP message has been received from. - * - * @return the IP address the RTCP message has been received from. - */ - public InetAddress getFromAddress() - { - return fromAddress; - } - - /** - * Returns the port of the RTCP message has been received from. - * - * @return the port of the RTCP message has been received from. - */ - public Integer getFromPort() - { - return fromPort; - } - - public void setFrom(String from) - { - // Format is "%s:%d" - this.fromAddress = stringToAddress(from); - this.fromPort = stringToPort(from); - } - - /** - * Indicates the format of the payload, typical values are 200 for sender reports and - * 201 for receiver reports. - * - * @return the format of the payload. - * @see #RtcpReceivedEvent.PT_SENDER_REPORT - * @see #RtcpReceivedEvent.PT_RECEIVER_REPORT - */ - public Long getPt() - { - return pt; - } - - public void setPt(String ptString) - { - // Format is "PT: %d(%s)" - if (ptString == null || ptString.length() == 0) - { - this.pt = null; - return; - } - - if (ptString.indexOf('(') > 0) - { - this.pt = Long.parseLong(ptString.substring(0, ptString.indexOf('('))); - } - else - { - this.pt = Long.parseLong(ptString); - } - } - - - /** - * Returns the IP address the RTCP message has been sent to. - * - * @return the IP address the RTCP message has been sent to. - */ - public InetAddress getToAddress() - { - return toAddress; - } - - /** - * Returns the port the RTCP message has been sent to. - * - * @return the port the RTCP message has been sent to. - */ - public Integer getToPort() - { - return toPort; - } - - public void setTo(String to) - { - // Format is "%s:%d" - this.toAddress = stringToAddress(to); - this.toPort = stringToPort(to); - } - - /** - * Returns our synchronization source identifier that uniquely identifies the source of a stream. - * @return our synchronization source identifier. - */ - public Long getOurSsrc() - { - return ourSsrc; - } - - public void setOurSsrc(Long ourSsrc) - { - this.ourSsrc = ourSsrc; - } - - public Double getSentNtp() - { - return sentNtp; - } - - public void setSentNtp(Double sentNtp) - { - this.sentNtp = sentNtp; - } - - public Long getSentRtp() - { - return sentRtp; - } - - public void setSentRtp(Long sentRtp) - { - this.sentRtp = sentRtp; - } - - /** - * Returns the number of packets sent. - * - * @return the number of packets sent. - */ - public Long getSentPackets() - { - return sentPackets; - } - - public void setSentPackets(Long sentPackets) - { - this.sentPackets = sentPackets; - } - - /** - * Returns the number of octets (bytes) sent. - * - * @return the number of octets (bytes) sent. - */ - public Long getSentOctets() - { - return sentOctets; - } - - public void setSentOctets(Long sentOctets) - { - this.sentOctets = sentOctets; - } - - public Long getCumulativeLoss() - { - return cumulativeLoss; - } - - public void setCumulativeLoss(Long cumulativeLoss) - { - this.cumulativeLoss = cumulativeLoss; - } - - public Long getTheirLastSr() - { - return theirLastSr; - } - - public void setTheirLastSr(Long theirLastSr) - { - this.theirLastSr = theirLastSr; - } - - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getReport0SequenceNumberCycles() - { - return report0SequenceNumberCycles; - } - - public void setReport0SequenceNumberCycles(String report0SequenceNumberCycles) - { - this.report0SequenceNumberCycles = report0SequenceNumberCycles; - } - - public String getSsrc() - { - return ssrc; - } - - public void setSsrc(String ssrc) - { - this.ssrc = ssrc; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getReport0lsr() - { - return report0lsr; - } - - public void setReport0lsr(String report0lsr) - { - this.report0lsr = report0lsr; - } - - public String getReport0Sourcessrc() - { - return report0Sourcessrc; - } - - public void setReport0Sourcessrc(String report0Sourcessrc) - { - this.report0Sourcessrc = report0Sourcessrc; - } - - public Double getReport0dlsr() - { - return report0dlsr; - } - - public void setReport0dlsr(Double report0dlsr) - { - this.report0dlsr = report0dlsr; - } - - public String getUniqueid() - { - return uniqueid; - } - - public void setUniqueid(String uniqueid) - { - this.uniqueid = uniqueid; - } - - public Integer getReportCount() - { - return reportCount; - } - - public void setReportCount(Integer reportCount) - { - this.reportCount = reportCount; - } - - public Integer getReport0CumulativeLost() - { - return report0CumulativeLost; - } - - public void setReport0CumulativeLost(Integer report0CumulativeLost) - { - this.report0CumulativeLost = report0CumulativeLost; - } - - public Integer getReport0FractionLost() - { - return report0FractionLost; - } - - public void setReport0FractionLost(Integer report0FractionLost) - { - this.report0FractionLost = report0FractionLost; - } - - public Integer getReport0iaJitter() - { - return report0iaJitter; - } - - public void setReport0iaJitter(Integer report0iaJitter) - { - this.report0iaJitter = report0iaJitter; - } - - public Integer getReport0HighestSequence() - { - return report0HighestSequence; - } - - public void setReport0HighestSequence(Integer report0HighestSequence) - { - this.report0HighestSequence = report0HighestSequence; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/RtpReceiverStatEvent.java b/src/main/java/org/asteriskjava/manager/event/RtpReceiverStatEvent.java deleted file mode 100644 index 49416cc88..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RtpReceiverStatEvent.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An RtpReceiverStatEvent is triggered at the end of an RTP transmission and reports - * transmission statistics.

- * Available since Asterisk 1.6

- * It is implemented in main/rtp.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class RtpReceiverStatEvent extends AbstractRtpStatEvent -{ - private static final long serialVersionUID = 1L; - - private Long receivedPackets; - private Double transit; - private Long rrCount; - private String accountCode; - - public RtpReceiverStatEvent(Object source) - { - super(source); - } - - /** - * Returns the number of packets received. - * - * @return the number of packets received. - */ - public Long getReceivedPackets() - { - return receivedPackets; - } - - public void setReceivedPackets(Long receivedPackets) - { - this.receivedPackets = receivedPackets; - } - - public Double getTransit() - { - return transit; - } - - public void setTransit(Double transit) - { - this.transit = transit; - } - - /** - * Returns the number of receiver reports. - * - * @return the number of receiver reports. - */ - public Long getRrCount() - { - return rrCount; - } - - public void setRrCount(Long rrCount) - { - this.rrCount = rrCount; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/RtpSenderStatEvent.java b/src/main/java/org/asteriskjava/manager/event/RtpSenderStatEvent.java deleted file mode 100644 index 793beeb69..000000000 --- a/src/main/java/org/asteriskjava/manager/event/RtpSenderStatEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An RtpSenderStatEvent is triggered at the end of an RTP transmission and reports - * transmission statistics.

- * Available since Asterisk 1.6

- * It is implemented in main/rtp.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class RtpSenderStatEvent extends AbstractRtpStatEvent -{ - private static final long serialVersionUID = 1L; - - private Long sentPackets; - private Long srCount; - private Double rtt; - - public RtpSenderStatEvent(Object source) - { - super(source); - } - - /** - * Returns the number of packets sent. - * - * @return the number of packets sent. - */ - public Long getSentPackets() - { - return sentPackets; - } - - public void setSentPackets(Long sentPackets) - { - this.sentPackets = sentPackets; - } - - /** - * Returns the number of sender reports. - * - * @return the number of sender reports. - */ - public Long getSrCount() - { - return srCount; - } - - public void setSrCount(Long srCount) - { - this.srCount = srCount; - } - - public Double getRtt() - { - return rtt; - } - - public void setRtt(Double rtt) - { - this.rtt = rtt; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/SendFaxEvent.java b/src/main/java/org/asteriskjava/manager/event/SendFaxEvent.java deleted file mode 100644 index 1f6ae5ae0..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SendFaxEvent.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SendFaxEvent is an event of Digium's Fax For Asterisk add-on. - */ -public class SendFaxEvent extends AbstractFaxEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1L; - private String callerId; - private String localStationId; - private String remoteStationId; - private String pagesTransferred; - private String resolution; - private String transferRate; - private String fileName; - - - public SendFaxEvent(Object source) - { - super(source); - } - - - /** - * @return the callerId - */ - public String getCallerId() - { - return callerId; - } - - - /** - * @param callerId the callerId to set - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - - /** - * @return the localStationId - */ - public String getLocalStationId() - { - return localStationId; - } - - - /** - * @param localStationId the localStationId to set - */ - public void setLocalStationId(String localStationId) - { - this.localStationId = localStationId; - } - - - /** - * @return the remoteStationId - */ - public String getRemoteStationId() - { - return remoteStationId; - } - - - /** - * @param remoteStationId the remoteStationId to set - */ - public void setRemoteStationId(String remoteStationId) - { - this.remoteStationId = remoteStationId; - } - - - /** - * @return the pagesTransferred - */ - public String getPagesTransferred() - { - return pagesTransferred; - } - - - /** - * @param pagesTransferred the pagesTransferred to set - */ - public void setPagesTransferred(String pagesTransferred) - { - this.pagesTransferred = pagesTransferred; - } - - - /** - * @return the resolution - */ - public String getResolution() - { - return resolution; - } - - - /** - * @param resolution the resolution to set - */ - public void setResolution(String resolution) - { - this.resolution = resolution; - } - - - /** - * @return the transferRate - */ - public String getTransferRate() - { - return transferRate; - } - - - /** - * @param transferRate the transferRate to set - */ - public void setTransferRate(String transferRate) - { - this.transferRate = transferRate; - } - - - /** - * @return the fileName - */ - public String getFileName() - { - return fileName; - } - - - /** - * @param fileName the fileName to set - */ - public void setFileName(String fileName) - { - this.fileName = fileName; - } - - -} - diff --git a/src/main/java/org/asteriskjava/manager/event/SendFaxStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/SendFaxStatusEvent.java deleted file mode 100644 index f09be6e8b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SendFaxStatusEvent.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SendFaxStatusEvent is an event of Digium's Fax For Asterisk add-on. - */ -public class SendFaxStatusEvent extends AbstractFaxEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1L; - private String status; - private String callerId; - private String localStationId; - private String fileName; - - - public SendFaxStatusEvent(Object source) - { - super(source); - } - - - /** - * @return the status - */ - public String getStatus() - { - return status; - } - - - /** - * @param status the status to set - */ - public void setStatus(String status) - { - this.status = status; - } - - - /** - * @return the callerId - */ - public String getCallerId() - { - return callerId; - } - - - /** - * @param callerId the callerId to set - */ - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - - /** - * @return the localStationId - */ - public String getLocalStationId() - { - return localStationId; - } - - - /** - * @param localStationId the localStationId to set - */ - public void setLocalStationId(String localStationId) - { - this.localStationId = localStationId; - } - - - /** - * @return the fileName - */ - public String getFileName() - { - return fileName; - } - - - /** - * @param fileName the fileName to set - */ - public void setFileName(String fileName) - { - this.fileName = fileName; - } - - -} - diff --git a/src/main/java/org/asteriskjava/manager/event/ShowDialplanCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/ShowDialplanCompleteEvent.java deleted file mode 100644 index 26f8ae015..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ShowDialplanCompleteEvent.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * A ShowDialplanCompleteEvent is triggered after the dialplan has been reported - * in response to a ShowDialplanAction.

- * Available since Asterisk 1.6

- * It is implemented in main/pbx.c - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ShowDialplanAction - * @see org.asteriskjava.manager.event.ListDialplanEvent - * @since 1.0.0 - */ -public class ShowDialplanCompleteEvent extends ResponseEvent -{ - private static final long serialVersionUID = 1L; - - private Integer listItems; - private Integer listExtensions; - private Integer listPriorities; - private Integer listContexts; - - public ShowDialplanCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns the total number of list items reported. - * - * @return the total number of list items reported. - */ - public Integer getListItems() - { - return listItems; - } - - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } - - /** - * Returns the number of extensions reported. - * - * @return the number of extensions reported. - */ - public Integer getListExtensions() - { - return listExtensions; - } - - public void setListExtensions(Integer listExtensions) - { - this.listExtensions = listExtensions; - } - - /** - * Returns the number of priorites reported. - * - * @return the number of priorites reported. - */ - public Integer getListPriorities() - { - return listPriorities; - } - - public void setListPriorities(Integer listPriorities) - { - this.listPriorities = listPriorities; - } - - /** - * Returns the number of contexts reported. - * - * @return the number of contexts reported. - */ - public Integer getListContexts() - { - return listContexts; - } - - public void setListContexts(Integer listContexts) - { - this.listContexts = listContexts; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/ShutdownEvent.java b/src/main/java/org/asteriskjava/manager/event/ShutdownEvent.java deleted file mode 100644 index 99f768952..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ShutdownEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ShutdownEvent is triggered when the asterisk server is shut down or restarted.

- * It is implemented in asterisk.c - * - * @author srt - * @version $Id$ - */ -public class ShutdownEvent extends ManagerEvent -{ - /** - * Serial version identifier - */ - static final long serialVersionUID = 2028136082664018423L; - - private Boolean restart = Boolean.FALSE; - private String shutdown; - - /** - * @param source - */ - public ShutdownEvent(Object source) - { - super(source); - } - - /** - * Returns the kind of shutdown or restart. Possible values are "Uncleanly" and "Cleanly". A - * shutdown is considered unclean if there are any active channels when the system is shut down. - */ - public String getShutdown() - { - return shutdown; - } - - public void setShutdown(String shutdown) - { - this.shutdown = shutdown; - } - - /** - * Returns true if the server has been restarted; false if it has - * been halted. - */ - public Boolean getRestart() - { - return restart; - } - - public void setRestart(Boolean restart) - { - this.restart = restart; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeAccountStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeAccountStatusEvent.java deleted file mode 100644 index e81b3c1d5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeAccountStatusEvent.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * amended 2010 Allan Wylie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SkypeAccountStatusEvent is sent when a Skype for Asterisk user logs in or out - * of the Skype community.

- * It is implemented in chan_skye.c.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeAccountStatusEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - private String username; - private String status; - - static final String STATUS_LOGGED_IN = "Logged In"; - static final String STATUS_LOGGED_OUT = "Logged Out"; - - public SkypeAccountStatusEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the Skype user. - * - * @return the name of the Skype user. - */ - public String getUsername() - { - return username; - } - - /** - * Sets the name of the Skype user. - * - * @param username the name of the Skype user. - */ - public void setUsername(String username) - { - this.username = username; - } - - /** - * Returns the Skype user status. - * - * @return the Skype user status. - */ - public String getStatus() - { - return status; - } - - /** - * Sets the Skype user status. - * - * @param status user status. - */ - public void setStatus(String status) - { - this.status = status; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeBuddyEntryEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeBuddyEntryEvent.java deleted file mode 100644 index 914b2b3c4..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeBuddyEntryEvent.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SkypeBuddyEntryEvent is triggered in response to a SkypeBuddiesAction for each - * buddy on the buddy list.

- * It is implemented in chan_skype.c.

- * Available with Skype for Asterisk. - * - * @see org.asteriskjava.manager.action.SkypeBuddiesAction - * @since 1.0.0 - */ -public class SkypeBuddyEntryEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String buddy; - private String status; - private String fullname; - - public SkypeBuddyEntryEvent(Object source) - { - super(source); - } - - /** - * Returns the Skype username of the buddy. - * - * @return the Skype username of the buddy. - */ - public String getBuddy() - { - return buddy; - } - - /** - * Sets the Skype username of the buddy. - * - * @param buddy the Skype username of the buddy. - */ - public void setBuddy(String buddy) - { - this.buddy = buddy; - } - - /** - * Returns the status of the buddy. - * - * @return the status of the buddy. - */ - public String getStatus() - { - return status; - } - - /** - * Sets the status of the buddy. - * - * @param status the status of the buddy. - */ - public void setStatus(String status) - { - this.status = status; - } - - /** - * Returns the full name of the buddy. - * - * @return the full name of the buddy. - */ - public String getFullname() - { - return fullname; - } - - /** - * Sets the full name of the buddy. - * - * @param fullname the full name of the buddy. - */ - public void setFullname(String fullname) - { - this.fullname = fullname; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeBuddyListCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeBuddyListCompleteEvent.java deleted file mode 100644 index d49f363b5..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeBuddyListCompleteEvent.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SkypeBuddyListCompleteEvent is triggered in response to a SkypeBuddiesAction when - * all buddies have been reported.

- * It is implemented in chan_skype.c.

- * Available with Skype for Asterisk. - * - * @see org.asteriskjava.manager.action.SkypeBuddiesAction - * @since 1.0.0 - */ -public class SkypeBuddyListCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private Integer listItems; - - public SkypeBuddyListCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns the number of buddies that have been reported. - * - * @return the number of buddies that have been reported. - */ - public Integer getListItems() - { - return listItems; - } - - /** - * Sets the number of buddies that have been reported. - * - * @param listItems the number of buddies that have been reported. - */ - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeBuddyStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeBuddyStatusEvent.java deleted file mode 100644 index 8934d18fa..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeBuddyStatusEvent.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * amended 2010 - Allan Wylie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * A SkypeBuddyStatusEvent indicates a status change for a contact in a Skype for Asterisk user's - * contact list.

- * It is implemented in chan_skye.c.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeBuddyStatusEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - public static final String BUDDYSTATUS_WAITAUTHORIZATION = "Waiting for Authorization"; - public static final String BUDDYSTATUS_BLOCKED = "Blocked"; - public static final String BUDDYSTATUS_BLOCKEDSKYPEOUT = "Blocked Skypout"; - public static final String BUDDYSTATUS_SKYPEOUT = "Skypeout"; - public static final String BUDDYSTATUS_OFFLINE = "Offline"; - public static final String BUDDYSTATUS_ONLINE = "Online"; - public static final String BUDDYSTATUSS_AWAY = "Away"; - public static final String BUDDYSTATUS_NOTAVAILABLE = "Not Available"; - public static final String BUDDYSTATUS_DONTDISTURB = "Do Not Disturb"; - public static final String BUDDYSTATUS_SKYPEME = "Skype Me"; - public static final String BUDDYSTATUS_OFFLINEVOICEENABLE = "Offline (Voicemail Enabled)"; - public static final String BUDDYSTATUS_OFFLINEFORWARDENABLEL = "Offline (Call Forwarding Enabled)"; - public static final String BUDDYSTATUS_UNKNOWN = "Unknown"; - - private static final Pattern BUDDY_PATTERN = Pattern.compile("Skype/(.*)@(.*)"); - - /** - * The name of the buddy - */ - private String buddy; - - /** - * The buddy status. - */ - private String buddyStatus; - - - public SkypeBuddyStatusEvent(Object source) - { - super(source); - } - - /** - * Returns the address of the buddy. The format is "Skype/user@buddy" where user is the Skype username of - * the Skype for Asterisk user and buddy is the Skype username of the buddy who changed his status.

- * For ease of use consider using {@link #getUser()} and {@link #getBuddySkypename()} which already do - * the parsing. - * - * @return the address of the buddy. - * @see #getUser() - * @see #getBuddySkypename() - */ - public String getBuddy() - { - return buddy; - } - - /** - * Returns the Skype username of the Skype for Asterisk user whose buddy changed his status. - * - * @return the Skype username of the Skype for Asterisk user. - */ - public String getUser() - { - return buddyGroup(1); - } - - /** - * Returns the Skype username of the buddy who changed his status. - * - * @return the Skype username of the buddy who changed his status. - */ - public String getBuddySkypename() - { - return buddyGroup(2); - } - - private String buddyGroup(int group) - { - if (buddy == null) - { - return null; - } - final Matcher buddyMatcher = BUDDY_PATTERN.matcher(buddy); - if (buddyMatcher.matches()) - { - return buddyMatcher.group(group); - } - return null; - } - - /** - * Sets the address of buddy. - * - * @param buddy the address of the buddy. - */ - public void setBuddy(String buddy) - { - this.buddy = buddy; - } - - /** - * Returns the status of the buddy. - * - * @return the status of the buddy. - */ - public String getBuddyStatus() - { - return buddyStatus; - } - - public void setBuddyStatus(String buddyStatus) - { - this.buddyStatus = buddyStatus; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeChatMessageEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeChatMessageEvent.java deleted file mode 100644 index e3a95a253..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeChatMessageEvent.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.nio.charset.Charset; - -import org.asteriskjava.util.Base64; - -/** - * A SkypeChatMessageEvent is triggered when a Skype Chat message is sent or received.

- * It is implemented in chan_skye.c.

- * Available with Skype for Asterisk. - * - * @since 1.0.0 - */ -public class SkypeChatMessageEvent extends ManagerEvent -{ - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 1L; - - private String to; - private String from; - private String message; - - public SkypeChatMessageEvent(Object source) - { - super(source); - } - - /** - * Returns the Skype username of the recipient of this chat message. - * - * @return the Skype username of the recipient of this chat message. - */ - public String getTo() - { - return to; - } - - /** - * Sets the Skype username of the recipient of this chat message. - * - * @param to the Skype username of the recipient of this chat message. - */ - public void setTo(String to) - { - this.to = to; - } - - /** - * Returns the Skype username of the sender of this chat message. - * - * @return the Skype username of the sender of this chat message. - */ - public String getFrom() - { - return from; - } - - /** - * Sets the Skype username of the sender of this chat message. - * - * @param from the Skype username of the sender of this chat message. - */ - public void setFrom(String from) - { - this.from = from; - } - - /** - * Returns the Base64 encoded message. - * - * @return the Base64 encoded message. - */ - public String getMessage() - { - return message; - } - - /** - * Sets the Base64 encoded message. - * - * @param message the Base64 encoded message. - */ - public void setMessage(String message) - { - this.message = message; - } - - /** - * Returns the decoded message. - * - * @return the decoded message. - */ - public String getDecodedMessage() - { - if (message == null) - { - return null; - } - return new String(Base64.base64ToByteArray(message), Charset.forName("UTF-8")); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeLicenseEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeLicenseEvent.java deleted file mode 100644 index 96aefa352..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeLicenseEvent.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SkypeLicenseEvent is triggered in response to a SkypeLicenseListAction for each - * license installed on the system.

- * It is implemented in chan_skype.c.

- * Available with Skype for Asterisk. - * - * @see org.asteriskjava.manager.action.SkypeLicenseListAction - * @since 1.0.0 - */ -public class SkypeLicenseEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - private String key; - private String expires; - private String hostId; - private Integer channels; - private String status; - - public SkypeLicenseEvent(Object source) - { - super(source); - } - - /** - * Returns the license key. - * - * @return the license key. - */ - public String getKey() - { - return key; - } - - /** - * Sets the license key. - * - * @param key the license key. - */ - public void setKey(String key) - { - this.key = key; - } - - /** - * Returns the date the license expires in the format "YYYY-MM-DD". - * - * @return the date the license expires in the format "YYYY-MM-DD". - */ - public String getExpires() - { - return expires; - } - - /** - * Sets the date the license expires in the format "YYYY-MM-DD". - * - * @param expires the date the license expires in the format "YYYY-MM-DD". - */ - public void setExpires(String expires) - { - this.expires = expires; - } - - public String getHostId() - { - return hostId; - } - - public void setHostId(String hostId) - { - this.hostId = hostId; - } - - /** - * Returns the number of licensed channels. - * - * @return the number of licensed channels. - */ - public Integer getChannels() - { - return channels; - } - - /** - * Sets the number of licensed channels. - * - * @param channels the number of licensed channels. - */ - public void setChannels(Integer channels) - { - this.channels = channels; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SkypeLicenseListCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/SkypeLicenseListCompleteEvent.java deleted file mode 100644 index ed0c586e6..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SkypeLicenseListCompleteEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A SkypeLicenseListCompleteEvent is triggered in response to a SkypeLicenseListAction when - * all licenses have been reported.

- * It is implemented in chan_skype.c.

- * Available with Skype for Asterisk. - * - * @see org.asteriskjava.manager.action.SkypeLicenseListAction - * @since 1.0.0 - */ -public class SkypeLicenseListCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 1L; - - public SkypeLicenseListCompleteEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SoftHangupRequestEvent.java b/src/main/java/org/asteriskjava/manager/event/SoftHangupRequestEvent.java deleted file mode 100644 index 25523b435..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SoftHangupRequestEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A HangupEvent is triggered when a channel is hung up. - *

- * It is implemented in channel.c - */ -public class SoftHangupRequestEvent extends AbstractChannelEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 0L; - - private Integer cause; - private String language; - private String linkedId; - - public SoftHangupRequestEvent(Object source) - { - super(source); - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - /** - * Returns the cause of the hangup. - * - * @return the hangup cause. - * @see org.asteriskjava.live.HangupCause - */ - public Integer getCause() - { - return cause; - } - - /** - * Sets the cause of the hangup. - * - * @param cause the hangup cause. - */ - public void setCause(Integer cause) - { - this.cause = cause; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/StatusCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/StatusCompleteEvent.java deleted file mode 100644 index ac0763832..000000000 --- a/src/main/java/org/asteriskjava/manager/event/StatusCompleteEvent.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A StatusCompleteEvent is triggered after the state of all channels has been - * reported in response to a StatusAction. - * - * @see org.asteriskjava.manager.action.StatusAction - * @see org.asteriskjava.manager.event.StatusEvent - * @author srt - * @version $Id$ - */ -public class StatusCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - private Integer items; - - private Integer listItems; - private String eventList; - - public StatusCompleteEvent(Object source) - { - super(source); - } - - /** - * Returns the number of channels reported. - *

- * Available since Asterisk 1.6. - * - * @return the number of channels reported. - * @since 1.0.0 - */ - public Integer getItems() - { - return items; - } - - /** - * Sets the number of channels reported. - *

- * Available since Asterisk 1.6. - * - * @param items the number of channels reported. - * @since 1.0.0 - */ - public void setItems(Integer items) - { - this.items = items; - } - - public Integer getListItems() - { - return listItems; - } - - public void setListitems(Integer listItems) - { - this.listItems = listItems; - } - - public String getEventList() - { - return eventList; - } - - public void setEventList(String eventList) - { - this.eventList = eventList; - } - - public void setListItems(Integer listItems) - { - this.listItems = listItems; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/StatusEvent.java b/src/main/java/org/asteriskjava/manager/event/StatusEvent.java deleted file mode 100644 index 60471f7a2..000000000 --- a/src/main/java/org/asteriskjava/manager/event/StatusEvent.java +++ /dev/null @@ -1,529 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -import java.util.Map; - -/** - * A StatusEvent is triggered for each active channel in response to a - * StatusAction. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.StatusAction - */ -public class StatusEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -3619197512835308812L; - private String channel; - private String accountCode; - private Integer seconds; - private String bridgedChannel; - private String bridgedUniqueId; - private String uniqueId; - private String linkedId; - private String data; - private String readFormat; - private String writeFormat; - private String type; - private String effectiveConnectedLineName; - private String effectiveConnectedLineNum; - private String application; - private String callGroup; - private String nativeFormats; - private String pickupGroup; - private String timeToHangup; - private Map variables; - private String dnid; - private String writetrans; - private String bridgeId; - private String readtrans; - private String connectedlinename; - private String connectedlinenum; - - public StatusEvent(Object source) - { - super(source); - } - - /** - * Returns the name of this channel. - * - * @return the name of this channel. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of this channel. - * - * @param channel the name of this channel. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the Caller*ID Number of this channel. - *

- * This property is deprecated as of Asterisk 1.4, use - * {@link #getCallerIdNum()} instead. - * - * @return the Caller*ID Number of this channel or null if none - * is available. - * @deprecated - */ - @Deprecated - public String getCallerId() - { - return callerIdNum; - } - - /** - * Sets the Caller*ID Number of this channel. - *

- * This property is deprecated as of Asterisk 1.4. - * - * @param callerIdNum the Caller*ID Number to set. - */ - public void setCallerId(String callerIdNum) - { - this.callerIdNum = callerIdNum; - } - - /** - * Returns the account code of this channel. - * - * @return the account code of this channel. - * @since 1.0.0 - */ - public String getAccountCode() - { - return accountCode; - } - - /** - * Sets the account code of this channel. - * - * @param accountCode the account code of this channel. - * @since 1.0.0 - */ - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - /** - * Returns the account code of this channel. - * - * @return the account code of this channel. - * @deprecated since 1.0.0, use {@link #getAccountCode()} instead. - */ - @Deprecated - public String getAccount() - { - return accountCode; - } - - /** - * Sets the account code of this channel. - *

- * Asterisk versions up to 1.4 use the "Account" property instead of - * "AccountCode". - * - * @param account the account code of this channel. - */ - public void setAccount(String account) - { - this.accountCode = account; - } - - /** - * Returns the state of the channel as a descriptive text. - * - * @return the state of the channel as a descriptive text. - * @deprecated use {@link #getChannelStateDesc()} instead. - */ - @Deprecated - public String getState() - { - return getChannelStateDesc(); - } - - public void setState(String state) - { - setChannelStateDesc(state); - } - - public String getExtension() - { - return getExten(); - } - - public void setExtension(String extension) - { - setExten(extension); - } - - /** - * Returns the number of elapsed seconds. - * - * @return the number of elapsed seconds. - */ - public Integer getSeconds() - { - return seconds; - } - - /** - * Sets the number of elapsed seconds. - * - * @param seconds the number of elapsed seconds. - */ - public void setSeconds(Integer seconds) - { - this.seconds = seconds; - } - - /** - * Returns the name of the linked channel if this channel is bridged. - * - * @return the name of the linked channel if this channel is bridged. - * @since 1.0.0 - */ - public String getBridgedChannel() - { - return bridgedChannel; - } - - /** - * Sets the name of the linked channel. - * - * @param bridgedChannel the name of the linked channel if this channel is - * bridged. - * @since 1.0.0 - */ - public void setBridgedChannel(String bridgedChannel) - { - this.bridgedChannel = bridgedChannel; - } - - /** - * Returns the name of the linked channel if this channel is bridged. - * - * @return the name of the linked channel if this channel is bridged. - * @deprecated as of 1.0.0, use {@link #getBridgedChannel()} instead. - */ - @Deprecated - public String getLink() - { - return bridgedChannel; - } - - /** - * Sets the name of the linked channel. - *

- * Asterisk versions up to 1.4 use "Link" instead of "BridgedChannel". - * - * @param link the name of the linked channel if this channel is bridged. - */ - public void setLink(String link) - { - this.bridgedChannel = link; - } - - /** - * Returns the unique id of the linked channel if this channel is bridged. - *

- * Available since Asterisk 1.6. - * - * @return the unique id of the linked channel if this channel is bridged. - * @since 1.0.0 - */ - public String getBridgedUniqueId() - { - return bridgedUniqueId; - } - - /** - * Sets the unique id of the linked channel if this channel is bridged. - *

- * Available since Asterisk 1.6. - * - * @param bridgedUniqueId the unique id of the linked channel if this - * channel is bridged. - * @since 1.0.0 - */ - public void setBridgedUniqueId(String bridgedUniqueId) - { - this.bridgedUniqueId = bridgedUniqueId; - } - - /** - * Returns the unique id of this channel. - * - * @return the unique id of this channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id of this channel. - * - * @param uniqueId the unique id of this channel. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the channel variables if the - * {@link org.asteriskjava.manager.action.StatusAction#setVariables(String)} - * property has been set. - *

- * Available since Asterisk 1.6 - * - * @return the channel variables. - * @since 1.0.0 - */ - public Map getVariables() - { - return variables; - } - - /** - * Sets the channel variables. - *

- * Available since Asterisk 1.6 - * - * @param variables the channel variables. - * @since 1.0.0 - */ - public void setVariables(Map variables) - { - this.variables = variables; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getData() - { - return data; - } - - public void setData(String data) - { - this.data = data; - } - - public String getReadFormat() - { - return readFormat; - } - - public void setReadFormat(String readFormat) - { - this.readFormat = readFormat; - } - - public String getWriteFormat() - { - return writeFormat; - } - - public void setWriteFormat(String writeFormat) - { - this.writeFormat = writeFormat; - } - - public String getType() - { - return type; - } - - public void setType(String type) - { - this.type = type; - } - - public String getEffectiveConnectedLineName() - { - return effectiveConnectedLineName; - } - - public void setEffectiveConnectedLineName(String effectiveConnectedLineName) - { - this.effectiveConnectedLineName = effectiveConnectedLineName; - } - - public String getEffectiveConnectedLineNum() - { - return effectiveConnectedLineNum; - } - - public void setEffectiveConnectedLineNum(String effectiveConnectedLineNum) - { - this.effectiveConnectedLineNum = effectiveConnectedLineNum; - } - - public String getApplication() - { - return application; - } - - public void setApplication(String application) - { - this.application = application; - } - - public String getCallGroup() - { - return callGroup; - } - - public void setCallGroup(String callGroup) - { - this.callGroup = callGroup; - } - - public String getNativeFormats() - { - return nativeFormats; - } - - public void setNativeFormats(String nativeFormats) - { - this.nativeFormats = nativeFormats; - } - - public String getPickupGroup() - { - return pickupGroup; - } - - public void setPickupGroup(String pickupGroup) - { - this.pickupGroup = pickupGroup; - } - - public String getTimeToHangup() - { - return timeToHangup; - } - - public void setTimeToHangup(String timeToHangup) - { - this.timeToHangup = timeToHangup; - } - - /** - * @return the dnid - */ - public String getDnid() - { - return dnid; - } - - /** - * @param dnid the dnid to set - */ - public void setDnid(String dnid) - { - this.dnid = dnid; - } - - /** - * @return the writetrans - */ - public String getWritetrans() - { - return writetrans; - } - - /** - * @param writetrans the writetrans to set - */ - public void setWritetrans(String writetrans) - { - this.writetrans = writetrans; - } - - /** - * @return the bridgeid - */ - public String getBridgeId() - { - return bridgeId; - } - - /** - * @param bridgeid the bridgeid to set - */ - public void setBridgeId(String bridgeid) - { - this.bridgeId = bridgeid; - } - - /** - * @return the readtrans - */ - public String getReadtrans() - { - return readtrans; - } - - /** - * @param readtrans the readtrans to set - */ - public void setReadtrans(String readtrans) - { - this.readtrans = readtrans; - } - - public String getConnectedlinename() { - return connectedlinename; - } - - public void setConnectedlinename(String connectedlinename) { - this.connectedlinename = connectedlinename; - } - - public String getConnectedlinenum() { - return connectedlinenum; - } - - public void setConnectedlinenum(String connectedlinenum) { - this.connectedlinenum = connectedlinenum; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/SuccessfulAuthEvent.java b/src/main/java/org/asteriskjava/manager/event/SuccessfulAuthEvent.java deleted file mode 100644 index 9e8b7e4df..000000000 --- a/src/main/java/org/asteriskjava/manager/event/SuccessfulAuthEvent.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.asteriskjava.manager.event; - -/** - * Created by plhk on 1/15/15. - */ -public class SuccessfulAuthEvent extends ManagerEvent -{ - /** - * - */ - private static final long serialVersionUID = 1L; - private String severity; - private Integer eventVersion; - private String accountId; - private Integer usingPassword; - private String sessiontv; - private String service; - private String eventtv; - private String remoteAddress; - private String localAddress; - private String sessionId; - - public SuccessfulAuthEvent(Object source) - { - super(source); - } - - public String getSeverity() - { - return severity; - } - - public void setSeverity(String severity) - { - this.severity = severity; - } - - public Integer getEventVersion() - { - return eventVersion; - } - - public void setEventVersion(Integer eventVersion) - { - this.eventVersion = eventVersion; - } - - public String getAccountId() - { - return accountId; - } - - public void setAccountId(String accountId) - { - this.accountId = accountId; - } - - public Integer getUsingPassword() - { - return usingPassword; - } - - public void setUsingPassword(Integer usingPassword) - { - this.usingPassword = usingPassword; - } - - public String getSessiontv() - { - return sessiontv; - } - - public void setSessiontv(String sessiontv) - { - this.sessiontv = sessiontv; - } - - public String getService() - { - return service; - } - - public void setService(String service) - { - this.service = service; - } - - public String getEventtv() - { - return eventtv; - } - - public void setEventtv(String eventtv) - { - this.eventtv = eventtv; - } - - public String getRemoteAddress() - { - return remoteAddress; - } - - public void setRemoteAddress(String remoteAddress) - { - this.remoteAddress = remoteAddress; - } - - public String getLocalAddress() - { - return localAddress; - } - - public void setLocalAddress(String localAddress) - { - this.localAddress = localAddress; - } - - public String getSessionId() - { - return sessionId; - } - - public void setSessionId(String sessionId) - { - this.sessionId = sessionId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/T38FaxStatusEvent.java b/src/main/java/org/asteriskjava/manager/event/T38FaxStatusEvent.java deleted file mode 100644 index 9a2a6248b..000000000 --- a/src/main/java/org/asteriskjava/manager/event/T38FaxStatusEvent.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A FaxDocumentStatusEvent is an event of Digium's Fax For Asterisk add-on. - */ -public class T38FaxStatusEvent extends AbstractFaxEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = -1L; - private String maxLag; - private String totalLag; - private String averageLag; - private Integer totalEvents; - private String t38SessionDuration; - private Integer t38PacketsSent; - private Integer t38OctetsSent; - private String averageTxDataRate; - private Integer t38PacketsReceived; - private Integer t38OctetsReceived; - private String averageRxDataRate; - private Integer jitterBufferOverflows; - private Integer minimumJitterSpace; - private Integer unrecoverablePackets; - - public T38FaxStatusEvent(Object source) - { - super(source); - } - - - /** - * @return the maxLag - */ - public String getMaxLag() - { - return maxLag; - } - - /** - * @param maxLag the maxLag to set - */ - public void setMaxLag(String maxLag) - { - this.maxLag = maxLag; - } - - /** - * @return the totalLag - */ - public String getTotalLag() - { - return totalLag; - } - - /** - * @param totalLag the totalLag to set - */ - public void setTotalLag(String totalLag) - { - this.totalLag = totalLag; - } - - /** - * @return the averageLag - */ - public String getAverageLag() - { - return averageLag; - } - - /** - * @param averageLag the averageLag to set - */ - public void setAverageLag(String averageLag) - { - this.averageLag = averageLag; - } - - /** - * @return the totalEvents - */ - public Integer getTotalEvents() - { - return totalEvents; - } - - /** - * @param totalEvents the totalEvents to set - */ - public void setTotalEvents(Integer totalEvents) - { - this.totalEvents = totalEvents; - } - - /** - * @return the t38SessionDuration - */ - public String getT38SessionDuration() - { - return t38SessionDuration; - } - - /** - * @param t38SessionDuration the t38SessionDuration to set - */ - public void setT38SessionDuration(String t38SessionDuration) - { - this.t38SessionDuration = t38SessionDuration; - } - - /** - * @return the t38PacketsSent - */ - public Integer getT38PacketsSent() - { - return t38PacketsSent; - } - - /** - * @param t38PacketsSent the t38PacketsSent to set - */ - public void setT38PacketsSent(Integer t38PacketsSent) - { - this.t38PacketsSent = t38PacketsSent; - } - - /** - * @return the t38OctetsSent - */ - public Integer getT38OctetsSent() - { - return t38OctetsSent; - } - - /** - * @param t38OctetsSent the t38OctetsSent to set - */ - public void setT38OctetsSent(Integer t38OctetsSent) - { - this.t38OctetsSent = t38OctetsSent; - } - - /** - * @return the averageTxDataRate - */ - public String getAverageTxDataRate() - { - return averageTxDataRate; - } - - /** - * @param averageTxDataRate the averageTxDataRate to set - */ - public void setAverageTxDataRate(String averageTxDataRate) - { - this.averageTxDataRate = averageTxDataRate; - } - - /** - * @return the t38PacketsReceived - */ - public Integer getT38PacketsReceived() - { - return t38PacketsReceived; - } - - /** - * @param t38PacketsReceived the t38PacketsReceived to set - */ - public void setT38PacketsReceived(Integer t38PacketsReceived) - { - this.t38PacketsReceived = t38PacketsReceived; - } - - /** - * @return the t38OctetsReceived - */ - public Integer getT38OctetsReceived() - { - return t38OctetsReceived; - } - - /** - * @param t38OctetsReceived the t38OctetsReceived to set - */ - public void setT38OctetsReceived(Integer t38OctetsReceived) - { - this.t38OctetsReceived = t38OctetsReceived; - } - - /** - * @return the averageRxDataRate - */ - public String getAverageRxDataRate() - { - return averageRxDataRate; - } - - /** - * @param averageRxDataRate the averageRxDataRate to set - */ - public void setAverageRxDataRate(String averageRxDataRate) - { - this.averageRxDataRate = averageRxDataRate; - } - - /** - * @return the jitterBufferOverflows - */ - public Integer getJitterBufferOverflows() - { - return jitterBufferOverflows; - } - - /** - * @param jitterBufferOverflows the jitterBufferOverflows to set - */ - public void setJitterBufferOverflows(Integer jitterBufferOverflows) - { - this.jitterBufferOverflows = jitterBufferOverflows; - } - - /** - * @return the minimumJitterSpace - */ - public Integer getMinimumJitterSpace() - { - return minimumJitterSpace; - } - - /** - * @param minimumJitterSpace the minimumJitterSpace to set - */ - public void setMinimumJitterSpace(Integer minimumJitterSpace) - { - this.minimumJitterSpace = minimumJitterSpace; - } - - /** - * @return the unrecoverablePackets - */ - public Integer getUnrecoverablePackets() - { - return unrecoverablePackets; - } - - /** - * @param unrecoverablePackets the unrecoverablePackets to set - */ - public void setUnrecoverablePackets(Integer unrecoverablePackets) - { - this.unrecoverablePackets = unrecoverablePackets; - } - - // convenience methods - public Integer getTotalLagInMilliSeconds() - { - final String totalLagStripped = stripUnit(this.totalLag); - return totalLagStripped == null ? null : Integer.valueOf(totalLagStripped); - } - - public Integer getMaxLagInMilliSeconds() - { - final String maxLagStripped = stripUnit(this.maxLag); - return maxLagStripped == null ? null : Integer.valueOf(maxLagStripped); - } - - public Double getT38SessionDurationInSeconds() - { - final String t38SessionDurationStripped = stripUnit(this.t38SessionDuration); - return t38SessionDurationStripped == null ? null : Double.valueOf(t38SessionDurationStripped); - } - - public Double getAverageLagInMilliSeconds() - { - final String averageLagStripped = stripUnit(this.averageLag); - return averageLagStripped == null ? null : Double.valueOf(averageLagStripped); - } - - public Integer getAverageTxDataRateInBps() - { - final String averageTxDataRateStripped = stripUnit(this.averageTxDataRate); - return averageTxDataRateStripped == null ? null : Integer.valueOf(averageTxDataRateStripped); - } - - public Integer getAverageRxDataRateInBps() - { - final String averageRxDataRateStripped = stripUnit(this.averageRxDataRate); - return averageRxDataRateStripped == null ? null : Integer.valueOf(averageRxDataRateStripped); - } - - String stripUnit(String s) - { - if (s == null || s.length() == 0) - { - return null; - } - - int index = s.indexOf(' '); - if (index < 0) - { - return s; - } - return s.substring(0, index); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/TransferEvent.java b/src/main/java/org/asteriskjava/manager/event/TransferEvent.java deleted file mode 100644 index 9e33d857a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/TransferEvent.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A TransferEvent is triggered when a SIP channel is transfered.

- * It is implemented in channels/chan_sip.c.

- * Available since Asterisk 1.6 for SIP channels. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class TransferEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - public static final String TRANSFER_METHOD_SIP = "SIP"; - - public static final String TRANSFER_TYPE_ATTENDED = "Attended"; - public static final String TRANSFER_TYPE_BLIND = "Blind"; - - private String channel; - private String uniqueId; - private String transferMethod; - private String transferType; - private String sipCallId; - private String targetChannel; - private String targetUniqueId; - private String transferExten; - private String transferContext; - private Boolean transfer2Parking; - - public TransferEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the transfering channel. - * - * @return channel the name of the transfering channel. - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the transfering channel. - * - * @return the unique id of the transfering channel. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the transfer method. Currently this is always "SIP". - * - * @return the transfer method ("SIP"). - */ - public String getTransferMethod() - { - return transferMethod; - } - - public void setTransferMethod(String transferMethod) - { - this.transferMethod = transferMethod; - } - - /** - * Returns whether this is an attended or a blind transfer. Possible values are - * "Attended" and "Blind". - * - * @return "Attended" if this an attended transfer, "Blind" if it is a blind transfer. - * @see #TRANSFER_TYPE_ATTENDED - * @see #TRANSFER_TYPE_BLIND - */ - public String getTransferType() - { - return transferType; - } - - /** - * Checks whether this is an attended transfer or not. - * - * @return true if this is an attended transfer, false if not. - */ - public boolean isAttended() - { - return TRANSFER_TYPE_ATTENDED.equals(transferType); - } - - /** - * Checks whether this is a blind transfer or not. - * - * @return true if this is an blind transfer, false if not. - */ - public boolean isBlind() - { - return TRANSFER_TYPE_BLIND.equals(transferType); - } - - public void setTransferType(String transferType) - { - this.transferType = transferType; - } - - /** - * Returns the SIP call id. - * - * @return the SIP call id. - */ - public String getSipCallId() - { - return sipCallId; - } - - public void setSipCallId(String sipCallId) - { - this.sipCallId = sipCallId; - } - - /** - * Returns the name of the target channel. - * - * @return the name of the target channel. - */ - public String getTargetChannel() - { - return targetChannel; - } - - public void setTargetChannel(String targetChannel) - { - this.targetChannel = targetChannel; - } - - /** - * Returns the unique id of the target channel. - * - * @return the unique id of the target channel. - */ - public String getTargetUniqueId() - { - return targetUniqueId; - } - - public void setTargetUniqueId(String targetUniqueId) - { - this.targetUniqueId = targetUniqueId; - } - - /** - * Returns the target extension the call is transfered to. This is only available for - * blind transfers. If the call is transfered to a parking extension, the parking extension - * is returned. - * - * @return the target extension the call is transfered to or null for attended - * transfers. - */ - public String getTransferExten() - { - return transferExten; - } - - public void setTransferExten(String transferExten) - { - this.transferExten = transferExten; - } - - /** - * Returns the target context (in the dialplan) the call is transfered to. This is only available for - * blind transfers. If the call is transfered to a parking extension null is returned. - * - * @return the target context the call is transfered to or null for attended - * transfers and transfers to a parking extension. - */ - public String getTransferContext() - { - return transferContext; - } - - public void setTransferContext(String transferContext) - { - this.transferContext = transferContext; - } - - /** - * Returns whether this is a transfer to a parking extension. - * - * @return Boolean.TRUE if this is a transfer to a parking extension, null otherwise. - */ - public Boolean getTransfer2Parking() - { - return transfer2Parking; - } - - public void setTransfer2Parking(Boolean transfer2Parking) - { - this.transfer2Parking = transfer2Parking; - } - - /** - * Convenience method to check if this is a transfer to a parking extension. - * - * @return true if this is a transfer to a parking extension, false otherwise. - */ - public boolean isParking() - { - return transfer2Parking != null && transfer2Parking; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/UnholdEvent.java b/src/main/java/org/asteriskjava/manager/event/UnholdEvent.java deleted file mode 100644 index dbfce1eca..000000000 --- a/src/main/java/org/asteriskjava/manager/event/UnholdEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An UnholdEvent is triggered by the SIP channel driver when a channel is no - * longer put on hold. - *

- * It is implemented in channels/chan_sip.c. - *

- * Available since Asterisk 1.2, as of Asterisk 1.6 only - * {@link org.asteriskjava.manager.event.HoldEvent} is sent with the status set - * to false to indicate unhold. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.HoldEvent - * @since 0.2 Enro 2015-03: No longer deprecated since Asterisk 13 uses this - * again. - */ -public class UnholdEvent extends AbstractHoldEvent -{ - /** - * Serializable version identifier. - */ - static final long serialVersionUID = 1L; - - - /** - * Creates a new UnholdEvent. - * - * @param source - */ - public UnholdEvent(Object source) - { - super(source); - setStatus(false); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/UnlinkEvent.java b/src/main/java/org/asteriskjava/manager/event/UnlinkEvent.java deleted file mode 100644 index 5a53f0e4c..000000000 --- a/src/main/java/org/asteriskjava/manager/event/UnlinkEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * An UnlinkEvent is triggered when a link between two voice channels is discontinued, for example, - * just before call completion.

- * It is implemented in channel.c - * - * @author srt - * @version $Id$ - * @deprecated as of 1.0.0, use {@link org.asteriskjava.manager.event.BridgeEvent} and - * {@link BridgeEvent#isUnlink()} instead - */ -@Deprecated public class UnlinkEvent extends BridgeEvent -{ - /** - * Serial version identifier. - */ - static final long serialVersionUID = -2943257621137870024L; - - public UnlinkEvent(Object source) - { - super(source); - setBridgeState(BRIDGE_STATE_UNLINK); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/UnparkedCallEvent.java b/src/main/java/org/asteriskjava/manager/event/UnparkedCallEvent.java deleted file mode 100644 index f8fa999a9..000000000 --- a/src/main/java/org/asteriskjava/manager/event/UnparkedCallEvent.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A UnparkedCallEvent is triggered when a channel that has been parked is - * resumed. - *

- * It is implemented in res/res_features.c - *

- * Available since Asterisk 1.2 - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class UnparkedCallEvent extends AbstractUnParkedEvent -{ - /** - * Serializable version identifier - */ - private static final long serialVersionUID = -7437833328723536814L; - - /** - * Enro 2015-03: Asterisk 13 Support - */ - private String RetrieverChannel; - private Integer RetrieverChannelState; - private String RetrieverChannelStateDesc; - private String RetrieverCallerIDNum; - private String RetrieverCallerIDName; - private String RetrieverConnectedLineNum; - private String RetrieverConnectedLineName; - private String RetrieverAccountCode; - private String RetrieverContext; - private String RetrieverExten; - private String RetrieverPriority; - private String RetrieverUniqueid; - - /** - * @param source - */ - public UnparkedCallEvent(Object source) - { - super(source); - } - - public String getRetrieverChannel() - { - return RetrieverChannel; - } - - public void setRetrieverChannel(String retrieverChannel) - { - RetrieverChannel = retrieverChannel; - } - - public Integer getRetrieverChannelState() - { - return RetrieverChannelState; - } - - public void setRetrieverChannelState(Integer retrieverChannelState) - { - RetrieverChannelState = retrieverChannelState; - } - - public String getRetrieverChannelStateDesc() - { - return RetrieverChannelStateDesc; - } - - public void setRetrieverChannelStateDesc(String retrieverChannelStateDesc) - { - RetrieverChannelStateDesc = retrieverChannelStateDesc; - } - - public String getRetrieverCallerIDNum() - { - return RetrieverCallerIDNum; - } - - public void setRetrieverCallerIDNum(String retrieverCallerIDNum) - { - RetrieverCallerIDNum = retrieverCallerIDNum; - } - - public String getRetrieverCallerIDName() - { - return RetrieverCallerIDName; - } - - public void setRetrieverCallerIDName(String retrieverCallerIDName) - { - RetrieverCallerIDName = retrieverCallerIDName; - } - - public String getRetrieverConnectedLineNum() - { - return RetrieverConnectedLineNum; - } - - public void setRetrieverConnectedLineNum(String retrieverConnectedLineNum) - { - RetrieverConnectedLineNum = retrieverConnectedLineNum; - } - - public String getRetrieverConnectedLineName() - { - return RetrieverConnectedLineName; - } - - public void setRetrieverConnectedLineName(String retrieverConnectedLineName) - { - RetrieverConnectedLineName = retrieverConnectedLineName; - } - - public String getRetrieverAccountCode() - { - return RetrieverAccountCode; - } - - public void setRetrieverAccountCode(String retrieverAccountCode) - { - RetrieverAccountCode = retrieverAccountCode; - } - - public String getRetrieverContext() - { - return RetrieverContext; - } - - public void setRetrieverContext(String retrieverContext) - { - RetrieverContext = retrieverContext; - } - - public String getRetrieverExten() - { - return RetrieverExten; - } - - public void setRetrieverExten(String retrieverExten) - { - RetrieverExten = retrieverExten; - } - - public String getRetrieverPriority() - { - return RetrieverPriority; - } - - public void setRetrieverPriority(String retrieverPriority) - { - RetrieverPriority = retrieverPriority; - } - - public String getRetrieverUniqueid() - { - return RetrieverUniqueid; - } - - public void setRetrieverUniqueid(String retrieverUniqueid) - { - RetrieverUniqueid = retrieverUniqueid; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/UnpausedEvent.java b/src/main/java/org/asteriskjava/manager/event/UnpausedEvent.java deleted file mode 100644 index 76ea9fe00..000000000 --- a/src/main/java/org/asteriskjava/manager/event/UnpausedEvent.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.asteriskjava.manager.event; - -public class UnpausedEvent extends UserEvent { - - public UnpausedEvent(Object source) { - super(source); - } - - /** - * - */ - private static final long serialVersionUID = 4175034098824101733L; - - private String header; - - private String extension; - - public String getHeader() { - return header; - } - - public void setHeader(String header) { - this.header = header; - } - - public String getExtension() { - return extension; - } - - public void setExtension(String extension) { - this.extension = extension; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/UserEvent.java b/src/main/java/org/asteriskjava/manager/event/UserEvent.java deleted file mode 100644 index 153a82496..000000000 --- a/src/main/java/org/asteriskjava/manager/event/UserEvent.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * Abstract base class for user events. - *

- * You can send arbitrary user events via the UserEvent application provided - * with asterisk. A user event by default has the attributes channel and - * uniqueId but you can add custom attributes by specifying an event body. - *

- * To add your own user events you must subclass this class and name it - * corresponding to your event. If you plan to send an event by - * UserEvent(VIPCall) you will create a new class called - * VIPCallEvent that extends UserEvent. The name of this class is important: - * Just use the name of the event you will send (VIPCall in this example) and - * append "Event". - *

- * To pass additional data create appropriate attributes with getter and setter - * methods in your new class. - *

- * Example: - * - *

- * public class VIPCallEvent extends UserEvent
- * {
- *     private String firstName;
- * 
- *     public VIPCallEvent(Object source)
- *     {
- *         super(source);
- *     }
- * 
- *     public String getFirstName()
- *     {
- *         return firstName;
- *     }
- * 
- *     public void setFirstName(String firstName)
- *     {
- *         this.firstName = firstName;
- *     }
- * }
- * 
- * - * To send this event use UserEvent(VIPCall|firstName: Jon) in your - * dialplan. Asterisk up to 1.2 (including) does only support one property in - * the UserEvent so something like - * UserEvent(VIPCall|firstName: Jon|lastName: Doe) will not work as - * expected. - *

- * The UserEvent is implemented in apps/app_userevent.c. - *

- * Note that you must register your UserEvent with the ManagerConnection you are - * using in order to be recognized. - * - * @see org.asteriskjava.manager.ManagerConnection#registerUserEventClass(Class) - * @author srt - * @version $Id$ - */ -public abstract class UserEvent extends ManagerEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 3256725065466000695L; - - /** - * The name of the channel. - */ - private String channel; - - /** - * The unique id of the channel. - */ - private String uniqueId; - - public UserEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel this event occured in. - * - * @return the name of the channel this event occured in. - */ - public String getChannel() - { - return channel; - } - - /** - * Sets the name of the channel this event occured in. - * - * @param channel the name of the channel this event occured in. - */ - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unqiue id of the channel this event occured in. - * - * @return the unqiue id of the channel this event occured in. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unqiue id of the channel this event occured in. - * - * @param uniqueId the unqiue id of the channel this event occured in. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/VarSetEvent.java b/src/main/java/org/asteriskjava/manager/event/VarSetEvent.java deleted file mode 100644 index 3b5feda69..000000000 --- a/src/main/java/org/asteriskjava/manager/event/VarSetEvent.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A VarSetEvent is triggered when a channel or global variable is set in - * Asterisk. - *

- * Available since Asterisk 1.6 - *

- * It is implemented in main/pbx.c - * - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class VarSetEvent extends ManagerEvent -{ - static final long serialVersionUID = 1L; - - private String channel; - private String uniqueId; - private String variable; - private String value; - private String language; - private String linkedId; - private String accountCode; - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public VarSetEvent(Object source) - { - super(source); - } - - /** - * Returns the name of the channel or null for global - * variables. - * - * @return the name of the channel or null for global - * variables. - */ - public String getChannel() - { - return channel; - } - - public void setChannel(String channel) - { - this.channel = channel; - } - - /** - * Returns the unique id of the channel or null for global - * variables. - * - * @return the unique id of the channel or null for global - * variables. - */ - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the name of the variable that has been set. - * - * @return the name of the variable that has been set. - */ - public String getVariable() - { - return variable; - } - - public void setVariable(String variable) - { - this.variable = variable; - } - - /** - * Returns the new value of the variable. - * - * @return the new value of the variable. - */ - public String getValue() - { - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - public String getLinkedId() - { - return linkedId; - } - - public void setLinkedId(String linkedId) - { - this.linkedId = linkedId; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/event/VoicemailUserEntryCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/VoicemailUserEntryCompleteEvent.java deleted file mode 100644 index 46039db1a..000000000 --- a/src/main/java/org/asteriskjava/manager/event/VoicemailUserEntryCompleteEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A VoicemailUserEntryCompleteEvent is triggered after the details of all voicemail users has - * been reported in response to a VoicemailUsersListAction.

- * It is implemented in apps/app_voicemail.c - *

- * Available since Asterisk 1.6 - * - * @see VoicemailUserEntryEvent - * @see org.asteriskjava.manager.action.VoicemailUsersListAction - * @author srt - * @version $Id$ - * @since 1.0.0 - */ -public class VoicemailUserEntryCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** - * Creates a new instance. - * - * @param source - */ - public VoicemailUserEntryCompleteEvent(Object source) - { - super(source); - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/VoicemailUserEntryEvent.java b/src/main/java/org/asteriskjava/manager/event/VoicemailUserEntryEvent.java deleted file mode 100644 index ede012636..000000000 --- a/src/main/java/org/asteriskjava/manager/event/VoicemailUserEntryEvent.java +++ /dev/null @@ -1,531 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A VoicemailUserEntryCompleteEvent is triggered in response to a VoicemailUsersListAction - * and contains the details about a voicemail user.

- * It is implemented in apps/app_voicemail.c - *
- * Available since Asterisk 1.6 - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.VoicemailUserEntryCompleteEvent - * @see org.asteriskjava.manager.action.VoicemailUsersListAction - * @since 1.0.0 - */ -public class VoicemailUserEntryEvent extends ResponseEvent -{ - /** - * Serial version identifier. - */ - private static final long serialVersionUID = 0L; - private String vmContext; - private String voicemailbox; - private String fullname; - private String email; - private String pager; - private String serverEmail; - private String mailCommand; - private String language; - private String timezone; - private String callback; - private String dialout; - private String uniqueId; // only for realtime? - private String exitContext; - private Integer sayDurationMinimum; - private Boolean sayEnvelope; - private Boolean sayCid; - private Boolean attachMessage; - private String attachmentFormat; - private Boolean deleteMessage; - private Double volumeGain; - private Boolean canReview; - private Boolean callOperator; - private Integer maxMessageCount; - private Integer maxMessageLength; - private Integer newMessageCount; - - // only if compiled with imap storage - private Integer oldMessageCount; - private String imapUser; - - /** - * Creates a new instance. - * - * @param source - */ - public VoicemailUserEntryEvent(Object source) - { - super(source); - } - - /** - * Returns the voicemail context. - * - * @return the voicemail context. - */ - public String getVmContext() - { - return vmContext; - } - - /** - * Sets the voicemail context. - * - * @param vmContext the voicemail context. - */ - public void setVmContext(String vmContext) - { - this.vmContext = vmContext; - } - - /** - * Returns the mailbox id. The mailbox is unique within the voicemail context. - * - * @return the mailbox id. - */ - public String getVoicemailbox() - { - return voicemailbox; - } - - /** - * Sets the mailbox id. - * - * @param voicemailbox the mailbox id. - */ - public void setVoicemailbox(String voicemailbox) - { - this.voicemailbox = voicemailbox; - } - - /** - * Returns the full name of the voicemail user that is used for the directory application. - * - * @return the full name of the voicemail user. - */ - public String getFullname() - { - return fullname; - } - - /** - * Sets the full name of the voicemail user. - * - * @param fullname the full name of the voicemail user. - */ - public void setFullname(String fullname) - { - this.fullname = fullname; - } - - /** - * Returns the email address of the voicemail user. - * - * @return the email address of the voicemail user. - */ - public String getEmail() - { - return email; - } - - /** - * Sets the email address of the voicemail user. - * - * @param email the email address of the voicemail user. - */ - public void setEmail(String email) - { - this.email = email; - } - - /** - * Returns the email adress of pager of the voicemail user. - * This email will not receive attachments. - * - * @return the email adress of pager of the voicemail user. - */ - public String getPager() - { - return pager; - } - - /** - * Sets the email adress of pager of the voicemail user. - * - * @param pager the email adress of pager of the voicemail user. - */ - public void setPager(String pager) - { - this.pager = pager; - } - - /** - * Returns the email address used for the "from" header when sending notification emails. - * - * @return the email address used for the "from" header when sending notification emails. - */ - public String getServerEmail() - { - return serverEmail; - } - - /** - * Sets the email address used for the "from" header when sending notification emails. - * - * @param serverEmail the email address used for the "from" header when sending notification emails. - */ - public void setServerEmail(String serverEmail) - { - this.serverEmail = serverEmail; - } - - /** - * Returns the custom mail command used to send notifications to the voicemail user. - * - * @return the custom mail command used to send notifications to the voicemail user. - */ - public String getMailCommand() - { - return mailCommand; - } - - /** - * Sets the custom mail command used to send notifications to the voicemail user. - * - * @param mailCommand the custom mail command used to send notifications to the voicemail user. - */ - public void setMailCommand(String mailCommand) - { - this.mailCommand = mailCommand; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getTimezone() - { - return timezone; - } - - public void setTimezone(String timezone) - { - this.timezone = timezone; - } - - /** - * Returns the dialplan context used by the "return phone call" feature in the advanced - * voicemail features menu. - * - * @return the dialplan context used by the "return phone call" feature in the advanced - * voicemail features menu. - */ - public String getCallback() - { - return callback; - } - - /** - * Sets the dialplan context used by the "return phone call" feature in the advanced - * voicemail features menu. - * - * @param callback the dialplan context used by the "return phone call" feature in the advanced - * voicemail features menu. - */ - public void setCallback(String callback) - { - this.callback = callback; - } - - /** - * Returns the dialplan context used by the "place an outgoing call" feature in the advanced - * voicemail features menu. - * - * @return the dialplan context used by the "place an outgoing call" feature in the advanced - * voicemail features menu. - */ - public String getDialout() - { - return dialout; - } - - /** - * Sets the dialplan context used by the "place an outgoing call" feature in the advanced - * voicemail features menu. - * - * @param dialout the dialplan context used by the "place an outgoing call" feature in the advanced - * voicemail features menu. - */ - public void setDialout(String dialout) - { - this.dialout = dialout; - } - - public String getUniqueId() - { - return uniqueId; - } - - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - /** - * Returns the dialplan context the user is dropped into after he has pressed * or 0 to exit voicemail. - * - * @return the dialplan context the user is dropped into after he has pressed * or 0 to exit voicemail. - */ - public String getExitContext() - { - return exitContext; - } - - /** - * Sets the dialplan context the user is dropped into after he has pressed * or 0 to exit voicemail. - * - * @param exitContext the dialplan context the user is dropped into after he has pressed * or 0 to exit voicemail. - */ - public void setExitContext(String exitContext) - { - this.exitContext = exitContext; - } - - public Integer getSayDurationMinimum() - { - return sayDurationMinimum; - } - - public void setSayDurationMinimum(Integer sayDurationMinimum) - { - this.sayDurationMinimum = sayDurationMinimum; - } - - public Boolean getSayEnvelope() - { - return sayEnvelope; - } - - public void setSayEnvelope(Boolean sayEnvelope) - { - this.sayEnvelope = sayEnvelope; - } - - public Boolean getSayCid() - { - return sayCid; - } - - public void setSayCid(Boolean sayCid) - { - this.sayCid = sayCid; - } - - /** - * Returns whether Asterisk copies a voicemail message to an audio file and sends it to the user as an - * attachment in an eemail voicemail notification message. - * - * @return Booelan.TRUE if message will be attached, Boolean.FALSE if not, null if unset. - */ - public Boolean getAttachMessage() - { - return attachMessage; - } - - /** - * Sets whether Asterisk copies a voicemail message to an audio file and sends it to the user as an - * attachment in an eemail voicemail notification message. - * - * @param attachMessage Booelan.TRUE if message will be attached, Boolean.FALSE if not, null if unset. - */ - public void setAttachMessage(Boolean attachMessage) - { - this.attachMessage = attachMessage; - } - - public String getAttachmentFormat() - { - return attachmentFormat; - } - - public void setAttachmentFormat(String attachmentFormat) - { - this.attachmentFormat = attachmentFormat; - } - - /** - * Returns whether messages will be deleted from the voicemailbox (after having been emailed). - * - * @return Booelan.TRUE if messages will be deleted from the voicemailbox, Boolean.FALSE if not, - * null if unset. - */ - public Boolean getDeleteMessage() - { - return deleteMessage; - } - - /** - * Sets whether messages will be deleted from the voicemailbox (after having been emailed). - * - * @param deleteMessage Booelan.TRUE if messages will be deleted from the voicemailbox, Boolean.FALSE if not. - */ - public void setDeleteMessage(Boolean deleteMessage) - { - this.deleteMessage = deleteMessage; - } - - /** - * Returns the volume gain used for voicemails sent via email. - * - * @return the volume gain used for voicemails sent via email. - */ - public Double getVolumeGain() - { - return volumeGain; - } - - /** - * Sets the volume gain used for voicemails sent via email. - * - * @param volumeGain the volume gain used for voicemails sent via email. - */ - public void setVolumeGain(Double volumeGain) - { - this.volumeGain = volumeGain; - } - - public Boolean getCanReview() - { - return canReview; - } - - public void setCanReview(Boolean canReview) - { - this.canReview = canReview; - } - - public Boolean getCallOperator() - { - return callOperator; - } - - public void setCallOperator(Boolean callOperator) - { - this.callOperator = callOperator; - } - - /** - * Returns the maximum number of messages per folder. 0 indicated unlimited. - * - * @return the maximum number of messages per folder or 0 for unlimited. - */ - public Integer getMaxMessageCount() - { - return maxMessageCount; - } - - /** - * Sets the maximum number of messages per folder. - * - * @param maxMessageCount the maximum number of messages per folder. - */ - public void setMaxMessageCount(Integer maxMessageCount) - { - this.maxMessageCount = maxMessageCount; - } - - /** - * Returns the maximum duration per message for voicemails in this mailbox. - * - * @return the maximum duration in seconds. - */ - public Integer getMaxMessageLength() - { - return maxMessageLength; - } - - /** - * Returns the maximum duration per message for voicemails in this mailbox. - * - * @param maxMessageLength the maximum duration in seconds. - */ - public void setMaxMessageLength(Integer maxMessageLength) - { - this.maxMessageLength = maxMessageLength; - } - - public Integer getNewMessageCount() - { - return newMessageCount; - } - - public void setNewMessageCount(Integer newMessageCount) - { - this.newMessageCount = newMessageCount; - } - - /** - * Returns the number of old ("read" or listened to) messages for this voicemail user.

- * This property is only available if the IMAP storage backend is used. - * - * @return the number of old messages for this voicemail user. - */ - public Integer getOldMessageCount() - { - return oldMessageCount; - } - - /** - * Sets the number of old messages for this voicemail user. - * - * @param oldMessageCount the number of old messages for this voicemail user. - */ - public void setOldMessageCount(Integer oldMessageCount) - { - this.oldMessageCount = oldMessageCount; - } - - /** - * Returns the username of the IMAP account associated with this mailbox.

- * This property is only available if the IMAP storage backend is used. - * - * @return the username of the IMAP account associated with this mailbox. - */ - public String getImapUser() - { - return imapUser; - } - - /** - * Sets the username of the IMAP account associated with this mailbox. - * - * @param imapUser the username of the IMAP account associated with this mailbox. - */ - public void setImapUser(String imapUser) - { - this.imapUser = imapUser; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/event/ZapShowChannelsCompleteEvent.java b/src/main/java/org/asteriskjava/manager/event/ZapShowChannelsCompleteEvent.java deleted file mode 100644 index fef123bf9..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ZapShowChannelsCompleteEvent.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ZapShowChannelsCompleteEvent is triggered after the state of all zap channels has been reported - * in response to a ZapShowChannelsAction. - * - * @see org.asteriskjava.manager.action.ZapShowChannelsAction - * @see org.asteriskjava.manager.event.ZapShowChannelsEvent - * - * @author srt - * @version $Id$ - */ -public class ZapShowChannelsCompleteEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 6323249250335886462L; - - /** - * @param source - */ - public ZapShowChannelsCompleteEvent(Object source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/ZapShowChannelsEvent.java b/src/main/java/org/asteriskjava/manager/event/ZapShowChannelsEvent.java deleted file mode 100644 index 062e1b391..000000000 --- a/src/main/java/org/asteriskjava/manager/event/ZapShowChannelsEvent.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.event; - -/** - * A ZapShowChannelsEvent is triggered in response to a ZapShowChannelsAction - * and shows the state of a zap channel. - * - * @see org.asteriskjava.manager.action.ZapShowChannelsAction - * @author srt - * @version $Id$ - */ -public class ZapShowChannelsEvent extends ResponseEvent -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -3613642267527361400L; - private Integer channel; - private String signalling; - // private String context; - private Boolean dnd; - private String alarm; - - /** - * @param source - */ - public ZapShowChannelsEvent(Object source) - { - super(source); - } - - /** - * Returns the number of this zap channel. - */ - public Integer getChannel() - { - return channel; - } - - /** - * Sets the number of this zap channel. - */ - public void setChannel(Integer channel) - { - this.channel = channel; - } - - /** - * Returns the signalling of this zap channel. - *

- * Possible values are: - *

    - *
  • E & M Immediate
  • - *
  • E & M Wink
  • - *
  • E & M E1
  • - *
  • Feature Group D (DTMF)
  • - *
  • Feature Group D (MF)
  • - *
  • Feature Group B (MF)
  • - *
  • E911 (MF)
  • - *
  • FXS Loopstart
  • - *
  • FXS Groundstart
  • - *
  • FXS Kewlstart
  • - *
  • FXO Loopstart
  • - *
  • FXO Groundstart
  • - *
  • FXO Kewlstart
  • - *
  • PRI Signalling
  • - *
  • R2 Signalling
  • - *
  • SF (Tone) Signalling Immediate
  • - *
  • SF (Tone) Signalling Wink
  • - *
  • SF (Tone) Signalling with Feature Group D (DTMF)
  • - *
  • SF (Tone) Signalling with Feature Group D (MF)
  • - *
  • SF (Tone) Signalling with Feature Group B (MF)
  • - *
  • GR-303 Signalling with FXOKS
  • - *
  • GR-303 Signalling with FXSKS
  • - *
  • Pseudo Signalling
  • - *
- */ - public String getSignalling() - { - return signalling; - } - - /** - * Sets the signalling of this zap channel. - */ - public void setSignalling(String signalling) - { - this.signalling = signalling; - } - - /** - * Returns whether dnd (do not disturb) is enabled for this zap channel. - * - * @return Boolean.TRUE if dnd is enabled, Boolean.FALSE if it is disabled, - * null if not set. - * @since 0.3 - */ - public Boolean getDnd() - { - return dnd; - } - - /** - * Sets whether dnd (do not disturb) is enabled for this zap channel. - * - * @param dnd Boolean.TRUE if dnd is enabled, Boolean.FALSE if it is - * disabled. - * @since 0.3 - */ - public void setDnd(Boolean dnd) - { - this.dnd = dnd; - } - - /** - * Returns the alarm state of this zap channel. - *

- * This may be one of - *

    - *
  • Red Alarm
  • - *
  • Yellow Alarm
  • - *
  • Blue Alarm
  • - *
  • Recovering
  • - *
  • Loopback
  • - *
  • Not Open
  • - *
  • No Alarm
  • - *
- */ - public String getAlarm() - { - return alarm; - } - - /** - * Sets the alarm state of this zap channel. - */ - public void setAlarm(String alarm) - { - this.alarm = alarm; - } -} diff --git a/src/main/java/org/asteriskjava/manager/event/package.html b/src/main/java/org/asteriskjava/manager/event/package.html deleted file mode 100644 index d6d1dcb81..000000000 --- a/src/main/java/org/asteriskjava/manager/event/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides classes that represent the standard events that can be received - from an Asterisk server via the Manager API.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/internal/.gitignore b/src/main/java/org/asteriskjava/manager/internal/.gitignore deleted file mode 100644 index f04e334d4..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/AbstractBuilder.class -/ActionBuilder.class -/ActionBuilderImpl.class -/Dispatcher.class -/EventBuilder.class -/EventBuilderImpl.class -/ManagerConnectionImpl$1.class -/ManagerConnectionImpl$DefaultSendActionCallback.class -/ManagerConnectionImpl$ProtocolIdentifierWrapper.class -/ManagerConnectionImpl$ResponseEventHandler.class -/ManagerConnectionImpl$ResponseHandlerResult.class -/ManagerConnectionImpl.class -/ManagerReader.class -/ManagerReaderImpl.class -/ManagerUtil.class -/ManagerWriter.class -/ManagerWriterImpl.class -/ResponseBuilder.class -/ResponseBuilderImpl.class -/ResponseEventsImpl.class diff --git a/src/main/java/org/asteriskjava/manager/internal/AbstractBuilder.java b/src/main/java/org/asteriskjava/manager/internal/AbstractBuilder.java deleted file mode 100644 index 8dd944a21..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/AbstractBuilder.java +++ /dev/null @@ -1,185 +0,0 @@ -package org.asteriskjava.manager.internal; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.asteriskjava.manager.event.UserEvent; -import org.asteriskjava.util.AstUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; -import org.asteriskjava.util.ReflectionUtil; - -/** - * Abstract base class for reflection based builders. - */ -abstract class AbstractBuilder -{ - protected final Log logger = LogFactory.getLog(getClass()); - - @SuppressWarnings("unchecked") - protected void setAttributes(Object target, Map attributes, Set ignoredAttributes) - { - Map setters; - - setters = ReflectionUtil.getSetters(target.getClass()); - for (Map.Entry entry : attributes.entrySet()) - { - Object value; - final Class< ? > dataType; - Method setter; - String setterName; - - if (ignoredAttributes != null && ignoredAttributes.contains(entry.getKey())) - { - continue; - } - - setterName = ReflectionUtil.stripIllegalCharacters(entry.getKey()); - - /* - * The source property needs special handling as it is already - * defined in java.util.EventObject (the base class of - * ManagerEvent), so we have to translate it. - */ - if ("source".equals(setterName)) - { - setterName = "src"; - } - else if ("class".equals(setterName)) - { - setterName = "clazz"; - } - - /* - * The class property needs to be renamed. It is used in - * MusicOnHoldEvent. - */ - if ("class".equals(setterName)) - { - setterName = "classname"; - } - - setter = setters.get(setterName); - - if (setter == null && !setterName.endsWith("s")) // no exact match - // => try plural - { - setter = setters.get(setterName + "s"); - // but only for maps - if (setter != null && !(setter.getParameterTypes()[0].isAssignableFrom(Map.class))) - { - setter = null; - } - } - - // it seems silly to warn if it's a user event -- maybe it was - // intentional - if (setter == null && !(target instanceof UserEvent)) - { - logger.warn("Unable to set property '" + entry.getKey() + "' to '" + entry.getValue() + "' on " - + target.getClass().getName() - + ": no setter. Please report at https://github.com/asterisk-java/asterisk-java/issues"); - } - - if (setter == null) - { - continue; - } - - dataType = setter.getParameterTypes()[0]; - - if (dataType == Boolean.class) - { - value = AstUtil.isTrue(entry.getValue()); - } - else if (dataType.isAssignableFrom(String.class)) - { - value = entry.getValue(); - if (AstUtil.isNull(value)) - { - - value = null; - } - if(value instanceof List){ - StringBuffer strBuff = new StringBuffer(); - for(String tmp : (List)value){ - if(tmp != null && tmp.length() != 0){ - strBuff.append(tmp + "\n"); - } - } - value = strBuff.toString(); - } - } - else if (dataType.isAssignableFrom(Map.class)) - { - if (entry.getValue() instanceof List) - { - List list = (List) entry.getValue(); - value = buildMap(list.toArray(new String[list.size()])); - } - else if (entry.getValue() instanceof String) - { - value = buildMap((String) entry.getValue()); - } - else - { - value = null; - } - } - else - { - try - { - Constructor< ? > constructor = dataType.getConstructor(new Class[]{String.class}); - value = constructor.newInstance(entry.getValue()); - } - catch (Exception e) - { - logger.error("Unable to convert value: Called the constructor of " + dataType + " with value '" - + entry.getValue() + "' for the attribute '" + entry.getKey() + "'\n of event type " - + target.getClass().getName() + " with resulting error: " + e.getMessage(), e); - continue; - } - } - - try - { - setter.invoke(target, value); - } - catch (Exception e) - { - logger.error("Unable to set property '" + entry.getKey() + "' to '" + entry.getValue() + "' on " - + target.getClass().getName(), e); - } - } - } - - private Map buildMap(String... lines) - { - if (lines == null) - { - return null; - } - - final Map map = new LinkedHashMap<>(); - for (String line : lines) - { - final int index = line.indexOf('='); - if (index > 0) - { - final String key = line.substring(0, index); - final String value = line.substring(index + 1, line.length()); - map.put(key, value); - } - else - { - logger.warn("Malformed line '" + line + "' for a map property"); - } - } - return map; - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ActionBuilder.java b/src/main/java/org/asteriskjava/manager/internal/ActionBuilder.java deleted file mode 100644 index 09cc3d44f..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ActionBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.ManagerAction; - - -/** - * Transforms ManagerActions to Strings suitable to be sent to Asterisk.

- * The attributes are determined using reflection. - * - * @author srt - * @version $Id$ - */ -interface ActionBuilder -{ - /** - * Sets the version of the Asterisk server to built the action for. - * - * @param targetVersion the version of the target Asterisk server. - * @since 0.2 - */ - void setTargetVersion(AsteriskVersion targetVersion); - - /** - * Builds a String suitable to be sent to Asterisk based on the given action object.

- * Asterisk actions consist of an unordered set of key value pairs corresponding to the - * attributes of the ManagerActions. Key and value are separated by a colon (":"), key value - * pairs by a CR/NL ("\r\n"). An action is terminated by an empty line ("\r\n\r\n"). - * - * @param action the action to transform - * @return a String representing the given action in an asterisk compatible format - */ - String buildAction(final ManagerAction action); - - /** - * Builds a String suitable to be sent to Asterisk based on the given action object.

- * Asterisk actions consist of an unordered set of key value pairs corresponding to the - * attributes of the ManagerActions. Key and value are separated by a colon (":"), key value - * pairs by a CR/NL ("\r\n"). An action is terminated by an empty line ("\r\n\r\n"). - * - * @param action the action to transform - * @param internalActionId the internal action id to add - * @return a String representing the given action in an asterisk compatible format - */ - String buildAction(final ManagerAction action, final String internalActionId); -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ActionBuilderImpl.java b/src/main/java/org/asteriskjava/manager/internal/ActionBuilderImpl.java deleted file mode 100644 index e4423b4b5..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ActionBuilderImpl.java +++ /dev/null @@ -1,416 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.AsteriskMapping; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.action.UserEventAction; -import org.asteriskjava.manager.event.UserEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; -import org.asteriskjava.util.ReflectionUtil; - -/** - * Default implementation of the ActionBuilder interface. - * - * @author srt - * @version $Id$ - */ -class ActionBuilderImpl implements ActionBuilder -{ - - private static final String LINE_SEPARATOR = "\r\n"; - private static final String ATTRIBUTES_PROPERTY_NAME = "attributes"; - - /** - * Instance logger. - */ - private final Log logger = LogFactory.getLog(getClass()); - private AsteriskVersion targetVersion; - private final Set membersToIgnore = new HashSet<>(); - - /** - * Creates a new ActionBuilder for Asterisk 1.0. - */ - ActionBuilderImpl() - { - this.targetVersion = AsteriskVersion.ASTERISK_1_0; - - /* - * When using the Reflection API to get all of the getters for building - * actions to send, we ignore some of the getters - */ - this.membersToIgnore.add("class"); - this.membersToIgnore.add("action"); - this.membersToIgnore.add("actionid"); - this.membersToIgnore.add(ATTRIBUTES_PROPERTY_NAME); - } - - public void setTargetVersion(AsteriskVersion targetVersion) - { - this.targetVersion = targetVersion; - } - - public String buildAction(final ManagerAction action) - { - return buildAction(action, null); - } - - @SuppressWarnings("unchecked") - public String buildAction(final ManagerAction action, final String internalActionId) - { - StringBuilder sb = new StringBuilder(); - - sb.append("action: "); - sb.append(action.getAction()); - sb.append(LINE_SEPARATOR); - if (internalActionId != null) - { - sb.append("actionid: "); - sb.append(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId)); - sb.append(LINE_SEPARATOR); - } - else if (action.getActionId() != null) - { - sb.append("actionid: "); - sb.append(action.getActionId()); - sb.append(LINE_SEPARATOR); - } - - Map getters; - - // if this is a user event action, we need to grab the internal event, - // otherwise do below as normal - if (action instanceof UserEventAction) - { - UserEvent userEvent = ((UserEventAction) action).getUserEvent(); - appendUserEvent(sb, userEvent); - - getters = ReflectionUtil.getGetters(userEvent.getClass()); - - // eventually we may want to add more Map keys for events to ignore - // when appending - appendGetters(sb, userEvent, getters); - } - else - { - getters = ReflectionUtil.getGetters(action.getClass()); - - appendGetters(sb, action, getters); - } - - // actions that have the special getAttributes method will - // have their Map appended without a singular key or separator - if (getters.containsKey(ATTRIBUTES_PROPERTY_NAME)) - { - Method getter = getters.get(ATTRIBUTES_PROPERTY_NAME); - Object value = null; - try - { - value = getter.invoke(action); - } - catch (Exception ex) - { - logger.error("Unable to retrieve property '" + ATTRIBUTES_PROPERTY_NAME + "' of " + action.getClass(), ex); - } - - if (value instanceof Map) - { - Map attributes = (Map) value; - for (Map.Entry entry : attributes.entrySet()) - { - appendString(sb, entry.getKey() == null ? "null" : entry.getKey().toString(), - entry.getValue() == null ? "null" : entry.getValue().toString()); - } - } - } - - sb.append(LINE_SEPARATOR); - return sb.toString(); - } - - private void appendMap(StringBuilder sb, String key, Map values) - { - String singularKey; - - // strip plural s (i.e. use "variable: " instead of "variables: " - if (key.endsWith("s")) - { - singularKey = key.substring(0, key.length() - 1); - } - else - { - singularKey = key; - } - - if (targetVersion.isAtLeast(AsteriskVersion.ASTERISK_1_2)) - { - appendMap12(sb, singularKey, values); - } - else - { - appendMap10(sb, singularKey, values); - } - } - - private void appendMap10(StringBuilder sb, String singularKey, Map values) - { - Iterator> entryIterator; - - sb.append(singularKey); - sb.append(": "); - entryIterator = values.entrySet().iterator(); - while (entryIterator.hasNext()) - { - Map.Entry entry; - - entry = entryIterator.next(); - sb.append(entry.getKey()); - sb.append("="); - if (entry.getValue() != null) - { - sb.append(entry.getValue()); - } - - if (entryIterator.hasNext()) - { - sb.append("|"); - } - } - sb.append(LINE_SEPARATOR); - } - - private void appendMap12(StringBuilder sb, String singularKey, Map values) - { - for (Map.Entry entry : values.entrySet()) - { - sb.append(singularKey); - sb.append(": "); - sb.append(entry.getKey()); - sb.append("="); - if (entry.getValue() != null) - { - if (entry.getKey().equalsIgnoreCase("Content")) - { - String sp[] = entry.getValue().split("\n"); - if (sp.length > 0) - { - sb.append(sp[0]); - for (int i = 1; i < sp.length; i++) - { - sb.append(LINE_SEPARATOR); - sb.append(singularKey); - sb.append(": "); - sb.append(entry.getKey()); - sb.append("="); - sb.append(sp[i]); - } - } - - } - else - { - sb.append(entry.getValue()); - } - } - - sb.append(LINE_SEPARATOR); - } - } - - private void appendString(StringBuilder sb, String key, String value) - { - sb.append(key); - sb.append(": "); - sb.append(value); - sb.append(LINE_SEPARATOR); - } - - private void appendUserEvent(StringBuilder sb, UserEvent event) - { - Class clazz = event.getClass(); - - String className = clazz.getName(); - String eventType = className.substring(className.lastIndexOf('.') + 1).toLowerCase(Locale.ENGLISH); - - if (eventType.endsWith("event")) - { - eventType = eventType.substring(0, eventType.length() - "event".length()); - } - - appendString(sb, "UserEvent", eventType); - } - - @SuppressWarnings("unchecked") - private void appendGetters(StringBuilder sb, Object action, Map getters) - { - for (Map.Entry entry : getters.entrySet()) - { - final String name = entry.getKey(); - final Method getter = entry.getValue(); - final Object value; - - if (membersToIgnore.contains(name)) - { - continue; - } - - try - { - value = getter.invoke(action); - } - catch (Exception ex) - { - logger.error("Unable to retrieve property '" + name + "' of " + action.getClass(), ex); - continue; - } - - if (value == null || value instanceof Class) - { - continue; - } - - final String mappedName = mapToAsterisk(getter); - if (value instanceof Map) - { - appendMap(sb, mappedName, (Map) value); - } - else if (value instanceof String) - { - appendString(sb, mappedName, (String) value); - } - else - { - appendString(sb, mappedName, value.toString()); - } - } - } - - private static String mapToAsterisk(Method getter) - { - AsteriskMapping annotation; - - // check annotation of getter method - annotation - = getter.getAnnotation(AsteriskMapping.class - ); - if (annotation != null) - { - return annotation.value(); - } - - // check annotation of setter method - String setterName = determineSetterName(getter.getName()); - try - { - Method setter = getter.getDeclaringClass().getDeclaredMethod(setterName, getter.getReturnType()); - annotation - = setter.getAnnotation(AsteriskMapping.class - ); - if (annotation != null) - { - return annotation.value(); - } - } - catch (NoSuchMethodException e) - { - // ok, no setter method - } - - // check annotation of field - String fieldName = determineFieldName(getter.getName()); - try - { - Field field = getter.getDeclaringClass().getDeclaredField(fieldName); - annotation - = field.getAnnotation(AsteriskMapping.class - ); - if (annotation != null) - { - return annotation.value(); - } - } - catch (NoSuchFieldException e) - { - // ok, no field - } - - return fieldName.toLowerCase(Locale.US); - } - - static String determineSetterName(String getterName) - { - if (getterName.startsWith("get")) - { - return "set" + getterName.substring(3); - } - else if (getterName.startsWith("is")) - { - return "set" + getterName.substring(2); - } - else - { - throw new IllegalArgumentException("Getter '" + getterName + "' doesn't start with either 'get' or 'is'"); - } - } - - static String determineFieldName(String accessorName) - { - if (accessorName.startsWith("get")) - { - return lcFirst(accessorName.substring(3)); - } - else if (accessorName.startsWith("is")) - { - return lcFirst(accessorName.substring(2)); - } - else if (accessorName.startsWith("set")) - { - return lcFirst(accessorName.substring(3)); - } - else - { - throw new IllegalArgumentException("Accessor '" + accessorName + "' doesn't start with either 'get', 'is' or 'set'"); - } - } - - /** - * Converts the first character to lower case. - * - * @param s the string to convert. - * @return the converted string. - */ - private static String lcFirst(String s) - { - if (s == null || s.isEmpty()) - { - return s; - } - - return Character.toLowerCase(s.charAt(0)) - + (s.length() == 1 ? "" : s.substring(1)); - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/Dispatcher.java b/src/main/java/org/asteriskjava/manager/internal/Dispatcher.java deleted file mode 100644 index 89891efc5..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/Dispatcher.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.ManagerResponse; - - -/** - * The Dispatcher defines the interface used for communication between - * ManagerConnection and ManagerReader.

- * Do not use this interface in your code, it is intended to be used only by the - * DefaultManagerConnection and its ManagerReader. - * - * @author srt - * @version $Id$ - */ -interface Dispatcher -{ - /** - * This method is called by the reader whenever a {@link ManagerResponse} is - * received. The response is dispatched to the associated - * {@link org.asteriskjava.manager.SendActionCallback}. - * - * @param response the resonse received by the reader - * @see ManagerReader - */ - void dispatchResponse(ManagerResponse response); - - /** - * This method is called by the reader whenever a ManagerEvent is received. - * The event is dispatched to all registered ManagerEventHandlers. - * - * @param event the event received by the reader - * @see ManagerReader - */ - void dispatchEvent(ManagerEvent event); -} diff --git a/src/main/java/org/asteriskjava/manager/internal/EventBuilder.java b/src/main/java/org/asteriskjava/manager/internal/EventBuilder.java deleted file mode 100644 index 8f1bfdc50..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/EventBuilder.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.util.Map; - -import org.asteriskjava.manager.event.ManagerEvent; - -/** - * Transforms maps of attributes to instances of ManagerEvent. - * - * @see org.asteriskjava.manager.event.ManagerEvent - * @author srt - * @version $Id$ - */ -interface EventBuilder -{ - /** - * Registers a new event class. The event this class is registered for is - * simply derived from the name of the class by stripping any package name - * (if present) and stripping the sufffix "Event". For example - * org.asteriskjava.manager.event.JoinEvent is registered for - * the event "Join". - *

- * The event class must be a concrete class with a default constructor (one - * that takes no arguments). - * - * @param clazz the event class to register, must extend - * {@link ManagerEvent}. - * @throws IllegalArgumentException if clazz is not a valid event class - */ - void registerEventClass(Class< ? extends ManagerEvent> clazz) throws IllegalArgumentException; - - /** - * Builds the event based on the given map of attributes and the registered - * event classes. - * - * @param source source attribute for the event - * @param attributes map containing event attributes - * @return a concrete instance of ManagerEvent or null if no - * event class was registered for the event type. - */ - ManagerEvent buildEvent(Object source, Map attributes); - - void deregisterEventClass(Class< ? extends ManagerEvent> eventClass); -} diff --git a/src/main/java/org/asteriskjava/manager/internal/EventBuilderImpl.java b/src/main/java/org/asteriskjava/manager/internal/EventBuilderImpl.java deleted file mode 100644 index 51561966d..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/EventBuilderImpl.java +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.asteriskjava.manager.event.*; - -/** - * Default implementation of the EventBuilder interface. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.event.ManagerEvent - */ -class EventBuilderImpl extends AbstractBuilder implements EventBuilder -{ - private static final Set ignoredAttributes = new HashSet<>(Arrays.asList("event")); - private Map> registeredEventClasses; - - EventBuilderImpl() - { - this.registeredEventClasses = new HashMap<>(); - registerBuiltinEventClasses(); - } - - @SuppressWarnings({"deprecation"}) - private void registerBuiltinEventClasses() - { - // please add new event classes alphabetically - registerEventClass(AgentCallbackLoginEvent.class); - registerEventClass(AgentCallbackLogoffEvent.class); - registerEventClass(AgentCalledEvent.class); - registerEventClass(AgentConnectEvent.class); - registerEventClass(AgentCompleteEvent.class); - registerEventClass(AgentDumpEvent.class); - registerEventClass(AgentLoginEvent.class); - registerEventClass(AgentLogoffEvent.class); - registerEventClass(AgentRingNoAnswerEvent.class); - registerEventClass(AgentsEvent.class); - registerEventClass(AgentsCompleteEvent.class); - registerEventClass(AgiExecEndEvent.class); - registerEventClass(AgiExecEvent.class); - registerEventClass(AgiExecStartEvent.class); - registerEventClass(AntennaLevelEvent.class); - registerEventClass(AsyncAgiEvent.class); - registerEventClass(AsyncAgiEndEvent.class); - registerEventClass(AsyncAgiExecEvent.class); - registerEventClass(AsyncAgiStartEvent.class); - registerEventClass(AlarmEvent.class); - registerEventClass(AlarmClearEvent.class); - registerEventClass(BridgeCreateEvent.class); - registerEventClass(BridgeDestroyEvent.class); - registerEventClass(BridgeEnterEvent.class); - registerEventClass(BridgeEvent.class); - registerEventClass(BridgeExecEvent.class); - registerEventClass(BridgeLeaveEvent.class); - registerEventClass(BridgeMergeEvent.class); - registerEventClass(BlindTransferEvent.class); - registerEventClass(AttendedTransferEvent.class); - registerEventClass(CdrEvent.class); - registerEventClass(CelEvent.class); - registerEventClass(ChallengeSentEvent.class); - registerEventClass(ChannelReloadEvent.class); - registerEventClass(ChannelUpdateEvent.class); - registerEventClass(ChanSpyStartEvent.class); - registerEventClass(ChanSpyStopEvent.class); - registerEventClass(ConfbridgeEndEvent.class); - registerEventClass(ConfbridgeJoinEvent.class); - registerEventClass(ConfbridgeLeaveEvent.class); - registerEventClass(ConfbridgeListEvent.class); - registerEventClass(ConfbridgeListCompleteEvent.class); - registerEventClass(ConfbridgeListRoomsEvent.class); - registerEventClass(ConfbridgeListRoomsCompleteEvent.class); - registerEventClass(ConfbridgeStartEvent.class); - registerEventClass(ConfbridgeTalkingEvent.class); - registerEventClass(CoreShowChannelEvent.class); - registerEventClass(CoreShowChannelsCompleteEvent.class); - registerEventClass(DAHDIChannelEvent.class); - registerEventClass(DahdiShowChannelsEvent.class); - registerEventClass(DahdiShowChannelsCompleteEvent.class); - registerEventClass(DbGetResponseEvent.class); - registerEventClass(DeviceStateChangeEvent.class); - registerEventClass(DialBeginEvent.class); - registerEventClass(DialEndEvent.class); - registerEventClass(DialEvent.class); - registerEventClass(DndStateEvent.class); - registerEventClass(DongleNewSMSBase64Event.class); - registerEventClass(DongleCENDEvent.class); - registerEventClass(DongleCallStateChangeEvent.class); - registerEventClass(DongleNewSMSEvent.class); - registerEventClass(DongleNewCMGREvent.class); - registerEventClass(DongleStatusEvent.class); - registerEventClass(DongleDeviceEntryEvent.class); - registerEventClass(DongleShowDevicesCompleteEvent.class); - registerEventClass(DtmfBeginEvent.class); - registerEventClass(DtmfEndEvent.class); - registerEventClass(DtmfEvent.class); - registerEventClass(ExtensionStatusEvent.class); - registerEventClass(FaxDocumentStatusEvent.class); - registerEventClass(FaxReceivedEvent.class); - registerEventClass(FaxStatusEvent.class); - registerEventClass(FullyBootedEvent.class); - registerEventClass(HangupEvent.class); - registerEventClass(HangupRequestEvent.class); - registerEventClass(HoldedCallEvent.class); - registerEventClass(HoldEvent.class); - registerEventClass(InvalidPasswordEvent.class); - registerEventClass(JabberEventEvent.class); - registerEventClass(JitterBufStatsEvent.class); - registerEventClass(JoinEvent.class); - registerEventClass(LeaveEvent.class); - registerEventClass(LinkEvent.class); - registerEventClass(ListDialplanEvent.class); - registerEventClass(LocalBridgeEvent.class); - registerEventClass(LogChannelEvent.class); - registerEventClass(NewConnectedLineEvent.class); - registerEventClass(MasqueradeEvent.class); - registerEventClass(MeetMeEndEvent.class); - registerEventClass(MeetMeJoinEvent.class); - registerEventClass(MeetMeLeaveEvent.class); - registerEventClass(MeetMeMuteEvent.class); - registerEventClass(MeetMeTalkingEvent.class); - registerEventClass(MeetMeTalkingRequestEvent.class); - registerEventClass(MeetMeStopTalkingEvent.class); - registerEventClass(MessageWaitingEvent.class); - registerEventClass(ModuleLoadReportEvent.class); - registerEventClass(MonitorStartEvent.class); - registerEventClass(MonitorStopEvent.class); - registerEventClass(MusicOnHoldEvent.class); - registerEventClass(MusicOnHoldStartEvent.class); - registerEventClass(MusicOnHoldStopEvent.class); - registerEventClass(NewAccountCodeEvent.class); - registerEventClass(NewCallerIdEvent.class); - registerEventClass(NewChannelEvent.class); - registerEventClass(NewExtenEvent.class); - registerEventClass(NewStateEvent.class); - registerEventClass(OriginateFailureEvent.class); - registerEventClass(OriginateSuccessEvent.class); - registerEventClass(OriginateResponseEvent.class); - registerEventClass(ParkedCallGiveUpEvent.class); - registerEventClass(ParkedCallEvent.class); - registerEventClass(ParkedCallTimeOutEvent.class); - registerEventClass(ParkedCallsCompleteEvent.class); - registerEventClass(PausedEvent.class); - registerEventClass(PeerEntryEvent.class); - registerEventClass(PeerlistCompleteEvent.class); - registerEventClass(PeersEvent.class); - registerEventClass(PeerStatusEvent.class); - registerEventClass(PickupEvent.class); - registerEventClass(PriEventEvent.class); - registerEventClass(QueueCallerAbandonEvent.class); - registerEventClass(QueueCallerJoinEvent.class); - registerEventClass(QueueCallerLeaveEvent.class); - registerEventClass(QueueEntryEvent.class); - registerEventClass(QueueMemberAddedEvent.class); - registerEventClass(QueueMemberEvent.class); - registerEventClass(QueueMemberPausedEvent.class); - registerEventClass(QueueMemberPauseEvent.class); - registerEventClass(QueueMemberPenaltyEvent.class); - registerEventClass(QueueMemberRemovedEvent.class); - registerEventClass(QueueMemberStatusEvent.class); - registerEventClass(QueueParamsEvent.class); - registerEventClass(QueueStatusCompleteEvent.class); - registerEventClass(QueueSummaryCompleteEvent.class); - registerEventClass(QueueSummaryEvent.class); - registerEventClass(ReceiveFaxEvent.class); - registerEventClass(RegistrationsCompleteEvent.class); - registerEventClass(RegistryEntryEvent.class); - registerEventClass(RegistryEvent.class); - registerEventClass(ReloadEvent.class); - registerEventClass(RenameEvent.class); - registerEventClass(RtcpReceivedEvent.class); - registerEventClass(RtcpSentEvent.class); - registerEventClass(RtpReceiverStatEvent.class); - registerEventClass(RtpSenderStatEvent.class); - registerEventClass(SendFaxStatusEvent.class); - registerEventClass(SendFaxEvent.class); - registerEventClass(SkypeAccountStatusEvent.class); - registerEventClass(SkypeBuddyEntryEvent.class); - registerEventClass(SkypeBuddyListCompleteEvent.class); - registerEventClass(SkypeBuddyStatusEvent.class); - registerEventClass(SkypeChatMessageEvent.class); - registerEventClass(SkypeLicenseEvent.class); - registerEventClass(SkypeLicenseListCompleteEvent.class); - registerEventClass(ShowDialplanCompleteEvent.class); - registerEventClass(ShutdownEvent.class); - registerEventClass(SoftHangupRequestEvent.class); - registerEventClass(StatusEvent.class); - registerEventClass(StatusCompleteEvent.class); - registerEventClass(SuccessfulAuthEvent.class); - registerEventClass(T38FaxStatusEvent.class); - registerEventClass(TransferEvent.class); - registerEventClass(UnholdEvent.class); - registerEventClass(UnpausedEvent.class); - registerEventClass(UnlinkEvent.class); - registerEventClass(UnparkedCallEvent.class); - registerEventClass(VarSetEvent.class); - registerEventClass(VoicemailUserEntryCompleteEvent.class); - registerEventClass(VoicemailUserEntryEvent.class); - registerEventClass(ZapShowChannelsEvent.class); - registerEventClass(ZapShowChannelsCompleteEvent.class); - } - - public final void registerEventClass(Class< ? extends ManagerEvent> clazz) throws IllegalArgumentException - { - String className; - String eventType; - - className = clazz.getName(); - eventType = className.substring(className.lastIndexOf('.') + 1).toLowerCase(Locale.ENGLISH); - - if (eventType.endsWith("event")) - { - eventType = eventType.substring(0, eventType.length() - "event".length()); - } - - if (UserEvent.class.isAssignableFrom(clazz) && !eventType.startsWith("userevent")) - { - eventType = "userevent" + eventType; - } - - registerEventClass(eventType, clazz); - } - - /** - * Registers a new event class for the event given by eventType. - * - * @param eventType the name of the event to register the class for. For - * example "Join". - * @param clazz the event class to register, must extend - * {@link ManagerEvent}. - * @throws IllegalArgumentException if clazz is not a valid event class. - */ - public final void registerEventClass(String eventType, Class< ? extends ManagerEvent> clazz) - throws IllegalArgumentException - { - Constructor< ? > defaultConstructor; - - if (!ManagerEvent.class.isAssignableFrom(clazz)) - { - throw new IllegalArgumentException(clazz + " is not a ManagerEvent"); - } - - if ((clazz.getModifiers() & Modifier.ABSTRACT) != 0) - { - throw new IllegalArgumentException(clazz + " is abstract"); - } - - try - { - defaultConstructor = clazz.getConstructor(new Class[]{Object.class}); - } - catch (NoSuchMethodException ex) - { - throw new IllegalArgumentException(clazz + " has no usable constructor"); - } - - if ((defaultConstructor.getModifiers() & Modifier.PUBLIC) == 0) - { - throw new IllegalArgumentException(clazz + " has no public default constructor"); - } - - registeredEventClasses.put(eventType.toLowerCase(Locale.US), clazz); - - logger.debug("Registered event type '" + eventType + "' (" + clazz + ")"); - } - - @SuppressWarnings("unchecked") - public ManagerEvent buildEvent(Object source, Map attributes) - { - ManagerEvent event; - String eventType = null; - Class< ? > eventClass; - Constructor< ? > constructor; - - if (attributes.get("event") == null) - { - logger.error("No event type in properties"); - return null; - } - - if (attributes.get("event") instanceof List) - { - List< ? > eventNames = (List< ? >) attributes.get("event"); - if (!eventNames.isEmpty() && "PeerEntry".equals(eventNames.get(0))) - { - // List of PeerEntry events was received (AJ-329) - // Convert map of lists to list of maps - one map for each - // PeerEntry event - int peersAmount = attributes.get("listitems") != null - ? Integer.parseInt((String) attributes.get("listitems")) - : eventNames.size() - 1; // Last event is - // PeerlistComplete - List> peersAttributes = new ArrayList<>(); - for (Map.Entry attribute : attributes.entrySet()) - { - String key = attribute.getKey(); - Object value = attribute.getValue(); - for (int i = 0; i < peersAmount; i++) - { - Map peerAttrs; - if (peersAttributes.size() > i) - { - peerAttrs = peersAttributes.get(i); - } - else - { - peerAttrs = new HashMap<>(); - peersAttributes.add(i, peerAttrs); - } - if (value instanceof List) - { - peerAttrs.put(key, ((List< ? >) value).get(i)); - } - else if (value instanceof String && !"listitems".equals(key)) - { - peerAttrs.put(key, value); - } - } - } - attributes.put("peersAttributes", peersAttributes); - eventType = "peers"; - } - } - else - { - if (!(attributes.get("event") instanceof String)) - { - logger.error("Event type is not a String or List"); - return null; - } - - eventType = ((String) attributes.get("event")).toLowerCase(Locale.US); - - // Change in Asterisk 1.4 where the name of the UserEvent is sent as - // property instead - // of the event name (AJ-48) - if ("userevent".equals(eventType)) - { - String userEventType; - - if (attributes.get("userevent") == null) - { - logger.error("No user event type in properties"); - return null; - } - if (!(attributes.get("userevent") instanceof String)) - { - logger.error("User event type is not a String"); - return null; - } - - userEventType = ((String) attributes.get("userevent")).toLowerCase(Locale.US); - eventType = eventType + userEventType; - } - } - - eventClass = registeredEventClasses.get(eventType); - if (eventClass == null) - { - logger.info("No event class registered for event type '" + eventType + "', attributes: " + attributes - + ". Please report at https://github.com/asterisk-java/asterisk-java/issues"); - return null; - } - - try - { - constructor = eventClass.getConstructor(new Class[]{Object.class}); - } - catch (NoSuchMethodException ex) - { - logger.error("Unable to get constructor of " + eventClass.getName(), ex); - return null; - } - - try - { - event = (ManagerEvent) constructor.newInstance(source); - } - catch (Exception ex) - { - logger.error("Unable to create new instance of " + eventClass.getName(), ex); - return null; - } - - if (attributes.get("peersAttributes") != null && attributes.get("peersAttributes") instanceof List) - { - // Fill Peers event with list of PeerEntry events (AJ-329) - PeersEvent peersEvent = (PeersEvent) event; - // TODO: This cast is very ugly, we should review how attributes are - // being passed around. - for (Map peerAttrs : (List>) attributes.get("peersAttributes")) - { - PeerEntryEvent peerEntryEvent = new PeerEntryEvent(source); - setAttributes(peerEntryEvent, peerAttrs, ignoredAttributes); - List peerEntryEvents = peersEvent.getChildEvents(); - if (peerEntryEvents == null) - { - peerEntryEvents = new ArrayList<>(); - peersEvent.setChildEvents(peerEntryEvents); - } - peerEntryEvents.add(peerEntryEvent); - } - peersEvent.setActionId(peersEvent.getChildEvents().get(0).getActionId()); - } - else - { - setAttributes(event, attributes, ignoredAttributes); - } - - // ResponseEvents are sent in response to a ManagerAction if the - // response contains lots of data. They include the actionId of - // the corresponding ManagerAction. - if (event instanceof ResponseEvent) - { - ResponseEvent responseEvent; - String actionId; - - responseEvent = (ResponseEvent) event; - actionId = responseEvent.getActionId(); - if (actionId != null) - { - responseEvent.setActionId(ManagerUtil.stripInternalActionId(actionId)); - responseEvent.setInternalActionId(ManagerUtil.getInternalActionId(actionId)); - } - } - - return event; - } - - @Override - public void deregisterEventClass(Class< ? extends ManagerEvent> eventClass) - { - - Set toRemove = new HashSet<>(); - for (Entry> registered : registeredEventClasses.entrySet()) - { - if (registered.getValue().equals(eventClass)) - { - toRemove.add(registered.getKey()); - } - } - if (toRemove.isEmpty()) - { - logger.error("Couldn't remove event type " + eventClass); - } - else - { - for (String key : toRemove) - { - registeredEventClasses.remove(key); - logger.warn("Removed event type " + key); - } - } - - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ManagerConnectionImpl.java b/src/main/java/org/asteriskjava/manager/internal/ManagerConnectionImpl.java deleted file mode 100644 index 0e3bb2c48..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ManagerConnectionImpl.java +++ /dev/null @@ -1,1688 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.asteriskjava.manager.ManagerConnectionState.CONNECTED; -import static org.asteriskjava.manager.ManagerConnectionState.CONNECTING; -import static org.asteriskjava.manager.ManagerConnectionState.DISCONNECTED; -import static org.asteriskjava.manager.ManagerConnectionState.DISCONNECTING; -import static org.asteriskjava.manager.ManagerConnectionState.INITIAL; -import static org.asteriskjava.manager.ManagerConnectionState.RECONNECTING; - -import java.io.IOException; -import java.io.Serializable; -import java.net.InetAddress; -import java.net.Socket; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.EventTimeoutException; -import org.asteriskjava.manager.ExpectedResponse; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerConnectionState; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.ResponseEvents; -import org.asteriskjava.manager.SendActionCallback; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.manager.action.ChallengeAction; -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.EventGeneratingAction; -import org.asteriskjava.manager.action.LoginAction; -import org.asteriskjava.manager.action.LogoffAction; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.action.UserEventAction; -import org.asteriskjava.manager.event.ConnectEvent; -import org.asteriskjava.manager.event.DialBeginEvent; -import org.asteriskjava.manager.event.DialEvent; -import org.asteriskjava.manager.event.DisconnectEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.ProtocolIdentifierReceivedEvent; -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.response.ChallengeResponse; -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; -import org.asteriskjava.util.SocketConnectionFacade; -import org.asteriskjava.util.internal.SocketConnectionFacadeImpl; - -/** - * Internal implemention of the ManagerConnection interface. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.ManagerConnectionFactory - */ -public class ManagerConnectionImpl implements ManagerConnection, Dispatcher -{ - private static final int RECONNECTION_INTERVAL_1 = 50; - private static final int RECONNECTION_INTERVAL_2 = 5000; - private static final String DEFAULT_HOSTNAME = "localhost"; - private static final int DEFAULT_PORT = 5038; - private static final int RECONNECTION_VERSION_INTERVAL = 500; - private static final int MAX_VERSION_ATTEMPTS = 4; - private static final Pattern SHOW_VERSION_PATTERN = Pattern.compile("^(core )?show version.*"); - - private static final Pattern VERSION_PATTERN_1_6 = Pattern.compile("^\\s*Asterisk ((SVN-branch|GIT)-)?1\\.6[-. ].*"); - private static final Pattern VERSION_PATTERN_1_8 = Pattern.compile("^\\s*Asterisk ((SVN-branch|GIT)-)?1\\.8[-. ].*"); - private static final Pattern VERSION_PATTERN_10 = Pattern.compile("^\\s*Asterisk ((SVN-branch|GIT)-)?10[-. ].*"); - private static final Pattern VERSION_PATTERN_11 = Pattern.compile("^\\s*Asterisk ((SVN-branch|GIT)-)?11[-. ].*"); - private static final Pattern VERSION_PATTERN_CERTIFIED_11 = Pattern.compile("^\\s*Asterisk certified/((SVN-branch|GIT)-)?11[-. ].*"); - private static final Pattern VERSION_PATTERN_12 = Pattern.compile("^\\s*Asterisk ((SVN-branch|GIT)-)?12[-. ].*"); - private static final Pattern VERSION_PATTERN_13 = Pattern.compile("^\\s*Asterisk ((SVN-branch|GIT)-)?13[-. ].*"); - private static final Pattern VERSION_PATTERN_CERTIFIED_13 = Pattern.compile("^\\s*Asterisk certified/((SVN-branch|GIT)-)?13[-. ].*"); - private static final Pattern VERSION_PATTERN_14 = Pattern.compile("^\\s*Asterisk (GIT-)?14[-. ].*"); - - private static final AtomicLong idCounter = new AtomicLong(0); - - /** - * Instance logger. - */ - private final Log logger = LogFactory.getLog(getClass()); - - private final long id; - - /** - * Used to construct the internalActionId. - */ - private AtomicLong actionIdCounter = new AtomicLong(0); - - /* Config attributes */ - /** - * Hostname of the Asterisk server to connect to. - */ - private String hostname = DEFAULT_HOSTNAME; - - /** - * TCP port to connect to. - */ - private int port = DEFAULT_PORT; - - /** - * true to use SSL for the connection, false for a - * plain text connection. - */ - private boolean ssl = false; - - /** - * The username to use for login as defined in Asterisk's - * manager.conf. - */ - protected String username; - - /** - * The password to use for login as defined in Asterisk's - * manager.conf. - */ - protected String password; - - /** - * Encoding used for transmission of strings. - */ - private Charset encoding = StandardCharsets.UTF_8; - - /** - * The default timeout to wait for a ManagerResponse after sending a - * ManagerAction. - */ - private long defaultResponseTimeout = 2000; - - /** - * The default timeout to wait for the last ResponseEvent after sending an - * EventGeneratingAction. - */ - private long defaultEventTimeout = 5000; - - /** - * The timeout to use when connecting the the Asterisk server. - */ - private int socketTimeout = 0; - - /** - * Closes the connection (and reconnects) if no input has been read for the - * given amount of milliseconds. A timeout of zero is interpreted as an - * infinite timeout. - * - * @see Socket#setSoTimeout(int) - */ - private int socketReadTimeout = 0; - - /** - * true to continue to reconnect after an authentication - * failure. - */ - private boolean keepAliveAfterAuthenticationFailure = true; - - /** - * The socket to use for TCP/IP communication with Asterisk. - */ - private SocketConnectionFacade socket; - - /** - * The thread that runs the reader. - */ - private Thread readerThread; - private final AtomicLong readerThreadCounter = new AtomicLong(0); - - private final AtomicLong reconnectThreadCounter = new AtomicLong(0); - - /** - * The reader to use to receive events and responses from asterisk. - */ - private ManagerReader reader; - - /** - * The writer to use to send actions to asterisk. - */ - private ManagerWriter writer; - - /** - * The protocol identifer Asterisk sends on connect wrapped into an object - * to be used as mutex. - */ - private final ProtocolIdentifierWrapper protocolIdentifier; - - /** - * The version of the Asterisk server we are connected to. - */ - private AsteriskVersion version; - - /** - * Contains the registered handlers that process the ManagerResponses. - *

- * Key is the internalActionId of the Action sent and value the - * corresponding ResponseListener. - */ - private final Map responseListeners; - - /** - * Contains the event handlers that handle ResponseEvents for the - * sendEventGeneratingAction methods. - *

- * Key is the internalActionId of the Action sent and value the - * corresponding EventHandler. - */ - private final Map responseEventListeners; - - /** - * Contains the event handlers that users registered. - */ - private final List eventListeners; - - protected ManagerConnectionState state = INITIAL; - - private String eventMask; - - /** - * Creates a new instance. - */ - public ManagerConnectionImpl() - { - this.id = idCounter.getAndIncrement(); - this.responseListeners = new HashMap<>(); - this.responseEventListeners = new HashMap<>(); - this.eventListeners = new ArrayList<>(); - this.protocolIdentifier = new ProtocolIdentifierWrapper(); - } - - // the following two methods can be overriden when running test cases to - // return a mock object - protected ManagerReader createReader(Dispatcher dispatcher, Object source) - { - return new ManagerReaderImpl(dispatcher, source); - } - - protected ManagerWriter createWriter() - { - return new ManagerWriterImpl(); - } - - /** - * Sets the hostname of the asterisk server to connect to. - *

- * Default is localhost. - * - * @param hostname the hostname to connect to - */ - public void setHostname(String hostname) - { - this.hostname = hostname; - } - - /** - * Sets the port to use to connect to the asterisk server. This is the port - * specified in asterisk's manager.conf file. - *

- * Default is 5038. - * - * @param port the port to connect to - */ - public void setPort(int port) - { - if (port <= 0) - { - this.port = DEFAULT_PORT; - } - else - { - this.port = port; - } - } - - /** - * Sets whether to use SSL.
- * Default is false. - * - * @param ssl true to use SSL for the connection, - * false for a plain text connection. - * @since 0.3 - */ - public void setSsl(boolean ssl) - { - this.ssl = ssl; - } - - /** - * Sets the username to use to connect to the asterisk server. This is the - * username specified in asterisk's manager.conf file. - * - * @param username the username to use for login - */ - public void setUsername(String username) - { - this.username = username; - } - - /** - * Sets the password to use to connect to the asterisk server. This is the - * password specified in Asterisk's manager.conf file. - * - * @param password the password to use for login - */ - public void setPassword(String password) - { - this.password = password; - } - - @Override - public void setEncoding(Charset encoding) - { - this.encoding = encoding; - } - - /** - * Sets the time in milliseconds the synchronous method - * {@link #sendAction(ManagerAction)} will wait for a response before - * throwing a TimeoutException.
- * Default is 2000. - * - * @param defaultResponseTimeout default response timeout in milliseconds - * @since 0.2 - */ - public void setDefaultResponseTimeout(long defaultResponseTimeout) - { - this.defaultResponseTimeout = defaultResponseTimeout; - } - - /** - * Sets the time in milliseconds the synchronous method - * {@link #sendEventGeneratingAction(EventGeneratingAction)} will wait for a - * response and the last response event before throwing a TimeoutException. - *
- * Default is 5000. - * - * @param defaultEventTimeout default event timeout in milliseconds - * @since 0.2 - */ - public void setDefaultEventTimeout(long defaultEventTimeout) - { - this.defaultEventTimeout = defaultEventTimeout; - } - - /** - * Set to true to try reconnecting to ther asterisk serve even - * if the reconnection attempt threw an AuthenticationFailedException.
- * Default is true. - * - * @param keepAliveAfterAuthenticationFailure true to try - * reconnecting to ther asterisk serve even if the reconnection - * attempt threw an AuthenticationFailedException, - * false otherwise. - */ - public void setKeepAliveAfterAuthenticationFailure(boolean keepAliveAfterAuthenticationFailure) - { - this.keepAliveAfterAuthenticationFailure = keepAliveAfterAuthenticationFailure; - } - - /* Implementation of ManagerConnection interface */ - - public String getUsername() - { - return username; - } - - public String getPassword() - { - return password; - } - - @Override - public Charset getEncoding() - { - return encoding; - } - - public AsteriskVersion getVersion() - { - return version; - } - - public String getHostname() - { - return hostname; - } - - public int getPort() - { - return port; - } - - public boolean isSsl() - { - return ssl; - } - - public InetAddress getLocalAddress() - { - return socket.getLocalAddress(); - } - - public int getLocalPort() - { - return socket.getLocalPort(); - } - - public InetAddress getRemoteAddress() - { - return socket.getRemoteAddress(); - } - - public int getRemotePort() - { - return socket.getRemotePort(); - } - - public void registerUserEventClass(Class< ? extends ManagerEvent> userEventClass) - { - if (reader == null) - { - reader = createReader(this, this); - } - - reader.registerEventClass(userEventClass); - } - - public void setSocketTimeout(int socketTimeout) - { - this.socketTimeout = socketTimeout; - } - - public void setSocketReadTimeout(int socketReadTimeout) - { - this.socketReadTimeout = socketReadTimeout; - } - - public synchronized void login() throws IOException, AuthenticationFailedException, TimeoutException - { - login(null); - } - - public synchronized void login(String eventMask) throws IOException, AuthenticationFailedException, TimeoutException - { - if (state != INITIAL && state != DISCONNECTED) - { - throw new IllegalStateException("Login may only be perfomed when in state " - + "INITIAL or DISCONNECTED, but connection is in state " + state); - } - - state = CONNECTING; - this.eventMask = eventMask; - try - { - doLogin(defaultResponseTimeout, eventMask); - } - finally - { - if (state != CONNECTED) - { - state = DISCONNECTED; - } - } - } - - /** - * Does the real login, following the steps outlined below.
- *

    - *
  1. Connects to the asterisk server by calling {@link #connect()} if not - * already connected - *
  2. Waits until the protocol identifier is received but not longer than - * timeout ms. - *
  3. Sends a {@link ChallengeAction} requesting a challenge for authType - * MD5. - *
  4. When the {@link ChallengeResponse} is received a {@link LoginAction} - * is sent using the calculated key (MD5 hash of the password appended to - * the received challenge). - *
- * - * @param timeout the maximum time to wait for the protocol identifier (in - * ms) - * @param eventMask the event mask. Set to "on" if all events should be - * send, "off" if not events should be sent or a combination of - * "system", "call" and "log" (separated by ',') to specify what - * kind of events should be sent. - * @throws IOException if there is an i/o problem. - * @throws AuthenticationFailedException if username or password are - * incorrect and the login action returns an error or if the MD5 - * hash cannot be computed. The connection is closed in this - * case. - * @throws TimeoutException if a timeout occurs while waiting for the - * protocol identifier. The connection is closed in this case. - */ - protected synchronized void doLogin(long timeout, String eventMask) - throws IOException, AuthenticationFailedException, TimeoutException - { - ChallengeAction challengeAction; - ManagerResponse challengeResponse; - String challenge; - String key; - LoginAction loginAction; - ManagerResponse loginResponse; - - if (socket == null) - { - connect(); - } - - synchronized (protocolIdentifier) - { - if (protocolIdentifier.value == null) - { - try - { - protocolIdentifier.wait(timeout); - } - catch (InterruptedException e) // NOPMD - { - Thread.currentThread().interrupt(); - } - } - - if (protocolIdentifier.value == null) - { - disconnect(); - if (reader != null && reader.getTerminationException() != null) - { - throw reader.getTerminationException(); - } - throw new TimeoutException("Timeout waiting for protocol identifier"); - } - } - - challengeAction = new ChallengeAction("MD5"); - try - { - challengeResponse = sendAction(challengeAction); - } - catch (Exception e) - { - disconnect(); - throw new AuthenticationFailedException("Unable to send challenge action", e); - } - - if (challengeResponse instanceof ChallengeResponse) - { - challenge = ((ChallengeResponse) challengeResponse).getChallenge(); - } - else - { - disconnect(); - throw new AuthenticationFailedException( - "Unable to get challenge from Asterisk. ChallengeAction returned: " + challengeResponse.getMessage()); - } - - try - { - MessageDigest md; - - md = MessageDigest.getInstance("MD5"); - if (challenge != null) - { - md.update(challenge.getBytes(StandardCharsets.UTF_8)); - } - if (password != null) - { - md.update(password.getBytes(StandardCharsets.UTF_8)); - } - key = ManagerUtil.toHexString(md.digest()); - } - catch (NoSuchAlgorithmException ex) - { - disconnect(); - throw new AuthenticationFailedException("Unable to create login key using MD5 Message Digest", ex); - } - - loginAction = new LoginAction(username, "MD5", key, eventMask); - try - { - loginResponse = sendAction(loginAction); - } - catch (Exception e) - { - disconnect(); - throw new AuthenticationFailedException("Unable to send login action", e); - } - - if (loginResponse instanceof ManagerError) - { - disconnect(); - throw new AuthenticationFailedException(loginResponse.getMessage()); - } - - logger.info("Successfully logged in"); - - version = determineVersion(); - - state = CONNECTED; - - writer.setTargetVersion(version); - - logger.info("Determined Asterisk version: " + version); - - // generate pseudo event indicating a successful login - ConnectEvent connectEvent = new ConnectEvent(this); - connectEvent.setProtocolIdentifier(getProtocolIdentifier()); - connectEvent.setDateReceived(DateUtil.getDate()); - // TODO could this cause a deadlock? - fireEvent(connectEvent); - } - - protected AsteriskVersion determineVersion() throws IOException, TimeoutException - { - int attempts = 0; - - // if ("Asterisk Call Manager/1.1".equals(protocolIdentifier.value)) - // { - // return AsteriskVersion.ASTERISK_1_6; - // } - - while (attempts++ < MAX_VERSION_ATTEMPTS) - { - final ManagerResponse showVersionFilesResponse; - final List showVersionFilesResult; - boolean Asterisk14outputPresent = false; - // increase timeout as output is quite large - showVersionFilesResponse = sendAction(new CommandAction("show version files pbx.c"), defaultResponseTimeout * 2); - if (!(showVersionFilesResponse instanceof CommandResponse)) - { - // return early in case of permission problems - // org.asteriskjava.manager.response.ManagerError: - // actionId='null'; message='Permission denied'; - // response='Error'; - // uniqueId='null'; systemHashcode=15231583 - if(showVersionFilesResponse.getOutput() != null){ - Asterisk14outputPresent = true; - }else{ - break; - } - } - if(Asterisk14outputPresent){ - List outputList = Arrays.asList(showVersionFilesResponse.getOutput().split(SocketConnectionFacadeImpl.NL_PATTERN.pattern())); - showVersionFilesResult = outputList; - }else{ - showVersionFilesResult = ((CommandResponse) showVersionFilesResponse).getResult(); - } - if (showVersionFilesResult != null && !showVersionFilesResult.isEmpty()) - { - final String line1 = showVersionFilesResult.get(0); - - if (line1 != null && line1.startsWith("File")) - { - final String rawVersion; - - rawVersion = getRawVersion(); - if (rawVersion != null && rawVersion.startsWith("Asterisk 1.4")) - { - return AsteriskVersion.ASTERISK_1_4; - } - return AsteriskVersion.ASTERISK_1_2; - } - else if (line1 != null && line1.contains("No such command")) - { - - final ManagerResponse coreShowVersionResponse = sendAction(new CommandAction("core show version"), - defaultResponseTimeout * 2); - - if (coreShowVersionResponse != null && coreShowVersionResponse instanceof CommandResponse) - { - final List coreShowVersionResult = ((CommandResponse) coreShowVersionResponse).getResult(); - - if (coreShowVersionResult != null && !coreShowVersionResult.isEmpty()) - { - final String coreLine = coreShowVersionResult.get(0); - - if (VERSION_PATTERN_1_6.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_1_6; - } - else if (VERSION_PATTERN_1_8.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_1_8; - } - else if (VERSION_PATTERN_10.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_10; - } - else if (VERSION_PATTERN_11.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_11; - } - else if (VERSION_PATTERN_CERTIFIED_11.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_11; - } - else if (VERSION_PATTERN_12.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_12; - } - else if (VERSION_PATTERN_13.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_13; - } - else if (VERSION_PATTERN_CERTIFIED_13.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_13; - } - else if (VERSION_PATTERN_14.matcher(coreLine).matches()) - { - return AsteriskVersion.ASTERISK_14; - } - } - } - - try - { - Thread.sleep(RECONNECTION_VERSION_INTERVAL); - } - catch (Exception ex) - { - // ingnore - } // NOPMD - } - else - { - // if it isn't the "no such command", break and return the - // lowest version immediately - break; - } - } - } - - // TODO: add retry logic; in a reconnect scenario the version fails to - // be identified leading to errors - - // as a fallback assume 1.6 - logger.error("Unable to determine asterisk version, assuming 1.6... you should expect problems to follow."); - return AsteriskVersion.ASTERISK_1_6; - } - - protected String getRawVersion() - { - final ManagerResponse showVersionResponse; - - try - { - showVersionResponse = sendAction(new CommandAction("show version"), defaultResponseTimeout * 2); - } - catch (Exception e) - { - return null; - } - - if (showVersionResponse instanceof CommandResponse) - { - final List showVersionResult; - - showVersionResult = ((CommandResponse) showVersionResponse).getResult(); - if (showVersionResult != null && !showVersionResult.isEmpty()) - { - return showVersionResult.get(0); - } - } - - return null; - } - - protected synchronized void connect() throws IOException - { - logger.info("Connecting to " + hostname + ":" + port); - - if (reader == null) - { - logger.debug("Creating reader for " + hostname + ":" + port); - reader = createReader(this, this); - } - - if (writer == null) - { - logger.debug("Creating writer"); - writer = createWriter(); - } - - logger.debug("Creating socket"); - socket = createSocket(); - - logger.debug("Passing socket to reader"); - reader.setSocket(socket); - - if (readerThread == null || !readerThread.isAlive() || reader.isDead()) - { - logger.debug("Creating and starting reader thread"); - readerThread = new Thread(reader); - readerThread - .setName("Asterisk-Java ManagerConnection-" + id + "-Reader-" + readerThreadCounter.getAndIncrement()); - readerThread.setDaemon(true); - readerThread.start(); - } - - logger.debug("Passing socket to writer"); - writer.setSocket(socket); - } - - protected SocketConnectionFacade createSocket() throws IOException - { - return new SocketConnectionFacadeImpl(hostname, port, ssl, socketTimeout, socketReadTimeout, encoding); - } - - public synchronized void logoff() throws IllegalStateException - { - if (state != CONNECTED && state != RECONNECTING) - { - throw new IllegalStateException("Logoff may only be perfomed when in state " - + "CONNECTED or RECONNECTING, but connection is in state " + state); - } - - state = DISCONNECTING; - - if (socket != null) - { - try - { - sendAction(new LogoffAction()); - } - catch (Exception e) - { - logger.warn("Unable to send LogOff action", e); - } - } - cleanup(); - state = DISCONNECTED; - } - - /** - * Closes the socket connection. - */ - protected synchronized void disconnect() - { - if (socket != null) - { - logger.info("Closing socket."); - try - { - socket.close(); - } - catch (IOException ex) - { - logger.warn("Unable to close socket: " + ex.getMessage()); - } - socket = null; - } - protocolIdentifier.value = null; - } - - public ManagerResponse sendAction(ManagerAction action) - throws IOException, TimeoutException, IllegalArgumentException, IllegalStateException - { - return sendAction(action, defaultResponseTimeout); - } - - /* - * Implements synchronous sending of "simple" actions. - */ - public ManagerResponse sendAction(ManagerAction action, long timeout) - throws IOException, TimeoutException, IllegalArgumentException, IllegalStateException - { - ResponseHandlerResult result; - SendActionCallback callbackHandler; - - result = new ResponseHandlerResult(); - callbackHandler = new DefaultSendActionCallback(result); - - synchronized (result) - { - sendAction(action, callbackHandler); - - // definitely return null for the response of user events - if (action instanceof UserEventAction) - { - return null; - } - - // only wait if we did not yet receive the response. - // Responses may be returned really fast. - if (result.getResponse() == null) - { - try - { - result.wait(timeout); - } - catch (InterruptedException ex) - { - logger.warn("Interrupted while waiting for result"); - Thread.currentThread().interrupt(); - } - } - } - - // still no response? - if (result.getResponse() == null) - { - throw new TimeoutException("Timeout waiting for response to " + action.getAction() - + (action.getActionId() == null ? "" : " (actionId: " + action.getActionId() + ")")); - } - - return result.getResponse(); - } - - public void sendAction(ManagerAction action, SendActionCallback callback) - throws IOException, IllegalArgumentException, IllegalStateException - { - final String internalActionId; - - if (action == null) - { - throw new IllegalArgumentException("Unable to send action: action is null."); - } - - // In general sending actions is only allowed while connected, though - // there are a few exceptions, these are handled here: - if ((state == CONNECTING || state == RECONNECTING) && (action instanceof ChallengeAction - || action instanceof LoginAction || isShowVersionCommandAction(action))) - { - // when (re-)connecting challenge and login actions are ok. - } // NOPMD - else if (state == DISCONNECTING && action instanceof LogoffAction) - { - // when disconnecting logoff action is ok. - } // NOPMD - else if (state != CONNECTED) - { - throw new IllegalStateException( - "Actions may only be sent when in state " + "CONNECTED, but connection is in state " + state); - } - - if (socket == null) - { - throw new IllegalStateException("Unable to send " + action.getAction() + " action: socket not connected."); - } - - internalActionId = createInternalActionId(); - - // if the callbackHandler is null the user is obviously not interested - // in the response, thats fine. - if (callback != null) - { - synchronized (this.responseListeners) - { - this.responseListeners.put(internalActionId, callback); - } - } - - Class< ? extends ManagerResponse> responseClass = getExpectedResponseClass(action.getClass()); - if (responseClass != null) - { - reader.expectResponseClass(internalActionId, responseClass); - } - - writer.sendAction(action, internalActionId); - } - - boolean isShowVersionCommandAction(ManagerAction action) - { - if (!(action instanceof CommandAction)) - { - return false; - } - final Matcher showVersionMatcher = SHOW_VERSION_PATTERN.matcher(((CommandAction) action).getCommand()); - return showVersionMatcher.matches(); - } - - private Class< ? extends ManagerResponse> getExpectedResponseClass(Class< ? extends ManagerAction> actionClass) - { - final ExpectedResponse annotation = actionClass.getAnnotation(ExpectedResponse.class); - if (annotation == null) - { - return null; - } - - return annotation.value(); - } - - public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException - { - return sendEventGeneratingAction(action, defaultEventTimeout); - } - - /* - * Implements synchronous sending of event generating actions. - */ - public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, long timeout) - throws IOException, EventTimeoutException, IllegalArgumentException, IllegalStateException - { - final ResponseEventsImpl responseEvents; - final ResponseEventHandler responseEventHandler; - final String internalActionId; - - if (action == null) - { - throw new IllegalArgumentException("Unable to send action: action is null."); - } - else if (action.getActionCompleteEventClass() == null) - { - throw new IllegalArgumentException( - "Unable to send action: actionCompleteEventClass for " + action.getClass().getName() + " is null."); - } - else if (!ResponseEvent.class.isAssignableFrom(action.getActionCompleteEventClass())) - { - throw new IllegalArgumentException( - "Unable to send action: actionCompleteEventClass (" + action.getActionCompleteEventClass().getName() - + ") for " + action.getClass().getName() + " is not a ResponseEvent."); - } - - if (state != CONNECTED) - { - throw new IllegalStateException( - "Actions may only be sent when in state " + "CONNECTED but connection is in state " + state); - } - - responseEvents = new ResponseEventsImpl(); - responseEventHandler = new ResponseEventHandler(responseEvents, action.getActionCompleteEventClass()); - - internalActionId = createInternalActionId(); - - try - { - // register response handler... - synchronized (this.responseListeners) - { - this.responseListeners.put(internalActionId, responseEventHandler); - } - - // ...and event handler. - synchronized (this.responseEventListeners) - { - this.responseEventListeners.put(internalActionId, responseEventHandler); - } - - synchronized (responseEvents) - { - writer.sendAction(action, internalActionId); - // only wait if response has not yet arrived. - if (responseEvents.getResponse() == null || !responseEvents.isComplete()) - { - try - { - responseEvents.wait(timeout); - } - catch (InterruptedException e) - { - logger.warn("Interrupted while waiting for response events."); - Thread.currentThread().interrupt(); - } - } - } - - // still no response or not all events received and timed out? - if (responseEvents.getResponse() == null || !responseEvents.isComplete()) - { - throw new EventTimeoutException( - "Timeout waiting for response or response events to " + action.getAction() - + (action.getActionId() == null ? "" : " (actionId: " + action.getActionId() + ")"), - responseEvents); - } - - } - finally - { - // remove the event handler - synchronized (this.responseEventListeners) - { - this.responseEventListeners.remove(internalActionId); - } - - // Note: The response handler should have already been removed - // when the response was received, however we remove it here - // just in case it was never received. - synchronized (this.responseListeners) - { - this.responseListeners.remove(internalActionId); - } - - } - - return responseEvents; - } - - /** - * Creates a new unique internal action id based on the hash code of this - * connection and a sequence. - * - * @return a new internal action id - * @see ManagerUtil#addInternalActionId(String,String) - * @see ManagerUtil#getInternalActionId(String) - * @see ManagerUtil#stripInternalActionId(String) - */ - private String createInternalActionId() - { - final StringBuilder sb; - - sb = new StringBuilder(); - sb.append(this.hashCode()); - sb.append("_"); - sb.append(actionIdCounter.getAndIncrement()); - - return sb.toString(); - } - - public void addEventListener(final ManagerEventListener listener) - { - synchronized (this.eventListeners) - { - // only add it if its not already there - if (!this.eventListeners.contains(listener)) - { - this.eventListeners.add(listener); - } - } - } - - public void removeEventListener(final ManagerEventListener listener) - { - synchronized (this.eventListeners) - { - if (this.eventListeners.contains(listener)) - { - this.eventListeners.remove(listener); - } - } - } - - public String getProtocolIdentifier() - { - return protocolIdentifier.value; - } - - public ManagerConnectionState getState() - { - return state; - } - - /* Implementation of Dispatcher: callbacks for ManagerReader */ - - /** - * This method is called by the reader whenever a {@link ManagerResponse} is - * received. The response is dispatched to the associated - * {@link SendActionCallback}. - * - * @param response the response received by the reader - * @see ManagerReader - */ - public void dispatchResponse(ManagerResponse response) - { - final String actionId; - String internalActionId; - SendActionCallback listener; - - // shouldn't happen - if (response == null) - { - logger.error("Unable to dispatch null response. This should never happen. Please file a bug."); - return; - } - - actionId = response.getActionId(); - internalActionId = null; - listener = null; - - if (actionId != null) - { - internalActionId = ManagerUtil.getInternalActionId(actionId); - response.setActionId(ManagerUtil.stripInternalActionId(actionId)); - } - - if (logger.isDebugEnabled()) - { - logger.debug("Dispatching response with internalActionId '" + internalActionId + "':\n" + response); - } - - if (internalActionId != null) - { - synchronized (this.responseListeners) - { - listener = responseListeners.get(internalActionId); - if (listener != null) - { - this.responseListeners.remove(internalActionId); - } - else - { - // when using the async sendAction it's ok not to register a - // callback so if we don't find a response handler thats ok - logger.debug("No response listener registered for " + "internalActionId '" + internalActionId + "'"); - } - } - } - else - { - logger.error( - "Unable to retrieve internalActionId from response: " + "actionId '" + actionId + "':\n" + response); - } - - if (listener != null) - { - try - { - listener.onResponse(response); - } - catch (Exception e) - { - logger.warn("Unexpected exception in response listener " + listener.getClass().getName(), e); - } - } - } - - /** - * This method is called by the reader whenever a ManagerEvent is received. - * The event is dispatched to all registered ManagerEventHandlers. - * - * @param event the event received by the reader - * @see #addEventListener(ManagerEventListener) - * @see #removeEventListener(ManagerEventListener) - * @see ManagerReader - */ - public void dispatchEvent(ManagerEvent event) - { - // shouldn't happen - if (event == null) - { - logger.error("Unable to dispatch null event. This should never happen. Please file a bug."); - return; - } - dispatchLegacyEventIfNeeded(event); - if (logger.isDebugEnabled()) - { - logger.debug("Dispatching event:\n" + event.toString()); - } - - // Some events need special treatment besides forwarding them to the - // registered eventListeners (clients) - // These events are handled here at first: - - // Dispatch ResponseEvents to the appropriate responseEventListener - if (event instanceof ResponseEvent) - { - ResponseEvent responseEvent; - String internalActionId; - - responseEvent = (ResponseEvent) event; - internalActionId = responseEvent.getInternalActionId(); - if (internalActionId != null) - { - synchronized (responseEventListeners) - { - ManagerEventListener listener; - - listener = responseEventListeners.get(internalActionId); - if (listener != null) - { - try - { - listener.onManagerEvent(event); - } - catch (Exception e) - { - logger.warn("Unexpected exception in response event listener " + listener.getClass().getName(), - e); - } - } - } - } - else - { - // ResponseEvent without internalActionId: - // this happens if the same event class is used as response - // event - // and as an event that is not triggered by a Manager command - // Example: QueueMemberStatusEvent. - // logger.debug("ResponseEvent without " - // + "internalActionId:\n" + responseEvent); - } // NOPMD - } - if (event instanceof DisconnectEvent) - { - // When we receive get disconnected while we are connected start - // a new reconnect thread and set the state to RECONNECTING. - if (state == CONNECTED) - { - state = RECONNECTING; - // close socket if still open and remove reference to - // readerThread - // After sending the DisconnectThread that thread will die - // anyway. - cleanup(); - Thread reconnectThread = new Thread(new Runnable() - { - public void run() - { - reconnect(); - } - }); - reconnectThread.setName( - "Asterisk-Java ManagerConnection-" + id + "-Reconnect-" + reconnectThreadCounter.getAndIncrement()); - reconnectThread.setDaemon(true); - reconnectThread.start(); - // now the DisconnectEvent is dispatched to registered - // eventListeners - // (clients) and after that the ManagerReaderThread is gone. - // So effectively we replaced the reader thread by a - // ReconnectThread. - } - else - { - // when we receive a DisconnectEvent while not connected we - // ignore it and do not send it to clients - return; - } - } - if (event instanceof ProtocolIdentifierReceivedEvent) - { - ProtocolIdentifierReceivedEvent protocolIdentifierReceivedEvent; - String protocolIdentifier; - - protocolIdentifierReceivedEvent = (ProtocolIdentifierReceivedEvent) event; - protocolIdentifier = protocolIdentifierReceivedEvent.getProtocolIdentifier(); - setProtocolIdentifier(protocolIdentifier); - // no need to send this event to clients - return; - } - - fireEvent(event); - } - - /** - * Enro 2015-03 Workaround to continue having Legacy Events from Asterisk - * 13. - */ - private void dispatchLegacyEventIfNeeded(ManagerEvent event) - { - if (event instanceof DialBeginEvent) - { - DialEvent legacyEvent = new DialEvent((DialBeginEvent) event); - dispatchEvent(legacyEvent); - } - } - - /** - * Notifies all {@link ManagerEventListener}s registered by users. - * - * @param event the event to propagate - */ - private void fireEvent(ManagerEvent event) - { - synchronized (eventListeners) - { - for (ManagerEventListener listener : eventListeners) - { - try - { - listener.onManagerEvent(event); - } - catch (RuntimeException e) - { - logger.warn("Unexpected exception in eventHandler " + listener.getClass().getName(), e); - } - } - } - } - - /** - * This method is called when a {@link ProtocolIdentifierReceivedEvent} is - * received from the reader. Having received a correct protocol identifier - * is the precodition for logging in. - * - * @param identifier the protocol version used by the Asterisk server. - */ - private void setProtocolIdentifier(final String identifier) - { - logger.info("Connected via " + identifier); - - if (!"Asterisk Call Manager/1.0".equals(identifier) && !"Asterisk Call Manager/1.1".equals(identifier) // Asterisk - // 1.6 - && !"Asterisk Call Manager/1.2".equals(identifier) // bri - // stuffed - && !"Asterisk Call Manager/1.3".equals(identifier) // Asterisk - // 11 - && !"Asterisk Call Manager/2.6.0".equals(identifier) // Asterisk - // 13 - && !"Asterisk Call Manager/2.7.0".equals(identifier) // Asterisk - // 13.2 - && !"Asterisk Call Manager/2.8.0".equals(identifier) // Asterisk > 13.5 - - && !"Asterisk Call Manager/2.9.0".equals(identifier) // Asterisk > 13.13 - - && !"Asterisk Call Manager/3.1.0".equals(identifier) //Asterisk =14.3.0 - - && !"OpenPBX Call Manager/1.0".equals(identifier) && !"CallWeaver Call Manager/1.0".equals(identifier) - && !(identifier != null && identifier.startsWith("Asterisk Call Manager Proxy/"))) - { - logger.warn("Unsupported protocol version '" + identifier + "'. Use at your own risk."); - } - - synchronized (protocolIdentifier) - { - protocolIdentifier.value = identifier; - protocolIdentifier.notifyAll(); - } - } - - /** - * Reconnects to the asterisk server when the connection is lost.
- * While keepAlive is true we will try to reconnect. - * Reconnection attempts will be stopped when the {@link #logoff()} method - * is called or when the login after a successful reconnect results in an - * {@link AuthenticationFailedException} suggesting that the manager - * credentials have changed and keepAliveAfterAuthenticationFailure is not - * set.
- * This method is called when a {@link DisconnectEvent} is received from the - * reader. - */ - private void reconnect() - { - int numTries; - - // try to reconnect - numTries = 0; - while (state == RECONNECTING) - { - try - { - if (numTries < 10) - { - // try to reconnect quite fast for the firt 10 times - // this succeeds if the server has just been restarted - Thread.sleep(RECONNECTION_INTERVAL_1); - } - else - { - // slow down after 10 unsuccessful attempts asuming a - // shutdown of the server - Thread.sleep(RECONNECTION_INTERVAL_2); - } - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - - try - { - connect(); - - try - { - doLogin(defaultResponseTimeout, eventMask); - logger.info("Successfully reconnected."); - // everything is ok again, so we leave - // when successful doLogin set the state to CONNECTED so no - // need to adjust it - break; - } - catch (AuthenticationFailedException e1) - { - if (keepAliveAfterAuthenticationFailure) - { - logger.error("Unable to log in after reconnect: " + e1.getMessage()); - } - else - { - logger.error("Unable to log in after reconnect: " + e1.getMessage() + ". Giving up."); - state = DISCONNECTED; - } - } - catch (TimeoutException e1) - { - // shouldn't happen - but happens! - logger.error("TimeoutException while trying to log in " + "after reconnect."); - } - } - catch (IOException e) - { - // server seems to be still down, just continue to attempt - // reconnection - String message = e.getClass().getSimpleName(); - if (e.getMessage() != null) - { - message = e.getMessage(); - } - - logger.warn("Exception while trying to reconnect: " + message); - } - numTries++; - } - } - - private void cleanup() - { - disconnect(); - this.readerThread = null; - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder("ManagerConnection["); - sb.append("id='").append(id).append("',"); - sb.append("hostname='").append(hostname).append("',"); - sb.append("port=").append(port).append(","); - sb.append("systemHashcode=").append(System.identityHashCode(this)).append("]"); - - return sb.toString(); - } - - /* Helper classes */ - - /** - * A simple data object to store a ManagerResult. - */ - private static class ResponseHandlerResult implements Serializable - { - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 7831097958568769220L; - private ManagerResponse response; - - public ResponseHandlerResult() - { - } - - public ManagerResponse getResponse() - { - return this.response; - } - - public void setResponse(ManagerResponse response) - { - this.response = response; - } - } - - /** - * A simple response handler that stores the received response in a - * ResponseHandlerResult for further processing. - */ - private static class DefaultSendActionCallback implements SendActionCallback, Serializable - { - /** - * Serializable version identifier. - */ - private static final long serialVersionUID = 2926598671855316803L; - private final ResponseHandlerResult result; - - /** - * Creates a new instance. - * - * @param result the result to store the response in - */ - public DefaultSendActionCallback(ResponseHandlerResult result) - { - this.result = result; - } - - public void onResponse(ManagerResponse response) - { - synchronized (result) - { - result.setResponse(response); - result.notifyAll(); - } - } - } - - /** - * A combinded event and response handler that adds received events and the - * response to a ResponseEvents object. - */ - private static class ResponseEventHandler implements ManagerEventListener, SendActionCallback - { - private final ResponseEventsImpl events; - private final Class< ? > actionCompleteEventClass; - - /** - * Creates a new instance. - * - * @param events the ResponseEventsImpl to store the events in - * @param actionCompleteEventClass the type of event that indicates that - * all events have been received - */ - public ResponseEventHandler(ResponseEventsImpl events, Class< ? > actionCompleteEventClass) - { - this.events = events; - this.actionCompleteEventClass = actionCompleteEventClass; - } - - public void onManagerEvent(ManagerEvent event) - { - synchronized (events) - { - // should always be a ResponseEvent, anyway... - if (event instanceof ResponseEvent) - { - ResponseEvent responseEvent; - - responseEvent = (ResponseEvent) event; - events.addEvent(responseEvent); - } - - // finished? - if (actionCompleteEventClass.isAssignableFrom(event.getClass())) - { - events.setComplete(true); - // notify if action complete event and response have been - // received - if (events.getResponse() != null) - { - events.notifyAll(); - } - } - } - } - - public void onResponse(ManagerResponse response) - { - synchronized (events) - { - events.setRepsonse(response); - if (response instanceof ManagerError) - { - events.setComplete(true); - } - - // finished? - // notify if action complete event and response have been - // received - if (events.isComplete()) - { - events.notifyAll(); - } - } - } - } - - private static class ProtocolIdentifierWrapper - { - String value; - } - - @Override - public void deregisterEventClass(Class< ? extends ManagerEvent> eventClass) - { - if (reader == null) - { - reader = createReader(this, this); - } - - reader.deregisterEventClass(eventClass); - - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ManagerReader.java b/src/main/java/org/asteriskjava/manager/internal/ManagerReader.java deleted file mode 100644 index 4fe566ccd..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ManagerReader.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.io.IOException; - -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.SocketConnectionFacade; - -/** - * The ManagerReader reads events and responses from the asterisk server, parses - * them using EventBuilderImpl and ResponseBuilder and dispatches them to the - * associated ManagerConnection. - *

- * Do not use this interface in your code, it is intended to be used only by the - * DefaultManagerConnection. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.internal.EventBuilder - * @see org.asteriskjava.manager.internal.ResponseBuilder - * @see org.asteriskjava.manager.DefaultManagerConnection - */ -public interface ManagerReader extends Runnable -{ - String COMMAND_RESULT_RESPONSE_KEY = "__result__"; - - /** - * Sets the socket to use for reading from the asterisk server. - * - * @param socket the socket to use for reading from the asterisk server. - */ - void setSocket(final SocketConnectionFacade socket); - - /** - * Registers a new event type with the underlying EventBuilderImpl. - *

- * The eventClass must extend ManagerEvent. - * - * @param event class of the event to register. - * @see EventBuilder - * @see ManagerEvent - */ - void registerEventClass(Class< ? extends ManagerEvent> event); - - void expectResponseClass(String internalActionId, Class< ? extends ManagerResponse> responseClass); - - /** - * Terminates this reader. - */ - void die(); - - /** - * Checks whether this reader is terminating or terminated. - * - * @return true if this reader is terminating or terminated, - * false otherwise. - */ - boolean isDead(); - - /** - * Returns the Exception that caused this reader to terminate if any. - * - * @return the Exception that caused this reader to terminate if any or - * null if not. - */ - IOException getTerminationException(); - - void deregisterEventClass(Class< ? extends ManagerEvent> eventClass); -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ManagerReaderImpl.java b/src/main/java/org/asteriskjava/manager/internal/ManagerReaderImpl.java deleted file mode 100644 index 3535a24d9..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ManagerReaderImpl.java +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.asteriskjava.manager.event.DisconnectEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.ProtocolIdentifierReceivedEvent; -import org.asteriskjava.manager.internal.backwardsCompatibility.BackwardsCompatibilityForManagerEvents; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; -import org.asteriskjava.util.SocketConnectionFacade; - -/** - * Default implementation of the ManagerReader interface. - * - * @author srt - * @version $Id$ - */ -public class ManagerReaderImpl implements ManagerReader -{ - /** - * Instance logger. - */ - private final Log logger = LogFactory.getLog(getClass()); - - /** - * The event builder utility to convert a map of attributes reveived from - * asterisk to instances of registered event classes. - */ - private final EventBuilder eventBuilder; - - /** - * The response builder utility to convert a map of attributes reveived from - * asterisk to instances of well known response classes. - */ - private final ResponseBuilder responseBuilder; - - /** - * The dispatcher to use for dispatching events and responses. - */ - private final Dispatcher dispatcher; - - private final Map> expectedResponseClasses; - - /** - * The source to use when creating {@link ManagerEvent}s. - */ - private final Object source; - - /** - * The socket to use for reading from the asterisk server. - */ - private SocketConnectionFacade socket; - - /** - * If set to true, terminates and closes the reader. - */ - private volatile boolean die = false; - - /** - * true if the main loop has finished. - */ - private boolean dead = false; - - /** - * Exception that caused this reader to terminate if any. - */ - private IOException terminationException; - - /** - * set of classes able to take newer versions of ManagerEvents and emit - * older style manager Events - */ - BackwardsCompatibilityForManagerEvents compatibility = new BackwardsCompatibilityForManagerEvents(); - - /** - * Creates a new ManagerReaderImpl. - * - * @param dispatcher the dispatcher to use for dispatching events and - * responses. - * @param source the source to use when creating {@link ManagerEvent}s - */ - public ManagerReaderImpl(final Dispatcher dispatcher, Object source) - { - this.dispatcher = dispatcher; - this.source = source; - - this.eventBuilder = new EventBuilderImpl(); - this.responseBuilder = new ResponseBuilderImpl(); - this.expectedResponseClasses = new ConcurrentHashMap<>(); - } - - /** - * Sets the socket to use for reading from the asterisk server. - * - * @param socket the socket to use for reading from the asterisk server. - */ - public void setSocket(final SocketConnectionFacade socket) - { - this.socket = socket; - } - - public void registerEventClass(Class< ? extends ManagerEvent> eventClass) - { - eventBuilder.registerEventClass(eventClass); - } - - public void expectResponseClass(String internalActionId, Class< ? extends ManagerResponse> responseClass) - { - expectedResponseClasses.put(internalActionId, responseClass); - } - - /** - * Reads line by line from the asterisk server, sets the protocol identifier - * (using a generated - * {@link org.asteriskjava.manager.event.ProtocolIdentifierReceivedEvent}) - * as soon as it is received and dispatches the received events and - * responses via the associated dispatcher. - * - * @see org.asteriskjava.manager.internal.Dispatcher#dispatchEvent(ManagerEvent) - * @see org.asteriskjava.manager.internal.Dispatcher#dispatchResponse(ManagerResponse) - */ - public void run() - { - final Map buffer = new HashMap<>(); - String line; - - if (socket == null) - { - throw new IllegalStateException("Unable to run: socket is null."); - } - - this.die = false; - this.dead = false; - - try - { - // main loop - while (!this.die && (line = socket.readLine()) != null) - { - // maybe we will find a better way to identify the protocol - // identifier but for now - // this works quite well. - if (line.startsWith("Asterisk Call Manager/") || line.startsWith("Asterisk Call Manager Proxy/") - || line.startsWith("Asterisk Manager Proxy/") || line.startsWith("OpenPBX Call Manager/") - || line.startsWith("CallWeaver Call Manager/")) - { - ProtocolIdentifierReceivedEvent protocolIdentifierReceivedEvent; - protocolIdentifierReceivedEvent = new ProtocolIdentifierReceivedEvent(source); - protocolIdentifierReceivedEvent.setProtocolIdentifier(line); - protocolIdentifierReceivedEvent.setDateReceived(DateUtil.getDate()); - dispatcher.dispatchEvent(protocolIdentifierReceivedEvent); - continue; - } - - /* - * Special handling for "Response: Follows" (CommandResponse) As - * we are using "\r\n" as the delimiter for line this also - * handles multiline results as long as they only contain "\n". - */ - if ("Follows".equals(buffer.get("response")) && line.endsWith("--END COMMAND--")) - { - buffer.put(COMMAND_RESULT_RESPONSE_KEY, line); - continue; - } - - if (line.length() > 0) - { - // begin of workaround for Astersik bug 13319 - // see AJ-77 - // Use this workaround only when line starts from "From " - // and "To " - int isFromAtStart = line.indexOf("From "); - int isToAtStart = line.indexOf("To "); - - int delimiterIndex = isFromAtStart == 0 || isToAtStart == 0 - ? line.indexOf(" ") : line.indexOf(":"); - // end of workaround for Astersik bug 13319 - - int delimiterLength = 1; - - if (delimiterIndex > 0 && line.length() > delimiterIndex + delimiterLength) - { - String name = line.substring(0, delimiterIndex).toLowerCase(Locale.ENGLISH).trim(); - String value = line.substring(delimiterIndex + delimiterLength).trim(); - - addToBuffer(buffer, name, value); - // TODO tracing - // logger.debug("Got name [" + name + "], value: [" + - // value + "]"); - } - } - - // an empty line indicates a normal response's or event's end so - // we build - // the corresponding value object and dispatch it through the - // ManagerConnection. - if (line.length() == 0) - { - if (buffer.containsKey("event")) - { - // TODO tracing - // logger.debug("attempting to build event: " + - // buffer.get("event")); - ManagerEvent event = buildEvent(source, buffer); - if (event != null) - { - dispatcher.dispatchEvent(event); - - // Backwards compatibility for bridge events. - // Asterisk 13 uses BridgeCreate, - // BridgeEnter, BridgeLeave and BridgeDestroy - // events. - // So here we track active bridges and simulate - // BridgeEvent's for them allowing legacy code to - // still work with BridgeEvent's - ManagerEvent secondaryEvent = compatibility.handleEvent(event); - if (secondaryEvent != null) - { - dispatcher.dispatchEvent(secondaryEvent); - } - } - else - { - logger.debug("buildEvent returned null"); - } - } - else if (buffer.containsKey("response")) - { - ManagerResponse response = buildResponse(buffer); - // TODO tracing - // logger.debug("attempting to build response"); - if (response != null) - { - dispatcher.dispatchResponse(response); - } - } - else - { - if (!buffer.isEmpty()) - { - logger.debug("Buffer contains neither response nor event"); - } - } - - buffer.clear(); - } - } - this.dead = true; - logger.debug("Reached end of stream, terminating reader."); - } - catch (IOException e) - { - this.terminationException = e; - this.dead = true; - logger.info("Terminating reader thread: " + e.getMessage()); - } - finally - { - this.dead = true; - // cleans resources and reconnects if needed - DisconnectEvent disconnectEvent = new DisconnectEvent(source); - disconnectEvent.setDateReceived(DateUtil.getDate()); - dispatcher.dispatchEvent(disconnectEvent); - } - } - - @SuppressWarnings("unchecked") - private void addToBuffer(Map buffer, String name, String value) - { - // if we already have a value for that key, convert the value to a list - // and add - // the new value to that list. - if (buffer.containsKey(name)) - { - Object currentValue = buffer.get(name); - if (currentValue instanceof List) - { - ((List) currentValue).add(value); - return; - } - List list = new ArrayList<>(); - if (currentValue instanceof String) - { - list.add((String) currentValue); - } - else - { - list.add(currentValue.toString()); - } - list.add(value); - buffer.put(name, list); - } - else - { - buffer.put(name, value); - } - } - - public void die() - { - this.die = true; - } - - public boolean isDead() - { - return dead; - } - - public IOException getTerminationException() - { - return terminationException; - } - - private ManagerResponse buildResponse(Map buffer) - { - Class< ? extends ManagerResponse> responseClass = null; - final String actionId = (String) buffer.get("actionid"); - final String internalActionId = ManagerUtil.getInternalActionId(actionId); - if (internalActionId != null) - { - responseClass = expectedResponseClasses.remove(internalActionId); - } - - final ManagerResponse response = responseBuilder.buildResponse(responseClass, buffer); - - if (response != null) - { - response.setDateReceived(DateUtil.getDate()); - } - - return response; - } - - private ManagerEvent buildEvent(Object source, Map buffer) - { - ManagerEvent event; - - event = eventBuilder.buildEvent(source, buffer); - - if (event != null) - { - event.setDateReceived(DateUtil.getDate()); - } - - return event; - } - - @Override - public void deregisterEventClass(Class< ? extends ManagerEvent> eventClass) - { - - eventBuilder.deregisterEventClass(eventClass); - - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ManagerUtil.java b/src/main/java/org/asteriskjava/manager/internal/ManagerUtil.java deleted file mode 100644 index 2ddf18d9f..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ManagerUtil.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -/** - * Utilitiy class with some static helper methods that are used in multiple - * contexts within the manager package. - *

- * The methods for handling the internal action id are used to make sure we send - * unique ids to Asterisk even when the user of Asterisk-Java does not provide a - * unique action id or no action id at all. - *

- * All the methods contained in this class are supposed to be internally only. - * - * @author srt - * @version $Id$ - */ -public class ManagerUtil -{ - public static final char INTERNAL_ACTION_ID_DELIMITER = '#'; - - /** - * The hex digits used to build a hex string representation of a byte array. - */ - private static final char[] hexChar = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; - - private ManagerUtil() { - - } - - /** - * Converts a byte array to a hex string representing it. The hex digits are - * lower case. - * - * @param b the byte array to convert - * @return the hex representation of b - */ - public static String toHexString(byte[] b) - { - final StringBuilder sb; - - sb = new StringBuilder(b.length * 2); - for (byte aB : b) - { - sb.append(hexChar[(aB & 0xf0) >>> 4]); - sb.append(hexChar[aB & 0x0f]); - } - return sb.toString(); - } - - /** - * Returns the internal action id contained in the given action id. - * - * @param actionId the action id prefixed by the internal action id as - * received from Asterisk. - * @return the internal action id that has been added before. - * @see #addInternalActionId(String, String) - */ - public static String getInternalActionId(String actionId) - { - final int delimiterIndex; - - if (actionId == null) - { - return null; - } - - delimiterIndex = actionId.indexOf(INTERNAL_ACTION_ID_DELIMITER); - if (delimiterIndex > 0) - { - return actionId.substring(0, delimiterIndex); - } - return null; - } - - /** - * Strips the internal action id from the given action id. - * - * @param actionId the action id prefixed by the internal action id as - * received from Asterisk. - * @return the original action id, that is the action id as it was before - * the internal action id was added. - * @see #addInternalActionId(String, String) - */ - public static String stripInternalActionId(String actionId) - { - int delimiterIndex; - - delimiterIndex = actionId.indexOf(INTERNAL_ACTION_ID_DELIMITER); - if (delimiterIndex > 0) - { - if (actionId.length() > delimiterIndex + 1) - { - return actionId.substring(delimiterIndex + 1); - } - return null; - } - return null; - } - - /** - * Adds the internal action id to the given action id. - * - * @param actionId the action id as set by the user. - * @param internalActionId the internal action id to add. - * @return the action id prefixed by the internal action id suitable to be - * sent to Asterisk. - */ - public static String addInternalActionId(String actionId, String internalActionId) - { - if (actionId == null) - { - return internalActionId + INTERNAL_ACTION_ID_DELIMITER; - } - return internalActionId + INTERNAL_ACTION_ID_DELIMITER + actionId; - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ManagerWriter.java b/src/main/java/org/asteriskjava/manager/internal/ManagerWriter.java deleted file mode 100644 index 987c23f30..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ManagerWriter.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.io.IOException; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.util.SocketConnectionFacade; - - -/** - * The ManagerWriter transforms actions using an ActionBuilder and sends them to - * the asterisk server.

- * This class is intended to be used only by the DefaultManagerConnection. - * - * @see org.asteriskjava.manager.internal.ActionBuilder - * @see org.asteriskjava.manager.DefaultManagerConnection - * @author srt - * @version $Id$ - */ -public interface ManagerWriter -{ - /** - * Sets the version of the target Asterisk server. - * - * @param targetVersion the version of the target Asterisk server. - * @since 0.2 - */ - public void setTargetVersion(AsteriskVersion targetVersion); - - /** - * Sets the socket to use for writing to Asterisk. - * - * @param socket the socket to use for writing to Asterisk. - */ - void setSocket(final SocketConnectionFacade socket); - - /** - * Sends the given action to the asterisk server. - * - * @param action the action to send to the asterisk server. - * @param internalActionId the internal action id to add. - * @throws IOException if there is a problem sending the action. - */ - void sendAction(final ManagerAction action, String internalActionId) throws IOException; -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ManagerWriterImpl.java b/src/main/java/org/asteriskjava/manager/internal/ManagerWriterImpl.java deleted file mode 100644 index 3e321b430..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ManagerWriterImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.io.IOException; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.util.SocketConnectionFacade; - - -/** - * Default implementation of ManagerWriter interface. - * - * @author srt - * @version $Id$ - */ -public class ManagerWriterImpl implements ManagerWriter -{ - /** - * Instance logger. - */ - //private final Log logger = LogFactory.getLog(getClass()); - - /** - * The action builder utility to convert ManagerAction to a String suitable to be sent to the - * asterisk server. - */ - private final ActionBuilder actionBuilder; - - private SocketConnectionFacade socket; - - /** - * Creates a new ManagerWriter. - */ - public ManagerWriterImpl() - { - this.actionBuilder = new ActionBuilderImpl(); - } - - public void setTargetVersion(AsteriskVersion version) - { - actionBuilder.setTargetVersion(version); - } - - public synchronized void setSocket(final SocketConnectionFacade socket) - { - this.socket = socket; - } - - public synchronized void sendAction(final ManagerAction action, final String internalActionId) throws IOException - { - final String actionString; - - if (socket == null) - { - throw new IllegalStateException("Unable to send action: socket is null"); - } - - actionString = actionBuilder.buildAction(action, internalActionId); - - socket.write(actionString); - socket.flush(); - - // TODO tracing - //logger.debug("Sent " + action.getAction() + " action with actionId '" + action.getActionId() + "':\n" + actionString); - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ResponseBuilder.java b/src/main/java/org/asteriskjava/manager/internal/ResponseBuilder.java deleted file mode 100644 index 8ede4237c..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ResponseBuilder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.util.Map; - -import org.asteriskjava.manager.response.ManagerResponse; - - -/** - * Transforms maps of attributes to instances of ManagerResponse. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.response.ManagerResponse - */ -interface ResponseBuilder -{ - /** - * Constructs an instance of ManagerResponse based on a map of attributes. - * - * @param responseClass the expected subclass of ManagerResponse. - * @param attributes the attributes and their values. The keys of this map must be all lower - * case. - * @return the response with the given attributes. - */ - ManagerResponse buildResponse(Class responseClass, Map attributes); -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ResponseBuilderImpl.java b/src/main/java/org/asteriskjava/manager/internal/ResponseBuilderImpl.java deleted file mode 100644 index 1e2f740ab..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ResponseBuilderImpl.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; - - -/** - * Default implementation of the ResponseBuilder interface. - * - * @see org.asteriskjava.manager.response.ManagerResponse - * @author srt - * @version $Id$ - */ -class ResponseBuilderImpl extends AbstractBuilder implements ResponseBuilder -{ - private static final Set ignoredAttributes = new HashSet<>(Arrays.asList( - "attributes", "proxyresponse", ManagerReader.COMMAND_RESULT_RESPONSE_KEY)); - - private static final String RESPONSE_KEY = "response"; - private static final String PROXY_RESPONSE_KEY = "proxyresponse"; - private static final String RESPONSE_TYPE_ERROR = "error"; - private static final String OUTPUT_RESPONSE_KEY = "output"; //Asterisk 14.3.0 - - @SuppressWarnings("unchecked") - public ManagerResponse buildResponse(Class responseClass, Map attributes) - { - final ManagerResponse response; - final String responseType = (String) attributes.get(RESPONSE_KEY); - - if (RESPONSE_TYPE_ERROR.equalsIgnoreCase(responseType)) - { - response = new ManagerError(); - } - else if (responseClass == null) - { - response = new ManagerResponse(); - } - else - { - try - { - response = responseClass.newInstance(); - } - catch (Exception ex) - { - logger.error("Unable to create new instance of " + responseClass.getName(), ex); - return null; - } - } - - setAttributes(response, attributes, ignoredAttributes); - - if (response instanceof CommandResponse) - { - final CommandResponse commandResponse = (CommandResponse) response; - final List result = new ArrayList<>(); - //For Asterisk 14 - if(attributes.get(OUTPUT_RESPONSE_KEY) != null){ - if(attributes.get(OUTPUT_RESPONSE_KEY) instanceof List){ - for(String tmp : (List)attributes.get(OUTPUT_RESPONSE_KEY)){ - if(tmp != null && tmp.length() != 0){ - result.add(tmp.trim()); - } - } - }else{ - result.add((String)attributes.get(OUTPUT_RESPONSE_KEY)); - } - - }else{ - for (String resultLine : ((String) attributes.get(ManagerReader.COMMAND_RESULT_RESPONSE_KEY)).split("\n")) - { - // on error there is a leading space - if (!resultLine.equals("--END COMMAND--") && !resultLine.equals(" --END COMMAND--")) - { - result.add(resultLine); - } - } - } - commandResponse.setResult(result); - } - - if (response.getResponse() != null && attributes.get(PROXY_RESPONSE_KEY) != null) - { - response.setResponse((String) attributes.get(PROXY_RESPONSE_KEY)); - } - - // make the map of all attributes available to the response - // but clone it as it is reused by the ManagerReader - response.setAttributes(new HashMap(attributes)); - - return response; - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/ResponseEventsImpl.java b/src/main/java/org/asteriskjava/manager/internal/ResponseEventsImpl.java deleted file mode 100644 index f94013923..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/ResponseEventsImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.util.ArrayList; -import java.util.Collection; - -import org.asteriskjava.manager.ResponseEvents; -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.response.ManagerResponse; - - -/** - * Implementation of the ResponseEvents interface. - * - * @author srt - * @version $Id$ - * @since 0.2 - */ -public class ResponseEventsImpl implements ResponseEvents -{ - private ManagerResponse response; - private final Collection events; - private boolean complete; - - /** - * Creates a new instance. - */ - public ResponseEventsImpl() - { - this.events = new ArrayList<>(); - this.complete = false; - } - - // implementation of the ResponseEvents interface - - public ManagerResponse getResponse() - { - return response; - } - - public Collection getEvents() - { - return events; - } - - public boolean isComplete() - { - return complete; - } - - // helper methods to populate the ResponseEvents object - - /** - * Sets the ManagerResponse received. - * - * @param response the ManagerResponse received. - */ - public void setRepsonse(ManagerResponse response) - { - this.response = response; - } - - /** - * Adds a ResponseEvent that has been received. - * - * @param event the ResponseEvent that has been received. - */ - public void addEvent(ResponseEvent event) - { - synchronized (events) - { - events.add(event); - } - } - - /** - * Indicats if all events have been received. - * - * @param complete true if all events have been received, - * false otherwise. - */ - public void setComplete(boolean complete) - { - this.complete = complete; - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/BackwardsCompatibilityForManagerEvents.java b/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/BackwardsCompatibilityForManagerEvents.java deleted file mode 100644 index 32d6c4fcd..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/BackwardsCompatibilityForManagerEvents.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.manager.internal.backwardsCompatibility; - -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.internal.backwardsCompatibility.bridge.BridgesActive; -import org.asteriskjava.manager.internal.backwardsCompatibility.meetme.MeetmeCompatibility; - -public class BackwardsCompatibilityForManagerEvents -{ - // Logger logger = LogManager.getLogger(); - BridgesActive bridges = new BridgesActive(); - MeetmeCompatibility meetme = new MeetmeCompatibility(); - - public ManagerEvent handleEvent(ManagerEvent event) - { - ManagerEvent newEvent = bridges.handleEvent(event); - if (newEvent == null) - { - newEvent = meetme.handleEvent(event); - } - return newEvent; - } - -} diff --git a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/bridge/BridgeState.java b/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/bridge/BridgeState.java deleted file mode 100644 index a16171c6a..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/bridge/BridgeState.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.asteriskjava.manager.internal.backwardsCompatibility.bridge; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.manager.event.BridgeEnterEvent; -import org.asteriskjava.manager.event.BridgeEvent; -import org.asteriskjava.manager.event.BridgeLeaveEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Track the current members of a bridge, emmitting BridgeEvents when 2 members - * join or breakup - * - * @author rsutton - */ -class BridgeState -{ - final Log logger = LogFactory.getLog(getClass()); - - private final Map members = new HashMap<>(); - - ManagerEvent destroy() - { - synchronized (members) { - members.clear(); - } - return null; - } - - /** - * if there are exactly 2 members in the bridge, return a BridgeEvent - * - * @param event - * @return - */ - ManagerEvent addMember(BridgeEnterEvent event) - { - List remaining = null; - - synchronized (members) - { - if (members.put(event.getChannel(), event) == null - && members.size() == 2) - { - remaining = new ArrayList<>(members.values()); - } - } - - if (remaining == null) - { - return null; - } - - logger.info("Members size " + remaining.size() + " " + event); - - BridgeEvent bridgeEvent = buildBridgeEvent( - BridgeEvent.BRIDGE_STATE_LINK, - remaining); - - logger.info("Bridge " + bridgeEvent.getChannel1() + " " + bridgeEvent.getChannel2()); - - return bridgeEvent; - } - - /** - * If there are exactly 2 members in the bridge, return a BridgeEvent - * - * @param event - * @return - */ - - ManagerEvent removeMember(BridgeLeaveEvent event) - { - List remaining = null; - - synchronized (members) - { - if (members.remove(event.getChannel()) != null - && members.size() == 2) - { - remaining = new ArrayList<>(members.values()); - } - } - - // If we didn't remove anything, or we aren't at exactly 2 members, - // there's nothing else for us to do - if (remaining == null) - { - return null; - } - - return buildBridgeEvent( - BridgeEvent.BRIDGE_STATE_UNLINK, - remaining); - } - - private BridgeEvent buildBridgeEvent(String bridgeState, List members) - { - BridgeEvent bridgeEvent = new BridgeEvent(this); - - bridgeEvent.setCallerId1(members.get(0).getCallerIdNum()); - bridgeEvent.setUniqueId1(members.get(0).getUniqueId()); - bridgeEvent.setChannel1(members.get(0).getChannel()); - - bridgeEvent.setCallerId2(members.get(1).getCallerIdNum()); - bridgeEvent.setUniqueId2(members.get(1).getUniqueId()); - bridgeEvent.setChannel2(members.get(1).getChannel()); - - bridgeEvent.setBridgeState(bridgeState); - bridgeEvent.setDateReceived(new Date()); - - return bridgeEvent; - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/bridge/BridgesActive.java b/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/bridge/BridgesActive.java deleted file mode 100644 index 7ebe13854..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/bridge/BridgesActive.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.asteriskjava.manager.internal.backwardsCompatibility.bridge; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.asteriskjava.manager.event.BridgeCreateEvent; -import org.asteriskjava.manager.event.BridgeDestroyEvent; -import org.asteriskjava.manager.event.BridgeEnterEvent; -import org.asteriskjava.manager.event.BridgeLeaveEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Backwards compatibility for bridge events.
- *
- * Asterisk 13 uses BridgeCreate, BridgeEnter, BridgeLeave and BridgeDestroy - * events.
- *
- * Here we track active bridges and simulate BridgeEvent's for them allowing - * legacy code to still work with BridgeEvent's - * - * @author rsutton - */ -public class BridgesActive -{ - private final Log logger = LogFactory.getLog(BridgesActive.class); - - // This map is shared (static) so that connections to asterisk that attach - // late can benefit from the known bridge information of older connections - private final static ConcurrentMap activeBridges = - new ConcurrentHashMap<>(); - - public ManagerEvent handleEvent(ManagerEvent event) - { - if (event instanceof BridgeCreateEvent) - { - return createBridge((BridgeCreateEvent) event); - } - else if (event instanceof BridgeDestroyEvent) - { - return destroyBridge((BridgeDestroyEvent) event); - } - else if (event instanceof BridgeEnterEvent) - { - return enterBridge((BridgeEnterEvent) event); - } - else if (event instanceof BridgeLeaveEvent) - { - return leaveBridge((BridgeLeaveEvent) event); - } - return null; - } - - ManagerEvent createBridge(BridgeCreateEvent event) - { - activeBridges.putIfAbsent(event.getBridgeUniqueId(), new BridgeState()); - return null; - } - - ManagerEvent destroyBridge(BridgeDestroyEvent event) - { - BridgeState state = activeBridges.remove(event.getBridgeUniqueId()); - if (state != null) - { - return state.destroy(); - } - logger.info("Cant find bridge for id " + event.getBridgeUniqueId()); - return null; - } - - ManagerEvent enterBridge(BridgeEnterEvent event) - { - BridgeState state = activeBridges.get(event.getBridgeUniqueId()); - if (state != null) - { - return state.addMember(event); - } - logger.error("Cant find bridge for id " + event.getBridgeUniqueId()); - return null; - } - - ManagerEvent leaveBridge(BridgeLeaveEvent event) - { - BridgeState state = activeBridges.get(event.getBridgeUniqueId()); - if (state != null) - { - return state.removeMember(event); - } - logger.info("Cant find bridge for id " + event.getBridgeUniqueId()); - return null; - } -} diff --git a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/meetme/MeetmeCompatibility.java b/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/meetme/MeetmeCompatibility.java deleted file mode 100644 index 51fd9096c..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/backwardsCompatibility/meetme/MeetmeCompatibility.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.asteriskjava.manager.internal.backwardsCompatibility.meetme; - -import java.util.Date; - -import org.asteriskjava.manager.event.ConfbridgeEndEvent; -import org.asteriskjava.manager.event.ConfbridgeJoinEvent; -import org.asteriskjava.manager.event.ConfbridgeLeaveEvent; -import org.asteriskjava.manager.event.ConfbridgeStartEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.MeetMeEndEvent; -import org.asteriskjava.manager.event.MeetMeJoinEvent; -import org.asteriskjava.manager.event.MeetMeLeaveEvent; - -/** - * Backwards compatibility for bridge events.
- *
- * Asterisk 13 uses BridgeCreate, BridgeEnter, BridgeLeave and BridgeDestroy - * events.
- *
- * Here we track active bridges and simulate BridgeEvent's for them allowing - * legacy code to still work with BridgeEvent's - * - * @author rsutton - */ -public class MeetmeCompatibility -{ - - public ManagerEvent handleEvent(ManagerEvent event) - { - if (event instanceof ConfbridgeStartEvent) - { - } - else if (event instanceof ConfbridgeEndEvent) - { - MeetMeEndEvent endEvent = new MeetMeEndEvent(this); - endEvent.setDateReceived(new Date()); - endEvent.setMeetMe(((ConfbridgeEndEvent) event).getConference()); - return endEvent; - } - else - - if (event instanceof ConfbridgeJoinEvent) - { - MeetMeJoinEvent joinEvent = new MeetMeJoinEvent(this); - joinEvent.setCallerIdNum(event.getCallerIdNum()); - joinEvent.setCallerIdName(event.getCallerIdName()); - joinEvent.setUniqueId(((ConfbridgeJoinEvent) event).getUniqueId()); - joinEvent.setChannel(((ConfbridgeJoinEvent) event).getChannel()); - joinEvent.setMeetMe(((ConfbridgeJoinEvent) event).getBridgeName()); - joinEvent.setDateReceived(new Date()); - - return joinEvent; - } - else if (event instanceof ConfbridgeLeaveEvent) - { - MeetMeLeaveEvent leaveEvent = new MeetMeLeaveEvent(this); - leaveEvent.setCallerIdNum(event.getCallerIdNum()); - leaveEvent.setCallerIdName(event.getCallerIdName()); - leaveEvent.setUniqueId(((ConfbridgeLeaveEvent) event).getUniqueId()); - leaveEvent.setChannel(((ConfbridgeLeaveEvent) event).getChannel()); - leaveEvent.setMeetMe(((ConfbridgeLeaveEvent) event).getConference()); - leaveEvent.setDateReceived(new Date()); - - return leaveEvent; - } - return null; - - } - -} diff --git a/src/main/java/org/asteriskjava/manager/internal/package.html b/src/main/java/org/asteriskjava/manager/internal/package.html deleted file mode 100644 index 18114dfdd..000000000 --- a/src/main/java/org/asteriskjava/manager/internal/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides private implementations for interfaces defined in the - org.asteriskjava.manager package.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/package.html b/src/main/java/org/asteriskjava/manager/package.html deleted file mode 100644 index 706dd9aa2..000000000 --- a/src/main/java/org/asteriskjava/manager/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

Provides an implementaion of Asterisk's Manager API.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/response/.gitignore b/src/main/java/org/asteriskjava/manager/response/.gitignore deleted file mode 100644 index 4b0f455d7..000000000 --- a/src/main/java/org/asteriskjava/manager/response/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/ChallengeResponse.class -/CommandResponse.class -/CoreSettingsResponse.class -/CoreStatusResponse.class -/ExtensionStateResponse.class -/GetConfigResponse.class -/GetVarResponse.class -/MailboxCountResponse.class -/MailboxStatusResponse.class -/ManagerError.class -/ManagerResponse.class -/ModuleCheckResponse.class -/PingResponse.class -/SipShowPeerResponse.class -/SkypeBuddyResponse.class -/SkypeLicenseStatusResponse.class diff --git a/src/main/java/org/asteriskjava/manager/response/ChallengeResponse.java b/src/main/java/org/asteriskjava/manager/response/ChallengeResponse.java deleted file mode 100644 index 0727fb552..000000000 --- a/src/main/java/org/asteriskjava/manager/response/ChallengeResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a ChallengeAction and contains the challenge needed to log in using - * challenge/response. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ChallengeAction - * @see org.asteriskjava.manager.action.LoginAction - */ -public class ChallengeResponse extends ManagerResponse -{ - private static final long serialVersionUID = -7253724086340850957L; - - private String challenge; - - /** - * Returns the challenge to use when creating the key for log in. - * - * @return the challenge to use when creating the key for log in. - * @see org.asteriskjava.manager.action.LoginAction#setKey(String) - */ - public String getChallenge() - { - return challenge; - } - - public void setChallenge(String challenge) - { - this.challenge = challenge; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/CommandResponse.java b/src/main/java/org/asteriskjava/manager/response/CommandResponse.java deleted file mode 100644 index f0a33baa9..000000000 --- a/src/main/java/org/asteriskjava/manager/response/CommandResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -import java.util.List; - -/** - * Response that is received when sending a CommandAction.

- * Asterisk's handling of the command action is generelly quite hairy. It sends a "Response: - * Follows" line followed by the raw output of the command including empty lines. At the end of the - * command output a line containing "--END COMMAND--" is sent. The reader parses this response into - * a CommandResponse object to hide these details. - * - * @see org.asteriskjava.manager.action.CommandAction - * - * @author srt - * @version $Id$ - */ -public class CommandResponse extends ManagerResponse -{ - private static final long serialVersionUID = 1L; - - private String privilege; - private List result; - - /** - * Returns the AMI authorization class of this response. - * - * @return always "Command" - * @since 1.0.0 - */ - public String getPrivilege() - { - return privilege; - } - - public void setPrivilege(String privilege) - { - this.privilege = privilege; - } - - /** - * Returns a List of strings representing the lines returned by the CLI command. - * - * @return a List of strings representing the lines returned by the CLI command. - */ - public List getResult() - { - return result; - } - - /** - * Sets the result. - */ - public void setResult(List result) - { - this.result = result; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/CoreSettingsResponse.java b/src/main/java/org/asteriskjava/manager/response/CoreSettingsResponse.java deleted file mode 100644 index cd06a0f82..000000000 --- a/src/main/java/org/asteriskjava/manager/response/CoreSettingsResponse.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a CoreSettingsAction and contains the current settings summary of the - * Asterisk server. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.CoreSettingsAction - * @since 1.0.0 - */ -public class CoreSettingsResponse extends ManagerResponse -{ - private static final long serialVersionUID = 1L; - - private String amiVersion; - private String asteriskVersion; - private String systemName; - private Integer coreMaxCalls; - private Double coreMaxLoadAvg; - private String coreRunUser; - private String coreRunGroup; - private Integer coreMaxFilehandles; - private Boolean coreRealtimeEnabled; - private Boolean coreCdrEnabled; - private Boolean coreHttpEnabled; - - /** - * Returns the version of the Asterisk Manager Interface (AMI). For Asterisk 1.6 this is "1.1". - * - * @return the version of the Asterisk Manager Interface (AMI). - */ - public String getAmiVersion() - { - return amiVersion; - } - - public void setAmiVersion(String amiVersion) - { - this.amiVersion = amiVersion; - } - - /** - * Returns the version of the Asterisk server. For example "1.6.0-beta9". - * - * @return the version of the Asterisk server. - */ - public String getAsteriskVersion() - { - return asteriskVersion; - } - - public void setAsteriskVersion(String asteriskVersion) - { - this.asteriskVersion = asteriskVersion; - } - - public String getSystemName() - { - return systemName; - } - - public void setSystemName(String systemName) - { - this.systemName = systemName; - } - - public Integer getCoreMaxCalls() - { - return coreMaxCalls; - } - - public void setCoreMaxCalls(Integer coreMaxCalls) - { - this.coreMaxCalls = coreMaxCalls; - } - - public Double getCoreMaxLoadAvg() - { - return coreMaxLoadAvg; - } - - public void setCoreMaxLoadAvg(Double coreMaxLoadAvg) - { - this.coreMaxLoadAvg = coreMaxLoadAvg; - } - - public String getCoreRunUser() - { - return coreRunUser; - } - - public void setCoreRunUser(String coreRunUser) - { - this.coreRunUser = coreRunUser; - } - - public String getCoreRunGroup() - { - return coreRunGroup; - } - - public void setCoreRunGroup(String coreRunGroup) - { - this.coreRunGroup = coreRunGroup; - } - - public Integer getCoreMaxFilehandles() - { - return coreMaxFilehandles; - } - - public void setCoreMaxFilehandles(Integer coreMaxFilehandles) - { - this.coreMaxFilehandles = coreMaxFilehandles; - } - - /** - * Checks whether the realtime subsystem is enabled. - * - * @return true if the realtime subsystem is enabled, false otherwise. - */ - public boolean isCoreRealtimeEnabled() - { - return coreRealtimeEnabled != null && coreRealtimeEnabled; - } - - public void setCoreRealtimeEnabled(Boolean coreRealtimeEnabled) - { - this.coreRealtimeEnabled = coreRealtimeEnabled; - } - - /** - * Checks whether the CDR (call detail records) subsystem is enabled. - * - * @return true if the CDR subsystem is enabled, false otherwise. - */ - public boolean isCoreCdrEnabled() - { - return coreCdrEnabled != null && coreCdrEnabled; - } - - public void setCoreCdrEnabled(Boolean coreCdrEnabled) - { - this.coreCdrEnabled = coreCdrEnabled; - } - - /** - * Checks whether the HTTP subsystem is enabled. - * - * @return true if the HTTP subsystem is enabled, false otherwise. - */ - public boolean isCoreHttpEnabled() - { - return coreHttpEnabled != null && coreHttpEnabled; - } - - public void setCoreHttpEnabled(Boolean coreHttpEnabled) - { - this.coreHttpEnabled = coreHttpEnabled; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/response/CoreStatusResponse.java b/src/main/java/org/asteriskjava/manager/response/CoreStatusResponse.java deleted file mode 100644 index 9e78dde1e..000000000 --- a/src/main/java/org/asteriskjava/manager/response/CoreStatusResponse.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -import java.util.Date; -import java.util.TimeZone; - -import org.asteriskjava.util.DateUtil; - -/** - * Corresponds to a CoreStatusAction and contains the current status summary of the - * Asterisk server. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.CoreStatusAction - * @since 1.0.0 - */ -public class CoreStatusResponse extends ManagerResponse -{ - private static final long serialVersionUID = 1L; - - private String coreStartupTime; - private String coreReloadTime; - private Integer coreCurrentCalls; - private String coreStartupDate; - private String coreReloadDate; - - - /** - * Returns the time the server (core module) was last reloaded. The format is %H:%M:%S. - * - * @return the time the server (core module) was last reloaded. - */ - public String getCoreReloadTime() - { - return coreReloadTime; - } - - public void setCoreReloadTime(String s) - { - // format is %H:%M:%S - this.coreReloadTime = s; - } - - /** - * Returns the date the server (core module) was last reloaded. The format is Y-%m-%d.

- * Available since Asterisk 1.6.3 - * - * @return the date the server (core module) was last reloaded. - */ - public String getCoreReloadDate() - { - return coreReloadDate; - } - - public void setCoreReloadDate(String CoreReloadDate) - { - this.coreReloadDate = CoreReloadDate; - } - - /** - * Returns the and time the server (core module) was last reloaded.

- * If either the date or time property is null (e.g. on Asterisk prior to 1.6.3) this method - * returns null. - * - * @return the and time the server (core module) was last reloaded or null if not available. - * @see #getCoreReloadDate() - * @see #getCoreReloadTime() - * @see #getCoreReloadDateTimeAsDate(java.util.TimeZone) - */ - public Date getCoreReloadDateTimeAsDate() - { - return getCoreReloadDateTimeAsDate(null); - } - - /** - * Returns the date the server (core module) was last reloaded.

- * If either the date or time property is null (e.g. on Asterisk prior to 1.6.3) this method - * returns null. - * - * @param tz the time zone of the Asterisk server, null to use the default time zone. - * @return the date the server (core module) was last reloaded or null if not available. - * @see #getCoreReloadDate() - * @see #getCoreReloadTime() - */ - public Date getCoreReloadDateTimeAsDate(TimeZone tz) - { - if (coreReloadDate == null || coreReloadTime == null) - { - return null; - } - - return DateUtil.parseDateTime(coreReloadDate + " " + coreReloadTime, tz); - } - - /** - * Returns the date the server was started. The format is Y-%m-%d.

- * Available since Asterisk 1.6.3 - * - * @return the date the server was started. - */ - public String getCoreStartupDate() - { - return coreStartupDate; - } - - public void setCoreStartupDate(String CoreStartupDate) - { - this.coreStartupDate = CoreStartupDate; - } - - /** - * Returns the time the server was started. The format is %H:%M:%S. - * - * @return the time the server was started. - */ - public String getCoreStartupTime() - { - return coreStartupTime; - } - - public void setCoreStartupTime(String s) - { - // format is %H:%M:%S - this.coreStartupTime = s; - } - - /** - * Returns the date and time the server was started.

- * If either the date or time property is null (e.g. on Asterisk prior to 1.6.3) this method - * returns null. - * - * @return the date the server was started or null if not available. - * @see #getCoreStartupDate() - * @see #getCoreStartupTime() - * @see #getCoreStartupDateTimeAsDate(java.util.TimeZone) - */ - public Date getCoreStartupDateTimeAsDate() - { - return getCoreStartupDateTimeAsDate(null); - } - - /** - * Returns the date and time the server was started.

- * If either the date or time property is null (e.g. on Asterisk prior to 1.6.3) this method - * returns null. - * - * @param tz the time zone of the Asterisk server, null to use the default time zone. - * @return the date the server was started or null if not available. - * @see #getCoreStartupDate() - * @see #getCoreStartupTime() - */ - public Date getCoreStartupDateTimeAsDate(TimeZone tz) - { - if (coreStartupDate == null || coreStartupTime == null) - { - return null; - } - - return DateUtil.parseDateTime(coreStartupDate + " " + coreStartupTime, tz); - } - - /** - * Returns the number of currently active channels on the server. - * - * @return the number of currently active channels on the server. - */ - public Integer getCoreCurrentCalls() - { - return coreCurrentCalls; - } - - public void setCoreCurrentCalls(Integer coreCurrentCalls) - { - this.coreCurrentCalls = coreCurrentCalls; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/ExtensionStateResponse.java b/src/main/java/org/asteriskjava/manager/response/ExtensionStateResponse.java deleted file mode 100644 index 086cf9635..000000000 --- a/src/main/java/org/asteriskjava/manager/response/ExtensionStateResponse.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Response to an {@link org.asteriskjava.manager.action.ExtensionStateAction}. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ExtensionStateAction - */ -public class ExtensionStateResponse extends ManagerResponse -{ - private static final long serialVersionUID = -2044248427247227390L; - private String exten; - private String context; - private String hint; - private Integer status; - private String statusText; - - public String getExten() - { - return exten; - } - - public void setExten(String exten) - { - this.exten = exten; - } - - public String getContext() - { - return context; - } - - public void setContext(String context) - { - this.context = context; - } - - public String getHint() - { - return hint; - } - - public void setHint(String hint) - { - this.hint = hint; - } - - public Integer getStatus() - { - return status; - } - - public void setStatus(Integer status) - { - this.status = status; - } - - public String getStatusText() - { - return statusText; - } - - public void setStatusText(String statusText) - { - this.statusText = statusText; - } - - - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder(getClass().getName() + ": "); - sb.append("actionId='").append(getActionId()).append("'; "); - sb.append("message='").append(getMessage()).append("'; "); - sb.append("response='").append(getResponse()).append("'; "); - sb.append("uniqueId='").append(getUniqueId()).append("'; "); - sb.append("exten='").append(getExten()).append("'; "); - sb.append("context='").append(getContext()).append("'; "); - sb.append("hint='").append(getHint()).append("'; "); - sb.append("status='").append(getStatus()).append("'; "); - sb.append("statustext='").append(getStatusText()).append("'; "); - sb.append("systemHashcode=").append(System.identityHashCode(this)); - - return sb.toString(); - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/GetConfigResponse.java b/src/main/java/org/asteriskjava/manager/response/GetConfigResponse.java deleted file mode 100644 index 7ed95d4d5..000000000 --- a/src/main/java/org/asteriskjava/manager/response/GetConfigResponse.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2004-2007 Stefan Reuter and others - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.TreeMap; - -/** - * Response that is received when sending a GetConfigAction. - *

- * Asterisk's response to the GetConfig command is ugly, and requires some - * parsing of attributes. This class lazily parses its own attributes to hide - * the ugly details. If the file requested exists but does not contain at least - * a line with a category, the ResponseBuilder won't create an instance of - * GetConfigResponse, as it won't know what the empty response is. - * - * @see org.asteriskjava.manager.action.GetConfigAction - * @author martins - * @since 0.3 - */ -public class GetConfigResponse extends ManagerResponse -{ - private static final long serialVersionUID = -2044248427247227390L; - - private Map categories; - private Map> lines; - - /** - * Returns the map of category numbers to category names. - * - * @return the map of category numbers to names. - * @see org.asteriskjava.manager.response.GetConfigResponse#getLines - */ - public Map getCategories() - { - if (categories == null) - { - categories = new TreeMap<>(); - } - - Map responseMap = super.getAttributes(); - for (Entry response : responseMap.entrySet()) - { - String key = response.getKey(); - if (key.toLowerCase(Locale.US).contains("category")) - { - String[] keyParts = key.split("-"); - - // if it doesn't have at least category-XXXXXX, skip - if (keyParts.length < 2) - continue; - - // try to get the number of this category, skip if we mess up - Integer categoryNumber; - try - { - categoryNumber = Integer.parseInt(keyParts[1]); - } - catch (Exception exception) - { - continue; - } - - categories.put(categoryNumber, (String) response.getValue()); - } - } - - return categories; - } - - /** - * Returns the map of line number to line value for a given category. - * - * @param categoryNumber a valid category number from getCategories. - * @return the map of category numbers to names. - * @see org.asteriskjava.manager.response.GetConfigResponse#getCategories - */ - public Map getLines(int categoryNumber) - { - if (lines == null) - { - lines = new TreeMap<>(); - } - - Map responseMap = super.getAttributes(); - for (Entry response : responseMap.entrySet()) - { - String key = response.getKey(); - if (key.toLowerCase(Locale.US).contains("line")) - { - String[] keyParts = key.split("-"); - - // if it doesn't have at least line-XXXXXX-XXXXXX, skip - if (keyParts.length < 3) - { - continue; - } - - // try to get the number of this category, skip if we mess up - Integer potentialCategoryNumber; - try - { - potentialCategoryNumber = Integer.parseInt(keyParts[1]); - } - catch (Exception exception) - { - continue; - } - - // try to get the number of this line, skip if we mess up - Integer potentialLineNumber; - try - { - potentialLineNumber = Integer.parseInt(keyParts[2]); - } - catch (Exception exception) - { - continue; - } - - // get the List out for placing stuff in - Map linesForCategory = lines.get(potentialCategoryNumber); - if (linesForCategory == null) - { - linesForCategory = new TreeMap<>(); - } - - // put the line we just parsed into the line map for this category - linesForCategory.put(potentialLineNumber, (String) response.getValue()); - if (!lines.containsKey(potentialCategoryNumber)) - { - lines.put(potentialCategoryNumber, linesForCategory); - } - } - } - - return lines.get(categoryNumber); - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/GetVarResponse.java b/src/main/java/org/asteriskjava/manager/response/GetVarResponse.java deleted file mode 100644 index ba862d475..000000000 --- a/src/main/java/org/asteriskjava/manager/response/GetVarResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a GetVarAction and contains the value of the requested variable. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.GetVarAction - * @since 1.0.0 - */ -public class GetVarResponse extends ManagerResponse -{ - private static final long serialVersionUID = 1L; - - private String variable; - private String value; - - /** - * Returns the name of the requested variable. - * - * @return the name of the requested variable. - */ - public String getVariable() - { - return variable; - } - - /** - * Sets the name of the requested variable. - * - * @param variable the name of the requested variable. - */ - public void setVariable(String variable) - { - this.variable = variable; - } - - /** - * Returns the value of the requested variable. - * - * @return the value of the requested variable. - */ - public String getValue() - { - return value; - } - - /** - * Sets the value of the requested variable. - * - * @param value the value of the requested variable. - */ - public void setValue(String value) - { - this.value = value; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/response/MailboxCountResponse.java b/src/main/java/org/asteriskjava/manager/response/MailboxCountResponse.java deleted file mode 100644 index 24db2e53e..000000000 --- a/src/main/java/org/asteriskjava/manager/response/MailboxCountResponse.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * A MailboxCountResponse is sent in response to a MailboxCountAction and contains the number of old - * and new messages in a mailbox. - * - * @see org.asteriskjava.manager.action.MailboxCountAction - * - * @author srt - * @version $Id$ - */ -public class MailboxCountResponse extends ManagerResponse -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = 7820598941277275838L; - private String mailbox; - private Integer newMessages; - private Integer oldMessages; - - /** - * Returns the name of the mailbox. - */ - public String getMailbox() - { - return mailbox; - } - - /** - * Sets the name of the mailbox. - */ - public void setMailbox(String mailbox) - { - this.mailbox = mailbox; - } - - /** - * Returns the number of new messages in the mailbox. - */ - public Integer getNewMessages() - { - return newMessages; - } - - /** - * Sets the number of new messages in the mailbox. - */ - public void setNewMessages(Integer newMessages) - { - this.newMessages = newMessages; - } - - /** - * Returns the number of old messages in the mailbox. - */ - public Integer getOldMessages() - { - return oldMessages; - } - - /** - * Sets the number of old messages in the mailbox. - */ - public void setOldMessages(Integer oldMessages) - { - this.oldMessages = oldMessages; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/MailboxStatusResponse.java b/src/main/java/org/asteriskjava/manager/response/MailboxStatusResponse.java deleted file mode 100644 index f76155fd5..000000000 --- a/src/main/java/org/asteriskjava/manager/response/MailboxStatusResponse.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * A MailboxStatusResponse is sent in response to a MailboxStatusAction and indicates if a set - * of mailboxes contains waiting messages. - * - * @see org.asteriskjava.manager.action.MailboxStatusAction - * - * @author srt - * @version $Id$ - */ -public class MailboxStatusResponse extends ManagerResponse -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -7193581424292429279L; - - /** - * The name of the mailbox. - */ - private String mailbox; - - /** - * Indicates if there are new messages waiting in the given set of mailboxes. - */ - private Boolean waiting; - - /** - * Returns the names of the mailboxes, separated by ",". - * @return the names of the mailbox. - */ - public String getMailbox() - { - return mailbox; - } - - /** - * Sets the names of the mailboxes. - * @param mailbox the names of the mailboxes. - */ - public void setMailbox(String mailbox) - { - this.mailbox = mailbox; - } - - /** - * Returns Boolean.TRUE if at least one of the given mailboxes contains new messages; - * Boolean.FALSE otherwise. - */ - public Boolean getWaiting() - { - return waiting; - } - - /** - * Set to Boolean.TRUE if at least one of the mailboxes contains new messages; - * Boolean.FALSE otherwise. - */ - public void setWaiting(Boolean waiting) - { - this.waiting = waiting; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/ManagerError.java b/src/main/java/org/asteriskjava/manager/response/ManagerError.java deleted file mode 100644 index 47947439f..000000000 --- a/src/main/java/org/asteriskjava/manager/response/ManagerError.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Represents an "Response: Error" response received from the asterisk server. - * The cause for the error is given in the message attribute. - * - * @author srt - * @version $Id$ - */ -public class ManagerError extends ManagerResponse -{ - /** - * Serial version identifier - */ - private static final long serialVersionUID = -8753149536715547476L; - - /** - * Creates a new ManagerError. - */ - public ManagerError() - { - super(); - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/ManagerResponse.java b/src/main/java/org/asteriskjava/manager/response/ManagerResponse.java deleted file mode 100644 index 75fb7650f..000000000 --- a/src/main/java/org/asteriskjava/manager/response/ManagerResponse.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -import java.io.Serializable; -import java.util.Date; -import java.util.Locale; -import java.util.Map; - -/** - * Represents a response received from the Asterisk server as the result of a - * previously sent ManagerAction. - *

- * The response can be linked with the action that caused it by looking the - * action id attribute that will match the action id of the corresponding - * action. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ManagerAction - */ -public class ManagerResponse implements Serializable -{ - private static final long serialVersionUID = 1L; - - private Date dateReceived; - private String actionId; - - /** - * The server from which this response has been received (only used with - * AstManProxy). - */ - private String server; - private String response; - private String eventList; - private String message; - private String uniqueId; - private String events; - private Map attributes; - private String output; - - public ManagerResponse() - { - this.attributes = null; - } - - /** - * Returns a Map with all attributes of this response. - *

- * The keys are all lower case! - * - * @see #getAttribute(String) - */ - public Map getAttributes() - { - return attributes; - } - - /** - * Sets the Map with all attributes. - * - * @param attributes Map with containing the attributes with all lower case - * keys. - */ - public void setAttributes(Map attributes) - { - this.attributes = attributes; - } - - /** - * Returns the value of the attribute with the given key. - *

- * This is particulary important when a response contains special attributes - * that are dependent on the action that has been sent. - *

- * An example of this is the response to the GetVarAction. It contains the - * value of the channel variable as an attribute stored under the key of the - * variable name. - *

- * Example: - * - *

-     * GetVarAction action = new GetVarAction();
-     * action.setChannel("SIP/1310-22c3");
-     * action.setVariable("ALERT_INFO");
-     * ManagerResponse response = connection.sendAction(action);
-     * String alertInfo = response.getAttribute("ALERT_INFO");
-     * 
- * - * As all attributes are internally stored in lower case the key is - * automatically converted to lower case before lookup. - * - * @param key the key to lookup. - * @return the value of the attribute stored under this key or - * null if there is no such attribute. - */ - public String getAttribute(String key) - { - return (String) attributes.get(key.toLowerCase(Locale.ENGLISH)); - } - - /** - * Returns the point in time this response was received from the asterisk - * server. - */ - public Date getDateReceived() - { - return dateReceived; - } - - /** - * Sets the point in time this response was received from the asterisk - * server. - */ - public void setDateReceived(Date dateReceived) - { - this.dateReceived = dateReceived; - } - - /** - * Returns the user provided action id of the ManagerAction that caused this - * response. If the application did not set an action id this method returns - * null. - * - * @return the action id of the ManagerAction that caused this response or - * null if none was set. - * @see org.asteriskjava.manager.action.ManagerAction#setActionId(String) - */ - public String getActionId() - { - return actionId; - } - - /** - * Returns the name of the Asterisk server from which this response has been - * received.
- * This property is only available when using to AstManProxy. - * - * @return the name of the Asterisk server from which this response has been - * received or null when directly connected to an - * Asterisk server instead of AstManProxy. - * @since 1.0.0 - */ - public final String getServer() - { - return server; - } - - /** - * Sets the name of the Asterisk server from which this response has been - * received. - * - * @param server the name of the Asterisk server from which this response - * has been received. - * @since 1.0.0 - */ - public final void setServer(String server) - { - this.server = server; - } - - /** - * Sent for manager events that reply with a list of events. - * - * @return "start", "stop" or "complete" - * @since 1.0.0 - */ - public String getEventList() - { - return eventList; - } - - /** - * Sets the eventList. - * - * @param eventList the eventList. - * @since 1.0.0 - */ - public void setEventList(String eventList) - { - this.eventList = eventList; - } - - /** - * Sets the action id of the ManagerAction that caused this response. - * - * @param actionId the action id of the ManagerAction that caused this - * response. - */ - public void setActionId(String actionId) - { - this.actionId = actionId; - } - - /** - * Returns the message received with this response. The content depends on - * the action that generated this response. - */ - public String getMessage() - { - return message; - } - - /** - * Sets the message. - */ - public void setMessage(String message) - { - this.message = message; - } - - /** - * Returns the value of the "Response:" line. This typically a String like - * "Success" or "Error" but depends on the action that generated this - * response. - */ - public String getResponse() - { - return response; - } - - /** - * Sets the response. - */ - public void setResponse(String response) - { - this.response = response; - } - - /** - * Returns the unique id received with this response. The unique id is used - * to keep track of channels created by the action sent, for example an - * OriginateAction. - */ - public String getUniqueId() - { - return uniqueId; - } - - /** - * Sets the unique id received with this response. - */ - public void setUniqueId(String uniqueId) - { - this.uniqueId = uniqueId; - } - - protected Integer stringToInteger(String s, String suffix) throws NumberFormatException - { - if (s == null || s.length() == 0) - { - return null; - } - - if (suffix != null && s.endsWith(suffix)) - { - return Integer.parseInt(s.substring(0, s.length() - suffix.length()).trim()); - } - - return Integer.parseInt(s.trim()); - } - - protected Long stringToLong(String s, String suffix) throws NumberFormatException - { - if (s == null || s.length() == 0) - { - return null; - } - - if (suffix != null && s.endsWith(suffix)) - { - return Long.parseLong(s.substring(0, s.length() - suffix.length()).trim()); - } - - return Long.parseLong(s.trim()); - } - - @Override - public String toString() - { - StringBuilder sb; - - sb = new StringBuilder(100); - sb.append(getClass().getName()).append(": "); - sb.append("actionId='").append(getActionId()).append("'; "); - sb.append("message='").append(getMessage()).append("'; "); - sb.append("response='").append(getResponse()).append("'; "); - sb.append("uniqueId='").append(getUniqueId()).append("'; "); - sb.append("systemHashcode=").append(System.identityHashCode(this)); - - return sb.toString(); - } - - public String getEvents() - { - return events; - } - - public void setEvents(String events) - { - this.events = events; - } - - public String getOutput() { - return output; - } - - public void setOutput(String output) { - this.output = output; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/ModuleCheckResponse.java b/src/main/java/org/asteriskjava/manager/response/ModuleCheckResponse.java deleted file mode 100644 index ce03aa160..000000000 --- a/src/main/java/org/asteriskjava/manager/response/ModuleCheckResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a ModuleCheckAction and contains the version of the module. - * - * @author srt - * @version $Id$ - * @see org.asteriskjava.manager.action.ModuleCheckAction - * @since 1.0.0 - */ -public class ModuleCheckResponse extends ManagerResponse -{ - private static final long serialVersionUID = -7253724086340850957L; - - private String version; - - /** - * Returns the version (svn revision) of the module. - * - * @return the version (svn revision) of the module. - */ - public String getVersion() - { - return version; - } - - public void setVersion(String version) - { - this.version = version; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/response/PingResponse.java b/src/main/java/org/asteriskjava/manager/response/PingResponse.java deleted file mode 100644 index 38a8a3f96..000000000 --- a/src/main/java/org/asteriskjava/manager/response/PingResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a PingAction and contains an additional (yet useless) ping property. - * - * @author srt - * @see org.asteriskjava.manager.action.PingAction - */ -public class PingResponse extends ManagerResponse -{ - private static final long serialVersionUID = 0L; - - private String ping; - private String timestamp; - - /** - * Returns always "Pong". - * - * @return always "Pong". - */ - public String getPing() - { - return ping; - } - - public void setPing(String ping) - { - this.ping = ping; - } - - /** - * Timestamp for the response. - * @return Timestamp as a String, e.g 1353747825.795863 - * @since 1.0.0 - */ - public String getTimestamp() - { - return timestamp; - } - - public void setTimestamp(String timestamp) - { - this.timestamp = timestamp; - } -} diff --git a/src/main/java/org/asteriskjava/manager/response/SipShowPeerResponse.java b/src/main/java/org/asteriskjava/manager/response/SipShowPeerResponse.java deleted file mode 100644 index cab680b14..000000000 --- a/src/main/java/org/asteriskjava/manager/response/SipShowPeerResponse.java +++ /dev/null @@ -1,889 +0,0 @@ -package org.asteriskjava.manager.response; - -import java.util.Map; - -/** - * Response to a {@link org.asteriskjava.manager.action.SipShowPeerAction}. - * - * @author srt - * @version $Id$ - * @since 1.0.0 - * @see org.asteriskjava.manager.action.SipShowPeerAction - */ -public class SipShowPeerResponse extends ManagerResponse -{ - private static final long serialVersionUID = 1L; - - private String channelType; - private String objectName; - private String chanObjectType; - private Boolean secretExist; - private Boolean md5SecretExist; - private Boolean remoteSecretExist; - private String context; - private String language; - private String accountCode; - private String amaFlags; - private String cidCallingPres; - private String sipFromUser; - private String sipFromDomain; - private String callGroup; - private String pickupGroup; - private String voiceMailbox; - private String transferMode; - private Integer lastMsgsSent; - private Integer callLimit; - private Integer busyLevel; - private Integer maxCallBr; // "%d kbps" - private Boolean dynamic; - private String callerId; - private Long regExpire; // "%ld seconds" - private Boolean sipAuthInsecure; - private Boolean sipNatSupport; - private Boolean acl; - private Boolean sipT38support; - private String sipT38ec; - private Long sipT38MaxDtgrm; - private Boolean sipDirectMedia; - private Boolean sipCanReinvite; - private Boolean sipPromiscRedir; - private Boolean sipUserPhone; - private Boolean sipVideoSupport; - private Boolean sipTextSupport; - private String sipSessTimers; - private String sipSessRefresh; - private Integer sipSessExpires; - private Integer sipSessMin; - private String sipDtmfMode; - private String toHost; - private String addressIp; - private Integer addressPort; - private String defaultAddrIp; - private Integer defaultAddrPort; - private String defaultUsername; - private String regExtension; - private String codecs; - private String codecOrder; - private String status; - private String sipUserAgent; - private String regContact; - private Integer qualifyFreq; // "%d ms" - private String parkingLot; - private Integer maxForwards; - - private String toneZone; - private String sipUseReasonHeader; - private String sipEncryption; - private String sipForcerport; - private String sipRtpEngine; - private String sipComedia; - private String mohsuggest; - - private Map chanVariable; - - public String getChannelType() - { - return channelType; - } - - public void setChannelType(String channelType) - { - this.channelType = channelType; - } - - public String getObjectName() - { - return objectName; - } - - public void setObjectName(String objectName) - { - this.objectName = objectName; - } - - public String getChanObjectType() - { - return chanObjectType; - } - - public void setChanObjectType(String chanObjectType) - { - this.chanObjectType = chanObjectType; - } - - public Boolean getSecretExist() - { - return secretExist; - } - - public void setSecretExist(Boolean secretExist) - { - this.secretExist = secretExist; - } - - public Boolean getMd5SecretExist() - { - return md5SecretExist; - } - - public void setMd5SecretExist(Boolean md5SecretExist) - { - this.md5SecretExist = md5SecretExist; - } - - public Boolean getRemoteSecretExist() - { - return remoteSecretExist; - } - - public void setRemoteSecretExist(Boolean remoteSecretExist) - { - this.remoteSecretExist = remoteSecretExist; - } - - public String getContext() - { - return context; - } - - public void setContext(String context) - { - this.context = context; - } - - public String getLanguage() - { - return language; - } - - public void setLanguage(String language) - { - this.language = language; - } - - public String getAccountCode() - { - return accountCode; - } - - public void setAccountCode(String accountCode) - { - this.accountCode = accountCode; - } - - public String getAmaFlags() - { - return amaFlags; - } - - public void setAmaFlags(String amaFlags) - { - this.amaFlags = amaFlags; - } - - public String getCidCallingPres() - { - return cidCallingPres; - } - - public void setCidCallingPres(String cidCallingPres) - { - this.cidCallingPres = cidCallingPres; - } - - public String getSipFromUser() - { - return sipFromUser; - } - - public void setSipFromUser(String sipFromUser) - { - this.sipFromUser = sipFromUser; - } - - public String getSipFromDomain() - { - return sipFromDomain; - } - - public void setSipFromDomain(String sipFromDomain) - { - this.sipFromDomain = sipFromDomain; - } - - public String getCallGroup() - { - return callGroup; - } - - public void setCallGroup(String callGroup) - { - this.callGroup = callGroup; - } - - public String getPickupGroup() - { - return pickupGroup; - } - - public void setPickupGroup(String pickupGroup) - { - this.pickupGroup = pickupGroup; - } - - public String getVoiceMailbox() - { - return voiceMailbox; - } - - public void setVoiceMailbox(String voiceMailbox) - { - this.voiceMailbox = voiceMailbox; - } - - public String getTransferMode() - { - return transferMode; - } - - public void setTransferMode(String transferMode) - { - this.transferMode = transferMode; - } - - public Integer getLastMsgsSent() - { - return lastMsgsSent; - } - - public void setLastMsgsSent(Integer lastMsgsSent) - { - this.lastMsgsSent = lastMsgsSent; - } - - public Integer getCallLimit() - { - return callLimit; - } - - public void setCallLimit(Integer callLimit) - { - this.callLimit = callLimit; - } - - public Integer getBusyLevel() - { - return busyLevel; - } - - public void setBusyLevel(Integer busyLevel) - { - this.busyLevel = busyLevel; - } - - public Integer getMaxCallBr() - { - return maxCallBr; - } - - public void setMaxCallBr(String maxCallBr) - { - this.maxCallBr = stringToInteger(maxCallBr, "kbps"); - } - - public Boolean getDynamic() - { - return dynamic; - } - - public void setDynamic(Boolean dynamic) - { - this.dynamic = dynamic; - } - - public String getCallerId() - { - return callerId; - } - - public void setCallerId(String callerId) - { - this.callerId = callerId; - } - - public Long getRegExpire() - { - return regExpire; - } - - public void setRegExpire(String regExpire) - { - this.regExpire = stringToLong(regExpire, "seconds"); - } - - public Boolean getSipAuthInsecure() - { - return sipAuthInsecure; - } - - public void setSipAuthInsecure(Boolean sipAuthInsecure) - { - this.sipAuthInsecure = sipAuthInsecure; - } - - public Boolean getSipNatSupport() - { - return sipNatSupport; - } - - public void setSipNatSupport(Boolean sipNatSupport) - { - this.sipNatSupport = sipNatSupport; - } - - public Boolean getAcl() - { - return acl; - } - - public void setAcl(Boolean acl) - { - this.acl = acl; - } - - public Boolean getSipT38support() - { - return sipT38support; - } - - public void setSipT38support(Boolean sipT38support) - { - this.sipT38support = sipT38support; - } - - public String getSipT38ec() - { - return sipT38ec; - } - - public void setSipT38ec(String sipT38ec) - { - this.sipT38ec = sipT38ec; - } - - public Long getSipT38MaxDtgrm() - { - return sipT38MaxDtgrm; - } - - public void setSipT38MaxDtgrm(Long sipT38MaxDtgrm) - { - - /** - * asterisk returns sipT38MaxDtgrm as 4394967295L when the value is -1 - * so I'm taking a long and then changing it to -1 if required - */ - if (sipT38MaxDtgrm == 4294967295L) - { - this.sipT38MaxDtgrm = -1L; - } - else - { - if (sipT38MaxDtgrm < Integer.MAX_VALUE && sipT38MaxDtgrm > Integer.MIN_VALUE) - { - this.sipT38MaxDtgrm = sipT38MaxDtgrm; - } - } - } - - public Boolean getSipDirectMedia() - { - return sipDirectMedia; - } - - public void setSipDirectMedia(Boolean sipDirectMedia) - { - this.sipDirectMedia = sipDirectMedia; - } - - public Boolean getSipCanReinvite() - { - return sipCanReinvite; - } - - public void setSipCanReinvite(Boolean sipCanReinvite) - { - this.sipCanReinvite = sipCanReinvite; - } - - public Boolean getSipPromiscRedir() - { - return sipPromiscRedir; - } - - public void setSipPromiscRedir(Boolean sipPromiscRedir) - { - this.sipPromiscRedir = sipPromiscRedir; - } - - public Boolean getSipUserPhone() - { - return sipUserPhone; - } - - public void setSipUserPhone(Boolean sipUserPhone) - { - this.sipUserPhone = sipUserPhone; - } - - public Boolean getSipVideoSupport() - { - return sipVideoSupport; - } - - public void setSipVideoSupport(Boolean sipVideoSupport) - { - this.sipVideoSupport = sipVideoSupport; - } - - public Boolean getSipTextSupport() - { - return sipTextSupport; - } - - public void setSipTextSupport(Boolean sipTextSupport) - { - this.sipTextSupport = sipTextSupport; - } - - public String getSipSessTimers() - { - return sipSessTimers; - } - - public void setSipSessTimers(String sipSessTimers) - { - this.sipSessTimers = sipSessTimers; - } - - public String getSipSessRefresh() - { - return sipSessRefresh; - } - - public void setSipSessRefresh(String sipSessRefresh) - { - this.sipSessRefresh = sipSessRefresh; - } - - public Integer getSipSessExpires() - { - return sipSessExpires; - } - - public void setSipSessExpires(Integer sipSessExpires) - { - this.sipSessExpires = sipSessExpires; - } - - public Integer getSipSessMin() - { - return sipSessMin; - } - - public void setSipSessMin(Integer sipSessMin) - { - this.sipSessMin = sipSessMin; - } - - public String getSipDtmfMode() - { - return sipDtmfMode; - } - - public void setSipDtmfMode(String sipDtmfMode) - { - this.sipDtmfMode = sipDtmfMode; - } - - public String getToHost() - { - return toHost; - } - - public void setToHost(String toHost) - { - this.toHost = toHost; - } - - public String getAddressIp() - { - return addressIp; - } - - public void setAddressIp(String addressIp) - { - this.addressIp = addressIp; - } - - public Integer getAddressPort() - { - return addressPort; - } - - public void setAddressPort(Integer addressPort) - { - this.addressPort = addressPort; - } - - public String getDefaultAddrIp() - { - return defaultAddrIp; - } - - public void setDefaultAddrIp(String defaultAddrIp) - { - this.defaultAddrIp = defaultAddrIp; - } - - public Integer getDefaultAddrPort() - { - return defaultAddrPort; - } - - public void setDefaultAddrPort(Integer defaultAddrPort) - { - this.defaultAddrPort = defaultAddrPort; - } - - public String getDefaultUsername() - { - return defaultUsername; - } - - public void setDefaultUsername(String defaultUsername) - { - this.defaultUsername = defaultUsername; - } - - public String getRegExtension() - { - return regExtension; - } - - public void setRegExtension(String regExtension) - { - this.regExtension = regExtension; - } - - public String getCodecs() - { - return codecs; - } - - public void setCodecs(String codecs) - { - this.codecs = codecs; - } - - public String getCodecOrder() - { - return codecOrder; - } - - public void setCodecOrder(String codecOrder) - { - this.codecOrder = codecOrder; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getSipUserAgent() - { - return sipUserAgent; - } - - public void setSipUserAgent(String sipUserAgent) - { - this.sipUserAgent = sipUserAgent; - } - - public String getParkingLot() - { - return parkingLot; - } - - public void setParkingLot(String parkingLot) - { - this.parkingLot = parkingLot; - } - - public String getRegContact() - { - return regContact; - } - - public void setRegContact(String regContact) - { - // workaround for Asterisk bug: - if (regContact.startsWith(": ")) - { - regContact = regContact.substring(2); - } - this.regContact = regContact; - } - - public Integer getQualifyFreq() - { - return qualifyFreq; - } - - public void setQualifyFreq(String qualifyFreq) - { - // workaround for Asterisk bugs: - if (qualifyFreq.startsWith(": ")) - { - qualifyFreq = qualifyFreq.substring(2); - } - if (qualifyFreq.indexOf('\n') > -1) - { - qualifyFreq = qualifyFreq.substring(0, qualifyFreq.indexOf('\n')); - } - this.qualifyFreq = stringToInteger(qualifyFreq, "ms"); - } - - public Map getChanVariable() - { - return chanVariable; - } - - public void setChanVariable(final Map chanVariable) - { - this.chanVariable = chanVariable; - } - - public Integer getMaxForwards() - { - return maxForwards; - } - - public void setMaxForwards(Integer maxForwards) - { - this.maxForwards = maxForwards; - } - - public String getToneZone() - { - return toneZone; - } - - public void setToneZone(String toneZone) - { - this.toneZone = toneZone; - } - - public String getSipUseReasonHeader() - { - return sipUseReasonHeader; - } - - public void setSipUseReasonHeader(String sipUseReasonHeader) - { - this.sipUseReasonHeader = sipUseReasonHeader; - } - - public String getSipEncryption() - { - return sipEncryption; - } - - public void setSipEncryption(String sipEncryption) - { - this.sipEncryption = sipEncryption; - } - - public String getSipForcerport() - { - return sipForcerport; - } - - public void setSipForcerport(String sipForcerport) - { - this.sipForcerport = sipForcerport; - } - - public String getSipRtpEngine() - { - return sipRtpEngine; - } - - public void setSipRtpEngine(String sipRtpEngine) - { - this.sipRtpEngine = sipRtpEngine; - } - - public String getSipComedia() - { - return sipComedia; - } - - public void setSipComedia(String sipComedia) - { - this.sipComedia = sipComedia; - } - - public String getMohsuggest() - { - return mohsuggest; - } - - public void setMohsuggest(String mohsuggest) - { - this.mohsuggest = mohsuggest; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("SipShowPeerResponse [channelType="); - builder.append(channelType); - builder.append(", objectName="); - builder.append(objectName); - builder.append(", chanObjectType="); - builder.append(chanObjectType); - builder.append(", secretExist="); - builder.append(secretExist); - builder.append(", md5SecretExist="); - builder.append(md5SecretExist); - builder.append(", remoteSecretExist="); - builder.append(remoteSecretExist); - builder.append(", context="); - builder.append(context); - builder.append(", language="); - builder.append(language); - builder.append(", accountCode="); - builder.append(accountCode); - builder.append(", amaFlags="); - builder.append(amaFlags); - builder.append(", cidCallingPres="); - builder.append(cidCallingPres); - builder.append(", sipFromUser="); - builder.append(sipFromUser); - builder.append(", sipFromDomain="); - builder.append(sipFromDomain); - builder.append(", callGroup="); - builder.append(callGroup); - builder.append(", pickupGroup="); - builder.append(pickupGroup); - builder.append(", voiceMailbox="); - builder.append(voiceMailbox); - builder.append(", transferMode="); - builder.append(transferMode); - builder.append(", lastMsgsSent="); - builder.append(lastMsgsSent); - builder.append(", callLimit="); - builder.append(callLimit); - builder.append(", busyLevel="); - builder.append(busyLevel); - builder.append(", maxCallBr="); - builder.append(maxCallBr); - builder.append(", dynamic="); - builder.append(dynamic); - builder.append(", callerId="); - builder.append(callerId); - builder.append(", regExpire="); - builder.append(regExpire); - builder.append(", sipAuthInsecure="); - builder.append(sipAuthInsecure); - builder.append(", sipNatSupport="); - builder.append(sipNatSupport); - builder.append(", acl="); - builder.append(acl); - builder.append(", sipT38support="); - builder.append(sipT38support); - builder.append(", sipT38ec="); - builder.append(sipT38ec); - builder.append(", sipT38MaxDtgrm="); - builder.append(sipT38MaxDtgrm); - builder.append(", sipDirectMedia="); - builder.append(sipDirectMedia); - builder.append(", sipCanReinvite="); - builder.append(sipCanReinvite); - builder.append(", sipPromiscRedir="); - builder.append(sipPromiscRedir); - builder.append(", sipUserPhone="); - builder.append(sipUserPhone); - builder.append(", sipVideoSupport="); - builder.append(sipVideoSupport); - builder.append(", sipTextSupport="); - builder.append(sipTextSupport); - builder.append(", sipSessTimers="); - builder.append(sipSessTimers); - builder.append(", sipSessRefresh="); - builder.append(sipSessRefresh); - builder.append(", sipSessExpires="); - builder.append(sipSessExpires); - builder.append(", sipSessMin="); - builder.append(sipSessMin); - builder.append(", sipDtmfMode="); - builder.append(sipDtmfMode); - builder.append(", toHost="); - builder.append(toHost); - builder.append(", addressIp="); - builder.append(addressIp); - builder.append(", addressPort="); - builder.append(addressPort); - builder.append(", defaultAddrIp="); - builder.append(defaultAddrIp); - builder.append(", defaultAddrPort="); - builder.append(defaultAddrPort); - builder.append(", defaultUsername="); - builder.append(defaultUsername); - builder.append(", regExtension="); - builder.append(regExtension); - builder.append(", codecs="); - builder.append(codecs); - builder.append(", codecOrder="); - builder.append(codecOrder); - builder.append(", status="); - builder.append(status); - builder.append(", sipUserAgent="); - builder.append(sipUserAgent); - builder.append(", regContact="); - builder.append(regContact); - builder.append(", qualifyFreq="); - builder.append(qualifyFreq); - builder.append(", parkingLot="); - builder.append(parkingLot); - builder.append(", maxForwards="); - builder.append(maxForwards); - builder.append(", toneZone="); - builder.append(toneZone); - builder.append(", sipUseReasonHeader="); - builder.append(sipUseReasonHeader); - builder.append(", sipEncryption="); - builder.append(sipEncryption); - builder.append(", sipForcerport="); - builder.append(sipForcerport); - builder.append(", sipRtpEngine="); - builder.append(sipRtpEngine); - builder.append(", sipComedia="); - builder.append(sipComedia); - builder.append(", chanVariable="); - builder.append(chanVariable); - builder.append(", mohSuggest="); - builder.append(mohsuggest); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/asteriskjava/manager/response/SkypeBuddyResponse.java b/src/main/java/org/asteriskjava/manager/response/SkypeBuddyResponse.java deleted file mode 100644 index 59df06498..000000000 --- a/src/main/java/org/asteriskjava/manager/response/SkypeBuddyResponse.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a SkypeBuddyAction and contains the details of a Skype buddy. - * - * @see org.asteriskjava.manager.action.SkypeBuddyAction - * @since 1.0.0 - */ -public class SkypeBuddyResponse extends ManagerResponse -{ - private static final long serialVersionUID = 0L; - - private String skypename; - private String timezone; - private String availability; - private String fullname; - private String language; - private String country; - private String phoneHome; - private String phoneOffice; - private String phoneMobile; - private String about; - - public String getSkypename() - { - return skypename; - } - - public void setSkypename(String skypename) - { - this.skypename = skypename; - } - - public String getTimezone() - { - return timezone; - } - - public void setTimezone(String timezone) - { - this.timezone = timezone; - } - - public String getAvailability() - { - return availability; - } - - public void setAvailability(String availability) - { - this.availability = availability; - } - - public String getFullname() - { - return fullname; - } - - public void setFullname(String fullname) - { - this.fullname = fullname; - } - - /** - * Returns the ISO language code. - * - * @return the ISO language code. - */ - public String getLanguage() - { - return language; - } - - /** - * Sets the ISO language code. - * - * @param language the ISO language code. - */ - public void setLanguage(String language) - { - this.language = language; - } - - /** - * Returns the ISO country code. - * - * @return the ISO country code (in lower case). - */ - public String getCountry() - { - return country; - } - - /** - * Sets the country code. - * - * @param country the country code. - */ - public void setCountry(String country) - { - this.country = country; - } - - public String getPhoneHome() - { - return phoneHome; - } - - public void setPhoneHome(String phoneHome) - { - this.phoneHome = phoneHome; - } - - public String getPhoneOffice() - { - return phoneOffice; - } - - public void setPhoneOffice(String phoneOffice) - { - this.phoneOffice = phoneOffice; - } - - public String getPhoneMobile() - { - return phoneMobile; - } - - public void setPhoneMobile(String phoneMobile) - { - this.phoneMobile = phoneMobile; - } - - public String getAbout() - { - return about; - } - - public void setAbout(String about) - { - this.about = about; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/response/SkypeLicenseStatusResponse.java b/src/main/java/org/asteriskjava/manager/response/SkypeLicenseStatusResponse.java deleted file mode 100644 index 504d54fb9..000000000 --- a/src/main/java/org/asteriskjava/manager/response/SkypeLicenseStatusResponse.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.response; - -/** - * Corresponds to a SkypeLicenseStatusAction and contains the number of licensed Skype calls. - * - * @see org.asteriskjava.manager.action.SkypeLicenseStatusAction - * @since 1.0.0 - */ -public class SkypeLicenseStatusResponse extends ManagerResponse -{ - private static final long serialVersionUID = 0L; - - private Integer callsLicensed; - - /** - * Returns the total number of concurrent Skype calls currently licenced for this system. - * - * @return the total number of concurrent Skype calls currently licenced for this system. - */ - public Integer getCallsLicensed() - { - return callsLicensed; - } - - /** - * Sets the total number of concurrent Skype calls currently licenced for this system. - * - * @param callsLicensed the total number of concurrent Skype calls currently licenced for this system. - */ - public void setCallsLicensed(Integer callsLicensed) - { - this.callsLicensed = callsLicensed; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/manager/response/package.html b/src/main/java/org/asteriskjava/manager/response/package.html deleted file mode 100644 index 3de9c914d..000000000 --- a/src/main/java/org/asteriskjava/manager/response/package.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - -

Provides classes that represent the responses that are received - from an Asterisk server in response to an action send via the - Manager API.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/package.html b/src/main/java/org/asteriskjava/package.html deleted file mode 100644 index 0fcf5ae3d..000000000 --- a/src/main/java/org/asteriskjava/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

The Asterisk-Java command line interface.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/pbx/Activity.java b/src/main/java/org/asteriskjava/pbx/Activity.java deleted file mode 100644 index 393dc2992..000000000 --- a/src/main/java/org/asteriskjava/pbx/Activity.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.asteriskjava.pbx; - -public interface Activity -{ - /** - * If an activity fails the getLastError contains a description of the cause - * of the error. This method should be called from the 'complete' method of - * the iCallBack listener. - * - * @return error message which caused the activity to fail. - */ - Throwable getLastException(); - - /** - * Set to true once the activity has suceeded. - * - * @return - */ - boolean isSuccess(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/ActivityCallback.java b/src/main/java/org/asteriskjava/pbx/ActivityCallback.java deleted file mode 100644 index de6627fbc..000000000 --- a/src/main/java/org/asteriskjava/pbx/ActivityCallback.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Provides a generic callback mechansim which allows tracking of the progress - * of any of the async methods provided by iPBX. - */ - -public interface ActivityCallback -{ - - /** - * Called periodically to indicate progress with the task being tracked. The - * number of progress messages sent is dependant on the task. Every activity - * will see a ActivityStatusEnum.START and either ActivityStatusEnum.SUCCESS - * or ActivityStatusEnum.FAILURE - * - * @param activity - the activity which is being monitored - * @param status TODO - * @param message - */ - - void progress(T activity, ActivityStatusEnum status, String message); - -} diff --git a/src/main/java/org/asteriskjava/pbx/ActivityStatusEnum.java b/src/main/java/org/asteriskjava/pbx/ActivityStatusEnum.java deleted file mode 100644 index c4af0a31a..000000000 --- a/src/main/java/org/asteriskjava/pbx/ActivityStatusEnum.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.pbx; - -public enum ActivityStatusEnum -{ - START("Starting"), PROGRESS("Progress"), SUCCESS("Success"), FAILURE("Failure"); - - String defaultMessage; - - ActivityStatusEnum(String defaultMessage) - { - this.defaultMessage = defaultMessage; - } - - public String getDefaultMessage() - { - return defaultMessage; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/AgiChannelActivityAction.java b/src/main/java/org/asteriskjava/pbx/AgiChannelActivityAction.java deleted file mode 100644 index 90daddbaf..000000000 --- a/src/main/java/org/asteriskjava/pbx/AgiChannelActivityAction.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.asteriskjava.pbx; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; - -public interface AgiChannelActivityAction -{ - - void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException; - - boolean isDisconnect(); - - void cancel(Channel channel); - -} diff --git a/src/main/java/org/asteriskjava/pbx/AsteriskSettings.java b/src/main/java/org/asteriskjava/pbx/AsteriskSettings.java deleted file mode 100644 index f4944c213..000000000 --- a/src/main/java/org/asteriskjava/pbx/AsteriskSettings.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.asteriskjava.pbx; - -public interface AsteriskSettings -{ - - /** - * The port no. that the asterisk manager api listens on. - * This should be 5060 unless you have re-configured the manager api. - * @return the port no. - */ - int getManagerPortNo(); - - /** - * This password MUST match the password (secret=) in manager.conf - * @return - */ - String getManagerPassword(); - - /** - * This MUST match the section header (e.g. '[myconnection]') in manager.conf - * @return - */ - String getManagerUsername(); - - /** - * The IP address of FQND of the Asterisk PBX - * @return IP address or FQDN. - */ - String getAsteriskIP(); - - - /** - * Asterisk-Java uses conference rooms for a variety of purposes. - * Just make certain that the base address doesn't overlap any conference - * rooms you are currently running on your pbx. - * You should probably allow 200 conference rooms here e.g. (3000-3200) - * Actions like transfers (and conference calls) use a conference room. - * @return meetme base address - */ - Integer getMeetmeBaseAddress(); - - - /** - * Return true if you Asterisk version doesn't support bridging channels. - * All version after 1.8 support bridging so normally you should returm false; - * - * @return false if you asterisk version supports bridging channels. - */ - boolean getDisableBridge(); - - - /** - * This is an asterisk dialplan context. - * Simply pick a context which doesn't already exist - * and use AsteriskPBX.createAgiEntryPoint() - * to inject the necessary dialplan used by asterisk-java - * @return an unused asterisk dialplan context. e.g. "asteriskjava" - */ - String getManagementContext(); - - /** - * Return an asterisk dialplan extension (within the above Management Context) - * that will be used to park calls. - * Just ensure that its a unique asterisk dialplan extension name. - */ - String getExtensionPark(); - - /** - * The time (in seconds) to wait for a dial attempt to be answered before giving up. - * Recommend a value of 30. - * @return - */ - int getDialTimeout(); - - /** - * Return the SIP header to be used to force a handset to auto-answer when dialed. - * e.g. For Yealink/Snom use return "Call-Info:\; answer-after=0"; - * @return - */ - String getAutoAnswer(); - - /** - * - * Return an asterisk dialplan extension (within the Management Context) - * that will be used to inject the agi dialplan entry point used by Activites.. - * Just ensure that its a unique asterisk dialplan extension name. - * @return "asterisk-java-agi" - */ - String getAgiExtension(); - - - /** - * Return true if the telephony tech you are dialing from can reliably detect - * hangups. (for SIP set to true, POTS set false). - * @return - */ - boolean getCanDetectHangup(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/Call.java b/src/main/java/org/asteriskjava/pbx/Call.java deleted file mode 100644 index 31813a5b8..000000000 --- a/src/main/java/org/asteriskjava/pbx/Call.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.asteriskjava.pbx; - -import java.util.Date; -import java.util.List; - -public interface Call -{ - /** - * Used to identify which channel of a call an operation is to be performed - * on. This is designed to stop the mis-use of some methods which operate on - * a specific channel of a call. The Operand allows the caller to specify - * which channel to operate on without having to explicitly pass in the - * channel. Without this enum they could potentially pass in a channel which - * is not owned by the call. - * - * @author bsutton - */ - - public enum OperandChannel - { - /** - * this party received (did not originate) the call - */ - ACCEPTING_PARTY, - - /** - * this party originated (dialled) the call - */ - ORIGINATING_PARTY, - - TRANSFER_TARGET_PARTY, - - /** - * is an end point that is on an external trunk - */ - REMOTE_PARTY, - /** - * a local call is a handset attached directly (via sip) to the pbx - */ - LOCAL_PARTY - } - - // Returns true of the given channel is part of this call. - boolean contains(Channel channel); - - // The caller id of the party that accepted (answered) the call. - CallerID getAcceptingPartyCallerID(); - - // The caller id of the party that dialed the call. - CallerID getOriginatingPartyCallerID(); - - // The caller id of the remote party. - CallerID getRemotePartyCallerID(); - - // The date/time the call started. - Date getCallStartTime(); - - // The channel associated with the party that originated (dialed) the call. - Channel getOriginatingParty(); - - // The channel associated with the part that accepted (answered) the call. - Channel getAcceptingParty(); - - Channel getTransferTargetParty(); - - /** - * retrieves the channel associated with the give Operand. - * - * @param lhs - * @return - */ - Channel getOperandChannel(OperandChannel lhs); - - /** - * This method use the CallDirection to determine which leg of the call is - * the local call and which is the called/calling party. It then returns the - * called/calling party. - * - * @return - */ - Channel getRemoteParty(); - - /** - * This method use the CallDirection to determine which leg of the call is - * the local call and which is the called/calling party. It then returns the - * local call . - * - * @return - */ - public Channel getLocalParty(); - - /** - * Returns true of the Call can be split into two (or more) separate calls. - * @return - */ - boolean canSplit(); - - /** - * Returns the direction of the call. - * The call Direction can be a little esoteric as a call can - * come in and then be transferred out again. So is this an inbound or outbound call? - * @return - */ - CallDirection getDirection(); - - /** - * Returns a list of the Channels associated with this call. - * @return - */ - List getChannels(); -} diff --git a/src/main/java/org/asteriskjava/pbx/CallDirection.java b/src/main/java/org/asteriskjava/pbx/CallDirection.java deleted file mode 100644 index 80baa9fc8..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallDirection.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Describes the direction of the call. - * - * @author bsutton - */ -public enum CallDirection -{ - /** - * INBOUND - call - */ - INBOUND(0), - /** - * OUTBOUND - call. - */ - OUTBOUND(1); - // /** - // * JOIN - call was created by joining two existing calls - // */ - // JOIN(2), - // - // /** - // * Often temporary channels are brought up for actions such as parking a - // * call. These calls don't really have a direction in their own right. - // * - // * TODO: is this really need, should the originating call be the - // controlling - // * entity. The problem is that currently we really track 'channels' rather - // * than Calls. - // */ - // TRANSIENT(3); - - private final int dbValue; - - private CallDirection(final int dbValue) - { - this.dbValue = dbValue; - } - - public static CallDirection valueOf(final int dbValue) - { - CallDirection result = null; - - for (final CallDirection direction : CallDirection.values()) - { - if (direction.dbValue == dbValue) - { - result = direction; - break; - } - } - return result; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/CallHangupListener.java b/src/main/java/org/asteriskjava/pbx/CallHangupListener.java deleted file mode 100644 index e0dcb79a2..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallHangupListener.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.asteriskjava.pbx; - -public interface CallHangupListener -{ - - void callHungup(Call call); - -} diff --git a/src/main/java/org/asteriskjava/pbx/CallImpl.java b/src/main/java/org/asteriskjava/pbx/CallImpl.java deleted file mode 100644 index 4f2ee7503..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallImpl.java +++ /dev/null @@ -1,897 +0,0 @@ -package org.asteriskjava.pbx; - -import java.util.ArrayList; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.activities.BlindTransferActivity; - -/** - * Holds a call which may consist of 0, 1, 2 or 3 channels. When dialing out a - * call The 1st channel is always the call 'originator'. Channel 2 is - * 'accepting' party Channel 3 is a 'third party' which has joined the call via - * a conference mode. The concept of a Call is independent of a particular PBX. - * All channels of a Call must belong to the same PBX as we have no way of - * bridging calls across multiple PBX's anyway. Calls can be established by: 1) - * When a call arrives at the NJR Management inbound context 2) Dialing 3) - * Joining two existing calls The 'originating' channel is the first channel - * introduced to the call and is stored in the zeroth element of the channel - * list. - * - * @author bsutton - */ - -public class CallImpl implements ChannelHangupListener, Call -{ - static Logger logger = Logger.getLogger(CallImpl.class); - - /** - * We give every call a unique call id to help track the calls when checking - * logs - */ - private static int global_call_identifier_index = 0; - - /** - * A id that uniquely identifies this call. - */ - private int _uniquecallID; - - /* - * transfer types - */ - public enum TransferType - { - NONE, ASSISTED, BLIND; - } - - /** - * The 1st channel is always the call 'originator'. - */ - private Channel _originatingParty; - - /** - * Channel 2 is 'accepting' party - */ - - private Channel _acceptingParty; - - /** - * Channel 3 is a 'third party' which has joined the call via a conference - * mode which would normally be created during a transfer attempt. - */ - private Channel _transferTargetParty; - - /** - * The direct of the call. If it is OUTBOUND then the originating party is - * the local call . If it is INBOUND then the originationg party is the - * caller. - */ - final private CallDirection _direction; - - private CallerID _originatingPartyCallerID = null; - - private CallerID _acceptingPartyCallerID = null; - - /** - * When we attempt to transfer a call to a third party we save the transfer - * target. This allows us to automatically re-try the transfer if the - * initial attempt failed. - */ - private EndPoint _transferTarget = null; - - private TransferType transferType = TransferType.NONE; - - private CallerID _transferTargetCallerID = null; - - private Date _callStarted; - - private Date _holdStarted = null; - - private EndPoint _parkingLot = null; - - private Date _timeAtDialin = null; - - private boolean _parked = false; - - /** - * The primary key for the Contact record. - * - * @return - */ - private Integer _contactId; - - private ArrayList _hangupListeners = new ArrayList<>(); - - /** - * Used to indicate the ownership of the call. SELF - this instance of NJR - * has answered the call and is now considered the owner. REMOTE - some - * other instance of NJR has answered the call. UNOWNED - the call has - * entered the inbound extension but has not been answered by any instance - * of NJR. Note: a calls ownership can change over time. All calls start as - * UNOWNED. If we answer a call it becomes SELF. If we put a call on hold - * and another NJR instances answers it then it can then become REMOTE. - * - * @author bsutton - */ - public enum OWNER - { - SELF - } - - private OWNER _owner; - - protected BlindTransferActivity _transferActivity; - - public CallImpl(Channel originatingChannel, CallDirection direction) throws PBXException - { - logger.debug("Created call=" + originatingChannel + " direction=" + direction); //$NON-NLS-1$ //$NON-NLS-2$ - this._owner = OWNER.SELF; - this._direction = direction; - this._callStarted = new Date(); - this.setUID(); - this.setOriginatingParty(originatingChannel); - - } - - public CallImpl(Channel originatingChannel, Channel acceptingChannel, CallDirection direction) throws PBXException - { - logger.debug("Created call=" + originatingChannel + " direction=" + direction); //$NON-NLS-1$ //$NON-NLS-2$ - this._owner = OWNER.SELF; - this._direction = direction; - this._callStarted = new Date(); - this.setUID(); - this.setOriginatingParty(originatingChannel); - this.setAcceptingParty(acceptingChannel); - - } - - public CallImpl(Channel agent, Channel callee) throws PBXException - { - this._owner = OWNER.SELF; - this._direction = CallDirection.OUTBOUND; - this._callStarted = new Date(); - this.setUID(); - this.setOriginatingParty(agent); - this.setAcceptingParty(callee); - - } - - /** - * Joins a specific channel from this call with a specific channel from - * another call which results in a new Call object being created. Channels - * that do not participate in the join are left in their original Call. - * - * @param originatingOperand the channel from this call that will - * participate in the join as the originating Channel - * @param rhs the call we are joining to. - * @param acceptingOperand the channel from the rhs call that will - * participate in the join as the accepting channel. - * @return - * @throws PBXException - */ - public CallImpl join(OperandChannel originatingOperand, Call rhs, OperandChannel acceptingOperand, - CallDirection direction) throws PBXException - { - CallImpl joinTo = (CallImpl) rhs; - - Channel originatingParty = null; - Channel acceptingParty = null; - - // Pull the originating party from the this call. - originatingParty = this.getOperandChannel(originatingOperand); - if (originatingParty != null && originatingParty.isLive()) - originatingParty.removeListener(this); - - // Pull the accepting party from the other 'call' as the accepting - // party. - acceptingParty = rhs.getOperandChannel(acceptingOperand); - if (acceptingParty != null && acceptingParty.isLive()) - acceptingParty.removeListener((CallImpl) rhs); - - if (originatingParty == null || !originatingParty.isLive() || acceptingParty == null || !acceptingParty.isLive()) - throw new PBXException("Call.HangupDuringJoin"); //$NON-NLS-1$ - - CallImpl joined = new CallImpl(originatingParty, direction); - joined.setAcceptingParty(acceptingParty); - joined._owner = OWNER.SELF; - - joined._callStarted = minDate(this._callStarted, joinTo._callStarted); - - joined._holdStarted = minDate(this._holdStarted, joinTo._holdStarted); - - joined._timeAtDialin = minDate(this._timeAtDialin, joinTo._timeAtDialin); - - logger.debug("Joined two calls lhs=" + this + ", rhs=" + joinTo); //$NON-NLS-1$//$NON-NLS-2$ - - return joined; - } - - private Date minDate(Date d1, Date d2) - { - - if (d1 == null) - { - return d2; - } - if (d2 == null) - { - return d1; - } - if (d1.before(d2)) - { - return d1; - } - return d2; - } - - // - // /** - // * Joins a specific channel from this call with a specific channel from - // another call which results in a new Call object - // * being created. - // * - // * Channels that do not participate in the join are left in their original - // Call. - // * - // * @param lhsOperand the channel from this call that will participate in - // the join - // * @param rhs the call we are joining to. - // * @param rhsOperand the channel from the rhs call that will participate - // in the join. - // * @return - // * @throws PBXException - // */ - // public Call join(OperandChannel lhsOperand, iCall rhs, OperandChannel - // rhsOperand) throws PBXException - // { - // Call joinTo = (Call) rhs; - // - // // // Check there is no transfer party. - // // if (this._transferTargetParty != null || joinTo._transferTargetParty - // != null) - //// throw new IllegalArgumentException("Neither call in a 'Join' may have a - // third party"); //$NON-NLS-1$ - // // - // // // Check that we only have one active party - // // if (this._originatingParty != null && this._acceptingParty != null) - // // throw new IllegalArgumentException( - //// "The call " + this + " has more than one active channel which is not - // allowed."); //$NON-NLS-1$ //$NON-NLS-2$ - // // - // // if (joinTo._originatingParty != null && joinTo._acceptingParty != - // null) - // // throw new IllegalArgumentException( - //// "The call " + joinTo + " has more than one active channel which is not - // allowed."); //$NON-NLS-1$ //$NON-NLS-2$ - // - // iChannel originatingParty = null; - // iChannel acceptingParty = null; - // - // // First select the remote party from this call. - // // For no particular reason we use 'this' as the originating party. - // originatingParty = this.getRemoteParty(); - // if (originatingParty != null && originatingParty.isLive()) - // originatingParty.removeListener(this); - // - // // Now select the remote party from the other 'call' as the accepting - // // party. - // acceptingParty = rhs.getRemoteParty(); - // if (acceptingParty != null && acceptingParty.isLive()) - // acceptingParty.removeListener((Call) rhs); - // - // if (originatingParty == null || acceptingParty == null) - // throw new PBXException(Messages.getString("Call.HangupDuringJoin")); - // //$NON-NLS-1$ - // - // /** - // * We just choose one of the directions as it doesn't really matter - // */ - // Call joined = new Call(originatingParty, this._direction); - // joined.setAcceptingParty(acceptingParty); - // joined._owner = OWNER.SELF; - // - // - // joined._callStarted = DateUtils.min(this._callStarted, - // joinTo._callStarted); - // - // joined._holdStarted = DateUtils.min(this._holdStarted, - // joinTo._holdStarted); - // - // joined._timeAtDialin = DateUtils.min(this._timeAtDialin, - // joinTo._timeAtDialin); - // - // // The selection of _didEntity is arbitrary - // if (this._didEntity != null) - // joined._didEntity = this._didEntity; - // else - // joined._didEntity = joinTo._didEntity; - // - // logger.debug("Joined two calls lhs=" + this + ", rhs=" + joinTo); - // //$NON-NLS-1$//$NON-NLS-2$ - // - // return joined; - // } - - /** - * Splits a channel out of a call into a separate call. This method should - * only be called from the SplitActivity. - * - * @return the resulting call. - * @throws PBXException - */ - public Call split(OperandChannel channelToSplit) throws PBXException - { - Channel channel = this.getOperandChannel(channelToSplit); - channel.removeListener(this); - - CallDirection direction = CallDirection.INBOUND; - - // If this is the operator channel we need to flip the default - // direction. - if (this.getLocalParty() != null && this.getLocalParty().isSame(channel)) - { - direction = CallDirection.OUTBOUND; - } - - CallImpl call = new CallImpl(channel, direction); - call._owner = OWNER.SELF; - - // clear the channel have just split out. - switch (channelToSplit) - { - case ACCEPTING_PARTY : - this.setAcceptingParty(null); - break; - case LOCAL_PARTY : - if (this._direction == CallDirection.INBOUND) - { - this.setAcceptingParty(null); - } - else - { - this.setOriginatingParty(null); - } - break; - case ORIGINATING_PARTY : - this.setOriginatingParty(null); - break; - case REMOTE_PARTY : - if (this._direction == CallDirection.INBOUND) - this.setOriginatingParty(null); - else - this.setAcceptingParty(null); - break; - case TRANSFER_TARGET_PARTY : - this.setTransferTargetParty(null); - break; - default : - break; - } - - return call; - } - - public Call split(Channel channelToSplit) throws PBXException - { - channelToSplit.removeListener(this); - CallDirection direction = CallDirection.INBOUND; - // If this is the operator channel we need to flip the default - // direction. - if (this.getLocalParty() != null && this.getLocalParty().isSame(channelToSplit)) - { - direction = CallDirection.OUTBOUND; - } - - CallImpl call = new CallImpl(channelToSplit, direction); - call._owner = OWNER.SELF; - if (_acceptingParty != null && _acceptingParty.isSame(channelToSplit)) - _acceptingParty = null; - if (_originatingParty != null && _originatingParty.isSame(channelToSplit)) - _originatingParty = null; - if (_transferTargetParty != null && _transferTargetParty.isSame(channelToSplit)) - _transferTargetParty = null; - return call; - - } - - @Override - public void channelHangup(Channel channel, Integer cause, String causeText) - { - try - { - if (isSameChannel(this._originatingParty, channel)) - { - this.setOriginatingParty(null); - logger.debug("Removed originatingParty=" + channel + " from Call=" + this._uniquecallID //$NON-NLS-1$ //$NON-NLS-2$ - + " as channel was hung up"); //$NON-NLS-1$ - } - - else if (isSameChannel(this._acceptingParty, channel)) - { - this.setAcceptingParty(null); - logger.debug("Removed acceptingParty=" + channel + " from Call=" + this._uniquecallID //$NON-NLS-1$ //$NON-NLS-2$ - + " as channel was hung up"); //$NON-NLS-1$ - - } - - else if (isSameChannel(this._transferTargetParty, channel)) - { - this.setTransferTargetParty(null); - logger.debug("Removed transferTarget=" + channel + " from Call=" + this._uniquecallID //$NON-NLS-1$ //$NON-NLS-2$ - + " as channel was hung up"); //$NON-NLS-1$ - } - - else - { - logger.warn("Received hangup for unknown channel=" + channel.getChannelId() + " on Call=" //$NON-NLS-1$ //$NON-NLS-2$ - + this._uniquecallID + " as channel was hung up"); //$NON-NLS-1$ - } - if (!this.isLive()) - { - notifyCallHangupListeners(); - } - } - catch (PBXException e) - { - // not much we can do here so just log it - logger.error(e, e); - } - } - - private boolean isSameChannel(Channel lhs, Channel rhs) - { - return lhs != null && rhs != null && lhs.isSame(rhs); - } - - // private int findChannel(iChannel channel) - // { - // int index = -1; - // - // synchronized (this.channelList) - // { - // for (int i = 0; i < this.channelList.size(); i++) - // { - // iChannel aChannel = this.channelList.get(i); - // if (aChannel.isSame(channel)) - // { - // index = i; - // break; - // } - // } - // } - // return index; - // } - - private void notifyCallHangupListeners() - { - for (CallHangupListener listener : this._hangupListeners) - { - listener.callHungup(this); - } - - } - - /** - * Returns the originating channel for this call. e.g. the first channel - * that came up. Whilst a call must always start with an originating channel - * as a call is shutting down it will get to the point where it will have no - * channels. In these cases the return will be null. - * - * @return null or the originating channel. - */ - - @Override - public Channel getOriginatingParty() - { - return this._originatingParty; - } - - // /** - // * Call this method to mark this call as owned by another instance of NJR - // as - // * that instance has answered the call. The only time a calls ownership - // can - // * transition is when the call is answered by an instances of NJR or the - // * call is transfered to the vacant transfer extension. Roaming calls are - // * still owned by the NJR instance that originally answered the call. - // */ - // public void callAnsweredRemotely() - // { - // this._owner = OWNER.REMOTE; - // - // } - - // private void callIsTransferring() throws PBXException - // { - // if (this.holdStarted == null) - // { - // this.holdStarted = new Date(); - // } - // this._state = Call.CallState.TRANSFER; - // } - - /** - * Call this method to indicate that this is an outbound call originated by - * this NJR instance. These type of calls are not seen by a remote operator - * unless they are put on hold. - * - * @param remoteChannel - the remote channel this call connected to when - * dialing. - * @throws PBXException - */ - public void callDialedOut(Channel remoteChannel, CallerID fromClid, CallerID toClid) throws PBXException - { - - // -- moved to ANSWER - } - - @Override - public Date getCallStartTime() - { - return this._callStarted; - } - - public Integer getContactId() - { - return this._contactId; - } - - /** - * The current transfer target. - * - * @return - */ - public EndPoint getTransferTarget() - { - return this._transferTarget; - } - - public CallerID getTransferTargetCallerID() - { - return this._transferTargetCallerID; - } - - @Override - public CallerID getAcceptingPartyCallerID() - { - return this._acceptingPartyCallerID; - } - - @Override - public CallerID getOriginatingPartyCallerID() - { - return this._originatingPartyCallerID; - } - - @Override - public CallerID getRemotePartyCallerID() - { - CallerID remoteCallerID = null; - - if (this.getDirection() == CallDirection.INBOUND) - { - remoteCallerID = this.getOriginatingPartyCallerID(); - } - else - { - remoteCallerID = this.getAcceptingPartyCallerID(); - } - return remoteCallerID; - } - - public Date getHoldStartTime() - { - return this._holdStarted; - } - - public EndPoint getParkingLot() - { - return this._parkingLot; - } - - public Date getTimeAtDialIn() - { - return this._timeAtDialin; - } - - public TransferType getTransferType() - { - return this.transferType; - } - - public String getUniqueCallID() - { - /* - * this is a unique call identifier. - */ - return "" + this._uniquecallID; //$NON-NLS-1$ - } - - public boolean isCallParked() - { - return this._parked; - } - - private void setOriginatingParty(Channel originatingParty) throws PBXException - { - this._originatingParty = originatingParty; - - if (originatingParty != null) - { - if (!this._originatingParty.canDetectHangup() && this._acceptingParty != null - && !this._acceptingParty.canDetectHangup()) - throw new PBXException("Call.BothWithNoHangupDetection"); //$NON-NLS-1$ - - this._originatingParty.addHangupListener(this); - } - } - - private void setAcceptingParty(Channel acceptingParty) throws PBXException - { - this._acceptingParty = acceptingParty; - - if (acceptingParty != null) - { - if (!this._acceptingParty.canDetectHangup() && this._originatingParty != null - && !this._originatingParty.canDetectHangup()) - throw new PBXException("Call.BothWithNoHangupDetection"); //$NON-NLS-1$ - - this._acceptingParty.addHangupListener(this); - } - } - - private void setTransferTargetParty(Channel transferTargetParty) - { - this._transferTargetParty = transferTargetParty; - - if (transferTargetParty != null) - { - this._transferTargetParty.addHangupListener(this); - } - } - - /** - * The contact id is just used when refilling the list of contacts so we - * know which one is selected at the moment. It probably should be stored - * here! - * - * @param _contactId - */ - public void setContactId(final Integer _contactId) - { - this._contactId = _contactId; - - } - - // private void setTransferType(final TransferType tType) - // { - // this.transferType = tType; - // } - - /** - * - */ - private synchronized void setUID() - { - this._uniquecallID = CallImpl.global_call_identifier_index++; - if (CallImpl.global_call_identifier_index > 99) - { - CallImpl.global_call_identifier_index = 0; - } - } - - @Override - public CallDirection getDirection() - { - return this._direction; - } - - /** - * Call this method to get a notification when this call hangs up. - * - * @param listener - * @return true if the hangup listener was added. False if the call has - * already been hungup. - */ - public boolean addHangupListener(CallHangupListener listener) - { - boolean callStillUp = true; - - if ((this._originatingParty != null && this._originatingParty.isLive()) - || (this._acceptingParty != null && this._acceptingParty.isLive()) - || (this._transferTargetParty != null && this._transferTargetParty.isLive())) - this._hangupListeners.add(listener); - else - callStillUp = false; - return callStillUp; - - } - - /** - * returns true if the call has any active channels. - * - * @return - */ - public boolean isLive() - { - boolean live = false; - if ((this._originatingParty != null && this._originatingParty.isLive()) - || (this._acceptingParty != null && this._acceptingParty.isLive()) - || (this._transferTargetParty != null && this._transferTargetParty.isLive())) - live = true; - return live; - } - - /** - * @return true if this call is owned by another instance of NJR. - */ - public OWNER getOwner() - { - return this._owner; - } - - // /** - // * Returns a shallow clone of the list of channels. - // */ - // @SuppressWarnings("unchecked") - // @Override - // public Collection getChannels() - // { - // synchronized (this.channelList) - // { - // return (Collection) this.channelList.clone(); - // } - // } - - @Override - public String toString() - { - return "State: Originating Channel:" + getOriginatingParty() + " Direction: " //$NON-NLS-1$ //$NON-NLS-2$ - // //$NON-NLS-3$ - + this.getDirection() + " accepting:" + this._acceptingParty; //$NON-NLS-1$ - } - - @Override - public boolean contains(Channel parkChannel) - { - boolean found = false; - - if (isSameChannel(this._originatingParty, parkChannel)) - { - found = true; - } - else if (isSameChannel(this._acceptingParty, parkChannel)) - { - found = true; - } - - else if (isSameChannel(this._transferTargetParty, parkChannel)) - { - found = true; - } - - return found; - } - - @Override - public Channel getAcceptingParty() - { - return this._acceptingParty; - } - - @Override - public Channel getTransferTargetParty() - { - return this._transferTargetParty; - } - - @Override - /** - * This method use the CallDirection to determine which leg of the call is - * the local call and which is the called/calling party. It then returns the - * called/calling party. - * - * @return - */ - public Channel getRemoteParty() - { - Channel remoteChannel = null; - - if (this.getDirection() == CallDirection.INBOUND) - { - remoteChannel = this.getOriginatingParty(); - } - else - { - remoteChannel = this.getAcceptingParty(); - } - if (remoteChannel == null) - { - logger.error("remoteChannel is null for {}" + this.getDirection()); - } - return remoteChannel; - - } - - /** - * This method use the CallDirection to determine which leg of the call is - * the local call and which is the called/calling party. It then returns the - * local call . - * - * @return - */ - @Override - public Channel getLocalParty() - { - - if (this.getDirection() == CallDirection.OUTBOUND) - return this.getOriginatingParty(); - - return this.getAcceptingParty(); - - } - - @Override - public boolean canSplit() - { - return (this._originatingParty != null && this._acceptingParty != null && this._transferTargetParty == null); - } - - @Override - public Channel getOperandChannel(OperandChannel operand) - { - final Channel channel; - - switch (operand) - { - case ACCEPTING_PARTY : - channel = this._acceptingParty; - break; - case ORIGINATING_PARTY : - channel = this._originatingParty; - break; - case REMOTE_PARTY : - channel = getRemoteParty(); - break; - case TRANSFER_TARGET_PARTY : - channel = this._transferTargetParty; - break; - case LOCAL_PARTY : - channel = this.getLocalParty(); - break; - default : - // should never happen - throw new IllegalArgumentException("An unsupported operand was passed:" + operand); //$NON-NLS-1$ - } - if (channel == null) - { - Exception e = new Exception("failed to get channel for {}" + operand); - logger.warn(e, e); - } - return channel; - } - - public boolean isSame(Call rhs) - { - return this._uniquecallID == ((CallImpl) rhs)._uniquecallID; - } - - /** - * Returns all of the Channels associated with this call. - */ - @Override - public List getChannels() - { - List channels = new LinkedList<>(); - if (_acceptingParty != null) - channels.add(_acceptingParty); - if (_originatingParty != null) - channels.add(_originatingParty); - if (_transferTargetParty != null) - channels.add(_transferTargetParty); - return channels; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/CallStateAnswered.java b/src/main/java/org/asteriskjava/pbx/CallStateAnswered.java deleted file mode 100644 index f7a9e273b..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallStateAnswered.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -public class CallStateAnswered extends CallStateData -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CallStateAnswered.class); - - // The channel that accepted the call. - private Channel _acceptingParty; - - public CallStateAnswered(Channel acceptingParty) - { - this._acceptingParty = acceptingParty; - } - - public Channel getAcceptingParty() - { - return this._acceptingParty; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/CallStateData.java b/src/main/java/org/asteriskjava/pbx/CallStateData.java deleted file mode 100644 index 3a58c0183..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallStateData.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -public class CallStateData -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CallStateData.class); -} diff --git a/src/main/java/org/asteriskjava/pbx/CallStateDataNewInbound.java b/src/main/java/org/asteriskjava/pbx/CallStateDataNewInbound.java deleted file mode 100644 index 34942a24d..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallStateDataNewInbound.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -public class CallStateDataNewInbound extends CallStateData -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CallStateDataNewInbound.class); - - CallerID _originatingPartyCallerID; - - private final String _fromDID; - - public CallStateDataNewInbound(String fromDID, CallerID originatingPartyCallerID) - { - this._originatingPartyCallerID = originatingPartyCallerID; - this._fromDID = fromDID; - } - - public CallerID getOriginatingPartyCallerID() - { - return this._originatingPartyCallerID; - } - - public String getFromDID() - { - return this._fromDID; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/CallStateDataParked.java b/src/main/java/org/asteriskjava/pbx/CallStateDataParked.java deleted file mode 100644 index 579a9aaa1..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallStateDataParked.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -public class CallStateDataParked extends CallStateData -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CallStateDataParked.class); - - EndPoint _parkingLot; - - public CallStateDataParked(EndPoint parkingLot) - { - this._parkingLot = parkingLot; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/CallStateDataTransfer.java b/src/main/java/org/asteriskjava/pbx/CallStateDataTransfer.java deleted file mode 100644 index cda21f04b..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallStateDataTransfer.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.CallImpl.TransferType; -import org.asteriskjava.pbx.activities.BlindTransferActivity; - -public class CallStateDataTransfer extends CallStateData -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CallStateDataTransfer.class); - - private TransferType _transferType; - /** - * the end point we are attempting to transfer the call to. - */ - private EndPoint _transferTarget; - - private CallerID _transferTargetCallerID; - - private BlindTransferActivity _transferActivity; - - public CallStateDataTransfer(TransferType transferType, EndPoint transferTarget, CallerID transferTargetCallerID, - BlindTransferActivity transferActivity) - { - this._transferType = transferType; - this._transferTarget = transferTarget; - this._transferTargetCallerID = transferTargetCallerID; - this._transferActivity = transferActivity; - } - - public EndPoint getTransferTarget() - { - return this._transferTarget; - } - - public CallerID getTransferTargetCallerID() - { - return this._transferTargetCallerID; - } - - public TransferType getTransferType() - { - return this._transferType; - } - - public BlindTransferActivity getActivity() - { - return this._transferActivity; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/CallerID.java b/src/main/java/org/asteriskjava/pbx/CallerID.java deleted file mode 100644 index 833edd5f3..000000000 --- a/src/main/java/org/asteriskjava/pbx/CallerID.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.asteriskjava.pbx; - -public interface CallerID -{ - /** - * Gets the number component of the caller id. - * - * @return the callerid's number - */ - String getNumber(); - - /** - * Gets the name component of the caller id. - * - * @return the callerid's name - */ - String getName(); - - /** - * Controls whether this caller id should be presented to the remote end. - * - * @param hide - * - if true then the caller id will be hidden. - */ - void setHideCallerID(boolean hide); - - /** - * - * @return true if the caller id is marked as hidden. - */ - boolean isHideCallerID(); - - /** - * Returns true if the caller id number is blank or equal to 'unknown'. - * - * @return - */ - boolean isUnknown(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/Channel.java b/src/main/java/org/asteriskjava/pbx/Channel.java deleted file mode 100644 index 7c018eb30..000000000 --- a/src/main/java/org/asteriskjava/pbx/Channel.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.asteriskjava.pbx; - -import java.util.concurrent.TimeUnit; - -/** - * Provides an abstraction for an channel object which is independant of the - * underlying PBX. - * - * @author bsutton - */ -public interface Channel -{ - /** - * Compares if two channels are the same logical channel on the pbx. This - * comparison uses the full unique name of the channel not just the - * abbreviated peer name. e.g. SIP/100-00000100 - * - * @param rhs - * @return - */ - boolean isSame(Channel rhs); - - boolean isSame(String channelName, String uniqueID); - - /* - * This comparision uses just the peer name. e.g. SIP/100 - */ - boolean sameEndPoint(Channel rhs); - - /* - * This comparision uses just the peer name. e.g. SIP/100 - */ - boolean sameEndPoint(EndPoint extensionRoaming); - - /** - * Compares if this channel is the same as the named channel. - * - * @param channelName - * @return - */ - boolean sameExtenededChannelName(String channelName); - - /** - * This method does not actually change the state of the channel, rather it - * is intended to be used to record the fact that the state has changed. - * - * @see public iPBX.iParkCallActivity park(iChannel channel, Direction - * direction, boolean parkState) for a method which actually parks the - * channel. - */ - void setParked(boolean parked); - - /** - * This method does not actually change the state of the channel, rather it - * is intended to be used to record the fact that the state has changed. - * - * @see public iPBX.iMuteCallActivity mute(iChannel channel, Direction - * direction, boolean muteState) for a method which actually mutes the - * channel. - */ - void setMute(boolean muteState); - - /** - * Each channel is assigned a unique PBX independent id to help track the - * channels when logging. - * - * @return - */ - long getChannelId(); - - /** - * Returns true if the channel is alive. A channel is considered to be alive - * from the moment it is created until we get a notification that it has - * been hungup. - * - * @return - */ - boolean isLive(); - - /** - * Adds a listener to the channel. The channel will send a hungup - * notification to the listener when it hungup. A channel must be able to - * support multiple listeners. - * - * @param call - */ - void addHangupListener(ChannelHangupListener listener); - - void removeListener(ChannelHangupListener listener); - - /** - * Returns true if the given endpont is currently connected to this channel. - * - * @param extension - * @return - */ - boolean isConnectedTo(EndPoint endPoint); - - /** - * returns a fully qualifed channel name which includes the tech. e.g. - * SIP/100-00000342 - * - * @return - */ - String getChannelName(); - - EndPoint getEndPoint(); - - /** - * Checks if this channel is currently mute. A channel is mute if the party - * connected to this channel cannot hear any audio. - * - * @return - */ - boolean isMute(); - - /** - * In Asterisk speak, this method returns true if it is a LOCAL/ channel Not - * quite certain how this will map to other pbx's - * - * @return - */ - boolean isLocal(); - - /** - * @return true if the channel is currently parked. - */ - boolean isParked(); - - /** - * Returns true if the channel has been marked as in a zombie state. - * - * @return - */ - boolean isZombie(); - - /** - * @return true if the channel was originated from the console - * (Console/DSP). - */ - boolean isConsole(); - - /** - * Returns the current callerid for this channel. Note: on some systems this - * involves a round trip to the pbx. - * - * @return - */ - CallerID getCallerID(); - - /** - * Called to rename a channel - * - * @param newname the new name of the channel - * @throws InvalidChannelName - */ - void rename(String newName) throws InvalidChannelName; - - /** - * Returns a PBX specific version of the Channel name. - * - * @return - */ - String getExtendedChannelName(); - - void notifyHangupListeners(Integer cause, String causeText); - - boolean canDetectHangup(); - - boolean isQuiescent(); - - boolean hasCallerID(); - - AgiChannelActivityAction getCurrentActivityAction(); - - public void setCurrentActivityAction(AgiChannelActivityAction action); - - void setIsInAgi(boolean b); - - boolean isInAgi(); - - String getUniqueId(); - - boolean waitForChannelToReachAgi(long timeout, TimeUnit timeunit) throws InterruptedException; - - void setCallerId(CallerID buildCallerID); - -} diff --git a/src/main/java/org/asteriskjava/pbx/ChannelFactory.java b/src/main/java/org/asteriskjava/pbx/ChannelFactory.java deleted file mode 100644 index 7d1d0f75a..000000000 --- a/src/main/java/org/asteriskjava/pbx/ChannelFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -/** - * Currently this factories only purposes is to serve up globally unique channel - * id's which every new channel must be assigned. - * - * @author bsutton - * - */ -public class ChannelFactory -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ChannelFactory.class); - - private static long nextChannelId = 0; - - public static synchronized long getNextChannelId() - { - return ++ChannelFactory.nextChannelId; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/ChannelHangupListener.java b/src/main/java/org/asteriskjava/pbx/ChannelHangupListener.java deleted file mode 100644 index 9f0abc4f1..000000000 --- a/src/main/java/org/asteriskjava/pbx/ChannelHangupListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Used to notify channel listeners of state changes to a channel. - * - * @author bsutton - */ -public interface ChannelHangupListener -{ - // Called by the channel when it is being hungup - void channelHangup(Channel channel, Integer cause, String causeText); - -} diff --git a/src/main/java/org/asteriskjava/pbx/CompletionAdaptor.java b/src/main/java/org/asteriskjava/pbx/CompletionAdaptor.java deleted file mode 100644 index f17271d68..000000000 --- a/src/main/java/org/asteriskjava/pbx/CompletionAdaptor.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.asteriskjava.pbx; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; - -/** - * This is a utility class designed to wait for an activity to complete. When - * starting an activity for that you want to wait until completion pass this - * class as the iCallback listener and then call waitForCompletion. - * waitForCompletion will not return until the activity completes. - * - * @author bsutton - * @param - */ -public class CompletionAdaptor implements ActivityCallback -{ - private static final Logger logger = Logger.getLogger(CompletionAdaptor.class); - - CountDownLatch _latch = new CountDownLatch(1); - - @Override - public void progress(final T activity, ActivityStatusEnum status, String message) - { - if (status == ActivityStatusEnum.FAILURE || status == ActivityStatusEnum.SUCCESS) - { - _latch.countDown(); - } - } - - public void waitForCompletion(long timeout, TimeUnit unit) - { - // wait until the activity completes - try - { - if (!_latch.await(timeout, unit)) - { - Exception e = new Exception("Timeout waiting for activity to complete (" + timeout + " " + unit + ")"); - logger.error(e, e); - } - } - catch (final InterruptedException e) - { - // should never happen - CompletionAdaptor.logger.error(e, e); - } - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/DTMFTone.java b/src/main/java/org/asteriskjava/pbx/DTMFTone.java deleted file mode 100644 index ab6166e02..000000000 --- a/src/main/java/org/asteriskjava/pbx/DTMFTone.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Used to indicate the set of possible DTMF tones which can be sent. - * - * @author bsutton - * - */ -public enum DTMFTone -{ - ZERO('0'), ONE('1'), TWO('2'), THREE('3'), FOUR('4'), FIVE('5'), SIX('6'), SEVEN('7'), EIGHT('8'), NINE('9'), - HASH('#'), STAR('*'); - - private final String character; - - DTMFTone(final char character) - { - this.character = new String(new char[] { character }); - } - - @Override - public String toString() - { - return this.character; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/DialPlanExtension.java b/src/main/java/org/asteriskjava/pbx/DialPlanExtension.java deleted file mode 100644 index 9b4bc5fa3..000000000 --- a/src/main/java/org/asteriskjava/pbx/DialPlanExtension.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -/** - * Represents an asterisk dial plan extension such as: - * - * [njr-operator] - * njr-inbound,1,xxxxx - * - * In the above example njr-inbound is the dialplan extension. - * - * This class primarily exists to stop common mistakes that can occur if we pass - * this around as a simple string. - * - * @author bsutton - * - */ -public class DialPlanExtension implements EndPoint -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(DialPlanExtension.class); - - // the dial plan extension. - String _extension; - final boolean _empty; - - public DialPlanExtension(String extension) - { - if (extension == null || extension.trim().length() == 0) - { - this._empty = true; - this._extension = ""; - } - else - { - this._extension = extension.trim(); - this._empty = false; - } - } - - @Override - public int compareTo(EndPoint rhs) - { - return this._extension.compareTo(rhs.getSimpleName()); - } - - @Override - public boolean isSame(EndPoint rhs) - { - return this.compareTo(rhs) == 0; - } - - @Override - public boolean isLocal() - { - return false; - } - - @Override - public boolean isSIP() - { - return false; - } - - /** - * The same as getSimpleName as in this case the Tech is really just an - * identifier rather than a legitimate tech that the pbx understands. - */ - @Override - public String getFullyQualifiedName() - { - return this._extension; - } - - @Override - public String getSimpleName() - { - return this._extension; - } - - @Override - public String getSIPSimpleName() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isUnknown() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public TechType getTech() - { - return TechType.DIALPLAN; - } - - public String toString() - { - return this._extension; - } - - @Override - public boolean isEmpty() - { - return false; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/EndPoint.java b/src/main/java/org/asteriskjava/pbx/EndPoint.java deleted file mode 100644 index c9d694d7f..000000000 --- a/src/main/java/org/asteriskjava/pbx/EndPoint.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Provides an abstract interface for entities which can be dialed. - * - * This encompasses entities such as: Phone extensions SIPPeers Asterisk - * extensions External phone numbers - * - * @author bsutton - * - */ -public interface EndPoint extends Comparable -{ - public boolean isSame(EndPoint rhs); - - public boolean isLocal(); - - public boolean isSIP(); - - /** - * Returns the fully qualified name of the EndPoint including the tech. e.g. - * SIP/100 - * - * @return - */ - public String getFullyQualifiedName(); - - /** - * Returns the simple name of the EndPoint sans the tech. e.g. SIP/100 would - * be returned as 100. - * - * @return - */ - public String getSimpleName(); - - /** - * Returns the simple name of a SIP EndPoint sans the tech. e.g. SIP/100 - * would be returned as 100. If the endpoint is not actually a SIP end point - * then this method returns the full end point name. - * - * - * @return - */ - public String getSIPSimpleName(); - - /** - * Returns true if the tech is not know for this end point. - * - * @return - */ - public boolean isUnknown(); - - /** - * Returns the Tech that is used to reach this endpoint. - * - * @return - */ - public TechType getTech(); - - public boolean isEmpty(); - - /** - * Sets the tech on the end point to the specified tech. - * - * @param sip - */ - // public void setTech(Tech tech); - -} diff --git a/src/main/java/org/asteriskjava/pbx/InvalidChannelName.java b/src/main/java/org/asteriskjava/pbx/InvalidChannelName.java deleted file mode 100644 index b1cb6de54..000000000 --- a/src/main/java/org/asteriskjava/pbx/InvalidChannelName.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.asteriskjava.pbx; - -public class InvalidChannelName extends Exception -{ - private static final long serialVersionUID = 1L; - - public InvalidChannelName(final String message) - { - super(message); - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/ListenerPriority.java b/src/main/java/org/asteriskjava/pbx/ListenerPriority.java deleted file mode 100644 index 7c622ff43..000000000 --- a/src/main/java/org/asteriskjava/pbx/ListenerPriority.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.pbx; - -public enum ListenerPriority -{ - /** - * Provide access to events in near real time for specialised services that - * need priority access to events. Realtime events are sent before any other - * listeners get a chance to process the events. With the event dispatcher - * running in its own thread. This means that they are passed without delay. - * You must also ensure that you don't delay the processing of these - * messages as there may be real time event listeners. If you are concerned - * that you are going to delay the processing then you need to add in your - * own ManagerEventQueue to insulate other priority listeners from your - * tardiness. NOTE: you cannot rely on the LiveChannelManager as it - * processes events from the standard event queue. This means that Rename - * and Masquerade events MAY (very likely) not have been process when the - * realtime listener recieves an event. - */ - - REALTIME(100), CRITICAL(10), HIGH(8), NORMAL(6), LOW(4); - - // The priority of the listeners. Higher priority listeners receive - // events first. - private int _priority; - - ListenerPriority(int priority) - { - this._priority = priority; - } - - public int compare(ListenerPriority rhs) - { - return rhs._priority - this._priority; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/pbx/NewChannelListener.java b/src/main/java/org/asteriskjava/pbx/NewChannelListener.java deleted file mode 100644 index c4725b1ac..000000000 --- a/src/main/java/org/asteriskjava/pbx/NewChannelListener.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.asteriskjava.pbx; - -public interface NewChannelListener -{ - /** - * Allows a listener to be informed as new channels come up during an - * originate. - * - * The OriginateBase class will call this for each channel that comes up (as - * a result of the originate). - * - * Intermediate channels (local etc) that the underlying pbx may create on - * the way through are ignored with only the final channels being notified. - * - * This listener should be used by anyone that needs to have the channel at - * the earliest possible moment. - * - * Listeners should not run long lived process from this call as it will - * stall the dialer. - * - * @param channel - */ - void channelUpdate(Channel channel); -} diff --git a/src/main/java/org/asteriskjava/pbx/NewExtensionListener.java b/src/main/java/org/asteriskjava/pbx/NewExtensionListener.java deleted file mode 100644 index 5bce30e85..000000000 --- a/src/main/java/org/asteriskjava/pbx/NewExtensionListener.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Used to notify interested parties when a new extension has been read from the - * pbx configuration. - * - * @author bsutton - * - */ -public interface NewExtensionListener -{ - - void newExtension(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/PBX.java b/src/main/java/org/asteriskjava/pbx/PBX.java deleted file mode 100644 index d36a4a14c..000000000 --- a/src/main/java/org/asteriskjava/pbx/PBX.java +++ /dev/null @@ -1,280 +0,0 @@ -package org.asteriskjava.pbx; - -import java.util.List; - -import org.asteriskjava.pbx.Call.OperandChannel; -import org.asteriskjava.pbx.activities.BlindTransferActivity; -import org.asteriskjava.pbx.activities.DialActivity; -import org.asteriskjava.pbx.activities.HoldActivity; -import org.asteriskjava.pbx.activities.JoinActivity; -import org.asteriskjava.pbx.activities.ParkActivity; -import org.asteriskjava.pbx.activities.SplitActivity; - -/** - * Provides an abstracted interface for communicating with a PBX. - * - * @author bsutton - */ -public interface PBX -{ - - /** - * Call this method when shutting down the PBX interface to allow it to - * cleanup. - */ - public void shutdown(); - - /** - * Returns true if the bridge function is supported. - */ - boolean isBridgeSupported(); - - /** - * The BlindTransferActivity is used by the AsteriksPBX to transfer a live - * channel to an endpoint that may need to be dialed. Note: this action is a - * long running action which is dependent on a user action to complete. The - * action will only complete when the call is answered by the tranferTarget. - * It is recommended that you use the blindTransfer method which takes a - * callback as there is no way to cancel this action. Until the - * transferTarget answers the call or the blind transfer times out. - * - * @param channelToTransfer the channel which is to be blind transfered - * @param transferTarget the endPoint to which the channel is to be - * tranferred. - * @param toCallerID - the callerID to display to the transferTarget during - * the transfer. - * @param autoAnswer - if true then the transferTarget is to be sent an auto - * answer header - * @param timeout - timeout (in seconds) for the blind transfer attempt. - * When the timeout is reached the Blind Transfer will be - * cancelled. - * @param ActivityCallback - */ - BlindTransferActivity blindTransfer(final Call call, OperandChannel channelToTransfer, final EndPoint transferTarget, - final CallerID toCallerID, boolean autoAnswer, long timeout); - - /** - * The BlindTransferActivity is used by the AsteriksPBX to transfer a live - * channel to an endpoint that may need to be dialed. Note: this action is a - * long running action which is defendant on a user action to complete. The - * action will only complete when the call is answered by the tranferTarget. - * You can cancel the action at any time by using the activity object - * returned from the callback start method. - * - * @param channelToTransfer the channel which is to be blind transfered - * @param transferTarget the endPoint to which the channel is to be - * transferred. - * @param toCallerID - the callerID to display to the transferTarget during - * the transfer. - * @param autoAnswer - if true then the transferTarget is to be sent an auto - * answer header - * @param timeout - timeout for the blind transfer attempt. When the timeout - * is reached the Blind Transfer will be cancelled. - */ - void blindTransfer(Call call, OperandChannel channelToTransfer, final EndPoint transferTarget, final CallerID toCallerID, - boolean autoAnswer, long timeout, ActivityCallback callback); - - /** - * Sends a DTMF tone to given channel. Not returning until the tone has been - * sent. - * - * @param channel - */ - void conference(Channel channelOne, Channel channelTwo, Channel channelThree); - - /** - * Sends a DTMF tone to the given channel. This method returns immediately - * with progress information passed to the given callback. Note: the - * callback method will be called from a different thread. - * - * @param channel - * @param callback - */ - void conference(Channel channelOne, Channel channelTwo, Channel channelThree, ActivityCallback callback); - - /** - * Dials the given phone number using the specified trunk. Not returning - * until the call has been dialled. The dial will return as soon as the - * trunk comes up, it does not wait for remote end to answer. - * - * @return Call - the call resulting from dialing the number. - */ - DialActivity dial(EndPoint from, CallerID fromCallerID, EndPoint to, CallerID toCallerID); - - /** - * Dials the given phone number using the specified trunk. Not returning - * until the call has been dialled. The dial will return as soon as the - * trunk comes up, it does not wait for remote end to answer. - * - * @return Call the call resulting from dialing the number. - */ - void dial(EndPoint from, CallerID fromCallerID, EndPoint to, CallerID toCallerID, - ActivityCallback callback); - - /** - * Hangs up the given channel. Not returning until the call is hungup. - * - * @param channel - * @throws PBXException - */ - void hangup(Channel channel) throws PBXException; - - /** - * Hangs up the given channel. This method returns immediately with progress - * information passed to the given callback. Note: the callback method will - * be called from a different thread. - * - * @param channel - * @param callback - */ - void hangup(Channel channel, ActivityCallback callback); - - /** - * Hangup the given call, not returning until the call is hungup. - * @param call - */ - public void hangup(Call call) throws PBXException; - - /** - * Put the given channel on hold. - * - * @param channel - * @return - */ - HoldActivity hold(Channel channel); - - /** - * Returns true if the mute function is supported. - */ - boolean isMuteSupported(); - - /** - * Parks a call by moving the parkChannel to the parking lot and hanging up - * the hangupChannel. This method will not return until the park has - * completed. The park expects two channels which are two legs legs of the - * same call. The parkChannel will be redirect to the njr-park extension. - * The hangupChannel (the second leg of the call) will be hung up. The - * (obvious?) limitation is that we can't park something like a conference - * call as it has more than two channels. The returned iParkActivty can be - * used to obtain the extension the call was parked on. - * - * @param the call which is to be parked. - * @param parkChannel - the channel which is going to be redirect to the - * njr-park extension. - * @param hangupChannel - the channel which is going to be hungup. - */ - ParkActivity park(Call call, Channel parkChannel); - - /** - * Parks a call by moving the parkChannel to the parking lot and hanging up - * the hangupChannel. This method returns almost immediately call progress - * can be tracked via the callback. The park expects two channels which are - * two legs legs of the same call. The parkChannel will be redirect to the - * njr-park extension. The hangupChannel (the second leg of the call) will - * be hung up. The (obvious?) limitation is that we can't park something - * like a conference call as it has more than two channels. The returned - * iParkActivty can be used to obtain the extension the call was parked on. - * - * @param the call which is to be parked. - * @param parkChannel - the channel which is going to be redirect to the - * njr-park extension. - */ - void park(Call call, Channel parkChannel, ActivityCallback callback); - - /** - * Sends a DTMF tone to given channel. Not returning until the tone has been - * sent. - * - * @param channel - * @throws PBXException - */ - void sendDTMF(Channel channel, DTMFTone tone) throws PBXException; - - /** - * Sends a DTMF tone to the given channel. This method returns immediately - * with progress information passed to the given callback. Note: the - * callback method will be called from a different thread. - * - * @param channel - * @param callback - */ - void sendDTMF(Channel channel, DTMFTone tone, ActivityCallback callback); - - /** - * Splits a call (with two channels) This call returns once the split action - * has completed. - */ - - public SplitActivity split(final Call callToSplit, final ActivityCallback listener) throws PBXException; - - public void split(final Call callToSplit) throws PBXException; - - /** - * Joins two calls not returning until the join completes. Each call must - * only have one active channel - */ - public JoinActivity join(Call lhs, OperandChannel originatingOperand, Call rhs, OperandChannel acceptingOperand, - CallDirection direction); - - public void join(Call lhs, OperandChannel originatingOperand, Call rhs, OperandChannel acceptingOperand, - CallDirection direction, ActivityCallback listener); - - /** - * Returns the channel currently attached to the given end point, if one - * exists. If no channel is attached to the given end point then null is - * returned. - * - * @return the channel attached to the end point or null if the endpoint is - * not currently in a call. - */ - Channel getChannelByEndPoint(EndPoint endPoint); - - // /** - // * Converts a String representation of an extension into an extension - // object. - // * - // * The conversion is PBX specific. - // * - // * @param extension - // * @return - // */ - // iExtension getExtension(String extension); - - /** - * Builds an end point from a fully qualified end point name. A fully - * qualified name includes the tech. How the tech is encoded is pbx - * specific. - * - * @param fullyQualifiedEndPointName - * @return - */ - EndPoint buildEndPoint(String fullyQualifiedEndPointName); - - /** - * Builds an iEndPoint from an end point name. If the tech isn't passed in - * the endPointName the tech is set to the defaultTech The encoding for an - * end point name is pbx specific. - * - * @param endPointName - * @return - */ - EndPoint buildEndPoint(TechType defaultTech, String endPointName); - - EndPoint buildEndPoint(TechType tech, Trunk trunk, String endPointName); - - void transferToMusicOnHold(Channel channel) throws PBXException; - - CallerID buildCallerID(String number, String name); - - boolean isChannel(String channel); - - boolean waitForChannelsToQuiescent(List channels, long timeout); - - EndPoint getExtensionAgi(); - - public boolean waitForChannelToQuiescent(Channel channel, int timeout); - - public Trunk buildTrunk(String string); - - -} diff --git a/src/main/java/org/asteriskjava/pbx/PBXException.java b/src/main/java/org/asteriskjava/pbx/PBXException.java deleted file mode 100644 index fe754e0ca..000000000 --- a/src/main/java/org/asteriskjava/pbx/PBXException.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -public class PBXException extends Exception -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(PBXException.class); - - public PBXException(String message, final Exception e) - { - super(message, e); - } - - public PBXException(final String message) - { - super(message); - } - - public PBXException(Throwable e) - { - super(e); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/PBXFactory.java b/src/main/java/org/asteriskjava/pbx/PBXFactory.java deleted file mode 100644 index b6fedfa2c..000000000 --- a/src/main/java/org/asteriskjava/pbx/PBXFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.asteriskjava.pbx; - -import java.util.concurrent.atomic.AtomicReference; - -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class PBXFactory -{ - - public static PBX getActivePBX() - { - return AsteriskPBX.SELF; - - } - - final static AtomicReference profile = new AtomicReference<>(); - - public static void init(AsteriskSettings newProfile) - { - profile.set(newProfile); - - } - - public static AsteriskSettings getActiveProfile() - { - AsteriskSettings activeProfile = profile.get(); - if (activeProfile == null) - { - throw new RuntimeException( - "you must call setAsteriskSettings() before getActiveProfile() is called the first time"); - } - - return activeProfile; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/PhoneNumber.java b/src/main/java/org/asteriskjava/pbx/PhoneNumber.java deleted file mode 100644 index 31c99e165..000000000 --- a/src/main/java/org/asteriskjava/pbx/PhoneNumber.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Provides an abstraction of a phone number. This allows different PBX's to - * store the phone numbers in a way that may be specific to the pbx. - * - * In general most PBX's there is no need for a special abstraction, however - * using the interface just makes the code clearer that we are passing a phone - * number. - * - * @author bsutton - * - */ -public interface PhoneNumber -{ - // TODO - -} diff --git a/src/main/java/org/asteriskjava/pbx/Tech.java b/src/main/java/org/asteriskjava/pbx/Tech.java deleted file mode 100644 index 954834e22..000000000 --- a/src/main/java/org/asteriskjava/pbx/Tech.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.asteriskjava.pbx; - -public interface Tech -{ - // TODO: do we need this? -} diff --git a/src/main/java/org/asteriskjava/pbx/TechType.java b/src/main/java/org/asteriskjava/pbx/TechType.java deleted file mode 100644 index fd20efa1b..000000000 --- a/src/main/java/org/asteriskjava/pbx/TechType.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.asteriskjava.pbx; - -import org.apache.log4j.Logger; - -public enum TechType implements Tech -{ - - // - UNKNOWN, SIP, DAHDI, LOCAL, IAX, IAX2 - // The DIALPLAN tech is used to suppresses output of the tech - // when obtaining the fully qualified name of the endpoint. - // Basically if you want to call into an asterisk dialplan extension - // then the tech needs to be suppressed. - , DIALPLAN - // CONSOLE is sent when a call is made from the asterisk console. - // These type of channels are ignored. - , CONSOLE; - - private static final Logger logger = Logger.getLogger(TechType.class); - - /** - * Extracts the technology from a fully qualified endpoint string of the - * form: TECH/NNNN - * - * @param fullyQualifiedEndPoint - * @return - */ - public static TechType getTech(final String fullyQualifiedEndPoint) - { - if (!TechType.hasValidTech(fullyQualifiedEndPoint)) - { - throw new IllegalArgumentException("The provided end point '" //$NON-NLS-1$ - + fullyQualifiedEndPoint + "' must contain a tech prefix. e.g. SIP/100"); //$NON-NLS-1$ - } - - final String techName = fullyQualifiedEndPoint.substring(0, fullyQualifiedEndPoint.indexOf("/")); //$NON-NLS-1$ - return TechType.valueOf(techName.toUpperCase()); - } - - /** - * returns true if the endPoint name contains a valid tech descriptor. - * - * @param endPointName - * @return - */ - public static boolean hasValidTech(final String endPointName) - { - TechType tech = UNKNOWN; - final int index = endPointName.indexOf("/"); //$NON-NLS-1$ - - if (index >= 1) - { - final String techName = endPointName.substring(0, index); - try - { - tech = TechType.valueOf(techName.toUpperCase()); - } - catch (final IllegalArgumentException e) - { - TechType.logger.error("Invalid tech for endpoint:" + endPointName); //$NON-NLS-1$ - } - } - - return tech != UNKNOWN; - - } - - /** - * returns true if the endPoint name contains a tech descriptor even if it - * isn't a known descriptor. - * - * @param endPointName - * @return - */ - public static boolean hasTech(final String endPointName) - { - boolean hasTech = false; - - final int index = endPointName.indexOf("/"); //$NON-NLS-1$ - - if (index != -1) - { - hasTech = true; - } - - return hasTech; - - } - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/pbx/Trunk.java b/src/main/java/org/asteriskjava/pbx/Trunk.java deleted file mode 100644 index 981591102..000000000 --- a/src/main/java/org/asteriskjava/pbx/Trunk.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.asteriskjava.pbx; - -/** - * Provides an abstraction of a trunk * @author bsutton - */ -public interface Trunk -{ - String getTrunkAsString(); -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/BlindTransferActivity.java b/src/main/java/org/asteriskjava/pbx/activities/BlindTransferActivity.java deleted file mode 100644 index e18527f6e..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/BlindTransferActivity.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBXException; - -public interface BlindTransferActivity extends Activity -{ - /** - * A bridged call is a successful transfer all other options are a failed - * transfer. - * - * @author bsutton - * - */ - enum CompletionCause - { - // The call was bridged. - BRIDGED("Connected") - // The call hungup - , HANGUP("Transfer Failed, Caller Hungup or Destination Busy") - // A timeout occur during the transfer - // which essentially means the transferTarget didn't answer the phone - , TIMEOUT("Transfer Failed, Timeout") - // The cancel method was called. - , CANCELLED("Transfer Cancelled"); - - String message; - - CompletionCause(String message) - { - this.message = message; - } - - public String getMessage() - { - return message; - } - } - - Channel getChannelToTransfer(); - - CallerID getTransferTargetCallerID(); - - EndPoint getTransferTarget(); - - Channel getTransferTargetChannel(); - - CompletionCause getCompletionCause(); - - void cancel(); - - /** - * The call created as a result of the blind transfer being answered. - * - * @return - * @throws PBXException - */ - Call getNewCall() throws PBXException; - -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/BridgeActivity.java b/src/main/java/org/asteriskjava/pbx/activities/BridgeActivity.java deleted file mode 100644 index 11fbd13dc..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/BridgeActivity.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; - -public interface BridgeActivity extends Activity -{ - // TODO -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/DialActivity.java b/src/main/java/org/asteriskjava/pbx/activities/DialActivity.java deleted file mode 100644 index 46a7ceab4..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/DialActivity.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; - -public interface DialActivity extends Activity -{ - /** - * Returns the end point which originated the dial. - */ - EndPoint getOriginatingEndPoint(); - - /** - * Returns the end point which is being dialed. This is available even - * before the dial commences. - */ - EndPoint getAcceptingEndPoint(); - - /** - * Returns the 'originating' channel which is brought up as part of the dial - * activity. The 'originating' channel may return null if the channel is not - * up. - * - * @return the 'originating' channel if it has been brought up otherwise - * null. - */ - Channel getOriginatingChannel(); - - /** - * Returns the 'accepting' channel which is brought up as part of the dial - * activity. The accepting party is the party that answers the call. The - * 'accepting' channel may return null if the channel is not up. - * - * @return the 'accepting' channel if it has been brought up otherwise null - */ - Channel getAcceptingChannel(); - - /** - * Call markCancelled if you want to stop a dial which is in progress from - * completing. This allows a user to cancel a dial. - */ - void markCancelled(); - - /** - * Returns true if markCancelled was called during the dial attempt. - * @return - */ - boolean cancelledByOperator(); - - Call getNewCall(); -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/DialToAgiActivity.java b/src/main/java/org/asteriskjava/pbx/activities/DialToAgiActivity.java deleted file mode 100644 index db557e4fb..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/DialToAgiActivity.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; - -public interface DialToAgiActivity extends Activity -{ - - void markCancelled(); - - boolean cancelledByOperator(); - - EndPoint getOriginatingEndPoint(); - - Channel getOriginatingChannel(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/HoldActivity.java b/src/main/java/org/asteriskjava/pbx/activities/HoldActivity.java deleted file mode 100644 index 812c927be..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/HoldActivity.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.Channel; - -public interface HoldActivity extends Activity -{ - // Returns the Channel that is on hold - public Channel getChannel(); -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/JoinActivity.java b/src/main/java/org/asteriskjava/pbx/activities/JoinActivity.java deleted file mode 100644 index 30acf65cd..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/JoinActivity.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.Call; - -public interface JoinActivity extends Activity -{ - Call getJoinedCall(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/ParkActivity.java b/src/main/java/org/asteriskjava/pbx/activities/ParkActivity.java deleted file mode 100644 index 5d4282115..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/ParkActivity.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.EndPoint; - -public interface ParkActivity extends Activity -{ - - /** - * Returns the endpoint (parking lot) that the call was park on. - * - * @return - */ - EndPoint getParkingLot(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/activities/SplitActivity.java b/src/main/java/org/asteriskjava/pbx/activities/SplitActivity.java deleted file mode 100644 index cfd99fcd9..000000000 --- a/src/main/java/org/asteriskjava/pbx/activities/SplitActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.pbx.activities; - -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.Call; - -public interface SplitActivity extends Activity -{ - - /** - * After a call has been split we get a new calls. The call created as a - * result of the lhsOperandChannel being split can be retrieved by calling - * this method. - * - * @return the call which holds the call associated with the - * lhsOperandChannel - */ - Call getLHSCall(); - - /** - * After a call has been split we get a new calls. The call created as a - * result of the rhsOperandChannel being split can be retrieved by calling - * this method. - * - * This method will return now if split was called with only a single - * operand channel. - * - * @return the call which holds the call associated with the - * lhsOperandChannel - */ - Call getRHSCall(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/ActivityAgi.java b/src/main/java/org/asteriskjava/pbx/agi/ActivityAgi.java deleted file mode 100644 index 79064af7b..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/ActivityAgi.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ChannelHangupListener; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class ActivityAgi extends NJAgiScript -{ - - private final Log logger = LogFactory.getLog(this.getClass()); - - @Override - public void service() throws AgiException - { - Channel channelProxy = null; - String channelName = channel.getName(); - - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - String proxyId = getVariable("proxyId"); - if (proxyId != null && proxyId.length() > 0) - { - channelProxy = pbx.getProxyById(proxyId); - } - if (channelProxy == null) - { - logger.warn("'proxyId' var not set or proxy doesn't exist anymore, trying to match the channel name... " - + channelName); - channelProxy = pbx.internalRegisterChannel(channel.getName(), channel.getUniqueId()); - - } - - logger.info("Channel " + channelName + " arrived in agi"); - - channelProxy.setIsInAgi(true); - channelProxy.addHangupListener(new ChannelHangupListener() - { - - @Override - public void channelHangup(Channel channel, Integer cause, String causeText) - { - final AgiChannelActivityAction currentActivityAction = channel.getCurrentActivityAction(); - if (currentActivityAction != null) - { - currentActivityAction.cancel(channel); - } - - } - }); - - AgiChannelActivityAction action = channelProxy.getCurrentActivityAction(); - if (action == null) - { - action = new AgiChannelActivityHold(); - } - - boolean isAlive = true; - RateLimiter rateLimiter = new RateLimiter(2); - while (!action.isDisconnect() && isAlive) - { - - action.execute(this.channel, channelProxy); - - action = channelProxy.getCurrentActivityAction(); - logger.info("Action for proxy " + channelProxy + " is " + action.getClass().getSimpleName()); - isAlive = checkChannelIsStillUp(); - rateLimiter.acquire(); - } - - } - catch (AgiHangupException e) - { - logger.warn("Channel hungup " + channelName); - } - catch (InvalidChannelName | InterruptedException e) - { - logger.error(e, e); - } - - logger.info("Channel leaving agi " + channelName); - - } - - private boolean checkChannelIsStillUp() - { - try - - { - this.answer(); - return true; - } - catch (Exception e) - { - - } - return false; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityBlindTransfer.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityBlindTransfer.java deleted file mode 100644 index 2ec97797e..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityBlindTransfer.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.util.concurrent.CountDownLatch; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; - -public class AgiChannelActivityBlindTransfer implements AgiChannelActivityAction -{ - - CountDownLatch latch = new CountDownLatch(1); - private String target; - private String sipHeader; - int timeout = 30; - - public AgiChannelActivityBlindTransfer(String fullyQualifiedName, String sipHeader) - { - this.target = fullyQualifiedName; - this.sipHeader = sipHeader; - if (sipHeader == null) - { - this.sipHeader = ""; - } - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - - channel.setVariable("__SIPADDHEADER", sipHeader); - ichannel.setCurrentActivityAction(new AgiChannelActivityHold()); - channel.dial(target, timeout, ""); - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - latch.countDown(); - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityBridge.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityBridge.java deleted file mode 100644 index d07c1711e..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityBridge.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.util.concurrent.CountDownLatch; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class AgiChannelActivityBridge implements AgiChannelActivityAction -{ - - private Channel target; - private final Log logger = LogFactory.getLog(this.getClass()); - - CountDownLatch latch = new CountDownLatch(1); - - public AgiChannelActivityBridge(Channel target) - { - this.target = target; - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - try - { - - channel.bridge(target.getChannelName(), ""); - channel.hangup(); - } - catch (AgiHangupException e) - { - logger.warn(e); - } - finally - { - latch.countDown(); - } - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - latch.countDown(); - - } - // Logger logger = LogManager.getLogger(); - - public void sleepWhileBridged() throws InterruptedException - { - latch.await(); - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityDial.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityDial.java deleted file mode 100644 index 5f65bd3e0..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityDial.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.util.concurrent.CountDownLatch; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; - -public class AgiChannelActivityDial implements AgiChannelActivityAction -{ - - CountDownLatch latch = new CountDownLatch(1); - private String target; - private String sipHeader; - - public AgiChannelActivityDial(String target) - { - this.target = target; - } - - public AgiChannelActivityDial(String fullyQualifiedName, String sipHeader) - { - target = fullyQualifiedName; - this.sipHeader = sipHeader; - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - if (sipHeader != null) - { - channel.setVariable("__SIPADDHEADER", sipHeader); - } - // setting the activity to hold, means that when the call falls out of - // the dial it'll go to hold. - - // also if some other code sets and activity and then redirects, we - // won't over write it on the way out (if we did it after the dial - // command) - ichannel.setCurrentActivityAction(new AgiChannelActivityHold()); - channel.dial(target, 30, ""); - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - latch.countDown(); - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHangup.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHangup.java deleted file mode 100644 index d6fd85bd7..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHangup.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.util.concurrent.CountDownLatch; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class AgiChannelActivityHangup implements AgiChannelActivityAction -{ - private final Log logger = LogFactory.getLog(this.getClass()); - - CountDownLatch latch = new CountDownLatch(1); - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - try - { - - channel.hangup(); - logger.info("Hungup"); - } - catch (AgiHangupException e) - { - // don't care - } - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - latch.countDown(); - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHold.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHold.java deleted file mode 100644 index efb5df319..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHold.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class AgiChannelActivityHold implements AgiChannelActivityAction -{ - private final Log logger = LogFactory.getLog(this.getClass()); - - CountDownLatch latch = new CountDownLatch(1); - volatile boolean callReachedAgi = false; - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - try - { - callReachedAgi = true; - channel.answer(); - channel.playMusicOnHold(); - logger.info(ichannel + " is still on hold"); - if (latch.await(10, TimeUnit.SECONDS)) - { - try - { - channel.stopMusicOnHold(); - } - catch (Exception e) - { - logger.warn(e); - } - } - } - catch (AgiHangupException e) - { - logger.warn(e); - } - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - latch.countDown(); - - } - - public boolean hasCallReachedAgi() - { - return callReachedAgi; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHoldForBridge.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHoldForBridge.java deleted file mode 100644 index d655c6ce5..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityHoldForBridge.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class AgiChannelActivityHoldForBridge implements AgiChannelActivityAction -{ - private final Log logger = LogFactory.getLog(this.getClass()); - private AgiChannelActivityBridge bridgeActivity; - - public AgiChannelActivityHoldForBridge(AgiChannelActivityBridge bridgeActivity) - { - this.bridgeActivity = bridgeActivity; - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - try - { - channel.playMusicOnHold(); - bridgeActivity.sleepWhileBridged(); - - channel.hangup(); - } - catch (AgiHangupException e) - { - logger.warn(e.getMessage() + " " + channel.getName()); - } - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - // TODO Auto-generated method stub - - } - // Logger logger = LogManager.getLogger(); -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityMeetme.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityMeetme.java deleted file mode 100644 index fe7c02a70..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityMeetme.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.io.IOException; -import java.util.concurrent.CountDownLatch; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.RedirectAction; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class AgiChannelActivityMeetme implements AgiChannelActivityAction -{ - private final Log logger = LogFactory.getLog(this.getClass()); - - CountDownLatch latch = new CountDownLatch(1); - private String room; - private volatile boolean hangup = true; - // volatile private iChannel ichannel; - - private String options; - - public AgiChannelActivityMeetme(String room, String options) - { - this.room = room; - this.options = options; - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - if (ichannel == null) - { - throw new NullPointerException("ichannel cannot be null"); - } - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - if (pbx.getVersion().isAtLeast(AsteriskVersion.ASTERISK_13)) - { - channel.confbridge(room, "transfer"); - } - else - { - channel.meetme(room, options); - } - if (hangup) - { - try - { - channel.hangup(); - } - catch (Exception e) - { - logger.warn(e); - } - } - logger.info(ichannel + " left the meetme"); - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - - if (channel == null) - { - throw new NullPointerException("channel cannot be null"); - } - - hangup = false; - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - final RedirectAction redirect = new RedirectAction(channel, profile.getManagementContext(), pbx.getExtensionAgi(), - 1); - try - { - pbx.sendAction(redirect, 1000); - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - logger.error(e, e); - } - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityQueue.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityQueue.java deleted file mode 100644 index 217eb60ac..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityQueue.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.io.IOException; -import java.util.concurrent.CountDownLatch; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.RedirectAction; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class AgiChannelActivityQueue implements AgiChannelActivityAction -{ - - private final Log logger = LogFactory.getLog(this.getClass()); - - CountDownLatch latch = new CountDownLatch(1); - - final private String queue; - private volatile boolean hangup = true; - // volatile private iChannel ichannel; - - public AgiChannelActivityQueue(String queue) - { - this.queue = queue; - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - channel.queue(queue); - if (hangup) - { - try - { - channel.hangup(); - } - catch (AgiHangupException e) - { - logger.warn("Channel " + channel.getName() + " hungup"); - } - catch (Exception e) - { - logger.warn(e); - } - } - logger.info(ichannel + " left the queue"); - - } - - @Override - public boolean isDisconnect() - { - return false; - } - - @Override - public void cancel(Channel channel) - { - if (channel == null) - { - throw new NullPointerException("channel cannot be null"); - } - - hangup = false; - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - final RedirectAction redirect = new RedirectAction(channel, profile.getManagementContext(), pbx.getExtensionAgi(), - 1); - try - { - - pbx.sendAction(redirect, 1000); - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - logger.error(e, e); - } - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityVoicemail.java b/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityVoicemail.java deleted file mode 100644 index 0010ae3f6..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/AgiChannelActivityVoicemail.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.Channel; - -public class AgiChannelActivityVoicemail implements AgiChannelActivityAction -{ - - public AgiChannelActivityVoicemail(String mailbox) - { - // TODO Auto-generated constructor stub - } - - @Override - public void execute(AgiChannel channel, Channel ichannel) throws AgiException, InterruptedException - { - // TODO Auto-generated method stub - - } - - @Override - public boolean isDisconnect() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public void cancel(Channel channel) - { - // TODO Auto-generated method stub - - } - // Logger logger = LogManager.getLogger(); -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/NJAgiScript.java b/src/main/java/org/asteriskjava/pbx/agi/NJAgiScript.java deleted file mode 100644 index 39ba5e5ae..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/NJAgiScript.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import org.apache.log4j.Logger; -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.BaseAgiScript; - -abstract public class NJAgiScript extends BaseAgiScript -{ - static transient Logger logger = Logger.getLogger(NJAgiScript.class); - protected AgiRequest request; - protected AgiChannel channel; - - public synchronized void service(AgiRequest request, AgiChannel channel) throws AgiException - { - this.request = request; - this.channel = channel; - service(); - } - - /** - * field variables request and channel will be set prior to calling - * service() AgiRequest request AgiChannel channel - * - * @throws AgiException - */ - - public abstract void service() throws AgiException; - - protected String required(String name, String parameter) throws AgiException - { - if (parameter == null || parameter.length() == 0) - throw new AgiException("Required parameter " + name + " missing."); - return parameter; - } - - protected String getParameter(String name) throws AgiException - { - return required(name, request.getParameter(name)); - } - - public void setVariable(String name, String value) throws AgiException - { - logger.debug("AGIVar set: " + name + "=(" + value + ")"); - super.setVariable(name, value); - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/agi/RateLimiter.java b/src/main/java/org/asteriskjava/pbx/agi/RateLimiter.java deleted file mode 100644 index 0efadab42..000000000 --- a/src/main/java/org/asteriskjava/pbx/agi/RateLimiter.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import java.util.LinkedList; -import java.util.List; - -public class RateLimiter -{ - private static final long ONE_THOUSAND_MILLIS = 1000L; - List available = new LinkedList<>(); - - /** - * this is NOT thread safe! - * - * @param perSecond - number of 'acquire()' calls allowed per second, a call - * to acquire() will block(sleep) if the per second limit is - * exceeded - */ - RateLimiter(int perSecond) - { - long now = System.currentTimeMillis(); - for (int i = 0; i < perSecond; i++) - { - available.add(now - ONE_THOUSAND_MILLIS); - } - } - - void acquire() throws InterruptedException - { - long now = System.currentTimeMillis(); - Long next = available.remove(0); - long timeRemaining = next - now; - if (timeRemaining > 0) - { - Thread.sleep(timeRemaining); - } - available.add(System.currentTimeMillis() + ONE_THOUSAND_MILLIS); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/AbstractManagerAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/AbstractManagerAction.java deleted file mode 100644 index 0b1f6e19d..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/AbstractManagerAction.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -/** - * Automatically generates a globally unique action id (based on the systems mac - * address - * - * @author bsutton - * - */ -abstract public class AbstractManagerAction implements ManagerAction -{ - - private static long _nextActionId = 1; - - private String _actionId; - - AbstractManagerAction() - { - this._actionId = generateActionId(); - } - - public String getActionId() - { - return this._actionId; - } - - synchronized public String generateActionId() - { - - return "" + _nextActionId++; - } - - protected void setActionId(String actionId) - { - this._actionId = actionId; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/BridgeAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/BridgeAction.java deleted file mode 100644 index 2961cf4bb..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/BridgeAction.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.pbx.Channel; - -public class BridgeAction extends AbstractManagerAction -{ - - private final Channel _lhs; - private final Channel _rhs; - - public BridgeAction(final Channel lhs, final Channel rhs) - { - this._lhs = lhs; - this._rhs = rhs; - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.BridgeAction action = new org.asteriskjava.manager.action.BridgeAction(); - action.setActionId(this.getActionId()); - action.setChannel1(this._lhs.getChannelName()); - action.setChannel2(this._rhs.getChannelName()); - return action; - } - - public String toString() - { - return "BridgeAction: lhs=" + this._lhs + " rhs=" + this._rhs; //$NON-NLS-1$ //$NON-NLS-2$ - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/CommandAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/CommandAction.java deleted file mode 100644 index 2c6b37988..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/CommandAction.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -public class CommandAction extends AbstractManagerAction -{ - - private String _command; - - public CommandAction(final String command) - { - this._command = command; - } - - public CommandAction() - { - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.CommandAction action = new org.asteriskjava.manager.action.CommandAction(); - action.setCommand(this._command); - action.setActionId(this.getActionId()); - - return action; - } - - public String toString() - { - return "CommandAction: command=" + this._command; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ConfbridgeListAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ConfbridgeListAction.java deleted file mode 100644 index af3535b0e..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ConfbridgeListAction.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.manager.action.ManagerAction; - -public class ConfbridgeListAction extends AbstractManagerAction implements EventGeneratingAction -{ - - @Override - public ManagerAction getAJAction() - { - return new org.asteriskjava.manager.action.ConfbridgeListAction(); - } - // Logger logger = LogManager.getLogger(); - - @Override - public org.asteriskjava.manager.action.EventGeneratingAction getAJEventGeneratingAction() - { - org.asteriskjava.manager.action.ConfbridgeListAction action = new org.asteriskjava.manager.action.ConfbridgeListAction(); - action.setActionId(this.getActionId()); - return action; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/DbGetAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/DbGetAction.java deleted file mode 100644 index 75ef3a8b5..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/DbGetAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.manager.action.ManagerAction; - -public class DbGetAction extends AbstractManagerAction -{ - - private final String _key; - private final String _family; - - public DbGetAction(final String family, final String key) - { - this._family = family; - this._key = key; - } - - @Override - public ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.DbGetAction action = new org.asteriskjava.manager.action.DbGetAction(); - action.setActionId(this.getActionId()); - action.setKey(this._key); - action.setFamily(this._family); - - return action; - } - - public String toString() - { - return "DbGetAction: key=" + this._key + " family=" + this._family; //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/EventGeneratingAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/EventGeneratingAction.java deleted file mode 100644 index 2f554fca3..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/EventGeneratingAction.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -public interface EventGeneratingAction -{ - - org.asteriskjava.manager.action.EventGeneratingAction getAJEventGeneratingAction(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/GetVarAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/GetVarAction.java deleted file mode 100644 index a222726be..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/GetVarAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.pbx.Channel; - -public class GetVarAction extends AbstractManagerAction -{ - - private final Channel _channel; - private String _variableName; - - public GetVarAction(final Channel channel, String variableName) - { - this._channel = channel; - this._variableName = variableName; - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.GetVarAction action = new org.asteriskjava.manager.action.GetVarAction(); - action.setActionId(this.getActionId()); - action.setChannel(this._channel.getChannelName()); - action.setVariable(this._variableName); - - return action; - } - - public String toString() - { - return "GetVarAction: channel=" + this._channel + " variableName=" + this._variableName; //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/HangupAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/HangupAction.java deleted file mode 100644 index 8bcf97441..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/HangupAction.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.pbx.Channel; - -public class HangupAction extends AbstractManagerAction -{ - - private final Channel _channel; - private Integer _cause; - - public HangupAction(final Channel channel) - { - this._channel = channel; - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.HangupAction action = new org.asteriskjava.manager.action.HangupAction(); - action.setActionId(this.getActionId()); - action.setCause(this._cause); - action.setChannel(this._channel.getChannelName()); - - return action; - } - - public Channel getChannel() - { - return this._channel; - } - - public String toString() - { - return "HangupAction: channel=" + this._channel + " cause=" + this._cause; //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ListCommandsAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ListCommandsAction.java deleted file mode 100644 index 12b9c8dc4..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ListCommandsAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.apache.log4j.Logger; - -public class ListCommandsAction extends AbstractManagerAction -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ListCommandsAction.class); - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.ListCommandsAction action = new org.asteriskjava.manager.action.ListCommandsAction(); - action.setActionId(this.getActionId()); - - return action; - } - - public String toString() - { - return "ListCommandsAction"; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ManagerAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ManagerAction.java deleted file mode 100644 index a573d7c0d..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/ManagerAction.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -public interface ManagerAction -{ - - // Converts an iManagerAction into an asterisk-java ManagerAction. - org.asteriskjava.manager.action.ManagerAction getAJAction(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/MonitorAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/MonitorAction.java deleted file mode 100644 index 7d7c1a6cf..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/MonitorAction.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.pbx.Channel; - -public class MonitorAction extends AbstractManagerAction -{ - - private final Channel _channel; - private final String _file; - private final String _format; - private final boolean _mix; - - public MonitorAction(final Channel channel, final String file, final String format, final boolean mix) - { - this._channel = channel; - this._file = file; - this._format = format; - this._mix = mix; - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.MonitorAction action = new org.asteriskjava.manager.action.MonitorAction( - this._channel.getChannelName(), this._file, this._format, this._mix); - action.setActionId(this.getActionId()); - - return action; - } - - public String toString() - { - return "MonitorAction: channel=" + this._channel + " file=" + this._file; //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/OriginateAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/OriginateAction.java deleted file mode 100644 index 50bcef2a8..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/OriginateAction.java +++ /dev/null @@ -1,142 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import java.util.Map; - -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.internal.asterisk.CallerIDImpl; - -public class OriginateAction extends AbstractManagerAction -{ - - /** - * Asterisk uses the term channel but it actually appears to be an endpoint - * or a channel. Hence we support both. - * - * Either of the following may be set but NOT BOTH. - */ - private EndPoint _endPoint; - private Channel _channel; - - private String _option; - - private String _context; - - private EndPoint _extension; - - private int _priority; - - private int _callingPres; - - private CallerID _callerID; - - private Map _variables; - - private Boolean _async; - - private long _timeout; - - public OriginateAction() - { - } - - public String toString() - { - return "OriginateAction: endPoint/Channel=" + (this._endPoint == null ? this._channel : this._endPoint) + " context=" + this._context //$NON-NLS-1$ //$NON-NLS-2$ - + " extension=" + this._extension + " callerId=" + this._callerID; //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.OriginateAction action = new org.asteriskjava.manager.action.OriginateAction(); - action.setActionId(getActionId()); - - // Was the channel or an end point passed. - String channel = (this._channel != null ? this._channel.getChannelName() : this._endPoint - .getFullyQualifiedName()); - if (this._option != null) - { - channel += this._option; - } - action.setChannel((channel)); - action.setContext(this._context); - action.setExten(this._extension.getFullyQualifiedName()); - action.setPriority(this._priority); - action.setCallingPres(this._callingPres); - action.setCallerId(((CallerIDImpl) this._callerID).formatted()); - action.setVariables(this._variables); - action.setAsync(this._async); - action.setTimeout(this._timeout); - - return action; - } - - public void setEndPoint(final EndPoint endPoint) - { - this._endPoint = endPoint; - this._channel = null; - } - - public void setChannel(Channel channel) - { - this._channel = channel; - this._endPoint = null; - - } - - public void setOption(final String option) - { - this._option = option; - - } - - public void setContext(final String context) - { - this._context = context; - - } - - public void setExten(final EndPoint extension) - { - this._extension = extension; - - } - - public void setPriority(final int priority) - { - this._priority = priority; - - } - - public void setCallingPres(final int callingPres) - { - this._callingPres = callingPres; - - } - - public void setCallerId(final CallerID callerID) - { - this._callerID = callerID; - - } - - public void setVariables(final Map variables) - { - this._variables = variables; - - } - - public void setAsync(final boolean async) - { - this._async = async; - - } - - public void setTimeout(final long timeout) - { - this._timeout = timeout; - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/PingAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/PingAction.java deleted file mode 100644 index c44c97e6b..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/PingAction.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.apache.log4j.Logger; - -public class PingAction extends AbstractManagerAction -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(PingAction.class); - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.PingAction action = new org.asteriskjava.manager.action.PingAction(); - action.setActionId(this.getActionId()); - return action; - } - - public String toString() - { - return "PingAction"; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/PlayDtmfAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/PlayDtmfAction.java deleted file mode 100644 index 59218af9e..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/PlayDtmfAction.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.DTMFTone; - -public class PlayDtmfAction extends AbstractManagerAction -{ - - private final Channel _channel; - private final DTMFTone _tone; - - public PlayDtmfAction(final Channel channel, final DTMFTone tone) - { - this._channel = channel; - this._tone = tone; - } - - @Override - public ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.PlayDtmfAction action = new org.asteriskjava.manager.action.PlayDtmfAction(); - action.setActionId(this.getActionId()); - action.setChannel(this._channel.getChannelName()); - action.setDigit(this._tone.toString()); - - return action; - } - - public String toString() - { - return "PlayDtmfAction: channel=" + this._channel + " tone=" + this._tone; //$NON-NLS-1$ //$NON-NLS-2$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/RedirectAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/RedirectAction.java deleted file mode 100644 index 32c067f57..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/RedirectAction.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; - -public class RedirectAction extends AbstractManagerAction -{ - - private final Channel _channel; - private final String _context; - private final EndPoint _exten; - private final Integer _priority; - private Channel _extraChannel; - private String _extraContext; - private EndPoint _extraExten; - private Integer _extraPriority; - - public RedirectAction(final Channel channel, final String context, final EndPoint extension, final int priority) - { - if (channel == null) - { - throw new NullPointerException("channel cannot be null"); - } - if (context == null) - { - throw new NullPointerException("context cannot be null"); - } - if (extension == null) - { - throw new NullPointerException("extension cannot be null"); - } - - this._channel = channel; - this._context = context; - this._exten = extension; - this._priority = priority; - } - - @Override - public String toString() - { - return "RedirectAction: chanel=" + this._channel + " context=" + this._context //$NON-NLS-1$ //$NON-NLS-2$ - + " exten=" + this._exten + " priority=" + this._priority //$NON-NLS-1$ //$NON-NLS-2$ - + " extraContext=" + this._extraContext //$NON-NLS-1$ - + " extraChannel=" + this._extraChannel //$NON-NLS-1$ - + " extraExten=" + this._extraExten; //$NON-NLS-1$ - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.RedirectAction action = new org.asteriskjava.manager.action.RedirectAction(); - action.setActionId(this.getActionId()); - action.setChannel(this._channel.getChannelName()); - action.setContext(this._context); - action.setExten(this._exten.getFullyQualifiedName()); - action.setPriority(this._priority); - if (this._extraChannel != null) - action.setExtraChannel(this._extraChannel.getChannelName()); - action.setExtraContext(this._extraContext); - if (this._extraExten != null) - action.setExtraExten(this._extraExten.getFullyQualifiedName()); - action.setExtraPriority(this._extraPriority); - - return action; - } - - public void setExtraChannel(final Channel extraChannel) - { - this._extraChannel = extraChannel; - } - - public void setExtraContext(final String extraContext) - { - this._extraContext = extraContext; - } - - public void setExtraExten(final EndPoint extraExten) - { - this._extraExten = extraExten; - } - - public void setExtraPriority(final int priority) - { - this._extraPriority = priority; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SetVarAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SetVarAction.java deleted file mode 100644 index 4f89aa5a4..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SetVarAction.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.pbx.Channel; - -public class SetVarAction extends AbstractManagerAction -{ - - private final Channel _channel; - private String _variableName; - private final String _value; - - public SetVarAction(final Channel channel, final String variableName, final String value) - { - this._channel = channel; - this._variableName = variableName; - this._value = value; - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.SetVarAction action = new org.asteriskjava.manager.action.SetVarAction(); - action.setActionId(this.getActionId()); - action.setChannel(this._channel.getChannelName()); - action.setVariable(this._variableName); - action.setValue(this._value); - - return action; - } - - public void setVariable(final String variableName) - { - this._variableName = variableName; - - } - - public String toString() - { - return "SetVarAction: channel=" + this._channel + " variableName=" + this._variableName + " value=" + this._value; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SipPeersAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SipPeersAction.java deleted file mode 100644 index b24ee11be..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SipPeersAction.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -public class SipPeersAction extends AbstractManagerAction implements EventGeneratingAction -{ - - public SipPeersAction() - { - } - - @Override - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - return new org.asteriskjava.manager.action.SipPeersAction(); - } - - @Override - public org.asteriskjava.manager.action.EventGeneratingAction getAJEventGeneratingAction() - { - org.asteriskjava.manager.action.SipPeersAction action = new org.asteriskjava.manager.action.SipPeersAction(); - action.setActionId(this.getActionId()); - return action; - } - - public String toString() - { - return "SipPeersAction"; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SipShowPeerAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SipShowPeerAction.java deleted file mode 100644 index f29bbfd1c..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/SipShowPeerAction.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.pbx.EndPoint; - -public class SipShowPeerAction extends AbstractManagerAction -{ - - private final EndPoint _peer; - - public SipShowPeerAction(final EndPoint peer) - { - this._peer = peer; - } - - @Override - public ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.SipShowPeerAction action = new org.asteriskjava.manager.action.SipShowPeerAction(); - action.setActionId(this.getActionId()); - action.setPeer(this._peer.getSimpleName()); - return action; - } - - public String toString() - { - return "SipShowPeerAction: peer=" + this._peer; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/StatusAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/StatusAction.java deleted file mode 100644 index 8a10e941c..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/StatusAction.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class StatusAction extends AbstractManagerAction implements EventGeneratingAction -{ - // used when the status of a single channel has been requested. - final private Channel _channel; - - public StatusAction() - { - this._channel = null; - } - - public StatusAction(Channel channel) - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - // channel specific request only available since 1.6 - if (pbx.getVersion().isAtLeast(AsteriskVersion.ASTERISK_1_6)) - this._channel = channel; - else - this._channel = null; - } - - public org.asteriskjava.manager.action.ManagerAction getAJAction() - { - final org.asteriskjava.manager.action.StatusAction action; - if (_channel == null) - action = new org.asteriskjava.manager.action.StatusAction(); - else - action = new org.asteriskjava.manager.action.StatusAction(_channel.getChannelName()); - - return action; - } - - @Override - public org.asteriskjava.manager.action.EventGeneratingAction getAJEventGeneratingAction() - { - final org.asteriskjava.manager.action.StatusAction action = (org.asteriskjava.manager.action.StatusAction) getAJAction(); - action.setActionId(getActionId()); - - return action; - } - - public String toString() - { - return "StatusAction"; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/UserEventAction.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/UserEventAction.java deleted file mode 100644 index 92c791f62..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/actions/UserEventAction.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.actions; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.asterisk.wrap.userEvents.UserEvent; - -abstract public class UserEventAction extends AbstractManagerAction -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(UserEventAction.class); - - private String _actionId; - - public UserEventAction(UserEvent event) - { - // NOOP - } - - public void setActionId(String actionId) - { - this._actionId = actionId; - } - - public String getActionId() - { - return this._actionId; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractChannelStateEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractChannelStateEvent.java deleted file mode 100644 index afe1f2b1b..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractChannelStateEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public abstract class AbstractChannelStateEvent extends ChannelEventHelper -{ - - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(AbstractChannelStateEvent.class); - - private final ChannelState channelState; - private final String channelStateDesc; - - AbstractChannelStateEvent(final org.asteriskjava.manager.event.AbstractChannelStateEvent event) - throws InvalidChannelName - { - super(event); - this.channelState = ChannelState.valueOfDesc(event.getChannelStateDesc()); - this.channelStateDesc = event.getChannelStateDesc(); - } - - public ChannelState getChannelState() - { - return this.channelState; - } - - public String getChannelStateDesc() - { - return this.channelStateDesc; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractMeetMeEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractMeetMeEvent.java deleted file mode 100644 index 47fa9ad86..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractMeetMeEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class AbstractMeetMeEvent extends ChannelEventHelper -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(AbstractMeetMeEvent.class); - - private final String meetMe; - private final Integer userNum; - - public AbstractMeetMeEvent(final org.asteriskjava.manager.event.AbstractMeetMeEvent event) throws InvalidChannelName - { - super(event.getChannel(), event.getUniqueId()); - this.meetMe = event.getMeetMe(); - this.userNum = event.getUser(); - } - - public String getMeetMe() - { - return this.meetMe; - } - - public Integer getUserNum() - { - return this.userNum; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractParkedCallEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractParkedCallEvent.java deleted file mode 100644 index 14442c78c..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AbstractParkedCallEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class AbstractParkedCallEvent extends ChannelEventHelper -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(AbstractParkedCallEvent.class); - - private final String exten; - private final String parkingLot; - - AbstractParkedCallEvent(final org.asteriskjava.manager.event.AbstractParkedCallEvent event) - throws InvalidChannelName - { - super(event.getParkeeChannel(), event.getUniqueId(), event.getCallerIdNum(), event.getCallerIdName()); - this.exten = event.getExten(); - this.parkingLot = event.getParkingLot(); - } - - public String getExten() - { - return this.exten; - } - - public String getParkingLot() - { - return this.parkingLot; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AgentCalledEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AgentCalledEvent.java deleted file mode 100644 index 6c3fb7370..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AgentCalledEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class AgentCalledEvent extends ChannelEventHelper -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(AgentCalledEvent.class); - - private String queue; - - private String agentInterface; - - public AgentCalledEvent(final org.asteriskjava.manager.event.AgentCalledEvent event) throws InvalidChannelName - { - super(event.getChannelCalling(), event.getUniqueId(), event.getCallerIdNum(), event.getCallerIdName()); - - agentInterface = event.getAgentCalled(); - queue = event.getQueue(); - } - - public String getQueueName() - { - return queue; - } - - public String getAgentInterface() - { - return agentInterface; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AgentConnectEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AgentConnectEvent.java deleted file mode 100644 index da6362880..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/AgentConnectEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class AgentConnectEvent extends ChannelEventHelper -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(AgentConnectEvent.class); - - private String queue; - - private String agentInterface; - - public AgentConnectEvent(final org.asteriskjava.manager.event.AgentConnectEvent event) throws InvalidChannelName - { - super(event.getChannel(), event.getUniqueId(), event.getCallerIdNum(), event.getCallerIdName()); - - agentInterface = event.getInterface(); - queue = event.getQueue(); - } - - public String getQueueName() - { - return queue; - } - - public String getAgentInterface() - { - return agentInterface; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/BridgeEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/BridgeEvent.java deleted file mode 100644 index ef5124235..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/BridgeEvent.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class BridgeEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(BridgeEvent.class); - - enum BridgeState - { - Link, Unlink - } - - private final BridgeState bridgeState; - private final Channel channel1; - private final Channel channel2; - - public BridgeEvent(final org.asteriskjava.manager.event.BridgeEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.bridgeState = BridgeState.valueOf(event.getBridgeState()); - this.channel1 = pbx.internalRegisterChannel(event.getChannel1(), event.getUniqueId1()); - this.channel2 = pbx.internalRegisterChannel(event.getChannel2(), event.getUniqueId2()); - } - - public BridgeState getBridgeState() - { - return this.bridgeState; - } - - public Channel getChannel1() - { - return this.channel1; - } - - public Channel getChannel2() - { - return this.channel2; - } - - /** - * Returns whether the two channels have been linked. - * - * @return true the two channels have been linked, - * false if they have been unlinked. - * @since 1.0.0 - */ - public boolean isLink() - { - return this.bridgeState == BridgeState.Link; - } - - /** - * Returns whether the two channels have been unlinked. - * - * @return true the two channels have been unlinked, - * false if they have been linked. - * @since 1.0.0 - */ - public boolean isUnlink() - { - return this.bridgeState == BridgeState.Unlink; - } - - public String toString() - { - return "BridgeEvent: channel1:" + this.channel1 + " channel2:" + this.channel2 + " bridgeState:" + this.bridgeState; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelEvent.java deleted file mode 100644 index f409cbd95..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelEvent.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.asteriskjava.pbx.Channel; - -public interface ChannelEvent -{ - public Channel getChannel(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelEventHelper.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelEventHelper.java deleted file mode 100644 index a65bf8695..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelEventHelper.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public abstract class ChannelEventHelper extends ManagerEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ChannelEventHelper.class); - - /** - * The name of the channel. - */ - private final Channel channel; - - protected ChannelEventHelper(final org.asteriskjava.manager.event.AbstractChannelEvent event) throws InvalidChannelName - { - this(event.getChannel(), event.getUniqueId(), event.getCallerIdNum(), event.getCallerIdName()); - } - - protected ChannelEventHelper(final String channel, final String uniqueId, final String callerIdNum, - final String callerIdName) throws InvalidChannelName - { - super(channel); // we must have a source but since don't have one pass - // anything. - this.channel = ChannelEventHelper.registerChannel(channel, uniqueId, callerIdNum, callerIdName); - } - - public ChannelEventHelper(final String channel, final String uniqueId) throws InvalidChannelName - { - super(channel);// we must have a source but since don't have one pass - // anything. - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.channel = pbx.internalRegisterChannel(channel, uniqueId); - } - - @Override - public Channel getChannel() - { - return this.channel; - } - - public static Channel registerChannel(final String channelName, final String uniqueId, final String callerIdNum, - final String callerIdName) throws InvalidChannelName - { - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - final Channel channel = pbx.internalRegisterChannel(channelName, uniqueId); - channel.setCallerId(pbx.buildCallerID(callerIdNum, callerIdName)); - return channel; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelState.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelState.java deleted file mode 100644 index 57163d544..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ChannelState.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -/** - * Holds the state of a channel as used by NewStateEvent and NewChannelEvent. - * - * @author bsutton - * - */ -public enum ChannelState -{ - Down, Rsrvd, OffHook, Dialing, Ring, Ringing, Up, Busy, DialingOffhook("Dialing Offhook"), PreRing("Pre-ring"); //$NON-NLS-1$ //$NON-NLS-2$ - - String _text; - - static ChannelState valueOfDesc(String description) - { - ChannelState theState = null; - - for (ChannelState aState : ChannelState.values()) - { - if (aState._text.compareToIgnoreCase(description) == 0) - { - theState = aState; - break; - } - } - - return theState; - - } - - ChannelState(String text) - { - this._text = text; - } - - ChannelState() - { - this._text = this.name(); - } - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConfbridgeListCompleteEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConfbridgeListCompleteEvent.java deleted file mode 100644 index a01b32ca9..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConfbridgeListCompleteEvent.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -public class ConfbridgeListCompleteEvent extends ManagerEvent -{ - - private static final long serialVersionUID = 1L; - - public ConfbridgeListCompleteEvent(org.asteriskjava.manager.event.ConfbridgeListCompleteEvent source) - { - super(source); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConfbridgeListEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConfbridgeListEvent.java deleted file mode 100644 index 5073f111b..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConfbridgeListEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -public class ConfbridgeListEvent extends ResponseEvent -{ - - private static final long serialVersionUID = 1L; - private String conference; - private String channel; - - public ConfbridgeListEvent(org.asteriskjava.manager.event.ConfbridgeListEvent source) - { - super(source); - conference = source.getConference(); - channel = source.getChannel(); - } - - public String getChannel() - { - return channel; - } - - public String getConference() - { - return conference; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConnectEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConnectEvent.java deleted file mode 100644 index 2edc4eae5..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ConnectEvent.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class ConnectEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ConnectEvent.class); - - /** - * The version of the manager protocol. - */ - private final String protocolIdentifier; - - public ConnectEvent(final org.asteriskjava.manager.event.ConnectEvent event) - { - super(event); - this.protocolIdentifier = event.getProtocolIdentifier(); - } - - public String getProtocolIdentifier() - { - return this.protocolIdentifier; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DbGetResponseEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DbGetResponseEvent.java deleted file mode 100644 index a64417197..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DbGetResponseEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class DbGetResponseEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(DbGetResponseEvent.class); - - private final String family; - private final String key; - private final String val; - - DbGetResponseEvent(final org.asteriskjava.manager.event.DbGetResponseEvent event) - { - super(event); - this.family = event.getFamily(); - this.key = event.getKey(); - this.val = event.getVal(); - } - - public String getVal() - { - return this.val; - } - - public String getFamily() - { - return this.family; - } - - public String getKey() - { - return this.key; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DialEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DialEvent.java deleted file mode 100644 index 72018b01f..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DialEvent.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class DialEvent extends ChannelEventHelper -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(DialEvent.class); - - /** - * The name of the destination channel. - */ - private final Channel destination; - - private final String dialString; - private final String dialStatus; - - public DialEvent(final org.asteriskjava.manager.event.DialEvent event) throws InvalidChannelName - { - super(event.getChannel(), event.getUniqueId(), event.getCallerIdNum(), event.getCallerIdName()); - - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - if (event.getDestination() != null) - this.destination = pbx.internalRegisterChannel(event.getDestination(), event.getDestUniqueId()); - else - this.destination = null; - - this.dialString = event.getDialString(); - this.dialStatus = event.getDialStatus(); - - } - - public Channel getDestination() - { - return this.destination; - } - - public String getDialString() - { - return this.dialString; - } - - public String getDialStatus() - { - return this.dialStatus; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DisconnectEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DisconnectEvent.java deleted file mode 100644 index cdf67b4e0..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DisconnectEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class DisconnectEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(DisconnectEvent.class); - - public DisconnectEvent(final org.asteriskjava.manager.event.DisconnectEvent event) - { - super(event); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DndStateEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DndStateEvent.java deleted file mode 100644 index e8c0df1f7..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/DndStateEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.ChannelImpl; - -public class DndStateEvent extends ManagerEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(DndStateEvent.class); - - /** - * The name of the channel. - */ - private final Channel channel; - - /** - * The DND state of the channel. - */ - private final Boolean state; - - public DndStateEvent(final org.asteriskjava.manager.event.DndStateEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - this.channel = pbx.internalRegisterChannel(event.getChannel(), ChannelImpl.UNKNOWN_UNIQUE_ID); - this.state = event.getState(); - } - - @Override - public Channel getChannel() - { - return this.channel; - } - - public Boolean getState() - { - return this.state; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ExtensionStatusEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ExtensionStatusEvent.java deleted file mode 100644 index a9e80c3fc..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ExtensionStatusEvent.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class ExtensionStatusEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ExtensionStatusEvent.class); - - enum Status - { - - /** - * No device INUSE or BUSY. - */ - NOT_INUSE(org.asteriskjava.manager.event.ExtensionStatusEvent.NOT_INUSE), - - /** - * One or more devices INUSE. - */ - INUSE(org.asteriskjava.manager.event.ExtensionStatusEvent.INUSE), - - /** - * All devices BUSY. - */ - BUSY(org.asteriskjava.manager.event.ExtensionStatusEvent.BUSY), - - /** - * All devices UNAVAILABLE/UNREGISTERED. - */ - UNAVAILABLE(org.asteriskjava.manager.event.ExtensionStatusEvent.UNAVAILABLE), - - /** - * One or more devices RINGING. - */ - RINGING(org.asteriskjava.manager.event.ExtensionStatusEvent.RINGING); - - int _status; - - Status(int status) - { - this._status = status; - } - - static Status valueOf(Integer status) - { - Status theStatus = null; - for (Status aStatus : Status.values()) - { - if (aStatus._status == status) - { - theStatus = aStatus; - break; - } - } - return theStatus; - } - } - - private final String exten; - private final String context; - private final String hint; - private final Status status; - - public ExtensionStatusEvent(final org.asteriskjava.manager.event.ExtensionStatusEvent event) - { - super(event); - this.exten = event.getExten(); - this.context = event.getContext(); - this.hint = event.getHint(); - this.status = Status.valueOf(event.getStatus()); - } - - public String getExten() - { - return this.exten; - } - - public String getContext() - { - return this.context; - } - - public String getHint() - { - return this.hint; - } - - public Status getStatus() - { - return this.status; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/HangupEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/HangupEvent.java deleted file mode 100644 index 7a6369f27..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/HangupEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class HangupEvent extends ManagerEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(HangupEvent.class); - - /** - * The name of the channel. - */ - private final Channel channel; - - private final Integer cause; - private final String causeTxt; - private final String uniqueId; - - public HangupEvent(final org.asteriskjava.manager.event.HangupEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.channel = pbx.registerHangupChannel(event.getChannel(), event.getUniqueId()); - this.cause = event.getCause(); - this.causeTxt = event.getCauseTxt(); - this.uniqueId = event.getUniqueId(); - - } - - public Integer getCause() - { - return this.cause; - } - - public String getCauseTxt() - { - return this.causeTxt; - } - - @Override - public Channel getChannel() - { - return this.channel; - } - - public String getUniqueId() - { - return this.uniqueId; - } - - public String toString() - { - return "HangupEvent: channel:" + this.channel + " cause:" + this.causeTxt; //$NON-NLS-1$//$NON-NLS-2$ - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/LinkEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/LinkEvent.java deleted file mode 100644 index 349d512a7..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/LinkEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class LinkEvent extends BridgeEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(LinkEvent.class); - - @SuppressWarnings("deprecation") - public LinkEvent(final org.asteriskjava.manager.event.LinkEvent event) throws InvalidChannelName - { - super(event); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ManagerEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ManagerEvent.java deleted file mode 100644 index fce61db8c..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ManagerEvent.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import java.util.EventObject; - -import org.apache.log4j.Logger; - -public class ManagerEvent extends EventObject -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ManagerEvent.class); - - public ManagerEvent(Object source) - { - super(source); - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MasqueradeEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MasqueradeEvent.java deleted file mode 100644 index 5b830b9ef..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MasqueradeEvent.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.ChannelImpl; - -/** - * A Masquerade is used when a new channel is created to replace an existing - * channel. The typical cause of this is an action such as a Redirect, Park etc. - * During the Redirect a new channel will be created which has the same name as - * the existing channel but with a Suffix attached such as ASYNCGOTO. The suffix - * selected will depend on the actual action that cause the masquerade. As we - * proxy all channels a key goal for us is for the existing proxy to end up - * containing the new channel. The existing channel will eventually be renamed - * with a suffix and then go on to become a zombie before it is hungup. - * The masquerade event is associated a NewEvent, three renames and one hangup - * event. The terminology used by asterisk is quite confusing. The 'original - * channel' is the channel created as a result of the action (redirect, park - * etc). The 'clone' channel is the pre-existing channel that was acted upon. - * New Event: Original - the Original channel is currently holding the active - * call due to the transfer/park.. event. - the Original name will be something - * like ASYNCGOTO/SIP/101-0000002D:1351178863.121 Masquerade Event: Clone, - * Original (e.g. SIP/101-0000002D:1351178863.121, - * ASYNCGOTO/SIP/101-0000002D:1351178863.121) - swap the guts of the two - * channels - for us this means that we swap the channels between the two parent - * proxies. Some channel information is also copied from the clone to the - * original channel (yes this terminology appears to be arse about. Remember the - * 'clone' is the pre-existing channel). Rename: Clone to Clone (e.g. - * rename the pre-existing channel SIP/101-0000002D:1351178863.121 to - * SIP/101-0000002D:1351178863.121 - start shutting down the clone - * (pre-existing channel). Rename: Original to Clone's initial name Name (e.g - * rename ASYNCGOTO/SIP/101-0000002D:1351178863.121, - * SIP/101-0000002D:1351178863.121) Rename:Clone to Clone (e.g. - * rename SIP/101-0000002D:1351178863.121 to - * SIP/101-0000002D:1351178863.121 Hangup: Clone (e.g. hangup - * SIP/101-0000002D:1351178863.121 Example sequence: RedirectAction: - * chanel=(proxy=2) SIP/101-0000002F:1351181832.124 context=njr-operator - * exten=njr-musiconhold priority=1 extraContext=null extraChannel=null - * extraExten=null Dump of LiveChannels, cause:Add: (proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181837.125 ChannelProxy: (proxy=1) - * SIP/110-0000002E:1351181832.123 ChannelProxy: (proxy=2) - * SIP/101-0000002F:1351181832.124 ChannelProxy: (proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181837.125 dispatch=NewChannelEvent: channel: - * (proxy=3) ASYNCGOTO/SIP/101-0000002F:1351181837.125 context=from-internal - * exten=null state=Up dispatch=MasqueradeEvent: originalChannel:(proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181837.125 cloned from:(proxy=2) - * SIP/101-0000002F:1351181832.124 Dump of LiveChannels, cause:Masquerade: - * (proxy=2) ASYNCGOTO/SIP/101-0000002F:1351181837.125 ChannelProxy: (proxy=1) - * SIP/110-0000002E:1351181832.123 ChannelProxy: (proxy=2) - * ASYNCGOTO/SIP/101-0000002F:1351181837.125 ChannelProxy: (proxy=3) - * SIP/101-0000002F:1351181832.124 RenameEvent: existing channel: (proxy=3) - * SIP/101-0000002F:1351181832.124 - * newname=SIP/101-0000002frawExisting:SIP/101-0000002f - * rawNewname:SIP/101-0000002frawUniquID:1351181832.124 Dump of - * LiveChannels, cause:RenameEvent: (proxy=3) - * SIP/101-0000002F:1351181832.124 ChannelProxy: (proxy=1) - * SIP/110-0000002E:1351181832.123 ChannelProxy: (proxy=2) - * ASYNCGOTO/SIP/101-0000002F:1351181837.125 ChannelProxy: (proxy=3) - * SIP/101-0000002F:1351181832.124 dispatch=RenameEvent: existing channel: - * (proxy=2) ASYNCGOTO/SIP/101-0000002F:1351181837.125 - * newname=SIP/101-0000002frawExisting:AsyncGoto/SIP/101-0000002f - * rawNewname:SIP/101-0000002frawUniquID:1351181837.125 Dump of LiveChannels, - * cause:RenameEvent: (proxy=2) SIP/101-0000002F:1351181837.125 ChannelProxy: - * (proxy=1) SIP/110-0000002E:1351181832.123 ChannelProxy: (proxy=2) - * SIP/101-0000002F:1351181837.125 ChannelProxy: (proxy=3) - * SIP/101-0000002F:1351181832.124 dispatch=RenameEvent: existing channel: - * (proxy=3) SIP/101-0000002F:1351181832.124 - * newname=AsyncGoto/SIP/101-0000002frawExisting:SIP/101-0000002f - * rawNewname:AsyncGoto/SIP/101-0000002frawUniquID:1351181832.124 Dump - * of LiveChannels, cause:RenameEvent: (proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181832.124 ChannelProxy: (proxy=1) - * SIP/110-0000002E:1351181832.123 ChannelProxy: (proxy=2) - * SIP/101-0000002F:1351181837.125 ChannelProxy: (proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181832.124 dispatch=BridgeEvent: - * channel1:(proxy=1) SIP/110-0000002E:1351181832.123 channel2:(proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181832.124 bridgeState:Unlink - * dispatch=HangupEvent: channel:(proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181832.124 cause:Normal Clearing Dump - * of LiveChannels, cause:Removing: (proxy=3) - * ASYNCGOTO/SIP/101-0000002F:1351181832.124 ChannelProxy: (proxy=1) - * SIP/110-0000002E:1351181832.123 ChannelProxy: (proxy=2) - * SIP/101-0000002F:1351181837.125 dispatch=HangupEvent: channel:(proxy=1) - * SIP/110-0000002E:1351181832.123 cause:Normal Clearing Dump of LiveChannels, - * cause:Removing: (proxy=1) SIP/110-0000002E:1351181832.123 ChannelProxy: - * (proxy=2) SIP/101-0000002F:1351181837.125 The end result is that the original - * (new) channel ends up with the clones (pre-existing) channel name. The - * pre-existing proxy ends up holding the original channel with the pre-existing - * channel's initial name. The masquerade event then is about ripping the guts - * out of the clone (pre-existing channel) and swapping with the original (new) - * channel. At the end of the swap the original (new) channel is left active (as - * it has the clones guts) and the clone (pre-existing) is inactive so we can - * hangup the clone as it is no longer needed. - * - * @author bsutton - */ -public class MasqueradeEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(MasqueradeEvent.class); - - private final Channel _original; - - private final Channel _clone; - - private ChannelState cloneState; - - private ChannelState originalState; - - public MasqueradeEvent(final org.asteriskjava.manager.event.MasqueradeEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this._original = pbx.internalRegisterChannel(event.getOriginal(), ChannelImpl.UNKNOWN_UNIQUE_ID); - this._clone = pbx.internalRegisterChannel(event.getClone(), ChannelImpl.UNKNOWN_UNIQUE_ID); - this.originalState = ChannelState.valueOf(event.getOriginalStateDesc()); - this.cloneState = ChannelState.valueOf(event.getCloneStateDesc()); - } - - /** - * Returns the original channel - * - * @return - */ - public Channel getOriginal() - { - return this._original; - } - - public Channel getClone() - { - return this._clone; - } - - public ChannelState getCloneState() - { - return this.cloneState; - } - - public ChannelState getOriginalState() - { - return this.originalState; - } - - public String toString() - { - // Even though it talks about the original channel - return "MasqueradeEvent: originalChannel(new):" + this._original + " cloned from (pre-existing):" + this._clone; //$NON-NLS-1$//$NON-NLS-2$ - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MeetMeJoinEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MeetMeJoinEvent.java deleted file mode 100644 index b49728adc..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MeetMeJoinEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; - -public class MeetMeJoinEvent extends AbstractMeetMeEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(MeetMeJoinEvent.class); - - CallerID callerID; - - public MeetMeJoinEvent(final org.asteriskjava.manager.event.MeetMeJoinEvent event) throws InvalidChannelName - { - super(event); - final PBX pbx = PBXFactory.getActivePBX(); - - pbx.buildCallerID(event.getCallerIdNum(), event.getCallerIdName()); - - } - - public CallerID getCallerID() - { - return this.callerID; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MeetMeLeaveEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MeetMeLeaveEvent.java deleted file mode 100644 index bdcdaf3b7..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/MeetMeLeaveEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; - -public class MeetMeLeaveEvent extends AbstractMeetMeEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(MeetMeLeaveEvent.class); - - private final CallerID callerID; - private final Long duration; - - public MeetMeLeaveEvent(final org.asteriskjava.manager.event.MeetMeLeaveEvent event) throws InvalidChannelName - { - super(event); - - final PBX pbx = PBXFactory.getActivePBX(); - - this.callerID = pbx.buildCallerID(event.getCallerIdNum(), event.getCallerIdName()); - this.duration = event.getDuration(); - } - - public CallerID getCallerID() - { - return this.callerID; - } - - public Long getDuration() - { - return this.duration; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewChannelEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewChannelEvent.java deleted file mode 100644 index 8147b2ee0..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewChannelEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class NewChannelEvent extends AbstractChannelStateEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(NewChannelEvent.class); - - private final String accountCode; - private final String context; - private final String exten; - - public NewChannelEvent(final org.asteriskjava.manager.event.NewChannelEvent event) throws InvalidChannelName - { - super(event); - this.accountCode = event.getAccountCode(); - this.context = event.getContext(); - this.exten = event.getExten(); - } - - public String getAccountCode() - { - return this.accountCode; - } - - public String getContext() - { - return this.context; - } - - public String getExten() - { - return this.exten; - } - - public String toString() - { - return "NewChannelEvent: channel: " + this.getChannel() + " context=" + this.context + " exten=" + this.exten + " state=" + this.getChannelStateDesc(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewExtenEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewExtenEvent.java deleted file mode 100644 index b8a3b5c0a..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewExtenEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class NewExtenEvent extends ManagerEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(NewExtenEvent.class); - - private final String context; - private final String extension; - private final String application; - private final String appData; - private final Integer priority; - private final Channel channel; - - public NewExtenEvent(final org.asteriskjava.manager.event.NewExtenEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.channel = pbx.internalRegisterChannel(event.getChannel(), event.getUniqueId()); - this.context = event.getContext(); - this.extension = event.getExtension(); - this.application = event.getApplication(); - this.appData = event.getAppData(); - this.priority = event.getPriority(); - } - - public String getContext() - { - return this.context; - } - - public String getExtension() - { - return this.extension; - } - - public String getApplication() - { - return this.application; - } - - public String getAppData() - { - return this.appData; - } - - public Integer getPriority() - { - return this.priority; - } - - @Override - public Channel getChannel() - { - return this.channel; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewStateEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewStateEvent.java deleted file mode 100644 index 65e3dab5d..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/NewStateEvent.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.internal.core.ChannelProxy; - -public class NewStateEvent extends AbstractChannelStateEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(NewStateEvent.class); - private ChannelProxy destChannel; - - public NewStateEvent(final org.asteriskjava.manager.event.NewStateEvent event) throws InvalidChannelName - { - super(event); - } - - public Channel getDestination() - { - return destChannel; - } - - public String toString() - { - return "NewStateEvent: channel:" + this.getChannel() + " channelState:" + this.getChannelState(); //$NON-NLS-1$//$NON-NLS-2$ - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/OriginateResponseEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/OriginateResponseEvent.java deleted file mode 100644 index bc9b8f3e9..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/OriginateResponseEvent.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.internal.core.ChannelImpl; - -public class OriginateResponseEvent extends ResponseEvent implements ChannelEvent -{ - - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(OriginateResponseEvent.class); - - // reflects whether we have a iChannel or an iEndPoint. We can't have both. - private final boolean isChannel; - private final Channel channel; - private final EndPoint endPoint; - private final String response; - private final String context; - private final String exten; - private final Integer reason; - - public OriginateResponseEvent(final org.asteriskjava.manager.event.OriginateResponseEvent event) - throws InvalidChannelName - { - super(event); - - PBX pbx = PBXFactory.getActivePBX(); - - // The doco says this should be a channel but under 1.4 it comes up as - // an endpoint. - this.isChannel = pbx.isChannel(event.getChannel()); - if (this.isChannel) - { - this.channel = ChannelEventHelper.registerChannel(event.getChannel(), - (event.getUniqueId() == null ? ChannelImpl.UNKNOWN_UNIQUE_ID : event.getUniqueId()), - event.getCallerIdNum(), event.getCallerIdName()); - this.endPoint = null; - } - else - { - this.endPoint = pbx.buildEndPoint(TechType.SIP, event.getChannel()); - this.channel = null; - } - - this.response = event.getResponse(); - this.context = event.getContext(); - this.exten = event.getExten(); - this.reason = event.getReason(); - - } - - public String getResponse() - { - return this.response; - } - - public String getContext() - { - return this.context; - } - - public String getExten() - { - return this.exten; - } - - public Integer getReason() - { - return this.reason; - } - - public boolean isChannel() - { - return this.isChannel; - } - - @Override - public Channel getChannel() - { - return this.channel; - } - - public EndPoint getEndPoint() - { - return this.endPoint; - } - - public boolean isSuccess() - { - return "Success".equalsIgnoreCase(this.response); //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ParkedCallEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ParkedCallEvent.java deleted file mode 100644 index 8669fcfba..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ParkedCallEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.ChannelImpl; - -public class ParkedCallEvent extends ManagerEvent -{ - - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ParkedCallEvent.class); - - private final Channel fromChannel; - private final Integer timeout; - private String exten; - - public ParkedCallEvent(final org.asteriskjava.manager.event.ParkedCallEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - if (event.getParkerDialString() != null) - this.fromChannel = pbx.internalRegisterChannel(event.getParkerDialString(), ChannelImpl.UNKNOWN_UNIQUE_ID); - else - this.fromChannel = null; - this.timeout = event.getTimeout(); - this.exten = event.getExten(); - } - - /** - * The channel that parked the call. In some circumstances this can be null. - * - * @return - */ - public Channel getFromChannel() - { - return this.fromChannel; - } - - public Integer getTimeout() - { - return this.timeout; - } - - public String getExten() - { - return this.exten; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerEntryEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerEntryEvent.java deleted file mode 100644 index 0525dd694..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerEntryEvent.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; - -public class PeerEntryEvent extends ResponseEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(PeerEntryEvent.class); - - private final EndPoint peer; - - public PeerEntryEvent(final org.asteriskjava.manager.event.PeerEntryEvent event) - { - super(event); - - PBX pbx = PBXFactory.getActivePBX(); - this.peer = pbx.buildEndPoint(TechType.valueOf(event.getChannelType()), event.getObjectName()); - } - - public EndPoint getPeer() - { - return this.peer; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerStatusEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerStatusEvent.java deleted file mode 100644 index 108f159ca..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerStatusEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class PeerStatusEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(PeerStatusEvent.class); - - private final EndPoint peer; - - public PeerStatusEvent(final org.asteriskjava.manager.event.PeerStatusEvent event) - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.peer = pbx.buildEndPoint(event.getPeer());// registerChannel(event.getPeer(), - // Channel.UNKNOWN_UNIQUE_ID); - } - - public EndPoint getPeer() - { - return this.peer; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerlistCompleteEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerlistCompleteEvent.java deleted file mode 100644 index 4d06148be..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/PeerlistCompleteEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class PeerlistCompleteEvent extends ResponseEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(PeerlistCompleteEvent.class); - - public PeerlistCompleteEvent(final org.asteriskjava.manager.event.PeerlistCompleteEvent event) - { - super(event); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/QueueCallerLeaveEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/QueueCallerLeaveEvent.java deleted file mode 100644 index 9a3138eef..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/QueueCallerLeaveEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class QueueCallerLeaveEvent extends ChannelEventHelper -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(QueueCallerLeaveEvent.class); - - private String queue; - - public QueueCallerLeaveEvent(final org.asteriskjava.manager.event.QueueCallerLeaveEvent event) throws InvalidChannelName - { - super(event.getChannel(), event.getUniqueId(), event.getCallerIdNum(), event.getCallerIdName()); - - queue = event.getQueue(); - } - - public String getQueueName() - { - return queue; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/RenameEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/RenameEvent.java deleted file mode 100644 index 925f94472..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/RenameEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.ChannelProxy; - -public class RenameEvent extends ManagerEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - private static final Logger logger = Logger.getLogger(RenameEvent.class); - - /** - * The existing channel which is about to be renamed. - */ - private final Channel _channel; - - /** - * New name of the channel after renaming occurred. - */ - private final String _newName; - - public RenameEvent(final org.asteriskjava.manager.event.RenameEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this._channel = pbx.internalRegisterChannel(event.getChannel(), event.getUniqueId()); - this._newName = event.getNewname(); - - String uniqueId = ((ChannelProxy) this._channel).getRealChannel().getUniqueId(); - logger.error("Renaming :" + uniqueId + " " + event.getUniqueId()); - - assert uniqueId.equalsIgnoreCase("-1") - || uniqueId.compareToIgnoreCase(event.getUniqueId()) == 0 : "Rename registered against incorrect channel"; //$NON-NLS-1$ - - } - - @Override - public final Channel getChannel() - { - return this._channel; - } - - public final String getNewName() - { - return this._newName; - } - - @Override - public String toString() - { - org.asteriskjava.manager.event.RenameEvent rawEvent = (org.asteriskjava.manager.event.RenameEvent) getSource(); - return "RenameEvent: existing channel: " + this._channel + " newname=" + this._newName //$NON-NLS-1$ //$NON-NLS-2$ - + "rawExisting:" + rawEvent.getChannel() + " rawNewname:" + rawEvent.getNewname() //$NON-NLS-1$ //$NON-NLS-2$ - + "rawUniquID:" + rawEvent.getUniqueId(); //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ResponseEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ResponseEvent.java deleted file mode 100644 index 0bc9464f3..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ResponseEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class ResponseEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ResponseEvent.class); - - private final String actionId; - private final String internalActionId; - - public ResponseEvent(final org.asteriskjava.manager.event.ResponseEvent event) - { - super(event); - this.actionId = event.getActionId(); - this.internalActionId = event.getInternalActionId(); - } - - public String getActionId() - { - return this.actionId; - } - - public String getInternalActionId() - { - return this.internalActionId; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ResponseEvents.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ResponseEvents.java deleted file mode 100644 index ba6c3dfcc..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/ResponseEvents.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import java.util.ArrayList; -import java.util.Collection; - -public class ResponseEvents -{ - - ArrayList events = new ArrayList<>(); - - /** - * Returns a Collection of ManagerEvents that have been received including - * the last one that indicates completion. - * - * @return a Collection of ManagerEvents received. - */ - public Collection getEvents() - { - return this.events; - } - - public void add(ResponseEvent event) - { - this.events.add(event); - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/StatusCompleteEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/StatusCompleteEvent.java deleted file mode 100644 index 5d81c3747..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/StatusCompleteEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; - -public class StatusCompleteEvent extends ResponseEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(StatusCompleteEvent.class); - - public StatusCompleteEvent(final org.asteriskjava.manager.event.StatusCompleteEvent event) - { - super(event); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/StatusEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/StatusEvent.java deleted file mode 100644 index 3c621b250..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/StatusEvent.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import java.util.Map; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.DialPlanExtension; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class StatusEvent extends ResponseEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(StatusEvent.class); - - private final Channel channel; - private final CallerID callerId; - private final String accountCode; - private final ChannelState channelState; - private final String channelStateDesc; - private final String context; - private final DialPlanExtension extension; - private final Integer priority; - private final Integer seconds; - private final Channel bridgedChannel; - private final Map variables; - private final String uniqueId; - - public StatusEvent(final org.asteriskjava.manager.event.StatusEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.channel = pbx.internalRegisterChannel(event.getChannel(), event.getUniqueId()); - this.callerId = pbx.buildCallerID(event.getCallerIdNum(), event.getCallerIdName()); - this.accountCode = event.getAccountCode(); - this.channelState = ChannelState.valueOfDesc(event.getChannelStateDesc()); - this.channelStateDesc = event.getChannelStateDesc(); - this.context = event.getContext(); - this.extension = pbx.buildDialPlanExtension(event.getExtension()); - this.priority = event.getPriority(); - this.seconds = event.getSeconds(); - if (event.getBridgedChannel() != null) - this.bridgedChannel = pbx.internalRegisterChannel(event.getBridgedChannel(), event.getBridgedUniqueId()); - else - this.bridgedChannel = null; - this.variables = event.getVariables(); - this.uniqueId = event.getUniqueId(); - } - - @Override - public final Channel getChannel() - { - return this.channel; - } - - public final CallerID getCallerId() - { - return this.callerId; - } - - public final String getAccountCode() - { - return this.accountCode; - } - - public final ChannelState getState() - { - return this.channelState; - } - - public final String getChannelStateDesc() - { - return this.channelStateDesc; - } - - public final String getContext() - { - return this.context; - } - - public final DialPlanExtension getExtension() - { - return this.extension; - } - - public final Integer getPriority() - { - return this.priority; - } - - public final Integer getSeconds() - { - return this.seconds; - } - - public final Channel getBridgedChannel() - { - return this.bridgedChannel; - } - - public final Map getVariables() - { - return this.variables; - } - - public String getUniqueId() - { - return this.uniqueId; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/UnlinkEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/UnlinkEvent.java deleted file mode 100644 index 7b7efb890..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/UnlinkEvent.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.InvalidChannelName; - -public class UnlinkEvent extends BridgeEvent -{ - private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(UnlinkEvent.class); - - @SuppressWarnings("deprecation") - public UnlinkEvent(final org.asteriskjava.manager.event.UnlinkEvent event) throws InvalidChannelName - { - super(event); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/UnparkedCallEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/UnparkedCallEvent.java deleted file mode 100644 index 2837ca2b0..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/UnparkedCallEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.ChannelImpl; - -public class UnparkedCallEvent extends AbstractParkedCallEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(UnparkedCallEvent.class); - - private final Channel fromChannel; - - public UnparkedCallEvent(final org.asteriskjava.manager.event.UnparkedCallEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this.fromChannel = pbx.internalRegisterChannel(event.getParkerDialString(), ChannelImpl.UNKNOWN_UNIQUE_ID); - } - - public Channel getFromChannel() - { - return this.fromChannel; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/VarSetEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/VarSetEvent.java deleted file mode 100644 index c743d7dad..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/events/VarSetEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.events; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class VarSetEvent extends ManagerEvent implements ChannelEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(VarSetEvent.class); - - /** - * The name of the channel. - */ - private final Channel _channel; - - private String _variableName; - - private String _variableValue; - - public VarSetEvent(final org.asteriskjava.manager.event.VarSetEvent event) throws InvalidChannelName - { - super(event); - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - this._channel = pbx.internalRegisterChannel(event.getChannel(), event.getUniqueId()); - this._variableName = event.getVariable(); - this._variableValue = event.getValue(); - } - - @Override - public Channel getChannel() - { - return this._channel; - } - - public String getVariableName() - { - return this._variableName; - } - - public String getVariableValue() - { - return this._variableValue; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/CommandResponse.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/CommandResponse.java deleted file mode 100644 index dde7a33fd..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/CommandResponse.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.response; - -import java.util.List; - -import org.apache.log4j.Logger; - -public class CommandResponse extends ManagerResponse -{ - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CommandResponse.class); - private List result; - - public CommandResponse(org.asteriskjava.manager.response.CommandResponse response) - { - super(response); - this.result = response.getResult(); - - } - - public List getResult() - { - return this.result; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/ManagerError.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/ManagerError.java deleted file mode 100644 index 397b42c63..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/ManagerError.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.response; - -import org.apache.log4j.Logger; - -public class ManagerError extends ManagerResponse -{ - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(ManagerError.class); - - public ManagerError(org.asteriskjava.manager.response.ManagerError error) - { - super(error); - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/ManagerResponse.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/ManagerResponse.java deleted file mode 100644 index 545f61b31..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/response/ManagerResponse.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.response; - -import java.util.Date; -import java.util.Locale; -import java.util.Map; - -public class ManagerResponse -{ - - private Date _dateReceived; - private String _actionId; - - /** - * The server from which this response has been received (only used with - * AstManProxy). - */ - final private String _server; - final private String _response; - final private String _eventList; - final private String message; - final private String _uniqueId; - final private Map _attributes; - - public ManagerResponse(org.asteriskjava.manager.response.ManagerResponse response) - { - this._dateReceived = response.getDateReceived(); - this._actionId = response.getActionId(); - this._server = response.getServer(); - this._response = response.getResponse(); - this._eventList = response.getEventList(); - this._uniqueId = response.getUniqueId(); - this._attributes = response.getAttributes(); - this.message = response.getMessage(); - } - - public Date getDateReceived() - { - return this._dateReceived; - } - - public String getActionId() - { - return this._actionId; - } - - public String getServer() - { - return this._server; - } - - public String getResponse() - { - return this._response; - } - - public String getEventList() - { - return this._eventList; - } - - public String getMessage() - { - return this.message; - } - - public String getUniqueId() - { - return this._uniqueId; - } - - public Map getAttributes() - { - return this._attributes; - } - - public String getAttribute(String key) - { - return (String) this._attributes.get(key.toLowerCase(Locale.ENGLISH)); - } - - public boolean isSuccess() - { - return this._response.compareToIgnoreCase("Success") == 0; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/userEvents/UserEvent.java b/src/main/java/org/asteriskjava/pbx/asterisk/wrap/userEvents/UserEvent.java deleted file mode 100644 index 2d67875af..000000000 --- a/src/main/java/org/asteriskjava/pbx/asterisk/wrap/userEvents/UserEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.asteriskjava.pbx.asterisk.wrap.userEvents; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class UserEvent extends ManagerEvent -{ - private static final long serialVersionUID = 1L; - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(UserEvent.class); - - private Channel channel; - - public UserEvent(org.asteriskjava.manager.event.UserEvent source, Channel channel) - { - super(source); - this.channel = channel; - } - - public UserEvent(org.asteriskjava.manager.event.UserEvent event) throws InvalidChannelName - { - super(event); - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - this.channel = pbx.internalRegisterChannel(event.getChannel(), event.getUniqueId()); - } - - public Channel getChannel() - { - return this.channel; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/ActivityHelper.java b/src/main/java/org/asteriskjava/pbx/internal/activity/ActivityHelper.java deleted file mode 100644 index 330cd7cdd..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/ActivityHelper.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.ActivityStatusEnum; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.SetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.managerAPI.EventListenerBaseClass; - -public abstract class ActivityHelper implements Runnable, Activity -{ - static private Logger logger = Logger.getLogger(ActivityHelper.class); - - /** - * If the activity fails due to an exception then lastException will contain - * the final exception that was thrown. - */ - private PBXException lastException; - - /** - * Set to true once the activity succeeds. - */ - private volatile boolean _success = false; - - private final ActivityCallback callback; - - private final String activityName; - - private boolean _sendEvents; - - Exception callSite = new Exception("Invoked from here"); - - public ActivityHelper(final String activityName, final ActivityCallback callback) - { - - this.callback = callback; - this.activityName = activityName; - } - - private AutoCloseable getManagerListener() - { - if (!_sendEvents) - { - return new AutoCloseable() - { - - @Override - public void close() throws Exception - { - // do nothing, we never started anything - } - }; - } - EventListenerBaseClass listener = new EventListenerBaseClass(activityName) - { - - @Override - public Set> requiredEvents() - { - return ActivityHelper.this.requiredEvents(); - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - ActivityHelper.this.onManagerEvent(event); - - } - - @Override - public ListenerPriority getPriority() - { - return ActivityHelper.this.getPriority(); - } - }; - listener.startListener(PBXFactory.getActivePBX()); - return listener; - - } - - @SuppressWarnings("unchecked") - public void startActivity(final boolean sendEvents) - { - this._sendEvents = sendEvents; - if (this.callback != null) - { - this.callback.progress((T) this, ActivityStatusEnum.START, ActivityStatusEnum.START.getDefaultMessage()); - } - - final Thread thread = new Thread(this, this.activityName); - thread.setDaemon(true); - thread.start(); - - } - - @Override - @SuppressWarnings("unchecked") - public void run() - { - try (AutoCloseable closer = getManagerListener()) - { - this._success = this.doActivity(); - } - catch (final PBXException e) - { - this.lastException = e; - ActivityHelper.logger.error(e, e); - logger.error(callSite, callSite); - } - catch (final Throwable e) - { - this.lastException = new PBXException(e); - ActivityHelper.logger.error(callSite, callSite); - logger.error(e, e); - } - finally - { - if (this.callback != null) - { - if (this._success) - { - this.callback.progress((T) this, ActivityStatusEnum.SUCCESS, - ActivityStatusEnum.SUCCESS.getDefaultMessage()); - } - else - { - // This went badly so make certain we hang everything up - this.callback.progress((T) this, ActivityStatusEnum.FAILURE, - ActivityStatusEnum.FAILURE.getDefaultMessage()); - } - } - } - - } - - abstract protected boolean doActivity() throws PBXException; - - /* - * Attempt to set a variable on the channel to see if it's up. - * @param channel the channel which is to be tested. - */ - public boolean validateChannel(final Channel channel) - { - - boolean ret = false; - final SetVarAction var = new SetVarAction(channel, "testState", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - - ManagerResponse response = null; - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - response = pbx.sendAction(var, 500); - } - catch (final Exception e) - { - ActivityHelper.logger.debug(e, e); - ActivityHelper.logger.error("getVariable: " + e); //$NON-NLS-1$ - } - if ((response != null) && (response.getAttribute("Response").compareToIgnoreCase("success") == 0)) //$NON-NLS-1$ //$NON-NLS-2$ - { - ret = true; - } - - return ret; - - } - - @Override - public boolean isSuccess() - { - return this._success; - } - - protected void setLastException(final PBXException e) - { - this.lastException = e; - } - - @Override - public Throwable getLastException() - { - return this.lastException; - } - - public void progess(final T activity, final String message) - { - this.callback.progress(activity, ActivityStatusEnum.PROGRESS, message); - - } - - abstract HashSet> requiredEvents(); - - abstract void onManagerEvent(final ManagerEvent event); - - abstract public ListenerPriority getPriority(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/BlindTransferActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/BlindTransferActivityImpl.java deleted file mode 100644 index 350d5ca3b..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/BlindTransferActivityImpl.java +++ /dev/null @@ -1,307 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.Call.OperandChannel; -import org.asteriskjava.pbx.CallDirection; -import org.asteriskjava.pbx.CallImpl; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.activities.BlindTransferActivity; -import org.asteriskjava.pbx.agi.AgiChannelActivityBlindTransfer; -import org.asteriskjava.pbx.asterisk.wrap.events.BridgeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.DialEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.LinkEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.UnlinkEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -/** - * The BlindTransferActivity is used by the AsteriksPBX to transfer a live - * channel to an endpoint that may need to be dialed. - * - * @author bsutton - */ -public class BlindTransferActivityImpl extends ActivityHelper implements BlindTransferActivity -{ - static Logger logger = Logger.getLogger(BlindTransferActivityImpl.class); - - private Call _call; - - private Call.OperandChannel _channelToTransfer; - - private EndPoint _transferTarget; - - private CallerID _toCallerID; - - private boolean _autoAnswer; - - private CountDownLatch _latch; - - private CompletionCause _completionCause; - - private long _timeout; - - /** - * The new channel that was originated for the transferTarget endpoint. - */ - private Channel _transferTargetChannel; - - private CallImpl _newCall; - - private Channel dialedChannel; - - final Channel actualChannelToTransfer; - - /** - * Blind transfers a live channel to a given endpoint which may need to be - * dialed. When we dial the endpoint we display the 'toCallerID'. - * - * @param channelToTransfer The channel which is being transfered - * @param transferTarget The target to transfer (connect) the channel to. - * @param toCallerID The caller id to display on the target endpoint. - * @param timeout The time to wait (in seconds) for the activity to - * complete. - * @param listener - */ - public BlindTransferActivityImpl(Call call, final Call.OperandChannel channelToTransfer, final EndPoint transferTarget, - final CallerID toCallerID, boolean autoAnswer, long timeout, - final ActivityCallback listener) - { - super("BlindTransferActivity", listener); //$NON-NLS-1$ - - this._call = call; - this._channelToTransfer = channelToTransfer; - this._transferTarget = transferTarget; - this._toCallerID = toCallerID; - this._autoAnswer = autoAnswer; - this._timeout = timeout; - - actualChannelToTransfer = _call.getOperandChannel(this._channelToTransfer); - - this.startActivity(true); - } - - public BlindTransferActivityImpl(Channel agentChannel, EndPoint transferTarget, CallerID toCallerID, boolean autoAnswer, - int timeout, ActivityCallback iCallback) throws PBXException - { - super("BlindTransferActivity", iCallback); //$NON-NLS-1$ - - this._transferTarget = transferTarget; - this._toCallerID = toCallerID; - this._autoAnswer = autoAnswer; - this._timeout = timeout; - actualChannelToTransfer = agentChannel; - _channelToTransfer = OperandChannel.ORIGINATING_PARTY; - this._call = new CallImpl(agentChannel, CallDirection.OUTBOUND); - this.startActivity(true); - - } - - @Override - public boolean doActivity() throws PBXException - { - - boolean success = false; - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - /* - * initiate a blind transfer of the call , to the specified destination. - * when a link event occurs this call will be removed from the active - * call list. - */ - try - { - - logger.info("*******************************************************************************"); //$NON-NLS-1$ - logger.info("*********** begin blind transfer ****************"); //$NON-NLS-1$ - logger.info("*********** " + this._channelToTransfer //$NON-NLS-1$ - + " ****************"); //$NON-NLS-1$ - logger.info("*********** " + this._transferTarget //$NON-NLS-1$ - + " ****************"); //$NON-NLS-1$ - logger.info("*********** " + this._toCallerID + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - logger.info("*******************************************************************************"); //$NON-NLS-1$ - - if (!pbx.moveChannelToAgi(actualChannelToTransfer)) - { - throw new PBXException("Channel: " + this._channelToTransfer + " couldn't be moved to agi"); - } - - if (!pbx.waitForChannelToQuiescent(actualChannelToTransfer, 3000)) - throw new PBXException( - "Channel: " + this._channelToTransfer + " cannot be transfered as it is still in transition."); - - // Set or clear the auto answer header. - // Clearing is important as it may have been set during the - // initial answer sequence. If we don't clear it then then transfer - // target will be auto-answered, which is fun but bad. - String sipHeader = null; - if (this._autoAnswer) - { - sipHeader = PBXFactory.getActiveProfile().getAutoAnswer(); - } - actualChannelToTransfer.setCurrentActivityAction( - new AgiChannelActivityBlindTransfer(this._transferTarget.getFullyQualifiedName(), sipHeader)); - - // TODO: At one point we were adding the /n option to the end of the - // channel to get around - // secondary transfer options. Need to review if this is still - // required. - // TODO control the caller id. - this._latch = new CountDownLatch(1); - - success = this._latch.await(this._timeout, TimeUnit.SECONDS); - if (!success) - { - this._completionCause = CompletionCause.TIMEOUT; - } - else if (_completionCause == CompletionCause.CANCELLED) - { - pbx.hangup(dialedChannel); - } - - else - { - Call call = ((CallImpl) _call).split(actualChannelToTransfer); - Call rhsCall = new CallImpl(_transferTargetChannel, CallDirection.OUTBOUND); - try - { - _newCall = ((CallImpl) call).join(OperandChannel.ORIGINATING_PARTY, rhsCall, - OperandChannel.ORIGINATING_PARTY, CallDirection.OUTBOUND); - } - catch (Exception e) - { - logger.error("New call doesn't seem to exist!?"); - } - } - } - catch (final Exception e) - { - logger.error("error occurred in blindtransfer", e); //$NON-NLS-1$ - this.setLastException(new PBXException(e)); - } - - return this._completionCause == CompletionCause.BRIDGED; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(BridgeEvent.class); - required.add(LinkEvent.class); - required.add(UnlinkEvent.class); - required.add(HangupEvent.class); - required.add(DialEvent.class); - return required; - } - - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - if (event instanceof BridgeEvent) - { - BridgeEvent bridge = (BridgeEvent) event; - if (bridge.isLink()) - { - if (bridge.getChannel1().isSame(_call.getOperandChannel(this._channelToTransfer))) - { - this._completionCause = CompletionCause.BRIDGED; - this._transferTargetChannel = bridge.getChannel2(); - this._latch.countDown(); - } - else if (bridge.getChannel2().isSame(_call.getOperandChannel(this._channelToTransfer))) - { - this._completionCause = CompletionCause.BRIDGED; - this._transferTargetChannel = bridge.getChannel1(); - this._latch.countDown(); - } - } - } - else if (event instanceof HangupEvent) - { - HangupEvent hangup = (HangupEvent) event; - if (hangup.getChannel().isSame(_call.getOperandChannel(this._channelToTransfer))) - { - this._completionCause = CompletionCause.HANGUP; - this._latch.countDown(); - } - if (hangup.getChannel().isSame(dialedChannel)) - { - this._completionCause = CompletionCause.HANGUP; - this._latch.countDown(); - } - } - else if (event instanceof DialEvent) - { - if (((DialEvent) event).getChannel().isSame(_call.getOperandChannel(_channelToTransfer))) - { - DialEvent de = (DialEvent) event; - dialedChannel = de.getDestination(); - } - } - - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public CompletionCause getCompletionCause() - { - return this._completionCause; - } - - /** - * cancels the BlindTransfer. - */ - @Override - public void cancel() - { - this._completionCause = CompletionCause.CANCELLED; - this._latch.countDown(); - } - - @Override - public Channel getChannelToTransfer() - { - return _call.getOperandChannel(this._channelToTransfer); - } - - @Override - public CallerID getTransferTargetCallerID() - { - return this._toCallerID; - } - - @Override - public EndPoint getTransferTarget() - { - return this._transferTarget; - } - - @Override - public Channel getTransferTargetChannel() - { - return this._transferTargetChannel; - } - - @Override - public Call getNewCall() throws PBXException - { - return _newCall; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/BridgeActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/BridgeActivityImpl.java deleted file mode 100644 index 6cde4e49d..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/BridgeActivityImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.activities.BridgeActivity; -import org.asteriskjava.pbx.agi.AgiChannelActivityBridge; -import org.asteriskjava.pbx.agi.AgiChannelActivityHoldForBridge; -import org.asteriskjava.pbx.asterisk.wrap.events.BridgeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusCompleteEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusEvent; -import org.asteriskjava.pbx.internal.asterisk.MeetmeRoom; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.managerAPI.RedirectToMeetMe; - -public class BridgeActivityImpl extends ActivityHelper implements BridgeActivity -{ - static Logger logger = Logger.getLogger(BridgeActivityImpl.class); - private final Channel _lhsChannel; - private final Channel _rhsChannel; - - private CountDownLatch _bridgeLatch; - - public BridgeActivityImpl(final Channel lhsChannel, final Channel rhsChannel, - final ActivityCallback callback) - { - super("Bridge", callback); //$NON-NLS-1$ - - this._lhsChannel = lhsChannel; - this._rhsChannel = rhsChannel; - this.startActivity(true); - } - - @Override - public boolean doActivity() throws PBXException - { - boolean success = false; - - BridgeActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - BridgeActivityImpl.logger.info("*********** begin Bridge ****************"); //$NON-NLS-1$ - BridgeActivityImpl.logger.info("*********** lhs:" + this._lhsChannel + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - BridgeActivityImpl.logger.info("*********** rhs:" + this._rhsChannel + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - BridgeActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - try - { - - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - if (!pbx.moveChannelToAgi(_lhsChannel)) - { - throw new PBXException("Channel: " + _lhsChannel + " couldn't be moved to agi"); - } - if (!pbx.moveChannelToAgi(_rhsChannel)) - { - throw new PBXException("Channel: " + _rhsChannel + " couldn't be moved to agi"); - } - - List channels = new LinkedList<>(); - channels.add(this._lhsChannel); - channels.add(_rhsChannel); - if (!pbx.waitForChannelsToQuiescent(channels, 3000)) - throw new PBXException( - "Channel: " + this._lhsChannel + " cannot be held as it is still in transition."); - try - { - if (pbx.isBridgeSupported()) - { - - this._bridgeLatch = new CountDownLatch(1); - final AgiChannelActivityBridge action = new AgiChannelActivityBridge(_lhsChannel); - _lhsChannel.setCurrentActivityAction(new AgiChannelActivityHoldForBridge(action)); - _rhsChannel.setCurrentActivityAction(action); - - // now wait for the bridge event to arrive. - success = this._bridgeLatch.await(3, TimeUnit.SECONDS); - - } - else if (pbx.isMeetmeInstalled()) - { - // As bridge isn't supported we need to do the bridge using - // a - // meetme - // room - - final RedirectToMeetMe meetmeTransfer = new RedirectToMeetMe(); - // meetme room is empty - // find a new available room. - MeetmeRoom room = pbx.acquireMeetmeRoom(); - - // redirect the lhs to meetme - meetmeTransfer.redirectToMeetme(_lhsChannel, room.getRoomNumber(), true); - - // redirect destination this is not the marked call - // as we want this to be hung up if no other calls are left - // in - // this - // room - final boolean markedCall = !_rhsChannel.canDetectHangup(); - meetmeTransfer.redirectToMeetme(_rhsChannel, room.getRoomNumber(), markedCall); - - // TODO put some logic to check that the meetme actually - // completes. - success = true; - - } - else - throw new PBXException( - "Cannot bridge two calls as neither the BridgeAction nor Meetme is available"); //$NON-NLS-1$ - } - catch (IllegalArgumentException | IllegalStateException | InterruptedException e) - { - throw new PBXException(e); - } - - } - catch (IllegalArgumentException | IllegalStateException e) - { - BridgeActivityImpl.logger.error(e, e); - BridgeActivityImpl.logger.error(e, e); - throw new PBXException(e); - } - return success; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - required.add(StatusCompleteEvent.class); - required.add(StatusEvent.class); - required.add(BridgeEvent.class); - return required; - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - - if (event instanceof BridgeEvent) - { - BridgeEvent bridge = (BridgeEvent) event; - if (bridge.isLink() - && (bridge.getChannel1().isSame(this._lhsChannel) || bridge.getChannel1().isSame(this._rhsChannel)) - && (bridge.getChannel2().isSame(this._lhsChannel) || bridge.getChannel2().isSame(this._rhsChannel))) - this._bridgeLatch.countDown(); - } - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/DialActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/DialActivityImpl.java deleted file mode 100644 index ef1e46a51..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/DialActivityImpl.java +++ /dev/null @@ -1,268 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallDirection; -import org.asteriskjava.pbx.CallImpl; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.NewChannelListener; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.activities.DialActivity; -import org.asteriskjava.pbx.asterisk.wrap.actions.SetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.managerAPI.Dial; -import org.asteriskjava.pbx.internal.managerAPI.OriginateResult; - -public class DialActivityImpl extends ActivityHelper implements DialActivity, NewChannelListener -{ - static Logger logger = Logger.getLogger(DialActivityImpl.class); - - private final boolean hideToCallerId; - - private boolean cancelledByOperator; - - private final EndPoint _originating; - - /** - * Once the 'from' channel has been brought up this is set. - */ - private Channel originatingChannel; - - private final EndPoint _accepting; - - private final CallerID toCallerID; - - /** - * Once the 'to' channel has been brought up this is set. - */ - private Channel acceptingChannel; - - private CallImpl newCall; - - private Map channelVarsToSet; - - public DialActivityImpl(final EndPoint originating, final EndPoint accepting, final CallerID toCallerID, - final boolean hideToCallerID, final ActivityCallback listener, - Map channelVarsToSet) - { - super("Dial", listener); //$NON-NLS-1$ - this._originating = originating; - this._accepting = accepting; - this.toCallerID = toCallerID; - this.hideToCallerId = hideToCallerID; - this.cancelledByOperator = false; - this.channelVarsToSet = channelVarsToSet; - - this.startActivity(false); - } - - @Override - public boolean doActivity() throws PBXException - { - boolean success = false; - - try (Dial nr = new Dial(this.toCallerID.toString())) - { - DialActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - DialActivityImpl.logger.info("*********** begin dial out ****************"); //$NON-NLS-1$ - DialActivityImpl.logger.info("*********** " + this._accepting //$NON-NLS-1$ - + " ****************"); //$NON-NLS-1$ - DialActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - final OriginateResult[] resultChannels = nr.dial(this, this._originating, this._accepting, - profile.getManagementContext(), this.toCallerID, this.hideToCallerId, channelVarsToSet); - - if ((resultChannels[0] == null) || (resultChannels[1] == null)) - { - // the dial failed - - // so notify the operator. - // Unless the operated cancelled the call - if (!this.cancelledByOperator) - { - this.setLastException(new PBXException(("OperatorEndedCall")));//$NON-NLS-1$ - DialActivityImpl.logger.error("dialout to " + this._accepting.getFullyQualifiedName() + " failed."); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - else - { - // Dial succeeded. - - // - get new channel name from result - this.originatingChannel = resultChannels[0].getChannel(); - this.acceptingChannel = resultChannels[1].getChannel(); - - newCall = new CallImpl(originatingChannel, acceptingChannel, CallDirection.OUTBOUND); - - DialActivityImpl.logger.debug("dialout succeeded: dest channel is :" + this.acceptingChannel); //$NON-NLS-1$ - - if (this.validateChannel(this.acceptingChannel) == false) - { - this.setLastException(new PBXException(("dialed extension hungup unexpectedly")));//$NON-NLS-1$ - DialActivityImpl.logger.error("dialed extension hungup unexpectedly"); //$NON-NLS-1$ - } - else - { - success = true; - } - } - } - finally - { - if (success != true) - { - this.hangup(); - } - } - return success; - } - - private void hangup() - { - try - { - final PBX pbx = PBXFactory.getActivePBX(); - if (this.acceptingChannel != null) - { - pbx.hangup(this.acceptingChannel); - } - if (this.originatingChannel != null) - { - pbx.hangup(this.originatingChannel); - } - } - catch (final Exception e) - { - DialActivityImpl.logger.error(e, e); - } - } - - /** - * Called to cancels the dial before it fully comes up. The caller must also - * hangup the associated channels. - */ - @Override - public void markCancelled() - { - this.cancelledByOperator = true; - } - - @Override - public Channel getOriginatingChannel() - { - return this.originatingChannel; - } - - @Override - public Channel getAcceptingChannel() - { - return this.acceptingChannel; - } - - @Override - public EndPoint getOriginatingEndPoint() - { - return this._originating; - } - - @Override - public EndPoint getAcceptingEndPoint() - { - return this._accepting; - } - - @Override - public void channelUpdate(final Channel channel) - { - if (channel.sameEndPoint(this._accepting)) - { - this.acceptingChannel = channel; - } - - if (channel.sameEndPoint(this._originating)) - { - this.originatingChannel = channel; - } - - super.progess(this, "Channel for " + channel.getEndPoint().getSIPSimpleName() + " is now up."); //$NON-NLS-1$ //$NON-NLS-2$ - - } - - /* - * Attempt to set a variable on the channel to see if it's up. - * @param channel the channel which is to be tested. - */ - @Override - public boolean validateChannel(final Channel channel) - { - - boolean ret = false; - final SetVarAction var = new SetVarAction(channel, "testState", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - - ManagerResponse response = null; - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - response = pbx.sendAction(var, 500); - } - catch (final Exception e) - { - DialActivityImpl.logger.debug(e, e); - DialActivityImpl.logger.error("getVariable: " + e); //$NON-NLS-1$ - } - if ((response != null) && (response.getAttribute("Response").compareToIgnoreCase("success") == 0)) //$NON-NLS-1$ //$NON-NLS-2$ - { - ret = true; - } - - return ret; - - } - - @Override - public boolean cancelledByOperator() - { - return this.cancelledByOperator; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - // no required. - return required; - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - // NOOP - } - - @Override - public Call getNewCall() - { - return newCall; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/DialToAgiActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/DialToAgiActivityImpl.java deleted file mode 100644 index 48ee786f9..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/DialToAgiActivityImpl.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.NewChannelListener; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.activities.DialToAgiActivity; -import org.asteriskjava.pbx.asterisk.wrap.actions.SetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.managerAPI.DialToAgi; -import org.asteriskjava.pbx.internal.managerAPI.OriginateResult; - -public class DialToAgiActivityImpl extends ActivityHelper implements DialToAgiActivity, NewChannelListener -{ - static Logger logger = Logger.getLogger(DialToAgiActivityImpl.class); - - private final boolean hideToCallerId; - - private boolean cancelledByOperator; - - private final EndPoint _originating; - - /** - * Once the 'from' channel has been brought up this is set. - */ - private Channel originatingChannel; - - private final CallerID toCallerID; - - private Map channelVarsToSet; - - private AgiChannelActivityAction action; - - public DialToAgiActivityImpl(final EndPoint originating, final CallerID toCallerID, final boolean hideToCallerID, - final ActivityCallback listener, Map channelVarsToSet, - AgiChannelActivityAction action) - { - super("Dial", listener); //$NON-NLS-1$ - - this.action = action; - this._originating = originating; - this.toCallerID = toCallerID; - this.hideToCallerId = hideToCallerID; - this.cancelledByOperator = false; - this.channelVarsToSet = channelVarsToSet; - - this.startActivity(false); - } - - @Override - public boolean doActivity() throws PBXException - { - boolean success = false; - - try (DialToAgi nr = new DialToAgi(this.toCallerID.toString())) - { - DialToAgiActivityImpl.logger.info("**************************************************************************"); - DialToAgiActivityImpl.logger.info("*********** begin dial out ***********"); - DialToAgiActivityImpl.logger.info("*********** to agi ***********"); - DialToAgiActivityImpl.logger.info("**************************************************************************"); - - final OriginateResult[] resultChannels = nr.dial(this, this._originating, this.action, this.toCallerID, - this.hideToCallerId, channelVarsToSet); - - if (resultChannels[0] == null || !resultChannels[0].isSuccess()) - { - // the dial failed - - // so notify the operator. - // Unless the operated cancelled the call - if (!this.cancelledByOperator) - { - this.setLastException(new PBXException(("OperatorEndedCall"))); - logger.error("dialout to failed."); - } - } - else - { - // Dial succeeded. - - // - get new channel name from result - this.originatingChannel = resultChannels[0].getChannel(); - - DialToAgiActivityImpl.logger.debug("dialout succeeded"); - - success = true; - - } - } - catch (InterruptedException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - finally - { - if (success != true) - { - this.hangup(); - } - } - return success; - } - - private void hangup() - { - try - { - final PBX pbx = PBXFactory.getActivePBX(); - - if (this.originatingChannel != null) - { - pbx.hangup(this.originatingChannel); - } - } - catch (final Exception e) - { - DialToAgiActivityImpl.logger.error(e, e); - } - } - - /** - * Called if the user cancels the call after starting it. The caller must - * also hangup the trc channel. - */ - @Override - public void markCancelled() - { - this.cancelledByOperator = true; - } - - @Override - public Channel getOriginatingChannel() - { - return this.originatingChannel; - } - - @Override - public EndPoint getOriginatingEndPoint() - { - return this._originating; - } - - @Override - public void channelUpdate(final Channel channel) - { - - if (channel.sameEndPoint(this._originating)) - { - this.originatingChannel = channel; - } - - super.progess(this, "Channel for " + channel.getEndPoint().getSIPSimpleName() + " is now up."); //$NON-NLS-1$ //$NON-NLS-2$ - - } - - /* - * Attempt to set a variable on the channel to see if it's up. - * @param channel the channel which is to be tested. - */ - @Override - public boolean validateChannel(final Channel channel) - { - - boolean ret = false; - final SetVarAction var = new SetVarAction(channel, "testState", "1"); //$NON-NLS-1$ //$NON-NLS-2$ - - ManagerResponse response = null; - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - response = pbx.sendAction(var, 500); - } - catch (final Exception e) - { - DialToAgiActivityImpl.logger.debug(e, e); - DialToAgiActivityImpl.logger.error("getVariable: " + e); //$NON-NLS-1$ - } - if ((response != null) && (response.getAttribute("Response").compareToIgnoreCase("success") == 0)) //$NON-NLS-1$ //$NON-NLS-2$ - { - ret = true; - } - - return ret; - - } - - @Override - public boolean cancelledByOperator() - { - return this.cancelledByOperator; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - // no required. - return required; - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - // NOOP - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/HoldActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/HoldActivityImpl.java deleted file mode 100644 index f56554bae..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/HoldActivityImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.activities.HoldActivity; -import org.asteriskjava.pbx.agi.AgiChannelActivityHold; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class HoldActivityImpl extends ActivityHelper implements HoldActivity -{ - static Logger logger = Logger.getLogger(HoldActivityImpl.class); - private final Channel _channel; - - public HoldActivityImpl(final Channel channel, final ActivityCallback callback) - { - super("HoldCall", callback); //$NON-NLS-1$ - - this._channel = channel; - this.startActivity(false); - } - - @Override - public boolean doActivity() throws PBXException - { - boolean success = false; - - HoldActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - HoldActivityImpl.logger.info("*********** begin Hold Audio ****************"); //$NON-NLS-1$ - HoldActivityImpl.logger.info("*********** " + this._channel + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - HoldActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - if (!pbx.moveChannelToAgi(_channel)) - { - throw new PBXException("Channel: " + _channel + " couldn't be moved to agi"); - } - - _channel.setCurrentActivityAction(new AgiChannelActivityHold()); - success = true; - - } - catch (IllegalArgumentException | IllegalStateException e) - { - HoldActivityImpl.logger.error(e, e); - HoldActivityImpl.logger.error(e, e); - throw new PBXException(e); - } - return success; - } - - public Channel getChannel() - { - return this._channel; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - // no events requried. - - return required; - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - // NOOP - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/JoinActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/JoinActivityImpl.java deleted file mode 100644 index bd3d8e30d..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/JoinActivityImpl.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallDirection; -import org.asteriskjava.pbx.CallImpl; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.Call.OperandChannel; -import org.asteriskjava.pbx.activities.JoinActivity; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -/** - * The JoinActivity is used by the AsteriksPBX implementation to Join two - * channels into a single call. The join activity expects two channels which are - * each a leg of a different call it will then join those two channels into a - * single call.iChannel hangupChannel, The channels that remain in the - * originating calls will be hungup implicitly. - * - * @author bsutton - */ -public class JoinActivityImpl extends ActivityHelper implements JoinActivity -{ - - static Logger logger = Logger.getLogger(JoinActivityImpl.class); - - private final Call _lhsCall; - private final OperandChannel _originatingOperand; - - private final Call _rhsCall; - private final OperandChannel _acceptingOperand; - private final CallDirection _direction; - - private Call _joined; - - private Exception callSite; - - /** - * Joins a specific channel from this call with a specific channel from - * another call which results in a new Call object being created. Channels - * that do not participate in the join are left in their original Call. - * - * @param lhsCall one of the calls we are joining - * @param originatingOperand the channel from lhsCall call that will - * participate in the join as the originating Channel - * @param rhsCall the other call we are joining. - * @param acceptingOperand the channel from the rhsCall that will - * participate in the join as the accepting channel. - * @return - * @throws PBXException - */ - public JoinActivityImpl(final Call lhsCall, OperandChannel originatingOperand, final Call rhsCall, - OperandChannel acceptingOperand, CallDirection direction, final ActivityCallback listener) - { - super("JoinActivity", listener); //$NON-NLS-1$ - - callSite = new Exception("Call site"); - - this._lhsCall = lhsCall; - this._originatingOperand = originatingOperand; - this._rhsCall = rhsCall; - this._acceptingOperand = acceptingOperand; - this._direction = direction; - - if (this._lhsCall == null) - { - throw new IllegalArgumentException("lhsCall may not be null"); //$NON-NLS-1$ - } - - if (this._originatingOperand == null) - { - throw new IllegalArgumentException("lhsOperand may not be null"); //$NON-NLS-1$ - } - - if (this._rhsCall == null) - { - throw new IllegalArgumentException("rhsCall may not be null"); //$NON-NLS-1$ - } - - if (this._acceptingOperand == null) - { - throw new IllegalArgumentException("rhsOperand may not be null"); //$NON-NLS-1$ - } - - - this.startActivity(true); - } - - @Override - public boolean doActivity() throws PBXException - { - boolean success = false; - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - JoinActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - JoinActivityImpl.logger.info("*********** begin join ****************"); //$NON-NLS-1$ - JoinActivityImpl.logger.info("*********** " + this._lhsCall + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - JoinActivityImpl.logger.info("*********** " + this._rhsCall + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - JoinActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - - try - { - final Channel rhsChannel = this._rhsCall.getOperandChannel(this._acceptingOperand); - final Channel lhsChannel = this._lhsCall.getOperandChannel(this._originatingOperand); - - if (!pbx.moveChannelToAgi(rhsChannel)) - { - throw new PBXException("Channel: " + rhsChannel + " couldn't be moved to agi"); - } - if (!pbx.moveChannelToAgi(lhsChannel)) - { - throw new PBXException("Channel: " + lhsChannel + " couldn't be moved to agi"); - } - - List channels = new LinkedList<>(); - channels.add(lhsChannel); - channels.add(rhsChannel); - if (!pbx.waitForChannelsToQuiescent(channels, 3000)) - { - logger.error(callSite, callSite); - throw new PBXException("Channel: " + rhsChannel - + " cannot be joined as it is still in transition."); - } - // Now do the actual join on the pbx. - pbx.bridge(lhsChannel, - rhsChannel); - this._joined = ((CallImpl) this._lhsCall).join(this._originatingOperand, this._rhsCall, this._acceptingOperand, - this._direction); - success = true; - - } - catch (RuntimeException e) - { - logger.error(e, e); - logger.error(callSite, callSite); - throw new PBXException(e); - - } - return success; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - return required; - } - - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - // NOOP - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public Call getJoinedCall() - { - return this._joined; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/ParkActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/ParkActivityImpl.java deleted file mode 100644 index e1eea5412..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/ParkActivityImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.io.IOException; -import java.util.HashSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallDirection; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.activities.ParkActivity; -import org.asteriskjava.pbx.asterisk.wrap.actions.RedirectAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ParkedCallEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -/** - * The ParkActivity is used by the AsteriksPBX implementation to park a channel. - * The park activity expects two channels which are two legs legs of the same - * call. The parkChannel will be redirect to the njr-park extension. The - * hangupChannel (the second leg of the call) will be hung up. The (obvious?) - * limitation is that we can't park something like a conference call as it has - * more than two channels. - * - * @author bsutton - */ -public class ParkActivityImpl extends ActivityHelper implements ParkActivity -{ - static Logger logger = Logger.getLogger(ParkActivityImpl.class); - - /** - * call - the call which is being packed. - */ - private final Call _call; - - /** - * parkChannel - the channel from the above call which is going to be - * parked. extension. - */ - private final Channel _parkChannel; - - private volatile EndPoint _parkingLot; - - private final CountDownLatch _latch = new CountDownLatch(1); - - /* - * @param call the that is being parked. - * @param parkChannel the channel from the call which is the one which will - * be parked. All other channels in the call will be hungup. - */ - public ParkActivityImpl(final Call call, final Channel parkChannel, final ActivityCallback listener) - { - super("ParkActivity", listener); //$NON-NLS-1$ - - if (call == null) - { - throw new IllegalArgumentException("call may not be null"); //$NON-NLS-1$ - } - if (parkChannel == null) - { - throw new IllegalArgumentException("parkChannel may not be null"); //$NON-NLS-1$ - } - this._parkChannel = parkChannel; - this._call = call; - - if (!this._call.contains(parkChannel)) - throw new IllegalArgumentException("The parkChannel must be from the call."); //$NON-NLS-1$ - - this.startActivity(true); - } - - @Override - public boolean doActivity() throws PBXException - { - boolean success = false; - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - ParkActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - ParkActivityImpl.logger.info("*********** begin park ****************"); //$NON-NLS-1$ - ParkActivityImpl.logger.info("*********** " + this._parkChannel + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - ParkActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - - try - { - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - if (!pbx.waitForChannelToQuiescent(this._parkChannel, 3000)) - throw new PBXException("Channel: " + this._parkChannel + " cannot be parked as it is still in transition."); - - // The extension must be a non-qualified name as - // otherwise it would be of the form DIALPLAN/njr-park - final RedirectAction redirect = new RedirectAction(this._parkChannel, profile.getManagementContext(), - pbx.getExtensionPark(), 1); - - final ManagerResponse response = pbx.sendAction(redirect, 1000); - if ((response != null) && (response.getResponse().compareToIgnoreCase("success") == 0))//$NON-NLS-1$ - { - // Hangup the call as we have parked the other side of - // the call. - if (this._call.getDirection() == CallDirection.INBOUND) - pbx.hangup(this._call.getAcceptingParty()); - else - pbx.hangup(this._call.getOriginatingParty()); - success = true; - } - - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - ParkActivityImpl.logger.error(e, e); - throw new PBXException(e); - - } - finally - { - // we wait at most 2 seconds for the parking extension to - // arrive. - try - { - if (success) - { - this._latch.await(2, TimeUnit.SECONDS); - } - - if (this._parkingLot == null) - { - success = false; - ParkActivityImpl.logger.warn("ParkCallEvent not recieved within 2 seconds of parking call."); //$NON-NLS-1$ - this.setLastException(new PBXException("ParkCallEvent not recieved within 2 seconds of parking call.")); //$NON-NLS-1$ - } - } - catch (final InterruptedException e) - { - ParkActivityImpl.logger.error(e, e); - - } - - } - return success; - } - - @Override - public EndPoint getParkingLot() - { - return this._parkingLot; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(ParkedCallEvent.class); - - return required; - } - - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - assert event instanceof ParkedCallEvent : "Unexpected event"; //$NON-NLS-1$ - - final ParkedCallEvent parkedEvent = (ParkedCallEvent) event; - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - this._parkingLot = pbx.buildEndPoint(TechType.LOCAL, parkedEvent.getExten()); - this._latch.countDown(); - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/activity/SplitActivityImpl.java b/src/main/java/org/asteriskjava/pbx/internal/activity/SplitActivityImpl.java deleted file mode 100644 index 876d223db..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/activity/SplitActivityImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -package org.asteriskjava.pbx.internal.activity; - -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.CallImpl; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.activities.SplitActivity; -import org.asteriskjava.pbx.agi.AgiChannelActivityHold; -import org.asteriskjava.pbx.asterisk.wrap.actions.RedirectAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.ChannelProxy; - -/** - * The SplitActivity is used by the AsteriksPBX to split a call and place the - * component channels into the specialist Activity fastagi. The SplitActivity - * can only split a call with two channels. The (obvious?) limitation is that we - * can't split something in a conference call as it has more than two channels. - * - * @author bsutton - */ -public class SplitActivityImpl extends ActivityHelper implements SplitActivity -{ - static Logger logger = Logger.getLogger(SplitActivityImpl.class); - - private Call _callToSplit; - - private Channel channel1; - - private Channel channel2; - - private Call _lhsCall; - - private Call _rhsCall; - - /** - * Splits a call by moving each of its two channels into the Activity agi. - * The channels will sit in the agi (with no audio) until something is done with them. - * As such you should leave them split for too long. - * - * - * @param callToSplit The call to split - * @param listener - */ - public SplitActivityImpl(final Call callToSplit, final ActivityCallback listener) - { - super("SplitActivity", listener); //$NON-NLS-1$ - - this._callToSplit = callToSplit; - - channel1 = callToSplit.getChannels().get(0); - channel2 = callToSplit.getChannels().get(1); - - callToSplit.getChannels(); - - this.startActivity(true); - } - - @Override - public boolean doActivity() throws PBXException - { - - SplitActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - SplitActivityImpl.logger.info("*********** begin split ****************"); //$NON-NLS-1$ - SplitActivityImpl.logger.info("*********** " + this.channel1 + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - SplitActivityImpl.logger.info("*********** " + this.channel2 + " ****************"); //$NON-NLS-1$ //$NON-NLS-2$ - SplitActivityImpl.logger.info("*******************************************************************************"); //$NON-NLS-1$ - - // Splits the originating and secondary channels by moving each of them - // into the associated - // target. - boolean success = false; - - if (this.channel2 != null) - { - success = splitTwo(); - - // Now update the call to reflect the split - if (success) - { - this._lhsCall = ((CallImpl) this._callToSplit).split(channel1); - this._rhsCall = ((CallImpl) this._callToSplit).split(channel2); - } - } - return success; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - // No events required. - return required; - } - - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - // NOOP - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - /** - * After a call has been split we get two new calls. One will hold the - * original remote party and the other will hold the original local party. - * - * @return the call which holds the original remote party. - */ - @Override - public Call getLHSCall() - { - return this._lhsCall; - } - - /** - * After a call has been split we get two new calls. One will hold the - * original remote party and the other will hold the original local party. - * - * @return the call which holds the original local party. - */ - @Override - public Call getRHSCall() - { - return this._rhsCall; - } - - /** - * Splits two channels moving them to defined endpoints. - * - * @param lhs - * @param lhsTarget - * @param lhsTargetContext - * @param rhs - * @param rhsTarget - * @param rhsTargetContext - * @return - * @throws PBXException - */ - private boolean splitTwo() throws PBXException - { - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - if (channel1 == channel2) - { - throw new NullPointerException( - "channel1 is the same as channel2. if I let this happen, asterisk will core dump :)"); - } - - List channels = new LinkedList<>(); - channels.add(channel1); - channels.add(channel2); - if (!pbx.waitForChannelsToQuiescent(channels, 3000)) - { - logger.error(callSite, callSite); - throw new PBXException( - "Channel: " + channel1 + " or " + channel2 + " cannot be split as they are still in transition."); - } - - /* - * redirects the specified channels to the specified endpoints. Returns - * true or false reflecting success. - */ - - AgiChannelActivityHold agi1 = new AgiChannelActivityHold(); - AgiChannelActivityHold agi2 = new AgiChannelActivityHold(); - - pbx.setVariable(channel1, "proxyId", "" + ((ChannelProxy) channel1).getIdentity()); - pbx.setVariable(channel2, "proxyId", "" + ((ChannelProxy) channel2).getIdentity()); - - channel1.setCurrentActivityAction(agi1); - channel2.setCurrentActivityAction(agi2); - - final String agiExten = profile.getAgiExtension(); - final String agiContext = profile.getManagementContext(); - logger.debug("splitTwo channel lhs:" + channel1 + " to " + agiExten + " in context " + agiContext + " from " - + this._callToSplit); - - final EndPoint extensionAgi = pbx.getExtensionAgi(); - final RedirectAction redirect = new RedirectAction(channel1, agiContext, extensionAgi, 1); - redirect.setExtraChannel(channel2); - redirect.setExtraContext(agiContext); - redirect.setExtraExten(extensionAgi); - redirect.setExtraPriority(1); - // logger.error(redirect); - - boolean ret = false; - { - try - { - - // final ManagerResponse response = - pbx.sendAction(redirect, 1000); - double ctr = 0; - while ((!agi1.hasCallReachedAgi() || !agi2.hasCallReachedAgi()) && ctr < 10) - { - Thread.sleep(100); - ctr += 100.0 / 1000.0; - if (!agi1.hasCallReachedAgi()) - { - logger.error("Waiting on (agi1) " + channel1); - } - if (!agi2.hasCallReachedAgi()) - { - logger.error("Waiting on (agi2) " + channel2); - } - } - ret = agi1.hasCallReachedAgi() && agi2.hasCallReachedAgi(); - - } - catch (final Exception e) - { - logger.error(e, e); - } - } - return ret; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/asterisk/CallerIDImpl.java b/src/main/java/org/asteriskjava/pbx/internal/asterisk/CallerIDImpl.java deleted file mode 100644 index 8bb4ab35e..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/asterisk/CallerIDImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.asteriskjava.pbx.internal.asterisk; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.PBXFactory; - -public class CallerIDImpl implements CallerID -{ - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(CallerIDImpl.class); - private final String number; - private final String name; - private boolean hideCallerID = false; - - /** - * Creates a caller ID. - * - * @param number - * - if null then we store an empty string. - * @param name - * - if null then we store an empty string. - */ - public CallerIDImpl(final String number, final String name) - { - this.number = (number == null ? "" : number.trim()); //$NON-NLS-1$ - this.name = (name == null ? "" : name.trim()); //$NON-NLS-1$ - } - - @Override - public String getNumber() - { - return this.number; - } - - @Override - public String getName() - { - return this.name; - } - - /** - * This is a little helper class which will buid the name component of a - * clid from the first and lastnames. - * - * If both firstname and lastname are null then the name component will be - * an empty string. - * - * @param firstname - * the person's firstname, may be null. - * @param lastname - * the person's lastname, may be null - * @param number - * the phone number. - * @return - */ - public static CallerID buildFromComponents(final String firstname, final String lastname, final String number) - { - String name = ""; //$NON-NLS-1$ - if (firstname != null) - { - name += firstname.trim(); - } - - if (lastname != null) - { - if (name.length() > 0) - { - name += " "; //$NON-NLS-1$ - } - name += lastname.trim(); - } - - return PBXFactory.getActivePBX().buildCallerID(number, name); - } - - /** - * Formats and returns the caller ID in an asterisk specific format suitable - * for passing to the likes of the originate action. The format is: name - * - * - * @return a formatted clid. - */ - public String formatted() - { - String callerID = ""; //$NON-NLS-1$ - if (this.name != null) - { - callerID += this.name; - } - if (this.number != null) - { - if (callerID.length() > 1) - { - callerID += " "; //$NON-NLS-1$ - } - callerID += "<" + this.number + ">"; //$NON-NLS-1$ //$NON-NLS-2$ - } - return callerID; - } - - @Override - public void setHideCallerID(final boolean hide) - { - this.hideCallerID = hide; - - } - - @Override - public boolean isHideCallerID() - { - return this.hideCallerID; - } - - @Override - public String toString() - { - return this.formatted(); - } - - @Override - public boolean isUnknown() - { - return (this.number.length() == 0) || (this.number.compareToIgnoreCase("unknown") == 0); //$NON-NLS-1$ - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/asterisk/MeetmeRoom.java b/src/main/java/org/asteriskjava/pbx/internal/asterisk/MeetmeRoom.java deleted file mode 100644 index 7a7eaa377..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/asterisk/MeetmeRoom.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.asteriskjava.pbx.internal.asterisk; - -import java.util.Date; -import java.util.LinkedList; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; - -/* - * This class tracks the status, channel names and number of participants in - * a meetme room. The hangup function will hangup all known participants in - * this meetme room. - */ -public class MeetmeRoom -{ - /** - * The asterisk room number. This will be value offset from the Meetme Base. - * e.g. if the base is 3750 and this is the third allocated room, then the - * roomNumber will equal 3753. - */ - private final int roomNumber; - - static Logger logger = Logger.getLogger(MeetmeRoom.class); - - LinkedList channels = new LinkedList<>(); - - private int channelCount = 0; - - private boolean active = false; - - private boolean forceClose = false; - - private Date lastUpdated = null; - - public MeetmeRoom(final int number) - { - this.roomNumber = number; - } - - /* - * returns true if the channel was added to the list of channels in this - * meetme. if the channel is already in the meetme, returns false - */ - synchronized public boolean addChannel(final Channel channel) - { - boolean newChannel = false; - if (!this.channels.contains(channel)) - { - this.channels.add(channel); - this.channelCount++; - newChannel = true; - } - else - MeetmeRoom.logger.error("rejecting " + channel + " already in meetme."); //$NON-NLS-1$ //$NON-NLS-2$ - return newChannel; - } - - synchronized public int getChannelCount() - { - return this.channelCount; - } - - synchronized public Channel[] getChannels() - { - final Channel list[] = new Channel[this.channels.size()]; - - int cnt = 0; - for (final Channel channel : this.channels) - { - list[cnt++] = channel; - } - return list; - } - - public boolean getForceClose() - { - return this.forceClose; - } - - public Date getLastUpdated() - { - return this.lastUpdated; - } - - public String getRoomNumber() - { - return ("" + this.roomNumber); //$NON-NLS-1$ - } - - /** - * returns true if the meetme room is active, false if it is available - * - * @return - */ - public boolean getStatus() - { - return this.active; - } - - synchronized public void removeChannel(final Channel channel) - { - final boolean channelCountInSync = this.channelCount == this.channels.size(); - final boolean removed = this.channels.remove(channel); - - if (!removed) - { - MeetmeRoom.logger.warn( - "An attempt to remove an non-existing channel " + channel + " from Meetme Room " + this.getRoomNumber()); //$NON-NLS-1$ //$NON-NLS-2$ - } - - if (channelCountInSync && removed) - { - this.channelCount--; - } - - // If the channel count is not insync then we decrement the channel - // count even if the remove was for a non-existent channel. - // We do this as if the channel count is out of sync it means that we - // have polled asterisk (usually during startup) - // and our local count was out of sync with asterisk. Asterisk is the - // definitive source. If we then get a remove - // channel then its probably a channel that asterisk knows about but - // which we don't know about. - // In that case our channelCount will also have come from asterisk so - // decrementing it keeps us in sync with asterisk - // and eventually we will get back in sync (hopefully). - if (!channelCountInSync && removed) - { - this.channelCount--; - } - - if ((this.channels.size() < 2) && (this.channels.size() > 0)) - { - if (!this.channels.get(0).isLocal()) - { - logger.warn("One channel left in the meet me room " + this.channels.get(0) + " room " + this.roomNumber); //$NON-NLS-1$ - } - } - - } - - public void setActive() - { - this.active = true; - } - - public void setForceClose(final boolean canClose) - { - this.forceClose = canClose; - } - - public void setInactive() - { - this.active = false; - this.channels.clear(); - this.forceClose = false; - this.lastUpdated = null; - - } - - public void setLastUpdated() - { - this.lastUpdated = new Date(); - } - - /** - * This method should only be called if asterisk is reporting a channel - * count for this meetme room which does not match our local channel count. - * This could happen if it was restarted whilst a call was active. - * - * @param channelCount - */ - public void resetChannelCount(final int resetChannelCount) - { - this.channelCount = resetChannelCount; - - } - - public boolean isActive() - { - return this.active; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/asterisk/MeetmeRoomControl.java b/src/main/java/org/asteriskjava/pbx/internal/asterisk/MeetmeRoomControl.java deleted file mode 100644 index 37791328b..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/asterisk/MeetmeRoomControl.java +++ /dev/null @@ -1,411 +0,0 @@ -package org.asteriskjava.pbx.internal.asterisk; - -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.log4j.Logger; -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.CommandAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.ConfbridgeListAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ConfbridgeListEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MeetMeJoinEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MeetMeLeaveEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ResponseEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ResponseEvents; -import org.asteriskjava.pbx.asterisk.wrap.response.CommandResponse; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.CoherentManagerEventListener; -import org.asteriskjava.pbx.internal.managerAPI.EventListenerBaseClass; - -public class MeetmeRoomControl extends EventListenerBaseClass implements CoherentManagerEventListener -{ - /* - * listens for a channel entering or leaving meetme rooms. when there is - * only 1 channel left in a room it sets it as inactive .It will not set to - * inactive unless okToKill is set to true. It is set to false by - * default.Also manages the available room list. - */ - - static Logger logger = Logger.getLogger(MeetmeRoomControl.class); - - private Integer meetmeBaseAddress; - - private MeetmeRoom rooms[]; - - private int roomCount; - - private boolean meetmeInstalled = false; - - private final static AtomicReference self = new AtomicReference<>(); - - synchronized public static void init(PBX pbx, final int roomCount) throws NoMeetmeException - { - if (MeetmeRoomControl.self.get() != null) - { - logger.warn("The MeetmeRoomControl has already been initialised."); //$NON-NLS-1$ - } - else - { - MeetmeRoomControl.self.set(new MeetmeRoomControl(pbx, roomCount)); - } - } - - public static MeetmeRoomControl getInstance() - { - if (MeetmeRoomControl.self.get() == null) - { - throw new IllegalStateException( - "Thee MeetmeRoomControl has not been initialised. Please call MeetmeRoomControl.init()."); //$NON-NLS-1$ - } - - return MeetmeRoomControl.self.get(); - - } - - private MeetmeRoomControl(PBX pbx, final int roomCount) throws NoMeetmeException - { - super("MeetmeRoomControl"); //$NON-NLS-1$ - this.roomCount = roomCount; - final AsteriskSettings settings = PBXFactory.getActiveProfile(); - this.meetmeBaseAddress = settings.getMeetmeBaseAddress(); - this.rooms = new MeetmeRoom[roomCount]; - this.configure((AsteriskPBX) pbx); - - this.startListener(pbx); - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(MeetMeJoinEvent.class); - required.add(MeetMeLeaveEvent.class); - - return required; - } - - /* - * returns the next available meetme room, or null if no rooms are - * available. - */ - public synchronized MeetmeRoom findAvailableRoom() - { - int count = 0; - for (final MeetmeRoom room : this.rooms) - { - if (MeetmeRoomControl.logger.isDebugEnabled()) - { - MeetmeRoomControl.logger.debug("room " + room.getRoomNumber() + " count " + count); //$NON-NLS-1$ //$NON-NLS-2$ - } - /* - * new code to attempt to recover uncleared meetme rooms safely - */ - try - { - final Date lastUpdated = room.getLastUpdated(); - final long now = new Date().getTime(); - if (lastUpdated != null) - { - final long elapsedTime = now - lastUpdated.getTime(); - MeetmeRoomControl.logger.debug("room: " + room.getRoomNumber() + " count: " + count + " elapsed: " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + elapsedTime); - if ((elapsedTime > 7200000) && (room.getChannelCount() == 1)) - { - MeetmeRoomControl.logger.debug("clearing room"); //$NON-NLS-1$ - room.setInactive(); - } - } - } - catch (final Exception e) - { - /* - * attempt to make this new change safe - */ - MeetmeRoomControl.logger.error(e, e); - } - - if (room.getChannelCount() == 0) - { - room.setInactive(); - } - if (room.getStatus() == false) - { - MeetmeRoomControl.logger.debug("Returning available room base+" + room.getRoomNumber()); //$NON-NLS-1$ - return room; - } - count++; - } - MeetmeRoomControl.logger.error("no more available rooms"); //$NON-NLS-1$ - return null; - } - - /** - * Returns the MeetmeRoom for the given room number. The room number will be - * an integer value offset from the meetme base address. - * - * @param roomNumber the meetme room number - * @return - */ - synchronized private MeetmeRoom findMeetmeRoom(final String roomNumber) - { - MeetmeRoom foundRoom = null; - for (final MeetmeRoom room : this.rooms) - { - if (room.getRoomNumber().compareToIgnoreCase(roomNumber) == 0) - { - foundRoom = room; - break; - } - } - return foundRoom; - } - - synchronized MeetmeRoom getRoom(final int room) - { - return this.rooms[room]; - } - - @Override - public void onManagerEvent(final ManagerEvent event) - { - MeetmeRoom room; - if (event instanceof MeetMeJoinEvent) - { - final MeetMeJoinEvent evt = (MeetMeJoinEvent) event; - room = this.findMeetmeRoom(evt.getMeetMe()); - final Channel channel = evt.getChannel(); - if (room != null) - { - if (room.addChannel(channel)) - { - MeetmeRoomControl.logger.debug(channel + " has joined the conference " //$NON-NLS-1$ - + room.getRoomNumber() + " channelCount " + (room.getChannelCount())); //$NON-NLS-1$ - room.setLastUpdated(); - } - } - } - if (event instanceof MeetMeLeaveEvent) - { - final MeetMeLeaveEvent evt = (MeetMeLeaveEvent) event; - room = this.findMeetmeRoom(evt.getMeetMe()); - final Channel channel = evt.getChannel(); - if (room != null) - { - // ignore local dummy channels// && - // !channel.toUpperCase().startsWith("LOCAL/")) { - - if (MeetmeRoomControl.logger.isDebugEnabled()) - { - MeetmeRoomControl.logger.debug(channel + " has left the conference " //$NON-NLS-1$ - + room.getRoomNumber() + " channel count " + (room.getChannelCount())); //$NON-NLS-1$ - } - room.removeChannel(channel); - room.setLastUpdated(); - if ((room.getChannelCount() < 2) && (room.getForceClose() == true)) - { - this.hangupChannels(room); - room.setInactive(); - } - - if (room.getChannelCount() < 1) - { - room.setInactive(); - } - } - } - } - - public void hangupChannels(final MeetmeRoom room) - { - - final Channel Channels[] = room.getChannels(); - if (room.getStatus() == true) - { - PBX pbx = PBXFactory.getActivePBX(); - - for (final Channel channel : Channels) - { - room.removeChannel(channel); - - try - { - pbx.hangup(channel); - } - catch (IllegalArgumentException | IllegalStateException | PBXException e) - { - logger.error(e, e); - - } - } - } - } - - private void configure(AsteriskPBX pbx) throws NoMeetmeException - { - final int base = this.meetmeBaseAddress; - for (int r = 0; r < this.roomCount; r++) - { - this.rooms[r] = new MeetmeRoom(r + base); - } - - try - { - String command; - if (pbx.getVersion().isAtLeast(AsteriskVersion.ASTERISK_13)) - { - command = "ConfBridge list"; //$NON-NLS-1$ - ConfbridgeListAction action = new ConfbridgeListAction(); - final ResponseEvents response = pbx.sendEventGeneratingAction(action, 3000); - Map roomChannelCount = new HashMap<>(); - for (ResponseEvent event : response.getEvents()) - { - - ConfbridgeListEvent e = (ConfbridgeListEvent) event; - Integer current = roomChannelCount.get(e.getConference()); - if (current == null) - { - roomChannelCount.put(e.getConference(), 1); - } - else - { - roomChannelCount.put(e.getConference(), current + 1); - } - } - for (Entry entry : roomChannelCount.entrySet()) - { - setRoomCount(entry.getKey(), entry.getValue(), Integer.parseInt(entry.getKey())); - - } - this.meetmeInstalled = true; - - } - else - { - if (pbx.getVersion().isAtLeast(AsteriskVersion.ASTERISK_1_6)) - { - command = "meetme list"; //$NON-NLS-1$ - } - else - { - command = "meetme"; //$NON-NLS-1$ - } - final CommandAction commandAction = new CommandAction(command); - final ManagerResponse response = pbx.sendAction(commandAction, 3000); - if (!(response instanceof CommandResponse)) - { - throw new ManagerCommunicationException(response.getMessage(), null); - } - - final CommandResponse commandResponse = (CommandResponse) response; - MeetmeRoomControl.logger.debug("parsing active meetme rooms"); //$NON-NLS-1$ - for (final String line : commandResponse.getResult()) - { - this.parseMeetme(line); - this.meetmeInstalled = true; - MeetmeRoomControl.logger.debug(line); - } - } - } - catch (final NoMeetmeException e) - { - throw e; - } - catch (final Exception e) - { - MeetmeRoomControl.logger.error(e, e); - throw new NoMeetmeException(e.getLocalizedMessage()); - } - } - - private synchronized void parseMeetme(final String line) throws NoMeetmeException - { - - if (line != null) - { - if (line.toLowerCase().startsWith("no such command 'meetme'") == true) //$NON-NLS-1$ - { - throw new NoMeetmeException("Asterisk is not configured correctly! Please enable the MeetMe app"); //$NON-NLS-1$ - } - - if ((line.toLowerCase().startsWith("no active meetme conferences.") == false) //$NON-NLS-1$ - && (line.toLowerCase().startsWith("conf num") == false) //$NON-NLS-1$ - && (line.toLowerCase().startsWith("* total number") == false) //$NON-NLS-1$ - && (line.toLowerCase().startsWith("no such conference") == false) //$NON-NLS-1$ - && (line.toLowerCase().startsWith("no such command 'meetme'") == false) //$NON-NLS-1$ - ) - { - // Update the stats on each meetme - final String roomNumber = line.substring(0, 10).trim(); - final String tmp = line.substring(11, 25).trim(); - final int channelCount = Integer.parseInt(tmp); - - final int roomNo = Integer.valueOf(roomNumber); - setRoomCount(roomNumber, channelCount, roomNo); - } - } - } - - private void setRoomCount(final String roomNumber, final int channelCount, final int roomNo) - { - Integer base = this.meetmeBaseAddress; - // First check if its one of our rooms. - if ((roomNo >= base) && (roomNo < (base + this.roomCount))) - { - final MeetmeRoom room = this.findMeetmeRoom(roomNumber); - if (room != null) - { - if (room.getChannelCount() != channelCount) - { - /* - * After a restart there may have been meetme rooms left up - * and running with live calls. We need to identify any - * active rooms so we don't accidentally re-use an active - * room which would result in a crossed channel. - */ - MeetmeRoomControl.logger.warn("Room number: " + room.getRoomNumber() //$NON-NLS-1$ - + " has a server side channel count = " + channelCount //$NON-NLS-1$ - + " when the channel count for that room is: " + room.getChannelCount() //$NON-NLS-1$ - + " the server side channel count will be reset."); //$NON-NLS-1$ - } - room.resetChannelCount(channelCount); - room.setActive(); - } - // else "Found roomNumber:" + roomNumber + " but it was not - // in the list of rooms managed by MeetmeRoomControl."); - // //$NON-NLS-1$ //$NON-NLS-2$ - - } - } - - public void stop() - { - this.close(); - - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - public boolean isMeetmeInstalled() - { - return this.meetmeInstalled; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/asterisk/NoMeetmeException.java b/src/main/java/org/asteriskjava/pbx/internal/asterisk/NoMeetmeException.java deleted file mode 100644 index eb666a2d5..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/asterisk/NoMeetmeException.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.asteriskjava.pbx.internal.asterisk; - -public class NoMeetmeException extends Exception -{ - private static final long serialVersionUID = 1L; - - public NoMeetmeException(final String message) - { - super(message); - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/ActiveCallListener.java b/src/main/java/org/asteriskjava/pbx/internal/core/ActiveCallListener.java deleted file mode 100644 index 1a4c44d22..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/ActiveCallListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import org.asteriskjava.pbx.Call; - -/** - * Used to notify a listener that the status of a call has changed. For instance - * the call may have just been parked. - * - * @author bsutton - * - */ -public interface ActiveCallListener -{ - - void callStatusChanged(Call call, boolean isHidden); - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/AsteriskPBX.java b/src/main/java/org/asteriskjava/pbx/internal/core/AsteriskPBX.java deleted file mode 100644 index 2e4e67db1..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/AsteriskPBX.java +++ /dev/null @@ -1,934 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.io.IOException; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.EventTimeoutException; -import org.asteriskjava.manager.ManagerConnectionState; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.manager.event.AbstractChannelEvent; -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.ActivityStatusEnum; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.Call.OperandChannel; -import org.asteriskjava.pbx.CallDirection; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ChannelHangupListener; -import org.asteriskjava.pbx.CompletionAdaptor; -import org.asteriskjava.pbx.DTMFTone; -import org.asteriskjava.pbx.DialPlanExtension; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.Trunk; -import org.asteriskjava.pbx.activities.BlindTransferActivity; -import org.asteriskjava.pbx.activities.BridgeActivity; -import org.asteriskjava.pbx.activities.DialActivity; -import org.asteriskjava.pbx.activities.DialToAgiActivity; -import org.asteriskjava.pbx.activities.HoldActivity; -import org.asteriskjava.pbx.activities.JoinActivity; -import org.asteriskjava.pbx.activities.ParkActivity; -import org.asteriskjava.pbx.activities.SplitActivity; -import org.asteriskjava.pbx.agi.AgiChannelActivityHangup; -import org.asteriskjava.pbx.agi.AgiChannelActivityHold; -import org.asteriskjava.pbx.asterisk.wrap.actions.CommandAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.EventGeneratingAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.HangupAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.ManagerAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.PlayDtmfAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.RedirectAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ResponseEvents; -import org.asteriskjava.pbx.asterisk.wrap.response.CommandResponse; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.activity.BlindTransferActivityImpl; -import org.asteriskjava.pbx.internal.activity.BridgeActivityImpl; -import org.asteriskjava.pbx.internal.activity.DialActivityImpl; -import org.asteriskjava.pbx.internal.activity.DialToAgiActivityImpl; -import org.asteriskjava.pbx.internal.activity.HoldActivityImpl; -import org.asteriskjava.pbx.internal.activity.JoinActivityImpl; -import org.asteriskjava.pbx.internal.activity.ParkActivityImpl; -import org.asteriskjava.pbx.internal.activity.SplitActivityImpl; -import org.asteriskjava.pbx.internal.asterisk.CallerIDImpl; -import org.asteriskjava.pbx.internal.asterisk.MeetmeRoom; -import org.asteriskjava.pbx.internal.asterisk.MeetmeRoomControl; -import org.asteriskjava.pbx.internal.managerAPI.RedirectCall; - -public enum AsteriskPBX implements PBX, ChannelHangupListener -{ - - SELF; - - private final Logger logger = Logger.getLogger(AsteriskPBX.class); - private boolean muteSupported; - private boolean bridgeSupport; - - private static final int MAX_MEETME_ROOMS = 50; - - private LiveChannelManager liveChannels; - - AsteriskPBX() - { - try - { - CoherentManagerConnection.init(); - - this.muteSupported = CoherentManagerConnection.getInstance().isMuteAudioSupported(); - this.bridgeSupport = CoherentManagerConnection.getInstance().isBridgeSupported(); - - try - { - MeetmeRoomControl.init(this, AsteriskPBX.MAX_MEETME_ROOMS); - } - catch (Throwable e) - { - logger.error(e, e); - } - - this.liveChannels = new LiveChannelManager(); - - } - catch (IllegalStateException | IOException | AuthenticationFailedException | TimeoutException e1) - { - logger.error(e1, e1); - } - - } - - /** - * Call this method when shutting down the PBX interface to allow it to - * cleanup. - */ - @Override - public void shutdown() - { - MeetmeRoomControl.getInstance().stop(); - CoherentManagerConnection.getInstance().shutDown(); - } - - @Override - public boolean isBridgeSupported() - { - return this.bridgeSupport; - } - - @Override - public BlindTransferActivity blindTransfer(Call call, Call.OperandChannel channelToTransfer, EndPoint transferTarget, - CallerID toCallerID, boolean autoAnswer, long timeout) - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - final BlindTransferActivityImpl transfer = new BlindTransferActivityImpl(call, channelToTransfer, transferTarget, - toCallerID, autoAnswer, timeout, completion); - - completion.waitForCompletion(timeout + 2, TimeUnit.SECONDS); - - return transfer; - - } - - @Override - public void blindTransfer(Call call, Call.OperandChannel channelToTransfer, EndPoint transferTarget, CallerID toCallerID, - boolean autoAnswer, long timeout, ActivityCallback listener) - { - new BlindTransferActivityImpl(call, channelToTransfer, transferTarget, toCallerID, autoAnswer, timeout, listener); - - } - - public BlindTransferActivity blindTransfer(Channel agentChannel, EndPoint transferTarget, CallerID toCallerID, - boolean autoAnswer, int timeout, ActivityCallback iCallback) throws PBXException - { - return new BlindTransferActivityImpl(agentChannel, transferTarget, toCallerID, autoAnswer, timeout, iCallback); - - } - - /** - * Utility method to bridge two channels - * - * @param lhsChannel - * @param rhsChannel - * @param direction - * @throws PBXException - */ - public BridgeActivity bridge(final Channel lhsChannel, final Channel rhsChannel) throws PBXException - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - final BridgeActivityImpl bridge = new BridgeActivityImpl(lhsChannel, rhsChannel, completion); - - completion.waitForCompletion(10, TimeUnit.SECONDS); - - return bridge; - - } - - @Override - public void split(final Call callToSplit) throws PBXException - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - new SplitActivityImpl(callToSplit, completion); - - completion.waitForCompletion(10, TimeUnit.SECONDS); - - } - - @Override - public SplitActivity split(final Call callToSplit, final ActivityCallback listener) - { - - return new SplitActivityImpl(callToSplit, listener); - } - - /** - * Joins two calls not returning until the join completes. The join will - * complete almost immediately as it is a simple bridging of two active - * channels. Each call must only have one active channel - */ - @Override - public JoinActivity join(Call lhs, OperandChannel originatingOperand, Call rhs, OperandChannel acceptingOperand, - CallDirection direction) - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - final JoinActivityImpl join = new JoinActivityImpl(lhs, originatingOperand, rhs, acceptingOperand, direction, - completion); - - completion.waitForCompletion(10, TimeUnit.SECONDS); - - return join; - - } - - /** - * Joins two calls not returning until the join completes. The join will - * complete almost immediately as it is a simple bridging of two active - * channels. Each call must only have one active channel - */ - @Override - public void join(Call lhs, OperandChannel originatingOperand, Call rhs, OperandChannel acceptingOperand, - CallDirection direction, ActivityCallback listener) - { - new JoinActivityImpl(lhs, originatingOperand, rhs, acceptingOperand, direction, listener); - - } - - @Override - public void conference(final Channel channelOne, final Channel channelTwo, final Channel channelThree) - { - // TODO Auto-generated method stub - - } - - @Override - public void conference(final Channel channelOne, final Channel channelTwo, final Channel channelThree, - final ActivityCallback callback) - { - // TODO Auto-generated method stub - - } - - @Override - public DialActivity dial(final EndPoint from, final CallerID fromCallerID, final EndPoint to, final CallerID toCallerID) - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - final DialActivityImpl dialer = new DialActivityImpl(from, to, toCallerID, false, completion, null); - - completion.waitForCompletion(3, TimeUnit.MINUTES); - - return dialer; - } - - public DialLocalToAgiActivity dialLocalToAgi(final EndPoint from, final CallerID fromCallerID, - ActivityCallback callback, Map channelVarsToSet) - { - return new DialLocalToAgiActivity(from, fromCallerID, callback, channelVarsToSet); - } - - public DialActivity dial(final EndPoint from, final CallerID fromCallerID, final EndPoint to, final CallerID toCallerID, - final ActivityCallback callback, Map channelVarsToSet) - { - final DialActivityImpl dialer = new DialActivityImpl(from, to, toCallerID, false, callback, channelVarsToSet); - return dialer; - } - - @Override - public void dial(final EndPoint from, final CallerID fromCallerID, final EndPoint to, final CallerID toCallerID, - final ActivityCallback callback) - { - new DialActivityImpl(from, to, toCallerID, false, callback, null); - - } - - /** - * Convenience method to hangup the call without having to extract the - * channel yourself. - */ - public void hangup(Call call) throws PBXException - { - this.hangup(call.getOriginatingParty()); - } - - @Override - public void hangup(final Channel channel) throws PBXException - { - if (channel.isLive()) - { - logger.debug("Sending hangup action for channel: " + channel); //$NON-NLS-1$ - - PBX pbx = PBXFactory.getActivePBX(); - if (!pbx.waitForChannelToQuiescent(channel, 3000)) - throw new PBXException("Channel: " + channel + " cannot be retrieved as it is still in transition."); - - final HangupAction hangup = new HangupAction(channel); - try - { - channel.setCurrentActivityAction(new AgiChannelActivityHangup()); - CoherentManagerConnection.sendAction(hangup, 1000); - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - logger.error(e, e); - throw new PBXException(e); - } - } - else - logger.debug("Suppressed hangup for " + channel + " as it was already hungup"); //$NON-NLS-1$ //$NON-NLS-2$ - - } - - @Override - public void hangup(final Channel channel, final ActivityCallback callback) - { - throw new UnsupportedOperationException("Not yet implemented."); //$NON-NLS-1$ - } - - @Override - public HoldActivity hold(final Channel channel) - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - HoldActivity activity = null; - try - { - activity = new HoldActivityImpl(channel, completion); - completion.waitForCompletion(10, TimeUnit.SECONDS); - - } - catch (final Exception e) - { - logger.error(e, e); - - } - return activity; - } - - @Override - public boolean isMuteSupported() - { - return this.muteSupported; - } - - @Override - public ParkActivity park(final Call call, final Channel parkChannel) - { - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - final ParkActivity activity = new ParkActivityImpl(call, parkChannel, completion); - parkChannel.setParked(true); - - completion.waitForCompletion(10, TimeUnit.SECONDS); - return activity; - } - - @Override - public void park(final Call call, final Channel parkChannel, final ActivityCallback callback) - { - new ParkActivityImpl(call, parkChannel, callback); - - } - - @Override - public void sendDTMF(final Channel channel, final DTMFTone tone) throws PBXException - { - try - { - if (!waitForChannelToQuiescent(channel, 3000)) - throw new PBXException("Channel: " + channel + " cannot play dtmf as it is still in transition."); - - CoherentManagerConnection.sendAction(new PlayDtmfAction(channel, tone), 1000); - } - catch (final Exception e) - { - logger.error(e, e); - throw new PBXException(e); - } - } - - @Override - public void sendDTMF(final Channel channel, final DTMFTone tone, final ActivityCallback callback) - { - // TODO Auto-generated method stub - - } - - @Override - public void transferToMusicOnHold(final Channel channel) throws PBXException - { - final RedirectCall transfer = new RedirectCall(); - transfer.redirect(channel, new AgiChannelActivityHold()); - } - - public String getManagementContext() - { - final AsteriskSettings settings = PBXFactory.getActiveProfile(); - return settings.getManagementContext(); - } - - @Override - public Channel getChannelByEndPoint(final EndPoint endPoint) - { - return this.liveChannels.getChannelByEndPoint(endPoint); - } - - @Override - public void channelHangup(Channel channel, Integer cause, String causeText) - { - this.liveChannels.remove((ChannelProxy) channel); - } - - public DialPlanExtension getExtensionPark() - { - final AsteriskSettings settings = PBXFactory.getActiveProfile(); - return this.buildDialPlanExtension(settings.getExtensionPark()); - } - - @Override - public EndPoint getExtensionAgi() - { - final AsteriskSettings settings = PBXFactory.getActiveProfile(); - return this.buildDialPlanExtension(settings.getAgiExtension()); - } - - /** - * Builds an end point from a fully qualified end point name. If the - * endpoint name doesn't have a tech then it is considered invalid and null - * is returned. - */ - - @Override - public EndPoint buildEndPoint(final String fullyQualifiedEndPoint) - { - EndPoint endPoint = null; - try - { - endPoint = new EndPointImpl(fullyQualifiedEndPoint); - } - catch (final IllegalArgumentException e) - { - logger.warn(e, e); - } - return endPoint; - } - - /** - * Builds an end point from an end point name. If the endpoint name doesn't - * have a tech specified then the defaultTech is used. - */ - @Override - public EndPoint buildEndPoint(final TechType defaultTech, final String endPointName) - { - EndPoint endPoint = null; - try - { - if (endPointName == null || endPointName.trim().length() == 0) - endPoint = new EndPointImpl(); - else - endPoint = new EndPointImpl(defaultTech, endPointName); - } - catch (final IllegalArgumentException e) - { - logger.error(e, e); - } - return endPoint; - - } - - @Override - public EndPoint buildEndPoint(final TechType defaultTech, final Trunk trunk, final String endPointName) - { - return new EndPointImpl(defaultTech, trunk, endPointName); - - } - - /** - * Builds an end point from an end point name. If the endpoint name doesn't - * have a tech specified then the defaultTech is used. - */ - public DialPlanExtension buildDialPlanExtension(final String extension) - { - DialPlanExtension dialPlan = null; - try - { - dialPlan = new DialPlanExtension(extension); - } - catch (final IllegalArgumentException e) - { - logger.error(e, e); - } - return dialPlan; - - } - - @Override - public CallerID buildCallerID(final String number, final String name) - { - return new CallerIDImpl(number, name); - } - - /** - * Convenience method to build a call id from an event. - * - * @param event - */ - public CallerID buildCallerID(final AbstractChannelEvent event) - { - final String number = event.getCallerIdNum(); - final String name = event.getCallerIdName(); - return this.buildCallerID(number, name); - } - - public Channel registerChannel(final String channelName, final String uniqueID) throws InvalidChannelName - { - if (channelName == null || channelName.trim().length() == 0) - { - throw new IllegalArgumentException("Channel name must not be empty"); - } - - Channel proxy = findChannel(cleanChannelName(channelName), null); - if (proxy == null) - { - logger.info("Couldn't find the channel " + channelName + ", creating it"); - proxy = internalRegisterChannel(channelName, uniqueID); - } - else - { - if (uniqueID != null && !uniqueID.equals(proxy.getUniqueId())) - { - logger.warn( - "Found the channel(" + proxy.getUniqueId() + "), but with a different uniqueId (" + uniqueID + ")"); - - } - } - liveChannels.sanityCheck(); - - return proxy; - } - - /** - * This method is not part of the public API.
- *
- * Use registerChannel instead calling this method with an incorrect or - * stale uniqueId will cause inconsistent behaviour. - * - * @param channelName - * @param uniqueID - * @return - * @throws InvalidChannelName - */ - public Channel internalRegisterChannel(final String channelName, final String uniqueID) throws InvalidChannelName - { - ChannelProxy proxy = null; - synchronized (this.liveChannels) - { - - String localUniqueID = (uniqueID == null ? ChannelImpl.UNKNOWN_UNIQUE_ID : uniqueID); - proxy = this.findChannel(cleanChannelName(channelName), localUniqueID); - if (proxy == null) - { - proxy = new ChannelProxy(new ChannelImpl(channelName, localUniqueID)); - logger.info("Creating new Channel Proxy " + proxy); - this.liveChannels.add(proxy); - proxy.addHangupListener(this); - } - } - return proxy; - } - - /** - * remove white space - * - * @param name - * @return - */ - private String cleanChannelName(final String name) - { - String cleanedName = name.trim().toUpperCase(); - - return cleanedName; - } - - public Channel registerHangupChannel(String channel, String uniqueId) throws InvalidChannelName - { - Channel newChannel = null; - synchronized (this.liveChannels) - { - newChannel = this.findChannel(channel, uniqueId); - if (newChannel == null) - { - // WE don't add this channel to the liveChannels as it is in the - // process - // of being hungup so we don't need to track it. - // If we tried to track it that would likely cause a problem - // as the livechannel manager would never be able to discard it - // as - // it relies on the hangup event which is being processed right - // now. - newChannel = new ChannelProxy(new ChannelImpl(channel, uniqueId)); - } - } - return newChannel; - } - - public ChannelProxy findChannel(final String channelName, final String uniqueID) - { - return this.liveChannels.findChannel(channelName, uniqueID); - } - - public MeetmeRoom acquireMeetmeRoom() - { - return MeetmeRoomControl.getInstance().findAvailableRoom(); - } - - public void addListener(FilteredManagerListener listener) - { - CoherentManagerConnection connection = CoherentManagerConnection.getInstance(); - connection.addListener(listener); - } - - public void removeListener(FilteredManagerListener listener) - { - CoherentManagerConnection connection = CoherentManagerConnection.getInstance(); - connection.removeListener(listener); - } - - /** - * sends an action with a default timeout of 30 seconds. - * - * @param theAction - * @return - * @throws IllegalArgumentException - * @throws IllegalStateException - * @throws IOException - * @throws TimeoutException - */ - public ManagerResponse sendAction(ManagerAction theAction) - throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException - { - return CoherentManagerConnection.sendAction(theAction, 30000); - } - - public ManagerResponse sendAction(ManagerAction theAction, int timeout) - throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException - { - return CoherentManagerConnection.sendAction(theAction, timeout); - } - - public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws EventTimeoutException, IllegalArgumentException, IllegalStateException, IOException - { - ResponseEvents events = CoherentManagerConnection.sendEventGeneratingAction(action); - return events; - - } - - public ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, int timeout) - throws EventTimeoutException, IllegalArgumentException, IllegalStateException, IOException - { - return CoherentManagerConnection.sendEventGeneratingAction(action, timeout); - - } - - public void setVariable(Channel channel, String name, String value) throws PBXException - { - CoherentManagerConnection.getInstance().setVariable(channel, name, value); - - } - - public void sendActionNoWait(final ManagerAction action) - { - CoherentManagerConnection.sendActionNoWait(action); - - } - - public String getVariable(Channel channel, String name) - { - return CoherentManagerConnection.getInstance().getVariable(channel, name); - } - - public AsteriskVersion getVersion() - { - return CoherentManagerConnection.getInstance().getVersion(); - } - - public boolean isConnected() - { - return ((CoherentManagerConnection.managerConnection != null) - && (CoherentManagerConnection.managerConnection.getState() == ManagerConnectionState.CONNECTED)); - } - - public boolean isMeetmeInstalled() - { - return MeetmeRoomControl.getInstance().isMeetmeInstalled(); - } - - @Override - public boolean isChannel(String channelName) - { - boolean isChannel = false; - try - { - internalRegisterChannel(channelName, ChannelImpl.UNKNOWN_UNIQUE_ID); - isChannel = true; - } - catch (InvalidChannelName e) - { - // if we get here then its not avalid channel name. - } - return isChannel; - } - - static public String getSIPADDHeader(final boolean inherit, final boolean targetIsSIP) - { - String sipHeader = "SIPADDHEADER"; //$NON-NLS-1$ - if (!targetIsSIP || inherit) - { - sipHeader = "__" + sipHeader; //$NON-NLS-1$ - } - return sipHeader; - } - - /** - * Waits for a channel to become quiescent. A Quiescent channel is one that - * is not in the middle of a name change (e.g. masquerade) - * - * @param channel - * @param timeout the time to wait (in milliseconds) for the channel to - * become quiescent. - */ - @Override - public boolean waitForChannelsToQuiescent(List channels, long timeout) - { - - while (timeout > 0 && !channelsAreQuiesent(channels)) - { - try - { - Thread.sleep(200); - } - catch (InterruptedException e) - { - logger.error(e, e); - } - timeout -= 200; - } - - return timeout > 0; - } - - private boolean channelsAreQuiesent(List channels) - { - boolean ret = true; - for (Channel channel : channels) - { - ret &= channel.isQuiescent(); - } - return ret; - } - - public boolean moveChannelToAgi(Channel channel) throws PBXException - { - if (!waitForChannelToQuiescent(channel, 3000)) - throw new PBXException("Channel: " + channel + " cannot be transfered as it is still in transition."); - - boolean isInAgi = channel.isInAgi(); - if (!isInAgi) - { - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - channel.setCurrentActivityAction(new AgiChannelActivityHold()); - final RedirectAction redirect = new RedirectAction(channel, profile.getManagementContext(), getExtensionAgi(), - 1); - - logger.error("Issuing redirect on channel " + channel + " to move it to the agi"); - - try - { - final ManagerResponse response = sendAction(redirect, 1000); - if ((response != null) && (response.getResponse().compareToIgnoreCase("success") == 0))//$NON-NLS-1$ - { - int limit = 50; - while (!channel.isInAgi() && limit-- > 0) - { - Thread.sleep(100); - } - isInAgi = channel.isInAgi(); - if (!isInAgi) - { - logger.error("Failed to move channel"); - } - } - - } - catch (final Exception e) - { - logger.error(e, e); - } - - } - return isInAgi; - - } - - public void moveChannelTo(Channel channel, String context, String exten, int prio) - { - - DialPlanExtension ext = this.buildDialPlanExtension(exten); - - channel.setCurrentActivityAction(new AgiChannelActivityHold()); - final RedirectAction redirect = new RedirectAction(channel, context, ext, prio); - - try - { - sendAction(redirect, 1000); - - } - catch (final Exception e) - { - logger.error(e, e); - } - - } - - @Override - public boolean waitForChannelToQuiescent(Channel channel, int timeout) - { - List channels = new LinkedList<>(); - channels.add(channel); - return waitForChannelsToQuiescent(channels, timeout); - } - - public ChannelProxy getProxyById(String id) - { - return liveChannels.findProxyById(id); - } - - public DialToAgiActivityImpl dialToAgi(EndPoint endPoint, CallerID callerID, AgiChannelActivityHold action, - ActivityCallback iCallback) - { - - final CompletionAdaptor completion = new CompletionAdaptor<>(); - - final DialToAgiActivityImpl dialer = new DialToAgiActivityImpl(endPoint, callerID, false, completion, null, action); - - completion.waitForCompletion(3, TimeUnit.MINUTES); - - final ActivityStatusEnum status; - - if (dialer.isSuccess()) - { - status = ActivityStatusEnum.SUCCESS; - } - else - { - status = ActivityStatusEnum.FAILURE; - } - - iCallback.progress(dialer, status, status.getDefaultMessage()); - - return dialer; - } - - /** - * Creates the set of extensions required to test NJR during the - * installation. The context must already exist in the dialplan. - * - * @param profile - * @param dialContext - * @return - * @throws IllegalStateException - * @throws IOException - * @throws AuthenticationFailedException - * @throws TimeoutException - */ - public String createAgiEntryPoint() throws IOException, AuthenticationFailedException, TimeoutException - { - - try - { - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - AsteriskSettings profile = PBXFactory.getActiveProfile(); - - String agi = profile.getAgiExtension(); - pbx.addAsteriskExtension(agi, 1, "AGI(agi://127.0.0.1/activityAgi), into " + profile.getManagementContext()); - pbx.addAsteriskExtension(agi, 2, "wait(0.5), into " + profile.getManagementContext()); - pbx.addAsteriskExtension(agi, 3, "goto(" + agi + ",1), into " + profile.getManagementContext()); - - } - catch (Exception e) - { - logger.error(e); - - return e.getLocalizedMessage(); - } - return null; - - } - - public String addAsteriskExtension(String extNumber, int priority, String command) throws Exception - - { - String ext = "dialplan add extension " + extNumber + "," + priority + "," + command; - - CommandAction action = new CommandAction(ext); - CommandResponse response = (CommandResponse) sendAction(action, 30000); - - List line = response.getResult(); - String answer = line.get(0); - String tmp = "Extension '" + extNumber + "," + priority + ","; - if (answer.substring(0, tmp.length()).compareToIgnoreCase(tmp) == 0) - return "OK"; - - throw new Exception("InitiateAction.AddExtentionFailed" + ext); - } - - @Override - public Trunk buildTrunk(final String trunk) - { - return new Trunk() - { - - @Override - public String getTrunkAsString() - { - return trunk; - } - }; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/CallEndedListener.java b/src/main/java/org/asteriskjava/pbx/internal/core/CallEndedListener.java deleted file mode 100644 index 3071596cf..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/CallEndedListener.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -/** - * Used to notify a listener that a Call (CallTracker) has ended. - * - * This generally means the last channel has hungup. - * - * @author bsutton - * - */ -public interface CallEndedListener -{ - public void callEnded(CallTracker listener); - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/CallTracker.java b/src/main/java/org/asteriskjava/pbx/internal/core/CallTracker.java deleted file mode 100644 index 325267218..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/CallTracker.java +++ /dev/null @@ -1,210 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ChannelHangupListener; -import org.asteriskjava.pbx.asterisk.wrap.events.ChannelState; - -/** - * This is a fairly simple class which is used by a Peer to track what calls are - * live for the given Peer. - * - * It should be noted that the Peer must keep track of all calls regardless of - * whether they are associated with NJR. The reason for this is that a Peer - * needs to track the status of the associated endpoint so that it can show if a - * handset is on a call. In this way the operator can tell if a person is busy - * even before they call them. - * - * Essentially all this calls does is track the set of channels associated with - * a call. - * - * @author bsutton - * - */ -public class CallTracker implements ChannelHangupListener -{ - private static final Logger logger = Logger.getLogger(CallTracker.class); - - /** - * The list of channels associated with this call. - */ - ArrayList _associatedChannels = new ArrayList<>(); - - /** - * The state of this call. - */ - PeerState _state; - - private CallEndedListener listener; - - CallTracker(Peer peer, Channel initialChannel) - { - this._associatedChannels.add(initialChannel); - initialChannel.addHangupListener(this); - this.listener = peer; - - } - - /** - * Used to merge two calls into a single call. This is required as during a - * masquerade a new channel is created an initially we will create a - * CallTracker for it. When the masquerade event finally turns up we will - * realise it belongs to an existing CallTracker and as such we need to - * merge the two CallTrackers. - * - * @param rhs - */ - void mergeCalls(CallTracker rhs) - { - synchronized (this._associatedChannels) - { - for (Channel channel : rhs._associatedChannels) - this._associatedChannels.add(channel); - // not certain this is necessary but lets just tidy up a bit. - rhs._associatedChannels.clear(); - } - } - - public PeerState getState() - { - return this._state; - } - - /** - * @param s - */ - public void setState(final ChannelState channelState) - { - this._state = PeerState.valueByChannelState(channelState); - } - - public int findChannel(Channel newChannel) - { - int index = -1; - synchronized (this._associatedChannels) - { - - for (int i = 0; i < this._associatedChannels.size(); i++) - { - Channel channel = this._associatedChannels.get(i); - if (channel.isSame(newChannel)) - { - index = i; - break; - } - } - } - - return index; - } - - /** - * Remove a channel from the call. - * - * @param channel - */ - public void remove(Channel channel) - { - synchronized (this._associatedChannels) - { - int index = findChannel(channel); - if (index != -1) - { - if (logger.isDebugEnabled()) - logger.debug("CallTracker removing channel: " + this.toString() + " " + channel.getExtendedChannelName()); //$NON-NLS-1$ //$NON-NLS-2$ - - this._associatedChannels.remove(index); - } - } - - } - - public void startSweep() - { - synchronized (this._associatedChannels) - { - for (final Channel channel : this._associatedChannels) - { - ((ChannelProxy) channel).getRealChannel().startSweep(); - } - } - } - - public void endSweep() - { - final List toremove = new LinkedList<>(); - synchronized (this._associatedChannels) - { - for (final Channel channel : this._associatedChannels) - { - if (!((ChannelProxy) channel).getRealChannel().wasMarkedDuringSweep()) - { - toremove.add(channel); - logger.warn("removing channel " + this.hashCode() + " " + channel.getChannelName());//$NON-NLS-1$ //$NON-NLS-2$ - } - } - - this._associatedChannels.removeAll(toremove); - } - - // Now tell each of the channels it has been hungup - for (final Channel channel : toremove) - { - ((ChannelProxy) channel).getRealChannel().notifyHangupListeners(-1, - "Lingering channel probably due to missed hangup event"); - } - - } - - void dumpChannelList() - { - if (logger.isDebugEnabled()) - { - logger.debug("CallTracker: dump channellist:" + this); //$NON-NLS-1$ - synchronized (this._associatedChannels) - { - for (final Channel channel : this._associatedChannels) - { - logger.debug("--> " + channel.toString()); //$NON-NLS-1$ - } - } - } - } - - public boolean hasEnded() - { - synchronized (this._associatedChannels) - { - return this._associatedChannels.size() == 0; - } - } - - @Override - public void channelHangup(Channel channel, Integer cause, String causeText) - { - remove(channel); - synchronized (this._associatedChannels) - { - if (this._associatedChannels.size() == 0) - { - this._state = PeerState.NOTSET; - notifyCallEndedListener(); - } - } - } - - private void notifyCallEndedListener() - { - this.listener.callEnded(this); - } - - public String toString() - { - return this.listener + " : " + this._state; //$NON-NLS-1$ - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/ChannelImpl.java b/src/main/java/org/asteriskjava/pbx/internal/core/ChannelImpl.java deleted file mode 100644 index f63e94bea..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/ChannelImpl.java +++ /dev/null @@ -1,853 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.Date; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ChannelFactory; -import org.asteriskjava.pbx.ChannelHangupListener; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.TechType; - -/** - * TODO set the channel unique id when registering against an existing channel - * which doesn't have its unique id set.
- *
- * Create a single asterisk event source. All users of MyBaseEventCalls will - * become listeners to this class rather than talking to asterisk directly. Each - * listener will have events queued to it. It can process these events in a - * separate thread.
- *
- * Key feature is that one a 'rename' event arrives we must pause all of the - * queues wait for them to empty and for the queue clients to quiescent, then - * apply the rename before resuming pushing data in to the queues.
- *
- * Additionally we need to redo the asterisk events classes with our own classes - * that pass around an iChannel rather than a raw channel name. By doing this - * the rename affectively becomes global updating every instance of the channel - * (because they actually only have an instance handle). - * - * @author bsutton - */ -public class ChannelImpl implements Channel -{ - public static final String ZOMBIE = ""; //$NON-NLS-1$ - public static final String MASQ = ""; //$NON-NLS-1$ - - public static final String UNKNOWN_UNIQUE_ID = "-1"; //$NON-NLS-1$ - - private static Logger logger = Logger.getLogger(ChannelImpl.class); - private static int logCounter = 100; - - /** - * The channel name including the tech and the channel sequence number but - * not the masquerade prefix and not the zombie suffix. Forced to upper case - * for comparisons. - */ - private String _channelName; - - /** - * A unique id created by Asterisk to uniquely identify this channel. Often - * a channel can be 're-created' on the fly. In this case the channels name - * will be the same but the unique id will change. - */ - final private String _uniqueID; - /** - * This is an abbreviated form of the channel name obtained by removing - * everything after the '-' in the channel name. - */ - private EndPoint _endPoint; - - /** - * The caller id for this channel. If this is an inbound channel then it the - * callerid received from the remote end. If this is an outbound channel - * then this is the caller id we are to present to the remote end. - */ - private CallerID _callerID; - - /** - * A globally unique id assigned to each channel as it is created - */ - private long _channelId; - - private boolean _muted = false; - - private boolean _parked = false; - - private boolean _isZombie = false; - - /** - * A channel is live if it has not been hungup. - */ - private boolean _isLive = true; - - /** - * Indicates that the channel is being masquerading by another channel. - * Masqueraded channels have an extra suffix after the sequence - * number e.g. SIP/100-000009823 - */ - private boolean _isMasqueraded = false; - - /** - * Indicates that the channel is undergoing an action such as being parked. - * Action channels have an extra prefix before the tech e.g. - * Parked/SIP/100-000009823 - */ - private boolean _isInAction = false; - - /** - * Indicates that the channel has been originated directly from the Asterisk - * console. We can generally ignore these cases. - */ - private boolean _isConsole = false; - - /** - * The prefix added to a channel during some type of action: e.g. - * Parked/SIP/100-0000032323 In this case the prefix is Parked. - */ - private String _actionPrefix = null; - - public static final String[] _actions = new String[]{"PARKED/", "ASYNCGOTO/", "BRIDGE/"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - /** - * There should be only one hangup listener which is the ChannelProxy that - * wraps this channel. - */ - private ChannelHangupListener hangupListener; - - /** - * When validating channels the start time is set in the _sweepStartTime. as - * a channel is validated the _mark field is set to true. if new channels - * are created as the sweep is in progress the _sweepStartTime will not be - * set so they won't be cleaned up. - */ - private Long _sweepStartTime = null; - private boolean _marked = false; - - /** - * Creates a channel from a channelName
- *
- * This constructor is package private for a reason, and is called from - * AsteriskPBX... If you need to add a channel to the PBX do it like - * this
- *
- * AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX();
- * final Channel channel = pbx.registerChannel(channelName, uniqueId);
- *
- * Channel names are one of the following formats: - * [Action/]Tech/EndPointName-[][ ] - * DAHDI/i/[:]-
- *
- * Where: [Action/] is an action that is being performed on a channel. e.g. - * Parked Tech is the Tech used to reach the end point.
- *
- * The set of supported techs are defined by the enum Tech.
- *
- * EndPointName the name of the endpoint.
- *
- * '' the optional terminating '' which indicates the channel is - * now being masqueraded. A masqueraded channel is one that has been cloned. - * The original channel is marked as being masqueraded and will hangup - * shortly. It plays no further part in the Call.
- *
- * '' the optional terminating '' which indicates the - * channel is now a zombie. A zombie channel is one that has been hungup and - * is awaiting final cleanup. I believe the zombie channel is used by the - * hangup extension 'h' in the dialplan.
- *
- * The channel name is stripped of the Action, MASQ and ZOMBIE elements. - * - * @param asteriskStateName - * @throws InvalidChannelName - */ - ChannelImpl(final String channelName, final String uniqueID) throws InvalidChannelName - { - if (uniqueID == null) - throw new IllegalArgumentException("The UniqueID may not be null."); //$NON-NLS-1$ - - if (channelName == null) - throw new IllegalArgumentException("The channelName may not be null."); //$NON-NLS-1$ - - if (uniqueID.compareToIgnoreCase("-1") == 0) - { - logger.info("uniqueID is -1"); - } - - this._uniqueID = uniqueID; - - this.setChannelName(channelName); - - } - - /** - * designed for use by the ChannelProxy when a channel is being cloned as a - * result of Asterisk undertaking an Masquerade. This is not intended to be - * a complete clone just the key elements that we generally track on our - * side rather than getting directly from asterisk. - */ - public void masquerade(Channel channel) - { - // If the channel doesn't have a caller id - // preserve the existing one (as given this is a clone they should be - // identical). - // Asterisk doesn't always pass the caller ID on the channel hence this - // protects us from Asterisk accidentally clearing the caller id. - if (channel.hasCallerID()) - { - this._callerID = channel.getCallerID(); - } - else if (this._callerID != null && ((ChannelImpl) channel)._callerID != null) - { - // Force the caller id back into the channel so it has one as well. - PBX pbx = PBXFactory.getActivePBX(); - if (this._callerID != null) - { - ((ChannelImpl) channel)._callerID = pbx.buildCallerID(this._callerID.getNumber(), this._callerID.getName()); - } - } - - this._muted = channel.isMute(); - - this._parked = channel.isParked(); - - // just in case the original channel is part way through a sweep by the - // PeerMonitor - // marking the sweep as true will stop the new clone being hungup as it - // may not have been around when the sweep started. - this._marked = true; - this._sweepStartTime = null; - } - - private void setChannelName(final String channelName) throws InvalidChannelName - { - logger.info("Renamed channel from " + this._channelName + " to " + channelName); - this._channelName = this.cleanChannelName(channelName); - this.validateChannelName(this._channelName); - - this._channelId = ChannelFactory.getNextChannelId(); - this._endPoint = new EndPointImpl(this.extractPeerName(this._channelName)); - - // After stripping everything from the channel name after the hypen - // we should have the endpoint name which shouldn't match the - // channel name - // unless its a channel caused by a console dial (Console/dsp) which - // we don't really care about. - // If the peer name still matches then we have a malformed channel - // name. - if ((this._channelName.compareTo(this.getEndPoint().getFullyQualifiedName()) == 0) && !this._isConsole) - { - if (ChannelImpl.logCounter > 0) - { - ChannelImpl.logger.warn("Invalid channel name " + this._channelName); //$NON-NLS-1$ - ChannelImpl.logCounter--; - } - else if (ChannelImpl.logCounter == 0) - { - ChannelImpl.logger.warn("Further Invalid channel name warnings suppressed"); //$NON-NLS-1$ - ChannelImpl.logCounter--; - } - } - } - - @Override - public void rename(final String newName) throws InvalidChannelName - { - this.setChannelName(newName); - - } - - /** - * validates the channel name. Validate is to be called after the channel - * has been cleaned. - * - * @param channelName - * @throws InvalidChannelName - */ - private void validateChannelName(final String channelName) throws InvalidChannelName - { - if (!this._isConsole) - { - if (!TechType.hasValidTech(channelName)) - { - throw new InvalidChannelName("Invalid channelName: " + channelName + ". Unknown tech."); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Check we have the expected hypen - final int hypen = channelName.indexOf("-"); //$NON-NLS-1$ - if (hypen == -1) - { - throw new InvalidChannelName("Invalid channelName: " + channelName + ". Missing hypen."); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Check we have the expected slash - final int slash = channelName.indexOf("/"); //$NON-NLS-1$ - if (slash == -1) - { - throw new InvalidChannelName("Invalid channelName: " + channelName + ". Missing slash."); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Check that the hypen is after the slash. - if (hypen < slash) - { - throw new InvalidChannelName("Invalid channelName: " + channelName + ". Hypen must be after the slash."); //$NON-NLS-1$ //$NON-NLS-2$ - } - - // Check that there is at least one characters between the hypen and - // the - // slash - if ((hypen - slash) < 2) - { - throw new InvalidChannelName("Invalid channelName: " + channelName //$NON-NLS-1$ - + ". Must be one character between the hypen and the slash."); //$NON-NLS-1$ - } - - // Check that the channel sequence number is at least 1 character - // long. - if ((channelName.length() - hypen) < 2) - { - throw new InvalidChannelName("Invalid channelName: " + channelName //$NON-NLS-1$ - + ". The channel sequence number must be at least 1 character."); //$NON-NLS-1$ - } - } - - } - - /** - * Cleans up the channel name by applying the following: 1) trim any - * whitespace 2) convert to upper case for easy string comparisions 3) strip - * of the masquerade prefix if it exists and mark the channel as - * masquerading 4) strip the zombie suffix and mark it as being a zombie. - * - * @param name - * @return - */ - private String cleanChannelName(final String name) - { - String cleanedName = name.trim().toUpperCase(); - - // If if the channel is the console - this._isConsole = false; - if (name.compareToIgnoreCase("Console/dsp") == 0) //$NON-NLS-1$ - { - this._isConsole = true; - } - - // Check if the channel is in an action - boolean wasInAction = this._isInAction; - this._isInAction = false; - for (final String prefix : ChannelImpl._actions) - { - if (cleanedName.startsWith(prefix)) - { - this._isInAction = true; - this._actionPrefix = cleanedName.substring(0, prefix.length() - 1); - cleanedName = cleanedName.substring(prefix.length()); - break; - } - } - if (wasInAction != this._isInAction) - { - logger.info("Channel " + this + " : inaction status changed from " + wasInAction + " to " + this._isInAction); - } - - // Channels can be marked as in a zombie state - // so we need to strip of the zombie suffix and just mark the channel - // as a - // zombie. - this._isZombie = false; - if (cleanedName.contains(ChannelImpl.ZOMBIE)) - { - this._isZombie = true; - cleanedName = cleanedName.substring(0, cleanedName.indexOf(ChannelImpl.ZOMBIE)); - } - - // Channels can be marked as in a MASQ state - // This happens during transfers (and other times) when the channel is - // replaced - // by a new channel in the call. The old channel is renamed with the - // word - // added as a suffix. - this._isMasqueraded = false; - if (cleanedName.contains(ChannelImpl.MASQ)) - { - this._isMasqueraded = true; - cleanedName = cleanedName.substring(0, cleanedName.indexOf(ChannelImpl.MASQ)); - } - - return cleanedName; - } - - @Override - public String getChannelName() - { - return this._channelName; - } - - @Override - public EndPoint getEndPoint() - { - return this._endPoint; - } - - /* - * Extracts the peer name from a full channel name. The channel name is - * created by asterisk and consists of the peer name a hypen and a unique - * sequence number. e.g. SIP/100-000000123 * For SIP channels the Peer name - * is of the form: SIP/100 For dahdi channels the channel name is of the - * form: DAHDI/i/[:]-0000000123 With the peer name - * of the form: DAHDI/i/[:] - */ - private final String extractPeerName(final String channelName) - { - // Find the start of the sequence number - int channelNameEndPoint = channelName.lastIndexOf("-"); //$NON-NLS-1$ - if (channelNameEndPoint == -1) - { - channelNameEndPoint = channelName.length(); - } - // return the peer name which is everything before the sequence number - // (and its hypen). - return channelName.substring(0, channelNameEndPoint); - } - - boolean wasMarkedDuringSweep() - { - boolean ret = false; - if ((this._sweepStartTime == null) || (this._marked == true)) - { - this._sweepStartTime = null; - ret = true; - } - return ret; - } - - public void setCallerId(final CallerID callerId) - { - this._callerID = callerId; - } - - /** - * Used to start the Mark and Sweep process by setting the marked status to - * false. At the end of the sweep the marked flag should have been set to - * true. If not then this channel has been hungup. - */ - void startSweep() - { - this._sweepStartTime = new Date().getTime(); - this._marked = false; - } - - /** - * The channel was found to be active on asterisk so it is still alive. - */ - void markChannel() - { - this._marked = true; - - } - - /** - * ************************************************************************* - * ************************** The remaining methods are bridging methods to - * the new abstract PBX classes. - * ************************************************************************* - * ************************** - */ - @Override - public boolean isSame(final Channel _rhs) - { - boolean equals = false; - - if (_rhs == null) - { - logger.warn("isSame called with null"); - return false; - } - ChannelImpl rhs; - if (_rhs instanceof ChannelImpl) - { - rhs = (ChannelImpl) _rhs; - } - else - { - rhs = ((ChannelProxy) _rhs).getRealChannel(); - } - // If we have unique id's for both channels then we can compare the id's - // directly. - if ((this._uniqueID.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0) - && (rhs._uniqueID.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0)) - { - if (this._uniqueID.compareToIgnoreCase(rhs._uniqueID) == 0) - { - equals = true; - } - } - else - { - boolean ok = (this._channelName != null) && (rhs._channelName != null); - final boolean namesMatch = (ok && (this._channelName.compareToIgnoreCase(rhs._channelName) == 0)); - - if (namesMatch) - { - // check if the actions match - if (this._isInAction != rhs._isInAction) - { - ok = false; - } - else if (this._isInAction) - { - ok = this._actionPrefix.compareTo(rhs._actionPrefix) == 0; - } - } - - if (ok && namesMatch) - { - // check if the zombie match - if (this._isZombie != rhs._isZombie) - { - ok = false; - } - } - - if (ok && namesMatch) - { - // check if the masquerade match - if (this._isMasqueraded != rhs._isMasqueraded) - { - ok = false; - } - } - - equals = ok & namesMatch; - } - return equals; - } - - @Override - public boolean isSame(final String extendedChannelName, final String uniqueID) - { - boolean equals = false; - if ((this._uniqueID.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0) - && (uniqueID.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0)) - { - if (this._uniqueID.compareTo(uniqueID) == 0) - { - equals = true; - } - } - else - { - equals = this.sameExtenededChannelName(extendedChannelName); - } - - return equals; - } - - @Override - public boolean sameExtenededChannelName(final String extendedChannelName) - { - boolean ok = (this.getExtendedChannelName() != null) && (extendedChannelName != null); - - return ok && (this.getExtendedChannelName().compareToIgnoreCase(extendedChannelName) == 0); - } - - /** - * Try to match a channel based solely on its unique ID - * - * @param uniqueID - * @return - */ - public boolean sameUniqueID(String uniqueID) - { - boolean equals = false; - if ((this._uniqueID.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0) - && (uniqueID.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0)) - { - if (this._uniqueID.compareTo(uniqueID) == 0) - { - equals = true; - } - } - - return equals; - } - - @Override - public boolean sameEndPoint(final Channel rhs) - { - return this.sameEndPoint(rhs.getEndPoint()); - } - - @Override - public boolean sameEndPoint(final EndPoint rhs) - { - boolean ok = (this._endPoint != null) && (rhs != null); - return ok && this._endPoint.isSame(rhs); - } - - @Override - public long getChannelId() - { - return this._channelId; - } - - @Override - public boolean isLive() - { - return this._isLive; - } - - @Override - public void addHangupListener(final ChannelHangupListener listener) - { - if (this.hangupListener != null) - throw new IllegalStateException("This channel may only have ONE listener which should be its ChannelProxy"); //$NON-NLS-1$ - - this.hangupListener = listener; - } - - @Override - public void removeListener(final ChannelHangupListener listener) - { - - if (this.hangupListener != listener) - throw new IllegalStateException("An invalid attempt was made to remove a non-existant listener."); //$NON-NLS-1$ - - this.hangupListener = null; - - } - - /** - * Called by Peer when we have been hungup. This can happen when Peer - * receives a HangupEvent or during a periodic sweep done by PeerMonitor to - * find the status of all channels. Notify any listeners that this channel - * has been hung up. - */ - @Override - public void notifyHangupListeners(Integer cause, String causeText) - { - this._isLive = false; - if (this.hangupListener != null) - { - this.hangupListener.channelHangup(this, cause, causeText); - } - else - { - logger.warn("Hangup listener is null"); - } - } - - @Override - public boolean isConnectedTo(final EndPoint endPoint) - { - return this._endPoint.isSame(endPoint); - } - - @Override - public boolean isMute() - { - return this._muted; - } - - @Override - public void setMute(final boolean mutedState) - { - this._muted = mutedState; - } - - @Override - public void setParked(final boolean parked) - { - this._parked = parked; - - } - - @Override - public boolean isParked() - { - return this._parked; - } - - @Override - public String toString() - { - return this.getExtendedChannelName() + ":" + this._uniqueID; //$NON-NLS-1$ - } - - /** - * Returns the full channel name including the masquerade prefix and the - * zombie suffix. - * - * @return - */ - @Override - public String getExtendedChannelName() - { - final StringBuilder name = new StringBuilder(); - - if (this._isInAction) - { - name.append(this._actionPrefix); - name.append("/"); //$NON-NLS-1$ - } - name.append(this._channelName); - - if (this._isMasqueraded) - { - name.append(ChannelImpl.MASQ); - } - - if (this._isZombie) - { - name.append(ChannelImpl.ZOMBIE); - } - - return name.toString(); - - } - - @Override - public boolean isLocal() - { - return this._endPoint.isLocal(); - } - - @Override - public boolean isZombie() - { - return this._isZombie; - } - - @Override - public boolean isConsole() - { - return this._isConsole; - } - - TechType getTech() - { - return this._endPoint.getTech(); - } - - /** - * Returns the actionPrefix for the channel or an empty string if the - * channel is not doing an action. - * - * @return - */ - String getActionPrefix() - { - return this._isInAction ? this._actionPrefix : ""; //$NON-NLS-1$ - } - - boolean isInAction() - { - return this._isInAction; - } - - boolean isMasqueraded() - { - return this._isMasqueraded; - } - - @Override - public boolean hasCallerID() - { - return this._callerID != null && !this._callerID.isUnknown(); - } - - @Override - public CallerID getCallerID() - { - if (this._callerID == null) - { - final CoherentManagerConnection smc = CoherentManagerConnection.getInstance(); - final String number = smc.getVariable(this, "CALLERID(number)"); //$NON-NLS-1$ - final String name = smc.getVariable(this, "CALLERID(name)"); //$NON-NLS-1$ - final PBX pbx = PBXFactory.getActivePBX(); - this._callerID = pbx.buildCallerID(number, name); - } - - return this._callerID; - - } - - @Override - public String getUniqueId() - { - return this._uniqueID; - } - - /* - * Returns true if this channel can detect hangups A SIP channel can always - * detect a hangup if its not channel then we need to check the profile to - * see if hangup detection is available. Hangup detection is important as we - * don't want to connect two channels both of which can't do hangup - * detection. If this happened then we would end up with a call which would - * never hangup. - */ - @Override - public boolean canDetectHangup() - { - boolean canDetectHangup = true; - - AsteriskSettings profile = PBXFactory.getActiveProfile(); - final boolean detect = profile.getCanDetectHangup(); - if (!this.getEndPoint().isSIP() && !detect) - { - canDetectHangup = false; - } - return canDetectHangup; - } - - /** - * Returns true if the channel is quiescent. A quescent channel is one that - * is current not going through a transition (name change) such as MASQ, - * ZOMBIE, ASYNC, PARK - * - * @return - */ - @Override - public boolean isQuiescent() - { - return !(_isInAction || _isMasqueraded || _isZombie); - } - - @Override - public AgiChannelActivityAction getCurrentActivityAction() - { - throw new RuntimeException("This method is only implemented in ChannelProxy"); - } - - @Override - public void setCurrentActivityAction(AgiChannelActivityAction action) - { - throw new RuntimeException("This method is only implemented in ChannelProxy"); - } - - @Override - public void setIsInAgi(boolean b) - { - throw new RuntimeException("This method is only implemented in ChannelProxy"); - } - - @Override - public boolean isInAgi() - { - throw new RuntimeException("This method is only implemented in ChannelProxy"); - } - - @Override - public boolean waitForChannelToReachAgi(long timeout, TimeUnit timeunit) throws InterruptedException - { - throw new RuntimeException("This method is only implemented in ChannelProxy"); - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/ChannelProxy.java b/src/main/java/org/asteriskjava/pbx/internal/core/ChannelProxy.java deleted file mode 100644 index 22ae2caf0..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/ChannelProxy.java +++ /dev/null @@ -1,394 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ChannelHangupListener; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.agi.AgiChannelActivityHold; - -/** - * The ChannelProxy exists to deal with the fact that Asterisk will often - * replace a channel during a call. This is referred to as Masquerading. When a - * channel is to be Masqueraded we get a Masquerade event. The ChannelProxy - * class acts as a level of indirection for an iChannel. Rather than holding an - * iChannel directly you can instead hold a ChannelProxy. If the underlying - * iChannel is replaced the ChannelProxy will be updated with the new iChannel. - * - * @author bsutton - */ -public class ChannelProxy implements Channel, ChannelHangupListener -{ - - private static final Logger logger = Logger.getLogger(ChannelProxy.class); - - /** - * We give each proxy a unique identity to help track them when debugging. - */ - private static final AtomicInteger _nextIdentity = new AtomicInteger(); - - private int _identity = _nextIdentity.incrementAndGet(); - - private ChannelImpl _channel; - - private List listeners = new CopyOnWriteArrayList<>(); - - public ChannelProxy(ChannelImpl channel) - { - this._channel = channel; - currentActivityAction.set(new AgiChannelActivityHold()); - - channel.addHangupListener(this); - - } - - /** - * returns the current channel - * - * @return - */ - public Channel getChannel() - { - return this._channel; - } - - @Override - public boolean isSame(Channel rhs) - { - return this._channel.isSame(rhs); - } - - @Override - public boolean isSame(String extendedChannelName, String uniqueID) - { - return this._channel.isSame(extendedChannelName, uniqueID); - } - - public boolean sameUniqueID(String uniqueID) - { - return this._channel.sameUniqueID(uniqueID); - } - - @Override - public boolean sameEndPoint(Channel rhs) - { - return this._channel.sameEndPoint(rhs); - } - - @Override - public boolean sameEndPoint(EndPoint extensionRoaming) - { - return this._channel.sameEndPoint(extensionRoaming); - } - - @Override - public boolean sameExtenededChannelName(String channelName) - { - return this._channel.sameExtenededChannelName(channelName); - } - - @Override - public void setParked(boolean parked) - { - this._channel.setParked(parked); - } - - @Override - public void setMute(boolean muteState) - { - this._channel.setMute(muteState); - - } - - @Override - public long getChannelId() - { - return this._channel.getChannelId(); - } - - @Override - public boolean isLive() - { - return this._channel.isLive(); - } - - @Override - public void addHangupListener(ChannelHangupListener listener) - { - this.listeners.add(listener); - - } - - @Override - public void removeListener(ChannelHangupListener listener) - { - this.listeners.remove(listener); - - } - - @Override - public boolean isConnectedTo(EndPoint endPoint) - { - return this._channel.isConnectedTo(endPoint); - } - - @Override - public String getChannelName() - { - return this._channel.getChannelName(); - } - - @Override - public EndPoint getEndPoint() - { - return this._channel.getEndPoint(); - } - - @Override - public boolean isMute() - { - return this._channel.isMute(); - } - - @Override - public boolean isLocal() - { - return this._channel.isLocal(); - } - - @Override - public boolean isZombie() - { - return this._channel.isZombie(); - } - - @Override - public boolean isConsole() - { - return this._channel.isConsole(); - } - - @Override - public CallerID getCallerID() - { - return this._channel.getCallerID(); - } - - @Override - public void rename(String newName) throws InvalidChannelName - { - this._channel.rename(newName); - } - - @Override - public boolean isParked() - { - return this._channel.isParked(); - } - - /** - * Used to handle a MasqueradeEvent. We essentially swap the two underlying - * channels between the two proxies. - * - * @param cloneProxy - * @throws InvalidChannelName - */ - public void masquerade(ChannelProxy cloneProxy) throws InvalidChannelName - { - ChannelImpl originalChannel = this._channel; - ChannelImpl cloneChannel = cloneProxy._channel; - - cloneChannel.masquerade(this._channel); - - // detach the hangup listeners - originalChannel.removeListener(this); - cloneChannel.removeListener(cloneProxy); - - // Now we swap the channels. - this._channel = cloneChannel; - cloneProxy._channel = originalChannel; - - // Now re-attach the hangup listeners - this._channel.addHangupListener(this); - cloneProxy._channel.addHangupListener(cloneProxy); - - logger.info(originalChannel + " Channel proxy now points to " + this._channel); - } - - public ChannelImpl getRealChannel() - { - return this._channel; - } - - @Override - public String getExtendedChannelName() - { - return this._channel.getExtendedChannelName(); - } - - @Override - public void notifyHangupListeners(Integer cause, String causeText) - { - for (ChannelHangupListener listener : this.listeners) - { - listener.channelHangup(this, cause, causeText); - } - - } - - @Override - public String toString() - { - return "(proxy=" + this._identity + ") " + this._channel.toString(); //$NON-NLS-1$ //$NON-NLS-2$ - } - - @Override - public void channelHangup(Channel channel, Integer cause, String causeText) - { - // When the underlying channel hangs up we need to notify all of the - // proxy listeners. - if (channel == this._channel) - notifyHangupListeners(cause, causeText); - - } - - @Override - public boolean canDetectHangup() - { - return this._channel.canDetectHangup(); - } - - @Override - public boolean isQuiescent() - { - return this._channel.isQuiescent(); - } - - @Override - public boolean hasCallerID() - { - return this._channel.hasCallerID(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + _identity; - return result; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (!(obj instanceof ChannelProxy)) - { - return false; - } - ChannelProxy other = (ChannelProxy) obj; - if (_identity != other._identity) - { - return false; - } - return true; - } - - private AtomicReference currentActivityAction = new AtomicReference<>(); - volatile private boolean isInAgi; - - @Override - public AgiChannelActivityAction getCurrentActivityAction() - { - return currentActivityAction.get(); - } - - @Override - public void setCurrentActivityAction(AgiChannelActivityAction action) - { - AgiChannelActivityAction previousAction = currentActivityAction.get(); - - logger.info("Setting action to " + action.getClass().getSimpleName() + " for " + this); - - // Exception e = new Exception("Setting action to " + - // action.getClass().getSimpleName() + " for " + this); - // logger.warn(e, e); - - currentActivityAction.set(action); - if (previousAction != null) - { - // when we cancel the previous action, the new one will be invoked - previousAction.cancel(this); - } - } - - @Override - public void setIsInAgi(boolean b) - { - if (b) - { - hasReachedAgi.countDown(); - } - isInAgi = b; - logger.info("Setting is in agi to " + b + " for channel " + this); - - } - - @Override - public boolean isInAgi() - { - return isInAgi; - } - - final CountDownLatch hasReachedAgi = new CountDownLatch(1); - - @Override - public boolean waitForChannelToReachAgi(long timeout, TimeUnit timeunit) throws InterruptedException - { - return hasReachedAgi.await(timeout, timeunit); - } - - @Override - public String getUniqueId() - { - return _channel.getUniqueId(); - } - - public int getIdentity() - { - return _identity; - } - - @Override - public void setCallerId(CallerID callerId) - { - _channel.setCallerId(callerId); - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentEventFactory.java b/src/main/java/org/asteriskjava/pbx/internal/core/CoherentEventFactory.java deleted file mode 100644 index ef9c94bbd..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentEventFactory.java +++ /dev/null @@ -1,261 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Hashtable; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.asterisk.wrap.actions.ManagerAction; -import org.asteriskjava.pbx.asterisk.wrap.events.AgentCalledEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.AgentConnectEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.BridgeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ConfbridgeListCompleteEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ConfbridgeListEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ConnectEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.DialEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.DisconnectEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.DndStateEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ExtensionStatusEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.LinkEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MasqueradeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MeetMeJoinEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MeetMeLeaveEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewChannelEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewStateEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.OriginateResponseEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ParkedCallEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.PeerEntryEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.PeerStatusEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.PeerlistCompleteEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.QueueCallerLeaveEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.RenameEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ResponseEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusCompleteEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.UnlinkEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.UnparkedCallEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.VarSetEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.CommandResponse; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerError; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; - -/** - * This class maps asterisk-java events to our internal events that use iChannel - * rather than raw channel names. - * - * @author bsutton - */ -@SuppressWarnings("deprecation") -public class CoherentEventFactory -{ - private static final Logger logger = Logger.getLogger(CoherentEventFactory.class); - - // Events - static Hashtable, Class< ? extends ManagerEvent>> mapEvents = new Hashtable<>(); - - // Response - static Hashtable, Class< ? extends ResponseEvent>> mapResponses = new Hashtable<>(); - - // Actions - // static Hashtable, Class> mapActions = new - // Hashtable<>(); - - // static initialiser - static - { - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.AgentCalledEvent.class, AgentCalledEvent.class); - - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.AgentConnectEvent.class, AgentConnectEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.QueueCallerLeaveEvent.class, - QueueCallerLeaveEvent.class); - - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.BridgeEvent.class, BridgeEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.ConnectEvent.class, ConnectEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.DialEvent.class, DialEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.DisconnectEvent.class, DisconnectEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.DndStateEvent.class, DndStateEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.ExtensionStatusEvent.class, - ExtensionStatusEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.HangupEvent.class, HangupEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.LinkEvent.class, LinkEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.MasqueradeEvent.class, MasqueradeEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.MeetMeJoinEvent.class, MeetMeJoinEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.MeetMeLeaveEvent.class, MeetMeLeaveEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.NewChannelEvent.class, NewChannelEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.NewStateEvent.class, NewStateEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.ParkedCallEvent.class, ParkedCallEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.PeerStatusEvent.class, PeerStatusEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.RenameEvent.class, RenameEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.ResponseEvent.class, ResponseEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.UnlinkEvent.class, UnlinkEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.UnparkedCallEvent.class, UnparkedCallEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.VarSetEvent.class, VarSetEvent.class); - - // response events - CoherentEventFactory.mapResponses.put(org.asteriskjava.manager.event.OriginateResponseEvent.class, - OriginateResponseEvent.class); - CoherentEventFactory.mapResponses.put(org.asteriskjava.manager.event.PeerEntryEvent.class, PeerEntryEvent.class); - CoherentEventFactory.mapResponses.put(org.asteriskjava.manager.event.PeerlistCompleteEvent.class, - PeerlistCompleteEvent.class); - CoherentEventFactory.mapResponses.put(org.asteriskjava.manager.event.ResponseEvent.class, ResponseEvent.class); - CoherentEventFactory.mapResponses.put(org.asteriskjava.manager.event.StatusCompleteEvent.class, - StatusCompleteEvent.class); - CoherentEventFactory.mapResponses.put(org.asteriskjava.manager.event.StatusEvent.class, StatusEvent.class); - - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.ConfbridgeListEvent.class, - ConfbridgeListEvent.class); - CoherentEventFactory.mapEvents.put(org.asteriskjava.manager.event.ConfbridgeListCompleteEvent.class, - ConfbridgeListCompleteEvent.class); - - // Actions - // CoherentEventFactory.mapActions.put( BridgeAction.class, - // org.asteriskjava.manager.action.BridgeAction.class); - // CoherentEventFactory.mapActions.put( CommandAction.class, - // org.asteriskjava.manager.action.CommandAction.class); - // CoherentEventFactory.mapActions.put( DbGetAction.class, - // org.asteriskjava.manager.action.DbGetAction.class); - // CoherentEventFactory.mapActions.put( GetVarAction.class, - // org.asteriskjava.manager.action.GetVarAction.class); - // CoherentEventFactory.mapActions.put( HangupAction.class, - // org.asteriskjava.manager.action.HangupAction.class); - // CoherentEventFactory.mapActions.put( ListCommandsAction.class, - // org.asteriskjava.manager.action.ListCommandsAction.class); - // CoherentEventFactory.mapActions.put( MonitorAction.class, - // org.asteriskjava.manager.action.MonitorAction.class); - // CoherentEventFactory.mapActions.put( MuteAudioAction.class, - // org.asteriskjava.manager.action.MuteAudioAction.class); - // CoherentEventFactory.mapActions.put( OriginateAction.class, - // org.asteriskjava.manager.action.OriginateAction.class); - // CoherentEventFactory.mapActions.put( PingAction.class, - // org.asteriskjava.manager.action.PingAction.class); - // CoherentEventFactory.mapActions.put( PlayDtmfAction.class, - // org.asteriskjava.manager.action.PlayDtmfAction.class); - // CoherentEventFactory.mapActions.put( RedirectAction.class, - // org.asteriskjava.manager.action.RedirectAction.class); - // CoherentEventFactory.mapActions.put( SetVarAction.class, - // org.asteriskjava.manager.action.SetVarAction.class); - // CoherentEventFactory.mapActions.put( SipPeersAction.class, - // org.asteriskjava.manager.action.SipPeersAction.class); - // CoherentEventFactory.mapActions.put( SipShowPeerAction.class, - // org.asteriskjava.manager.action.SipShowPeerAction.class); - // CoherentEventFactory.mapActions.put( StatusAction.class, - // org.asteriskjava.manager.action.StatusAction.class); - // CoherentEventFactory.mapActions.put( UpdateConfigAction.class, - // org.asteriskjava.manager.action.UpdateConfigAction.class); - - } - - public static Class< ? extends ManagerEvent> getShadowEvent(org.asteriskjava.manager.event.ManagerEvent event) - { - Class< ? extends ManagerEvent> result = CoherentEventFactory.mapEvents.get(event.getClass()); - if (result == null) - { - Class< ? extends ResponseEvent> response = CoherentEventFactory.mapResponses.get(event.getClass()); - result = response; - } - - return result; - - } - - public static ManagerEvent build(final org.asteriskjava.manager.event.ManagerEvent event) - { - ManagerEvent iEvent = null; - - Class< ? extends ManagerEvent> target = null; - - if (event instanceof org.asteriskjava.manager.event.ResponseEvent) - target = CoherentEventFactory.mapResponses.get(event.getClass()); - else - target = CoherentEventFactory.mapEvents.get(event.getClass()); - - if (target == null) - { - logger.warn("The given event " + event.getClass().getName() + " is not supported "); //$NON-NLS-1$ //$NON-NLS-2$ - } - else - { - - try - { - iEvent = target.getDeclaredConstructor(event.getClass()).newInstance(event); - } - catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) - { - CoherentEventFactory.logger.error(e, e); - - } - } - return iEvent; - } - - public static ResponseEvent build(org.asteriskjava.manager.event.ResponseEvent event) - { - ResponseEvent response = null; - - final Class< ? extends ResponseEvent> target = CoherentEventFactory.mapResponses.get(event.getClass()); - - if (target == null) - { - logger.warn("The given event " + event.getClass().getName() + " is not supported "); //$NON-NLS-1$ //$NON-NLS-2$ - } - else - { - - try - { - final Constructor< ? extends ResponseEvent> declaredConstructor = target - .getDeclaredConstructor(event.getClass()); - response = declaredConstructor.newInstance(event); - } - catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) - { - CoherentEventFactory.logger.error(e, e); - - } - } - return response; - } - - public static ManagerResponse build(org.asteriskjava.manager.response.ManagerResponse response) - { - ManagerResponse result; - if (response instanceof org.asteriskjava.manager.response.CommandResponse) - result = new CommandResponse((org.asteriskjava.manager.response.CommandResponse) response); - else if (response instanceof org.asteriskjava.manager.response.ManagerError) - result = new ManagerError((org.asteriskjava.manager.response.ManagerError) response); - else - result = new ManagerResponse(response); - return result; - - } - - public static org.asteriskjava.manager.action.ManagerAction build(ManagerAction action) - { - org.asteriskjava.manager.action.ManagerAction result = null; - - // final Class - // target = CoherentEventFactory.mapActions.get(action.getClass()); - - if (logger.isDebugEnabled()) - logger.debug("Action " + action); //$NON-NLS-1$ - - // if (target == null) - // { - // logger.warn("The given action " + action.getClass().getName() + " is - // not supported "); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // else - { - result = action.getAJAction(); - } - return result; - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerConnection.java b/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerConnection.java deleted file mode 100644 index bacc6d4b5..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerConnection.java +++ /dev/null @@ -1,631 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.io.IOException; -import java.net.InetAddress; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import javax.naming.OperationNotSupportedException; - -import org.apache.log4j.Logger; -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.EventTimeoutException; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerConnectionState; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.EventGeneratingAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.GetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.ListCommandsAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.ManagerAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.SetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.events.ConnectEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.DisconnectEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ResponseEvents; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.managerAPI.Connector; - -/** - * This is a wrapper class for the asterisk manager.
- *
- * It handles the hot swap of an asterisk server and distributes events to event - * listeners.
- *
- * The CoherentManagerConnection should be used whenever manager events need to - * be received either for short or extended periods of time.
- *
- * The CoherentManagerConnection uses the ManagerEventQueue to queue events to - * each listener.
- *
- * The ManagerEventQueue dispatches the events to the set of listeners using a - * separate thread (shared by all of the listeners).
- *
- * This means that we are always responsive to asterisk when receiving events, - * if we are not responsive then asterisk will drop the connection.
- *
- * It should be noted that as all events are dispatch from a single thread and as such - * a single tardy listener can block all other listeners.
- *
- * If your listener is likely to be slow in handling events then you should wrap - * the listener in its own ManagerEventQueue.
- *
- * It is critical that you use the ManagerEventQueue as it forms an intrinsic - * part of this classes ability to ensure that channel/event processing is - * coherent (i.e events are processed in the correct order).
- *
- * For connections that generate large number of events you should use - * - * @see org.asteriskjava.pbx.internal.core.CoherentManagerEventQueue Note: - * events for any action are distributed to all listeners! - */ -class CoherentManagerConnection implements FilteredManagerListener -{ - - static private Logger logger = Logger.getLogger(CoherentManagerConnection.class); - - static Map eventStatistics = new HashMap<>(); - - /** - * Used to instantiate the manager connection including the initial login. - */ - static Connector connector = null; - - /** - * The actual manager connection. AJ actually maintains two socket - * connections one for reading events and the other writing events. - */ - static ManagerConnection managerConnection = null; - - /** - * We operate two separate event queues each of which dispatches events via - * its own thread. All ListenerPriority.REALTIME events are dispatch via the - * realtime queue. REALTIME events cannot rely on the LiveChannelManager as - * it will may have been updated (renames, masquerades) when the realtime - * listener processes its event. - */ - private CoherentManagerEventQueue eventQueue; - - private CoherentManagerEventQueue realtimeEventQueue; - - // private List> realtimeListeners = - // new CopyOnWriteArrayList<>(); - - // True if the AMI function 'Bridge' is available. - private boolean canBridge; - - // True if the AMI function 'MuteAudio' is available. - private boolean canMuteAudio; - - private static CoherentManagerConnection self = null; - - // latch used for reconnections. - // We create an initial latch incase we get connect before we are really - // ready to wait for one. - private CountDownLatch _reconnectLatch = new CountDownLatch(0); - - public static synchronized void init() - throws IllegalStateException, IOException, AuthenticationFailedException, TimeoutException - { - if (self != null) - logger.warn("The CoherentManagerConnection has already been initialised"); //$NON-NLS-1$ - else - { - self = new CoherentManagerConnection(); - self.checkFeatures(); - } - - self.checkConnection(); - } - - public static void reset() - { - self = null; - } - - public static synchronized CoherentManagerConnection getInstance() - { - if (self == null) - throw new IllegalStateException("The CoherentManagerConnection has not been initialised"); //$NON-NLS-1$ - - self.checkConnection(); - - return self; - } - - private CoherentManagerConnection() - throws IllegalStateException, IOException, AuthenticationFailedException, TimeoutException - { - super(); - connector = new Connector(); - this.configureConnection(); - } - - public AsteriskVersion getVersion() throws IllegalStateException - { - return CoherentManagerConnection.managerConnection.getVersion(); - } - - public void setVariable(final Channel channel, final String variableName, final String value) throws PBXException - { - try - { - /* - * Sets the specified variable on the specified channel to the - * specified value. - */ - final SetVarAction setVariable = new SetVarAction(channel, variableName, value); - ManagerResponse response; - - PBX pbx = PBXFactory.getActivePBX(); - if (!pbx.waitForChannelToQuiescent(channel, 3000)) - throw new PBXException("Channel: " + channel + " cannot be retrieved as it is still in transition."); - - response = sendAction(setVariable, 500); - if ((response != null) && (response.getResponse().compareToIgnoreCase("success") == 0)) //$NON-NLS-1$ - { - // $NON-NLS-1$ - - CoherentManagerConnection.logger.debug("set variable " + variableName + " to " + value //$NON-NLS-1$ //$NON-NLS-2$ - + " on " + channel); //$NON-NLS-1$ - } - else - { - throw new PBXException("failed to set variable '" + variableName + "' on channel " + channel + " to '" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - + value + "'" + (response != null ? " Error:" + response.getMessage() : "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - logger.error(e, e); - throw new PBXException(e); - - } - - } - - /** - * Retrieves and returns the value of a variable associated with a channel. - * If the variable is empty or null then an empty string is returned. - * - * @param channel - * @param variableName - * @return - */ - public String getVariable(final Channel channel, final String variableName) - { - String value = ""; - final GetVarAction var = new GetVarAction(channel, variableName); - - try - { - PBX pbx = PBXFactory.getActivePBX(); - if (!pbx.waitForChannelToQuiescent(channel, 3000)) - throw new PBXException("Channel: " + channel + " cannot be retrieved as it is still in transition."); - - ManagerResponse convertedResponse = sendAction(var, 500); - if (convertedResponse != null) - { - value = convertedResponse.getAttribute("value"); //$NON-NLS-1$ - if (value == null) - value = ""; - CoherentManagerConnection.logger.debug("getVarAction returned name:" + variableName + " value:" + value); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - catch (final Exception e) - { - CoherentManagerConnection.logger.debug(e, e); - CoherentManagerConnection.logger.error("getVariable: " + e); //$NON-NLS-1$ - } - return value; - } - - /** - * Allows the caller to send an action to asterisk without waiting for the - * response. You should only use this if you don't care whether the action - * actually succeeds. - * - * @param sa - */ - public static void sendActionNoWait(final ManagerAction action) - { - final Thread background = new Thread() - { - @Override - public void run() - { - try - { - CoherentManagerConnection.sendAction(action, 5000); - } - catch (final Exception e) - { - CoherentManagerConnection.logger.error(e, e); - } - } - }; - background.setName("sendActionNoWait"); //$NON-NLS-1$ - background.setDaemon(true); - background.start(); - } - - public static ResponseEvents sendEventGeneratingAction(EventGeneratingAction action) - throws EventTimeoutException, IllegalArgumentException, IllegalStateException, IOException - { - org.asteriskjava.manager.ResponseEvents events = CoherentManagerConnection.managerConnection - .sendEventGeneratingAction(action.getAJEventGeneratingAction()); - - ResponseEvents convertedEvents = new ResponseEvents(); - for (org.asteriskjava.manager.event.ResponseEvent event : events.getEvents()) - { - convertedEvents.add(CoherentEventFactory.build(event)); - } - return convertedEvents; - - } - - public static ResponseEvents sendEventGeneratingAction(EventGeneratingAction action, int timeout) - throws EventTimeoutException, IllegalArgumentException, IllegalStateException, IOException - { - org.asteriskjava.manager.ResponseEvents events = CoherentManagerConnection.managerConnection - .sendEventGeneratingAction(action.getAJEventGeneratingAction(), timeout); - - ResponseEvents convertedEvents = new ResponseEvents(); - for (org.asteriskjava.manager.event.ResponseEvent event : events.getEvents()) - { - convertedEvents.add(CoherentEventFactory.build(event)); - } - return convertedEvents; - - } - - /** - * Sends an Asterisk action and waits for a ManagerRespose. - * - * @param action - * @param timeout timeout in milliseconds - * @return - * @throws IllegalArgumentException - * @throws IllegalStateException - * @throws IOException - * @throws TimeoutException - * @throws OperationNotSupportedException - */ - public static ManagerResponse sendAction(final ManagerAction action, final int timeout) - throws IllegalArgumentException, IllegalStateException, IOException, TimeoutException - { - if (logger.isDebugEnabled()) - CoherentManagerConnection.logger.debug("Sending Action: " + action.toString()); //$NON-NLS-1$ - - CoherentManagerConnection.getInstance(); - if ((CoherentManagerConnection.managerConnection != null) - && (CoherentManagerConnection.managerConnection.getState() == ManagerConnectionState.CONNECTED)) - { - final org.asteriskjava.manager.action.ManagerAction ajAction = action.getAJAction(); - - org.asteriskjava.manager.response.ManagerResponse response = CoherentManagerConnection.managerConnection - .sendAction(ajAction, timeout); - ManagerResponse convertedResponse = null; - - // UserEventActions always return a null - if (response != null) - convertedResponse = CoherentEventFactory.build(response); - - if ((convertedResponse != null) && (convertedResponse.getResponse().compareToIgnoreCase("Error") == 0))//$NON-NLS-1$ - { - CoherentManagerConnection.logger.warn("Action '" + ajAction + "' failed, Response: " //$NON-NLS-1$ //$NON-NLS-2$ - + convertedResponse.getResponse() + " Message: " + convertedResponse.getMessage()); //$NON-NLS-1$ - } - return convertedResponse; - } - - throw new IllegalStateException("not connected."); //$NON-NLS-1$ - } - - private void checkConnection() - { - int trys = 3; - - this._reconnectLatch = new CountDownLatch(1); - while ((trys > 0) && ((CoherentManagerConnection.managerConnection == null) - || (CoherentManagerConnection.managerConnection.getState() != ManagerConnectionState.CONNECTED))) - { - if (trys == 3) - { - CoherentManagerConnection.logger.warn("Awaiting Manager connection"); //$NON-NLS-1$ - } - try - { - - this._reconnectLatch.await(300, TimeUnit.MILLISECONDS); - } - catch (final InterruptedException e) - { - CoherentManagerConnection.logger.error(e, e); - } - trys--; - } - } - - public ManagerConnectionState getState() - { - return CoherentManagerConnection.managerConnection.getState(); - } - - private void configureConnection() - throws IOException, AuthenticationFailedException, TimeoutException, IllegalStateException - { - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - CoherentManagerConnection.managerConnection = CoherentManagerConnection.connector.connect(profile); - - // After a reconnect we will have duplicate eventQueues and - // realtimeEventQueues but - // the original queues will be drained quite quickly (on the small - // chance - // that it hasn't already) - // and should have no duplicate events. Once drained the queue will be - // garbage collected. - CoherentManagerEventQueue newRealtime = new CoherentManagerEventQueue("Realtime"); //$NON-NLS-1$ - if (this.realtimeEventQueue != null) - { - this.realtimeEventQueue.stop(); - newRealtime.transferListeners(this.realtimeEventQueue); - } - this.realtimeEventQueue = newRealtime; - - CoherentManagerEventQueue newStandard = new CoherentManagerEventQueue("Standard"); //$NON-NLS-1$ - if (this.eventQueue != null) - { - this.eventQueue.stop(); - newStandard.transferListeners(this.eventQueue); - } - this.eventQueue = newStandard; - } - - private void checkFeatures() throws IOException, TimeoutException - { - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - // Determine if the Bridge and Mute events are available. - final ListCommandsAction lca = new ListCommandsAction(); - ManagerResponse convertedResponse = sendAction(lca, 500); - boolean bridgeFound = false; - boolean muteAudioFound = false; - for (final String command : convertedResponse.getAttributes().keySet()) - { - if (command.toLowerCase().contains("bridge")) //$NON-NLS-1$ - { - bridgeFound = true; - } - if (command.toLowerCase().contains("muteaudio")) //$NON-NLS-1$ - { - muteAudioFound = true; - } - - } - this.canMuteAudio = muteAudioFound; - if (profile.getDisableBridge()) - { - this.canBridge = false; - } - else - { - this.canBridge = bridgeFound; - } - } - - // @SuppressWarnings("unused") - // private boolean ping(final int timeout) - // { - // boolean result = false; - // - // try - // { - // // logger.debug("ping"); - // final PingAction pa = new PingAction(); - // result = true; - // } - // catch (final Exception e) - // { - // // logger.warn("ping failed asterisk connection may have been lost"); - // - // } - // return result; - // - // } - - // // TODO consider putting the ping logic back in. - // // Having said that the ping command doesn't appear to have been working - // for - // // some time - // // as it was always returning true. - // public void run() - // { - // // Establish the initial connection. - // this.connector = new Connector(); - // try - // { - // this.managerListener = this.con.connect(this.profile); - // this.queue = new ManagerEventQueue(this); - // - // this.managerListener.addEventListener(this.queue); - // - // this.managerWriter = this.con.connect(this.profile); - // - // } - // catch (final Exception e) - // { - // logger.error(e, e); - // } - // - // // Monitor the connection by doing an asterisk ping. - // while (this.stop == false) - // { - // if (!this.ping(200)) - // { - // if (!this.ping(90)) - // { - // if (!this.ping(90)) - // { - // logger.error("Asterisk connection lost, attempting reconnect"); - // //$NON-NLS-1$ - // // The ping has failed so we need to force a reconnect. - // this.reconnect(); - // } - // } - // } - // try - // { - // Thread.sleep(500); - // } - // catch (final InterruptedException e) - // { - // CallMarker.logger.error(e, e); - // } - // - // } - // - // } - - private void reconnect() - { - final ManagerConnection oldConnection = CoherentManagerConnection.managerConnection; - try - { - try - { - final InetAddress address = InetAddress.getByName(CoherentManagerConnection.managerConnection.getHostname()); - int counter = 0; - while (!address.isReachable(100)) - { - if (counter % 10 == 0) - CoherentManagerConnection.logger.debug("Testing for host " //$NON-NLS-1$ - + CoherentManagerConnection.managerConnection.getHostname()); - counter++; - } - } - catch (final Exception e2) - { - CoherentManagerConnection.logger.error(e2, e2); - } - try - { - CoherentManagerConnection.logger.debug("reconnecting to asterisk"); //$NON-NLS-1$ - - connector = new Connector(); - this.configureConnection(); - CoherentManagerConnection.logger.debug("asterisk reconnection complete"); //$NON-NLS-1$ - } - catch (final Exception e1) - { - - CoherentManagerConnection.logger.error(e1, e1); - } - } - finally - { - oldConnection.logoff(); - } - } - - public void shutDown() - { - CoherentManagerConnection.managerConnection.removeEventListener(this.eventQueue); - this.eventQueue.stop(); - try - { - CoherentManagerConnection.managerConnection.logoff(); - } - catch (final Exception e) - { - CoherentManagerConnection.logger.debug("Manager logging off"); //$NON-NLS-1$ - CoherentManagerConnection.logger.debug(e, e); - } - } - - public boolean isBridgeSupported() - { - return this.canBridge; - } - - public boolean isMuteAudioSupported() - { - return this.canMuteAudio; - } - - public void removeListener(FilteredManagerListener listener) - { - if (listener.getPriority() == ListenerPriority.REALTIME) - this.realtimeEventQueue.removeListener(listener); - else - this.eventQueue.removeListener(listener); - - } - - public void addListener(FilteredManagerListener listener) - { - if (listener.getPriority() == ListenerPriority.REALTIME) - this.realtimeEventQueue.addListener(listener); - else - this.eventQueue.addListener(listener); - - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - required.add(ConnectEvent.class); - required.add(DisconnectEvent.class); - return required; - } - - @Override - public String getName() - { - return "CoherentManagerConnection"; //$NON-NLS-1$ - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.REALTIME; - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - // Special handler for the connect event in case we are - // wait()ing for - // the connection to complete. This wakes the code up in the shortest - // time possible - // by notifying it of the connection. - if (event instanceof ConnectEvent) - { - logger.warn("****************** Asterisk manager connection acquired **************************"); //$NON-NLS-1$ - this._reconnectLatch.countDown(); - } - else if (event instanceof DisconnectEvent) - { - logger.warn("****************** Asterisk manager connection lost **************************"); //$NON-NLS-1$ - new Thread(new Runnable() - { - public void run() - { - reconnect(); - } - }); - } - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerEventListener.java b/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerEventListener.java deleted file mode 100644 index c5aa4799d..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerEventListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.EventListener; - -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; - -public interface CoherentManagerEventListener extends EventListener -{ - /** - * This method is called when an event is received. - * - * @param event - * the event that has been received - */ - void onManagerEvent(ManagerEvent event); -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerEventQueue.java b/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerEventQueue.java deleted file mode 100644 index b2507a650..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/CoherentManagerEventQueue.java +++ /dev/null @@ -1,322 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.Comparator; -import java.util.HashSet; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.eventQueue.EventLifeMonitor; -import org.asteriskjava.pbx.util.LogTime; - -/** - * This class provides a method of accepting, queueing and delivering manager - * events. - * - * Asterisk is very sensitive to delays in receiving events. This class ensures - * that events are received and queued rapidly. A separate thread dequeues them - * and delivers them to the manager listener. - * - * Used this queue as follows: - * - * manager.addEventListener(new CoherentManagerEventQueue(originalListener)); - * - * This affectively daisy changes the originalListener via our queue. - * - * @author bsutton - * - */ -class CoherentManagerEventQueue implements ManagerEventListener, Runnable -{ - static Logger logger = Logger.getLogger(CoherentManagerEventQueue.class); - - private class Listener - { - FilteredManagerListener _listener; - Set> requiredEvents; - - public Listener(FilteredManagerListener listener) - { - this._listener = listener; - this.requiredEvents = listener.requiredEvents(); - } - - @Override - public String toString() - { - return this._listener.getName(); - } - - } - - private final TreeSet listeners = new TreeSet<>(new ListenerPriorityComparator()); - - private boolean _stop = false; - private final Thread _th; - private final BlockingQueue> _eventQueue = new LinkedBlockingQueue<>(); - - private int _queueMaxSize; - - private long _queueSum; - - private long _queueCount; - - private HashSet> globalEvents = new HashSet<>(); - - public CoherentManagerEventQueue(String name) - { - CoherentManagerConnection.managerConnection.addEventListener(this); - - this._th = new Thread(this); - this._th.setName("EventQueue: " + name);//$NON-NLS-1$ - this._th.setDaemon(true); - this._th.start(); - } - - /** - * handles manager events passed to us in our role as a listener. - * - * We queue the event so that it can be read, by the run method of this - * class, and subsequently passed on to the original listener. - */ - @Override - public void onManagerEvent(final org.asteriskjava.manager.event.ManagerEvent event) - { - - // logger.error(event); - boolean wanted = false; - /** - * Dump any events we arn't interested in ASAP to minimise the - * processing overhead of these events. - */ - // Only enqueue the events that are of interest to one of our listeners. - synchronized (this.globalEvents) - { - Class shadowEvent = CoherentEventFactory.getShadowEvent(event); - if (this.globalEvents.contains(shadowEvent)) - { - wanted = true; - } - } - - if (wanted) - { - - // We don't support all events. - this._eventQueue.add(new EventLifeMonitor<>(event)); - final int queueSize = this._eventQueue.size(); - if (this._queueMaxSize < queueSize) - { - this._queueMaxSize = queueSize; - } - this._queueSum += queueSize; - this._queueCount++; - - if (CoherentManagerEventQueue.logger.isDebugEnabled()) - { - if (this._eventQueue.size() > ((this._queueMaxSize + (this._queueSum / this._queueCount)) / 2)) - { - CoherentManagerEventQueue.logger.debug("queue gtr max avg: size=" + queueSize + " max:" //$NON-NLS-1$ //$NON-NLS-2$ - + this._queueMaxSize + " avg:" + (this._queueSum / this._queueCount)); //$NON-NLS-1$ - } - } - } - } - - @Override - public void run() - { - - while (this._stop == false) - { - try - { - final EventLifeMonitor elm = this._eventQueue.poll(2, - TimeUnit.SECONDS); - if (elm != null) - { - // A poison queue event means its time to shutdown. - if (elm.getEvent().getClass() == PoisonQueueEvent.class) - break; - - final ManagerEvent iEvent = CoherentEventFactory.build(elm.getEvent()); - if (iEvent != null) - { - dispatchEvent(iEvent); - elm.assessAge(); - } - } - } - catch (final Exception e) - { - /** - * If an exception is thrown whilst we are shutting down then we - * don't care. If it is thrown when we aren't shutting down then - * we have a problem and we need to log it. - */ - if (this._stop == false) - { - CoherentManagerEventQueue.logger.error(e, e); - } - } - - } - - } - - class PoisonQueueEvent extends org.asteriskjava.manager.event.ManagerEvent - { - private static final long serialVersionUID = 1L; - - public PoisonQueueEvent() - { - super("PoisonQueueEvent"); //$NON-NLS-1$ - } - - } - - public void stop() - { - this._stop = true; - try - { - this._eventQueue - .put(new EventLifeMonitor(new PoisonQueueEvent())); - } - catch (InterruptedException e) - { - logger.error(e, e); - - } - } - - /** - * Events are sent here from the CoherentManagerEventQueue after being - * converted from a ManagerEvent to an ManagerEvent. This method is called - * from a dedicated thread attached to the event queue which it uses for - * dispatching events. - */ - public void dispatchEvent(final ManagerEvent event) - { - if (logger.isDebugEnabled()) - { - logger.debug("dispatch=" + event.toString()); //$NON-NLS-1$ - } - - // take a copy of the listeners so they can be modified whilst we - // iterate over them - // The iteration may call some long running processes. - final TreeSet listenerCopy = new TreeSet<>(new ListenerPriorityComparator()); - synchronized (this.listeners) - { - listenerCopy.addAll(this.listeners); - } - - for (final Listener filter : listenerCopy) - { - if (filter.requiredEvents.contains(event.getClass())) - { - final LogTime time = new LogTime(); - - filter._listener.onManagerEvent(event); - if (time.timeTaken() > 500) - { - logger.warn("ManagerListener :" + filter._listener.getName() //$NON-NLS-1$ - + " is taken too long to process events " + " time taken: " + time.timeTaken()); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - } - - /** - * Adds a listener which will be sent all events that its filterEvent - * handler will accept. All events are dispatch by way of a shared queue - * which is read via a thread which is shared by all listeners. Whilst poor - * performance of you listener can affect other listeners you can't affect - * the read thread which takes events from asterisk and enqueues them. - * - * @param listener - */ - public void addListener(final FilteredManagerListener listener) - { - synchronized (this.listeners) - { - this.listeners.add(new Listener(listener)); - synchronized (this.globalEvents) - { - this.globalEvents.addAll(listener.requiredEvents()); - } - } - logger.debug("listener added"); //$NON-NLS-1$ - } - - public void removeListener(final FilteredManagerListener melf) - { - synchronized (this.listeners) - { - if (melf != null) - { - for (Listener container : this.listeners) - { - if (container._listener == melf) - { - this.listeners.remove(container); - - // When we remove a listener we must unfortunately - // completely - // recalculate the set of required events. - synchronized (this.globalEvents) - { - this.globalEvents.clear(); - for (Listener readdContainer : this.listeners) - { - this.globalEvents.addAll(readdContainer._listener.requiredEvents()); - } - } - break; - } - } - } - } - } - - final class ListenerPriorityComparator implements Comparator - { - @Override - public int compare(Listener lhs, Listener rhs) - { - - int result = lhs._listener.getPriority().compare(rhs._listener.getPriority()); - - if (result == 0) - result = (lhs._listener.equals(rhs._listener) ? 0 : 1); - - return result; - } - } - - /** - * transfers the listeners from one queue to another. - * - * @param eventQueue - */ - public void transferListeners(CoherentManagerEventQueue eventQueue) - { - synchronized (this.listeners) - { - synchronized (eventQueue.listeners) - { - for (Listener listener : eventQueue.listeners) - { - this.addListener(listener._listener); - } - eventQueue.listeners.clear(); - } - } - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/DialLocalToAgiActivity.java b/src/main/java/org/asteriskjava/pbx/internal/core/DialLocalToAgiActivity.java deleted file mode 100644 index 498fc5c8b..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/DialLocalToAgiActivity.java +++ /dev/null @@ -1,244 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.Activity; -import org.asteriskjava.pbx.ActivityCallback; -import org.asteriskjava.pbx.ActivityStatusEnum; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.GetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.OriginateAction; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewChannelEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.OriginateResponseEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.managerAPI.EventListenerBaseClass; -import org.asteriskjava.pbx.internal.managerAPI.OriginateBaseClass; -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -public class DialLocalToAgiActivity extends EventListenerBaseClass implements Runnable, Activity -{ - - private EndPoint from; - private CallerID fromCallerID; - private Thread thread; - private final Log logger = LogFactory.getLog(this.getClass()); - private String originateId; - - CountDownLatch latch = new CountDownLatch(1); - private List channels = new LinkedList<>(); - private ActivityCallback callback; - private Map channelVarsToSet; - - public DialLocalToAgiActivity(EndPoint from, CallerID fromCallerID, ActivityCallback callback, - Map channelVarsToSet) - { - super("Dial " + from + " to AGI"); - this.from = from; - this.fromCallerID = fromCallerID; - this.callback = callback; - this.channelVarsToSet = channelVarsToSet; - - this.startListener(PBXFactory.getActivePBX()); - thread = new Thread(this, "Dial " + from + " to AGI"); - thread.start(); - } - // Logger logger = LogManager.getLogger(); - - @Override - public void run() - { - logger.info("*******************************************************************************"); - logger.info("*********** begin dial local to AGI ****************"); - logger.info("*********** " + " ****************"); - logger.info("*******************************************************************************"); - final AsteriskSettings settings = PBXFactory.getActiveProfile(); - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - final OriginateAction originate = new OriginateAction(); - originate.setEndPoint(from); - originate.setContext(settings.getManagementContext()); - originate.setExten(pbx.getExtensionAgi()); - originate.setPriority(1); - originate.setCallerId(fromCallerID); - originate.setTimeout(30000); - originateId = originate.getActionId(); - - Map myVars = new HashMap<>(); - - myVars.put("__" + OriginateBaseClass.NJR_ORIGINATE_ID, this.originateId); - if (channelVarsToSet != null) - { - myVars.putAll(channelVarsToSet); - } - - originate.setVariables(myVars); - - try - { - pbx.sendAction(originate, 30000); - latch.await(30, TimeUnit.SECONDS); - callback.progress(this, ActivityStatusEnum.SUCCESS, ActivityStatusEnum.SUCCESS.getDefaultMessage()); - - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - // TODO Auto-generated catch block - logger.error(e, e); - } - catch (InterruptedException e) - { - // TODO Auto-generated catch block - logger.error(e, e); - } - - } - - public void abort(final String reason) - { - logger.debug("Aborting originate ");//$NON-NLS-1$ - this.close(); - - for (Channel channel : channels) - { - PBX pbx = PBXFactory.getActivePBX(); - try - { - pbx.hangup(channel); - } - catch (IllegalArgumentException | IllegalStateException | PBXException e) - { - logger.error(e, e); - - } - } - latch.countDown(); - - } - - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - if (event instanceof HangupEvent) - { - this.close(); - } - if (event instanceof NewChannelEvent) - { - final NewChannelEvent newState = (NewChannelEvent) event; - final Channel channel = newState.getChannel(); - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - final GetVarAction var = new GetVarAction(channel, OriginateBaseClass.NJR_ORIGINATE_ID); - - ManagerResponse response; - try - { - if (channel.isLocal()) - { - int wait = 5; - while (wait > 0) - { - wait--; - response = pbx.sendAction(var, 500); - String channelsOriginateId = response.getAttribute("value"); - if (originateId.equalsIgnoreCase(channelsOriginateId)) - { - logger.info("Found the local channel " + channel); - channels.add(channel); - wait = 0; - if (channels.size() == 2) - { - latch.countDown(); - } - } - else if (channelsOriginateId == null || channelsOriginateId.length() == 0) - - { - Thread.sleep(100); - logger.error("Waiting for variables on " + channel); - } - else - { - logger.error("Didn't match " + channel + " " + channelsOriginateId + "!=" + originateId); - - wait = 0; - } - } - } - } - catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e) - { - // TODO Auto-generated catch block - logger.error(e, e); - } - catch (InterruptedException e) - { - // TODO Auto-generated catch block - logger.error(e, e); - } - - } - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(OriginateResponseEvent.class); - required.add(HangupEvent.class); - required.add(NewChannelEvent.class); - - return required; - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - - @Override - public Throwable getLastException() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isSuccess() - { - // TODO Auto-generated method stub - return channels.size() == 2; - } - - public Channel getChannel1() - { - return channels.get(0); - - } - - public Channel getChannel2() - { - return channels.get(1); - - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/EndPointImpl.java b/src/main/java/org/asteriskjava/pbx/internal/core/EndPointImpl.java deleted file mode 100644 index 2a3ee57f3..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/EndPointImpl.java +++ /dev/null @@ -1,274 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.TechType; -import org.asteriskjava.pbx.Trunk; - -public class EndPointImpl implements EndPoint -{ - private static final String DELIMITER = "/"; //$NON-NLS-1$ - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(EndPointImpl.class); - - final private TechType _tech; - - final private String _endPointName; - - final private String _fullyQualifiedName; - - // If true then this is an empty end point e.g. blank name and unknown tech. - final private boolean _empty; - - private Trunk _trunk; - - /** - * Creates a EndPoint from a fully qualified peer name of the form: SIP/NNN - * LOCAL/NNN TODO: the tech encoding should probably be specific to a - * particular pbx Implementation. - * - * @param fullyQualifiedPeerName - */ - public EndPointImpl(final String fullyQualifiedEndPoint) - { - if (fullyQualifiedEndPoint == null) - { - throw new IllegalArgumentException("The fullyQualifiedEndPoint may not be null"); //$NON-NLS-1$ - } - - final String cleaned = this.clean(fullyQualifiedEndPoint); - this._tech = TechType.getTech(cleaned); - this._endPointName = cleaned.substring(this._tech.name().length() + 1); - - if (this._tech == TechType.DIALPLAN) - { - this._fullyQualifiedName = this._endPointName; - } - else - { - this._fullyQualifiedName = this._tech.name() + EndPointImpl.DELIMITER + this._endPointName; - } - this._empty = false; - } - - /** - * Creates a empty end point. - */ - public EndPointImpl() - { - this._empty = true; - this._tech = TechType.UNKNOWN; - this._endPointName = ""; - this._fullyQualifiedName = ""; - } - - /** - * Creates an EndPoint from from a simple endpoint name and a tech. - * - * @param _tech - * @param peerName - */ - // EndPoint(String endPointName, String tech) - // { - // if (endPointName == null) - // throw new IllegalArgumentException("The endPoint Name may not be null"); - // - // if (tech == null) - // throw new IllegalArgumentException("The endPoint Tehc may not be null"); - // - // String cleaned = clean(endPointName); - // // Tech must be upper case to match the enum but - // // the simple name must be lower case to matcht the context extension - // // names. - // this.tech = Tech.valueOf(tech.toUpperCase()); - // this.endPointName = cleaned; - // } - - public EndPointImpl(final TechType defaultTech, final String endPointName) - { - if (endPointName == null) - { - throw new IllegalArgumentException("The endPointName may not be null"); //$NON-NLS-1$ - } - - final String cleaned = this.clean(endPointName); - - if (cleaned.length() == 0) - { - throw new IllegalArgumentException("The endPointName may not be empty"); //$NON-NLS-1$ - } - - // If tech is unknown then attempt to extract the tech from the - // endPointName. - if (TechType.hasTech(cleaned)) - { - this._tech = TechType.getTech(cleaned); - this._endPointName = cleaned.substring(this._tech.name().length() + 1); - - } - else - { - this._tech = defaultTech; - this._endPointName = cleaned; - } - - if (this._tech == TechType.DIALPLAN) - { - this._fullyQualifiedName = this._endPointName; - } - else - { - this._fullyQualifiedName = this._tech.name() + EndPointImpl.DELIMITER + this._endPointName; - } - this._empty = false; - } - - public EndPointImpl(TechType defaultTech, Trunk trunk, String endPointName) - { - if (endPointName == null) - { - throw new IllegalArgumentException("The endPointName may not be null"); //$NON-NLS-1$ - } - - final String cleaned = this.clean(endPointName); - - if (cleaned.length() == 0) - { - throw new IllegalArgumentException("The endPointName may not be empty"); //$NON-NLS-1$ - } - - // If tech is unknown then attempt to extract the tech from the - // endPointName. - if (TechType.hasTech(cleaned)) - { - throw new IllegalArgumentException("endPointName may not contain a Tech"); - - } - - this._tech = defaultTech; - this._endPointName = cleaned; - this._trunk = trunk; - - if (this._tech == TechType.DIALPLAN || this._tech == TechType.CONSOLE || this._tech == TechType.LOCAL) - { - throw new IllegalArgumentException("defaultTech may not be DIALPLAN, LOCAL or CONSOLE"); - } - - this._fullyQualifiedName = this._tech.name() + EndPointImpl.DELIMITER + trunk.getTrunkAsString() - + EndPointImpl.DELIMITER + this._endPointName; - - this._empty = false; - - } - - /** - * Returns the fully qualified endPoint. - */ - @Override - public String getFullyQualifiedName() - { - return this._fullyQualifiedName; - } - - public Trunk getTrunk() - { - return _trunk; - } - - @Override - public boolean isSame(final EndPoint rhs) - { - return this.compareTo(rhs) == 0; - } - - @Override - public int compareTo(EndPoint rhs) - { - return this.getFullyQualifiedName().compareTo(rhs.getFullyQualifiedName()); - } - - @Override - public boolean isLocal() - { - return this._tech == TechType.LOCAL; - } - - /** - * For the purposes of asterisk IAX and SIP are both considered SIP. - */ - @Override - public boolean isSIP() - { - return this._tech == TechType.SIP || this._tech == TechType.IAX || this._tech == TechType.IAX2; - } - - public boolean isDAHDI() - { - return this._tech == TechType.DAHDI; - } - - @Override - public String getSimpleName() - { - return this._endPointName; - } - - @Override - public boolean isUnknown() - { - return this._tech == TechType.UNKNOWN; - } - - /** - * Cleans up an endpoint name by removing all whitespace (including internal - * whitespace) as well as making the string lower case. - * - * @param _endPointName - * @return - */ - private String clean(final String _endPointName) - { - String localTo = _endPointName.trim(); - - // strip all white space from within the name as some source - // pass in a formatted phone number (e.g. 03 8320 8100) - int tmp = localTo.indexOf(" "); //$NON-NLS-1$ - while (tmp != -1) - { - localTo = localTo.substring(0, tmp) + localTo.substring(tmp + 1, localTo.length()); - tmp = localTo.indexOf(" "); //$NON-NLS-1$ - } - return localTo.toLowerCase(); - } - - @Override - public TechType getTech() - { - return this._tech; - } - - @Override - public String toString() - { - return this.getFullyQualifiedName(); - } - - @Override - public String getSIPSimpleName() - { - String name; - - if (isSIP()) - name = getSimpleName(); - else - name = getFullyQualifiedName(); - return name; - } - - public boolean isEmpty() - { - return this._empty; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/FilteredManagerListener.java b/src/main/java/org/asteriskjava/pbx/internal/core/FilteredManagerListener.java deleted file mode 100644 index 08c70e462..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/FilteredManagerListener.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.Set; - -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; - -/** - * Allows a object to receive Manager event notification which are pre-filtered. - * - * @author bsutton - * - */ -public interface FilteredManagerListener -{ - /** - * Provides a unique name for the listener. - * - * @return a unique name for the listener. - */ - abstract String getName(); - - /** - * Called whenever the listener is first added and any time any listener is - * removed to refresh the list of required events. - * - * @return list of required events. - */ - abstract public Set> requiredEvents(); - - /** - * Called for each manager event that the connection receives for which the - * filterEvent returned true. - * - * @param event - */ - abstract void onManagerEvent(T event); - - /** - * Set the listeners priority. Higher priority listeners have events - * dispatched to them before lower priority listeners. - * - * @return - */ - abstract ListenerPriority getPriority(); - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/LiveChannelManager.java b/src/main/java/org/asteriskjava/pbx/internal/core/LiveChannelManager.java deleted file mode 100644 index aac187c1e..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/LiveChannelManager.java +++ /dev/null @@ -1,366 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; -import org.apache.log4j.Priority; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.InvalidChannelName; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MasqueradeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.RenameEvent; - -/** - * The LiveChannelManager keeps a list of all of the live channels present on an - * asterisk system. For this to work it needs to control the stream of asterisk - * events consumed by others. This need is caused by the fact that Asterisk can - * rename a channel many times after its comes up. When a channel is renamed - * Asterisk sends a rename event. After the rename event all future asterisk - * events will refer to the channel by its new name. Masquerade events pose - * further issues in that a channel can be replaced mid way through a call. The - * LiveChannelManager works with the ChannelProxy to manage this process. The - * issue is that if multiple classes are accessing the LiveChannelManager and - * those classes are consuming asterisk events form their own direct source then - * they may be behind or ahead of the LiveChannelManager in processing events. - * The result is that when attempting to access a channel by name from the - * LiveChannelManager the channel name may not match as the LiveChannelManager - * may have processed a rename event whilst the consumer may still be processing - * older events which are still referring to the channel via its old name. The - * first part of the solution is to wrap the asterisk-java events with our own - * events which pass an iChannel interface rather than a raw channel name. - * Because the iChannel interface is a handle to a channel managed via the - * LiveChannelManager then the name will be updated during the rename. To ensure - * that events are processed in an orderly fashion you MUST only obtain an event - * listener via AsteriskPBX.addListener(); The second part of the solution is - * the ChannelProxy. The ChannelProxy handles masquerading of channels where in - * a live channel is replaced with a new channel part way through a call. This - * can happen when transfering a call, parking a call or other similar actions. - * The ChannelProxy implements the iChannel interface and is affectively hidden - * from consumers of iChannels. The LiveChannelManager uses the proxy to replace - * a live channel during a masqurade event. A consumer holding an iChannel - * handle will not even be aware (and does not need to be) that the underlying - * channel has been replaced. - * - * @author bsutton - */ -public class LiveChannelManager implements FilteredManagerListener -{ - private static final Logger logger = Logger.getLogger(LiveChannelManager.class); - - /** - * A collection of all of the live proxies in the system. We monitor the - * channels and remove them as they hangup. The hash is keyed by the - * channel's name. e.g. SIP/100-000000100 - */ - private final List _liveChannels = new CopyOnWriteArrayList<>(); - - public LiveChannelManager() - { - CoherentManagerConnection.getInstance().addListener(this); - } - - public ChannelProxy getChannelByEndPoint(EndPoint endPoint) - { - ChannelProxy connectedChannel = null; - for (final ChannelProxy channel : _liveChannels) - { - if (channel.isConnectedTo(endPoint)) - { - connectedChannel = channel; - break; - } - - } - return connectedChannel; - } - - public void add(ChannelProxy proxy) - { - synchronized (this._liveChannels) - { - ChannelProxy index = findProxy(proxy); - if (index == null) - this._liveChannels.add(proxy); - } - logger.info("Adding liveChannel " + proxy); - - dumpProxies(proxy, "Add"); //$NON-NLS-1$ - sanityCheck(); - - } - - private void dumpProxies(ChannelProxy proxy, String cause) - { - if (logger.isDebugEnabled()) - { - logger.debug("Dump of LiveChannels, cause:" + cause + ": " + proxy); //$NON-NLS-1$ //$NON-NLS-2$ - for (ChannelProxy aProxy : _liveChannels) - { - logger.debug("ChannelProxy: " + aProxy); //$NON-NLS-1$ - } - } - } - - public void remove(ChannelProxy proxy) - { - - ChannelProxy index = findProxy(proxy); - if (index != null) - { - logger.info("Removing liveChannel " + proxy); - this._liveChannels.remove(index); - } - dumpProxies(proxy, "Removing"); //$NON-NLS-1$ - - } - - public ChannelProxy findChannel(String extendedChannelName, String uniqueID) - { - ChannelProxy proxy = null; - logger.info("Trying to find channel " + extendedChannelName + " " + uniqueID); - - String localUniqueId = uniqueID; - if (localUniqueId == null) - localUniqueId = ChannelImpl.UNKNOWN_UNIQUE_ID; - - // In order to get the 'best' match we first match each by unique id. - // Sometimes we can have two channels with the same name but - // different - - if (localUniqueId.compareTo(ChannelImpl.UNKNOWN_UNIQUE_ID) != 0) - { - - for (ChannelProxy aChannel : _liveChannels) - { - if (aChannel.sameUniqueID(localUniqueId)) - { - proxy = aChannel; - break; - } - } - } - - // If we don't have a match from the first pass and the new uniqueID - // is unknown - // then do a search matching by name. - if (proxy == null) - { - for (ChannelProxy aChannel : _liveChannels) - { - - if (aChannel.isSame(extendedChannelName, localUniqueId)) - { - proxy = aChannel; - break; - } - } - } - - if (proxy == null) - { - logger.info("Failed to match channel to any of..."); - for (ChannelProxy aChannel : _liveChannels) - { - logger.info(aChannel); - } - - } - - return proxy; - } - - private ChannelProxy findProxy(Channel original) - { - for (ChannelProxy aChannel : _liveChannels) - { - if (aChannel.isSame(original)) - { - return aChannel; - } - } - return null; - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(MasqueradeEvent.class); - required.add(RenameEvent.class); - required.add(HangupEvent.class); - - return required; - } - - ChannelProxy findProxyById(String id) - { - for (ChannelProxy aChannel : _liveChannels) - { - if (("" + aChannel.getIdentity()).equals(id)) - { - return aChannel; - } - } - return null; - } - - @Override - public void onManagerEvent(ManagerEvent event) - { - if (event instanceof MasqueradeEvent) - { - MasqueradeEvent masq = (MasqueradeEvent) event; - ChannelProxy originalIndex = findProxy(masq.getOriginal()); - ChannelProxy cloneIndex = findProxy(masq.getClone()); - if (originalIndex != null && cloneIndex != null) - { - ChannelProxy originalProxy = (ChannelProxy) masq.getOriginal(); - ChannelProxy cloneProxy = (ChannelProxy) masq.getClone(); - try - { - // After the masquerade the two underlying channels will - // have been switched - // between the two proxies. - // At this point the cloneProxy will be owned by a Peer - // (as they process NewChannelEvents) - // as such we cannot just discard the cloneProxy. The - // simplest solution then - // is to put the clone channel into the existing - // channel, as this is the core reason we have a proxy, - // and then put the original channel into the - // cloneProxy. At the end of this manuvour - // the Peer will still have two proxy which point to the - // two different channels. - // This is fine for the Peer as it doesn't attach any - // special meaning to any channel - // it just needs a list of all channels associated with - // the Peer. - // The original channel will shortly receive a hangup in - // which case the Peer will - // remove it from its list of channels and the Peer will - // be back to having - // one channel which will be the clone channel which is - // now the active channel - // and everyone will be happy. - originalProxy.masquerade(cloneProxy); - dumpProxies(cloneProxy, "Masquerade"); //$NON-NLS-1$ - sanityCheck(); - } - catch (InvalidChannelName e) - { - logger.error(e, e); - - } - - } - else - logger.error("Either the clone or original channelProxy was missing during a masquerade: cloneIndex=" //$NON-NLS-1$ - + cloneIndex + " originalIndex=" + originalIndex); //$NON-NLS-1$ - - } - if (event instanceof RenameEvent) - { - RenameEvent rename = (RenameEvent) event; - - ChannelProxy oldChannel = findProxy(rename.getChannel()); - if (oldChannel != null) - { - try - { - oldChannel.rename(rename.getNewName()); - dumpProxies(oldChannel, "RenameEvent"); //$NON-NLS-1$ - sanityCheck(); - } - catch (InvalidChannelName e) - { - logger.error(e, e); - } - } - else - { - logger.warn("Unable to rename channel -> Failed to find channel " + rename.getChannel()); - } - } - else if (event instanceof HangupEvent) - { - // We need to process every hangup event that goes through the - // system - // as the LiveChannelManager has a Channel added for every channel - // that is created via Asterisk even if it has nothing to - // do with NJR. This is because channels are created - // whenever an event arrives before we actually can determine - // if we are interested in the event and its associated channels. - HangupEvent hangup = (HangupEvent) event; - // Yes I've seen a hangup where the channel was null, who knows - // why? - - if (hangup.getChannel() != null) - { - - ChannelProxy proxy = findProxy(hangup.getChannel()); - if (proxy != null) - { - this._liveChannels.remove(proxy); - logger.info("Removing liveChannel " + proxy); - proxy.getChannel().notifyHangupListeners(hangup.getCause(), hangup.getCauseTxt()); - dumpProxies(proxy, "HangupEvent"); //$NON-NLS-1$ - } - - } - else - { - logger.error("Didn't remove hungup channel"); - } - } - } - - @Override - public String getName() - { - return "LiveChannelManager"; //$NON-NLS-1$ - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.CRITICAL; - } - - @SuppressWarnings("deprecation") - public void sanityCheck() - { - - if (logger.isEnabledFor(Priority.INFO)) - { - logger.error("Performing Sanity Check"); - Set channels = new HashSet<>(); - for (ChannelProxy channel : _liveChannels) - { - if (!channels.add(channel.getChannel().getExtendedChannelName())) - { - logger.error( - "Multiple channels by the name " + channel.getChannel().getExtendedChannelName() + " exist"); - for (ChannelProxy channel2 : _liveChannels) - { - if (channel2.getChannel().getExtendedChannelName() - .equals(channel.getChannel().getExtendedChannelName())) - { - logger.error(channel2); - } - } - Exception ex = new Exception("called from here"); - logger.error(ex, ex); - } - - } - } - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/Peer.java b/src/main/java/org/asteriskjava/pbx/internal/core/Peer.java deleted file mode 100644 index 870010c3d..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/Peer.java +++ /dev/null @@ -1,328 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.LinkedList; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.asterisk.wrap.events.MasqueradeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewChannelEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewStateEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusEvent; - -/* - * this class tracks the status of a Peer on asterisk. T - * - * Peers are created by the PeerMonitor which also sends asterisk events to - * the peer. - * - */ - -public class Peer implements CallEndedListener -{ - static private Logger logger = Logger.getLogger(Peer.class); - - private final EndPoint peerEndPoint; - - /** - * Used to track the list of channels associated with this peer. - * - * I think there would normally only be a single channel unless we are in - * the middle of a transfer or the phone has two calls up. - */ - private final LinkedList callList = new LinkedList<>(); - - private PeerState _state = PeerState.NOTSET; - private boolean dnd = false; - - public Peer(final EndPoint endPoint) - { - this.peerEndPoint = endPoint; - } - - public boolean isSame(final Peer rhs) - { - return this.peerEndPoint.isSame(rhs.getEndPoint()); - } - - private CallTracker registerChannel(final Channel newChannel) - { - CallTracker associatedCall = null; - boolean found = false; - synchronized (this.callList) - { - for (final CallTracker call : this.callList) - { - if (call.findChannel(newChannel) != -1) - { - found = true; - associatedCall = call; - break; - } - } - if (!found) - { - if (logger.isDebugEnabled()) - logger.debug("Peer adding Call: " + this.toString() + " " + newChannel.getExtendedChannelName()); //$NON-NLS-1$ //$NON-NLS-2$ - associatedCall = createCallTracker(newChannel); - this.dumpCallList(); - } - } - return associatedCall; - } - - private CallTracker createCallTracker(final Channel newChannel) - { - CallTracker newCall; - synchronized (this.callList) - { - newCall = new CallTracker(this, newChannel); - this.callList.add(newCall); - } - return newCall; - } - - public boolean getDND() - { - return this.dnd; - } - - // public String getFullChannelName() - // { - // String channelName = null; - // synchronized (this.callList) - // { - // if (this.callList.size() > 0) - // { - // channelName = this.callList.get(0).getChannelName(); - // } - // } - // - // return channelName; - // } - - public PeerState getState() - { - return this._state; - } - - /** - * Determines if the given channel is connected to this peer. - * - * @param channel - * @return - */ - private boolean isConnectedToSelf(final Channel channel) - { - return this.getEndPoint().isSame(channel.getEndPoint()); - } - - /** - * We handle the masqurade event is it contains channel state information. - * During a masquerade we will have two channels for the one peer, the - * original and the clone. As the clone is taking over from the original - * peer we now need to use that as true indicator of state. - * - * @param b - * @throws Exception - */ - public void handleEvent(final MasqueradeEvent b) - { - if (this.isConnectedToSelf(b.getClone())) - { - // At this point we will actually have two CallTrackers - // which we now need to merge into a single CallTracker. - CallTracker original = findCall(b.getOriginal()); - CallTracker clone = findCall(b.getClone()); - if (original != null && clone != null) - { - clone.mergeCalls(original); - clone.setState(b.getCloneState()); - this.evaluateState(); - } - else - logger.warn("When processing masquradeEvent we could not find the expected calls. event=" //$NON-NLS-1$ - + b.toString() + " original=" + original + " clone=" + clone); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * When a new channel comes up associated it with the peer. - * - * Be warned a peer can have multiple calls associated with it. - * - * @param b - * @throws Exception - */ - public void handleEvent(final NewChannelEvent b) - { - // Very occasionally we get a null channel which we can't do anything - // with so just throw the event away. - // If we get a Console/dsp channel name it means that someone has - // dialled from the asterisk - // console. We just ignore these. - if ((b.getChannel() == null) || (b.getChannel().isConsole())) - { - return; - } - - if (this.isConnectedToSelf(b.getChannel())) - { - CallTracker call = this.registerChannel(b.getChannel()); - if (call != null) - { - call.setState(b.getChannelState()); - this.evaluateState(); - } - } - } - - public void handleEvent(final NewStateEvent b) - { - if (this.isConnectedToSelf(b.getChannel())) - { - CallTracker call = this.registerChannel(b.getChannel()); - if (call != null) - { - call.setState(b.getChannelState()); - this.evaluateState(); - } - } - } - - public void handleEvent(final StatusEvent b) - { - final Channel channel = b.getChannel(); - if (this.isConnectedToSelf(channel)) - { - ((ChannelProxy) channel).getRealChannel().markChannel(); - - CallTracker call = findCall(channel); - if (call != null) - { - call.setState(b.getState()); - this.evaluateState(); - } - } - } - - private CallTracker findCall(Channel channel) - { - CallTracker result = null; - synchronized (this.callList) - { - for (CallTracker call : this.callList) - { - if (call.findChannel(channel) != -1) - { - result = call; - break; - } - } - - } - return result; - } - - public void setDND(final boolean on) - { - this.dnd = on; - } - - public void startSweep() - { - Peer.logger.debug("Starting sweep for " + this.peerEndPoint.getFullyQualifiedName());//$NON-NLS-1$ - synchronized (this.callList) - { - for (final CallTracker call : this.callList) - { - call.startSweep(); - } - } - } - - public void endSweep() - { - Peer.logger.debug("Ending sweep for " + this.peerEndPoint.getFullyQualifiedName());//$NON-NLS-1$ - synchronized (this.callList) - { - for (final CallTracker call : this.callList) - { - call.endSweep(); - } - } - this.evaluateState(); - } - - /** - * Called each time the state of a call changes to determine the Peers - * overall state. - */ - private void evaluateState() - { - synchronized (this.callList) - { - // Get the highest prioirty state from the set of calls. - PeerState newState = PeerState.NOTSET; - for (CallTracker call : this.callList) - { - if (call.getState().getPriority() > newState.getPriority()) - newState = call.getState(); - } - - this._state = newState; - } - } - - public EndPoint getEndPoint() - { - return this.peerEndPoint; - } - - @Override - public String toString() - { - return this.getEndPoint().toString(); - } - - private void dumpCallList() - { - if (logger.isDebugEnabled()) - { - Peer.logger.debug("Peer: dump CallList:" + this); //$NON-NLS-1$ - for (final CallTracker call : this.callList) - { - call.dumpChannelList(); - } - } - } - - @Override - public void callEnded(CallTracker call) - { - boolean found = false; - synchronized (this.callList) - { - for (final CallTracker aCall : this.callList) - { - if (call == aCall) - { - found = true; - if (logger.isDebugEnabled()) - logger.debug("peer Removing call " + call); //$NON-NLS-1$ - this.callList.remove(call); - this.evaluateState(); - this.dumpCallList(); - break; - } - } - if (!found) - { - logger.error("Error call not found removing call from peer: call=" + call + " peer=" + this); //$NON-NLS-1$ //$NON-NLS-2$ - this.dumpCallList(); - } - } - - } - -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/PeerMonitor.java b/src/main/java/org/asteriskjava/pbx/internal/core/PeerMonitor.java deleted file mode 100644 index 7c5c84c25..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/PeerMonitor.java +++ /dev/null @@ -1,386 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.NewExtensionListener; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.SipPeersAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.StatusAction; -import org.asteriskjava.pbx.asterisk.wrap.events.DndStateEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.MasqueradeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewChannelEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewStateEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.PeerEntryEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.PeerStatusEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.PeerlistCompleteEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusCompleteEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.StatusEvent; -import org.asteriskjava.pbx.internal.managerAPI.EventListenerBaseClass; - -/* - * this class tracks the status of all peers on asterisk. - */ -public class PeerMonitor extends EventListenerBaseClass implements Runnable -{ - - static Logger logger = Logger.getLogger(PeerMonitor.class); - - LinkedList peerList = new LinkedList<>(); - - boolean initSip = false; - - private final Thread markAndSweepThread; - - private static PeerMonitor self; - - private static NewExtensionListener listener; - - /** - * needs to notify PhoneBookDisplayController.getInstance().addExtensions(); - * - * @param _listener - */ - public synchronized static void init(final NewExtensionListener _listener) - { - PeerMonitor.listener = _listener; - - if (PeerMonitor.self == null) - { - PeerMonitor.self = new PeerMonitor(); - } - else if (_listener != null) - { - logger.error("Call to PeerMonitor.init, but it's already initialized. Listener will not be set"); - } - } - - public static synchronized PeerMonitor getInstance() - { - if (PeerMonitor.self == null) - { - throw new IllegalStateException("You must call PeerMonitor.init()"); //$NON-NLS-1$ - } - return PeerMonitor.self; - } - - private PeerMonitor() - { - super("PeerMonitor"); //$NON-NLS-1$ - this.peerList = new LinkedList<>(); - this.startListener(PBXFactory.getActivePBX()); - this.addSipsToMonitor(); - try - { - if (PeerMonitor.listener != null) - { - PeerMonitor.listener.newExtension(); - } - else - { - logger.warn("Peer monitor listener is null"); - } - } - catch (final Exception e) - { - PeerMonitor.logger.error(e, e); - } - - this.markAndSweepThread = new Thread(this); - this.markAndSweepThread.setName("PeerMonitor-MarkAndSweep"); //$NON-NLS-1$ - this.markAndSweepThread.setDaemon(true); - this.markAndSweepThread.start(); - - } - - public void addSipsToMonitor() - { - /* - * request asterisk to send a list of sip peers. The monitor will - * dynamically add the peers to its list - */ - this.initSip = false; - - final StatusAction sa = new StatusAction(); - final SipPeersAction t = new SipPeersAction(); - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - pbx.sendAction(t, 5000); - pbx.sendAction(sa, 5000); - } - catch (final Exception e) - { - PeerMonitor.logger.error(e, e); - } - - } - - synchronized public Peer registerPeer(final Channel newChannel) - { - final Peer peer = this.registerPeer(newChannel.getEndPoint()); - return peer; - } - - synchronized public Peer registerPeer(final EndPoint endPoint) - { - if (endPoint.isLocal()) - { - return null; - } - - Peer peer = this.findPeer(endPoint); - if (peer == null) - { - peer = new Peer(endPoint); - this.peerList.add(peer); - } - - return peer; - } - - synchronized public Peer findPeer(final EndPoint peerEndPoint) - { - Peer found = null; - - for (final Peer peer : this.peerList) - { - if (peer.getEndPoint().isSame(peerEndPoint)) - { - found = peer; - break; - } - } - return found; - } - - @SuppressWarnings("unchecked") - public Iterator getIterator() - { - final List clone = (LinkedList) this.peerList.clone(); - final List tmpList = clone; - return tmpList.iterator(); - - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(NewChannelEvent.class); - required.add(PeerStatusEvent.class); - required.add(PeerEntryEvent.class); - required.add(PeerlistCompleteEvent.class); - required.add(NewStateEvent.class); - required.add(StatusEvent.class); - required.add(StatusCompleteEvent.class); - required.add(DndStateEvent.class); - - return required; - } - - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - /* - * This function is called from the base class. Here we process events - * we are interested in. - */ - - if (event instanceof PeerStatusEvent) - { - this.handleEvent((PeerStatusEvent) event); - } - else if (event instanceof PeerlistCompleteEvent) - { - this.handleEvent((PeerlistCompleteEvent) event); - } - else if (event instanceof PeerEntryEvent) - { - this.handleEvent((PeerEntryEvent) event); - } - else if (event instanceof NewChannelEvent) - { - this.handleEvent((NewChannelEvent) event); - } - else if (event instanceof MasqueradeEvent) - { - this.handleEvent((MasqueradeEvent) event); - } - else if (event instanceof StatusEvent) - { - this.handleEvent((StatusEvent) event); - } - else if (event instanceof StatusCompleteEvent) - { - this.handleEvent((StatusCompleteEvent) event); - } - else if (event instanceof NewStateEvent) - { - this.handleEvent((NewStateEvent) event); - } - } - - private void handleEvent(NewStateEvent event) - { - for (Peer peer : this.peerList) - { - peer.handleEvent(event); - } - } - - private void handleEvent(final NewChannelEvent event) - { - for (Peer peer : this.peerList) - { - peer.handleEvent(event); - } - } - - private void handleEvent(final MasqueradeEvent event) - { - for (Peer peer : this.peerList) - { - peer.handleEvent(event); - } - } - - private void handleEvent(final StatusEvent event) - { - for (Peer peer : this.peerList) - { - peer.handleEvent(event); - } - } - - private void handleEvent(final PeerEntryEvent event) - { - final EndPoint endPoint = event.getPeer(); - this.registerPeer(endPoint); - } - - private void handleEvent(final PeerlistCompleteEvent b) - { - this.initSip = true; - } - - /** - * @param event - */ - private void handleEvent(final PeerStatusEvent event) - { - this.registerPeer(event.getPeer()); - } - - /** - * We receive the StatusComplete event once the Mark and Sweep channel - * operation has completed. We now call endSweep which will remove any - * channels that were not marked during the operation. - * - * @param event - */ - private synchronized void handleEvent(final StatusCompleteEvent event) - { - - for (final Peer peer : this.peerList) - { - peer.endSweep(); - } - PeerMonitor.logger.debug("Channel Mark and Sweep complete"); //$NON-NLS-1$ - } - - boolean isInitialized() - { - return this.initSip; - } - - public void stop() - { - this.close(); - - } - - /************************************************************************************** - * - * Mark and Sweep logic follows - * - **************************************************************************************/ - - /** - * Runs the mark and sweep operation every 120 seconds on all channels to - * clean up any channels that have died and for which (for some reason) we - * missed the hangup event. - * - */ - @Override - public void run() - { - while (true) - { - try - { - Thread.sleep(120000); - PeerMonitor.getInstance().startSweep(); - } - catch (final InterruptedException e) - { - PeerMonitor.logger.error(e, e); - - } - } - - } - - /** - * Check every channel to make certain they are still active. We do this in - * case we missed a hangup event along the way somewhere. This allows us to - * cleanup any old channels. We start by clearing the mark on all channels - * and then generates a Asterisk status message for every active channel. At - * the end of the process any channels which haven't been marked are then - * discarded. - */ - public void startSweep() - { - PeerMonitor.logger.debug("Starting channel mark and sweep"); //$NON-NLS-1$ - - // Mark every channel as 'clearing' - synchronized (PeerMonitor.class) - { - for (final Peer peer : this.peerList) - { - peer.startSweep(); - } - } - - /** - * Request Asterisk to send us a status update for every channel. - * - */ - final StatusAction sa = new StatusAction(); - try - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - pbx.sendAction(sa, 5000); - } - catch (final Exception e) - { - PeerMonitor.logger.error(e, e); - } - - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.HIGH; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/core/PeerState.java b/src/main/java/org/asteriskjava/pbx/internal/core/PeerState.java deleted file mode 100644 index c5887e700..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/core/PeerState.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.asteriskjava.pbx.internal.core; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.asterisk.wrap.events.ChannelState; - -public enum PeerState -{ - DOWN(1,"Down", "OnHook", false), //$NON-NLS-1$ //$NON-NLS-2$ - UP(2,"Up", "OnPhone", true), //$NON-NLS-1$ //$NON-NLS-2$ - UNKNOWN(0,"Unknown", "Unknown", false), //$NON-NLS-1$ //$NON-NLS-2$ - NOTSET(0, "Not Set", "", false), //$NON-NLS-1$ //$NON-NLS-2$ - UNMONITORED(0, "Unmonitored", "Unmonitored", true), //$NON-NLS-1$ //$NON-NLS-2$ - DND(3,"DND", "DND", true), //$NON-NLS-1$ //$NON-NLS-2$ - RINGING(4,"Ringing", "Ringing", true), //$NON-NLS-1$ //$NON-NLS-2$ - OFF_LINE(1,"Off line", "Offline", true), //$NON-NLS-1$ //$NON-NLS-2$ - UNREGISTERED(0,"Unregistered", "Unregistered", true), //$NON-NLS-1$ //$NON-NLS-2$ - REGISTERED(0,"Registered", "Registered", false), //$NON-NLS-1$ //$NON-NLS-2$ - BUSY(2,"Busy", "Busy", true), //$NON-NLS-1$//$NON-NLS-2$ - RING(4,"Ring", "Dialing", true), //$NON-NLS-1$ //$NON-NLS-2$ - EXTERNAL(0,"External", "External", false);//$NON-NLS-1$ //$NON-NLS-2$ - - static private final Logger logger = Logger.getLogger(PeerState.class); - - final String _asteriskStateName; - - final String label; - - /** - * Controls whether the state should be displayed to the end user or just - * hidden. - * - */ - private boolean _visible; - - /** - * The priority ranks the PeerStates relative to each other. When a Peer has - * multiple active calls we need to display the call state from the call - * with the highest priority. e.g. If one call is UP and another is RINGING - * then we need to display the RINGING state as this is more interesting. - */ - private int _priority; - - public static PeerState valueByName(final String value) - { - PeerState status = NOTSET; - - for (PeerState aState : PeerState.values()) - { - - if (aState.getAsteriskStateName().compareToIgnoreCase(value) == 0) - { - status = aState; - break; - } - } - return status; - } - - private String getAsteriskStateName() - { - return this._asteriskStateName; - } - - public static PeerState valueByChannelState(final ChannelState state) - { - PeerState status = NOTSET; - - for (PeerState aState : PeerState.values()) - { - - if (aState.getAsteriskStateName().compareToIgnoreCase(state.name()) == 0) - { - status = aState; - break; - } - } - - if (status == NOTSET) - logger.warn("Unknown channelState: " + state + " recieved", new Throwable("Unknown channelState")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return status; - } - - PeerState(int priority, final String asteriskStateName, final String label, boolean visible) - { - this._asteriskStateName = asteriskStateName; - this.label = label; - this._visible = visible; - this._priority = priority; - } - - public String getLabel() - { - return this.label; - } - - @Override - public String toString() - { - return this.label; - } - - public boolean isVisible() - { - return this._visible; - } - - public int getPriority() - { - return this._priority; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/eventQueue/EventLifeMonitor.java b/src/main/java/org/asteriskjava/pbx/internal/eventQueue/EventLifeMonitor.java deleted file mode 100644 index a49dc43b8..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/eventQueue/EventLifeMonitor.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asteriskjava.pbx.internal.eventQueue; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.util.LogTime; - -public class EventLifeMonitor -{ - static Logger logger = Logger.getLogger(EventLifeMonitor.class); - - /* - * this class is used to hold an event while its in the queue and calculate - * how long it spent in the que before being processed. - */ - - private final T theEvent; - - private final LogTime age; - - public EventLifeMonitor(final T event) - { - this.theEvent = event; - this.age = new LogTime(); - } - - public void assessAge() - { - if (this.age.timeTaken() > 2000) - { - EventLifeMonitor.logger.warn("event age : " + this.age.timeTaken()); //$NON-NLS-1$ - } - - } - - public T getEvent() - { - return this.theEvent; - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/eventQueue/ManagerEventQueue.java b/src/main/java/org/asteriskjava/pbx/internal/eventQueue/ManagerEventQueue.java deleted file mode 100644 index 3339e9ce1..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/eventQueue/ManagerEventQueue.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.asteriskjava.pbx.internal.eventQueue; - -/** - * This class provides a method of accepting, queueing and delivering manager - * events. - * - * Asterisk is very sensitive to delays in receiving events. This class ensures - * that events are received and queued rapidly. A separate thread dequeues them - * and delivers them to the manager listener. - * - * Used this queue as follows: - * - * manager.addEventListener(new ManagerEventQueue(originalListener)); - * - * This affectively daisy changes the originalListener via our queue. - * - * @author bsutton - * @deprecated use CoherentManagerEventQueue - */ -public class ManagerEventQueue // implements ManagerEventListener, Runnable -{ - // static Logger logger = Logger.getLogger(ManagerEventQueue.class); - // - // private final ManagerEventListener listener; - // private boolean stop = false; - // private final Thread th; - // private final BlockingQueue> eventQueue = - // new LinkedBlockingQueue<>(); - // - // private int queueMaxSize; - // - // private long queueSum; - // - // private long queueCount; - // - // public ManagerEventQueue(final ManagerEventListener listener) - // { - // this.listener = listener; - // this.th = new Thread(this); - // this.th.setName("EventQueue: " + listener.getClass().getSimpleName());//$NON-NLS-1$ - // this.th.setDaemon(true); - // this.th.start(); - // } - // - // /** - // * handles manager events passed to us in our role as a listener. - // * - // * We queue the event so that it can be read, by the run method of this - // * class, and subsequently passed on to the original listener. - // */ - // @Override - // public void onManagerEvent(final ManagerEvent event) - // { - // // if ((event instanceof DisconnectEvent) || (event instanceof - // // ConnectEvent) || (event instanceof HangupEvent) - // // || (event instanceof NewExtenEvent)) - // // { - // - // if (event instanceof NewExtenEvent) - // return; - // - // this.eventQueue.add(new EventLifeMonitor<>(event)); - // final int queueSize = this.eventQueue.size(); - // if (this.queueMaxSize < queueSize) - // { - // this.queueMaxSize = queueSize; - // } - // this.queueSum += queueSize; - // this.queueCount++; - // - // if (ManagerEventQueue.logger.isDebugEnabled()) - // { - // if (this.eventQueue.size() > ((this.queueMaxSize + (this.queueSum / - // this.queueCount)) / 2)) - // { - // ManagerEventQueue.logger.debug("queue size max avg"); //$NON-NLS-1$ - // ManagerEventQueue.logger - // .debug(" " + queueSize + " " + this.queueMaxSize + " " + (this.queueSum / this.queueCount)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - // } - // - // ManagerEventQueue.logger.debug("queue size " + this.eventQueue.size());//$NON-NLS-1$ - // } - // // } - // - // } - // - // @Override - // public void run() - // { - // - // while (this.stop == false) - // { - // try - // { - // final EventLifeMonitor elm = this.eventQueue.poll(2, - // TimeUnit.SECONDS); - // if (elm != null) - // { - // // Re-add the following line if you want to log every event. - // // logger.error(elm.getEvent()); - // this.listener.onManagerEvent(elm.getEvent()); - // elm.assessAge(); - // } - // } - // catch (final Exception e) - // { - // /** - // * If an exception is thrown whilst we are shutting down then we - // * don't care. If it is thrown when we aren't shutting down then - // * we have a problem and we need to log it. - // */ - // if (this.stop == false) - // { - // ManagerEventQueue.logger.error(e, e); - // } - // } - // - // } - // - // } - // - // public void stop() - // { - // this.stop = true; - // synchronized (this.eventQueue) - // { - // this.eventQueue.notify(); - // } - // } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/Connector.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/Connector.java deleted file mode 100644 index 3f07e1bf3..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/Connector.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.UnknownHostException; - -import org.apache.log4j.Logger; -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerConnectionFactory; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.pbx.AsteriskSettings; - -/* - * this class is a very thin wrapper around the manager connection class - */ -public class Connector -{ - private ManagerConnection managerConnection; - static Logger logger = Logger.getLogger(Connector.class); - - /** - * Establishes a Asterisk ManagerConnection as well as performing the - * 'login' required by Asterisk. - * - * @param asteriskSettings - * @return - * @throws IOException - * @throws AuthenticationFailedException - * @throws TimeoutException - * @throws IllegalStateException - */ - public ManagerConnection connect(final AsteriskSettings asteriskSettings) - throws IOException, AuthenticationFailedException, TimeoutException, IllegalStateException - { - checkIfAsteriskRunning(asteriskSettings); - this.makeConnection(asteriskSettings); - return this.managerConnection; - } - - /** - * This method will try to make a simple tcp connection to the asterisk - * manager to establish it is up. We do this as the default makeConnection - * doesn't have a timeout and will sit trying to connect for a minute or so. - * By using method when the user realises they have a problem on start up - * they can go to the asterisk panel. Fix the problem and then we can retry - * with the new connection settings within a couple of seconds rather than - * waiting a minute for a timeout. - * - * @param asteriskSettings - * @throws UnknownHostException - * @throws IOException - */ - private void checkIfAsteriskRunning(AsteriskSettings asteriskSettings) throws UnknownHostException, IOException - { - try (Socket socket = new Socket();) - { - socket.setSoTimeout(2000); - - InetSocketAddress asteriskHost = new InetSocketAddress(asteriskSettings.getAsteriskIP(), - asteriskSettings.getManagerPortNo()); - socket.connect(asteriskHost, 2000); - } - - } - - /** - * @param socketReadTimeout - * @throws IOException - * @throws AuthenticationFailedException - * @throws TimeoutException - * @throws InsufficientPermissionsException - * @throws IllegalStateException - */ - private void makeConnection(final AsteriskSettings asteriskSettings) - throws IOException, AuthenticationFailedException, TimeoutException, IllegalStateException - { - ManagerConnectionFactory factory = null; - if (asteriskSettings.getManagerPortNo() == -1) - { - Connector.logger.debug("Using default port 5038."); //$NON-NLS-1$ - factory = new ManagerConnectionFactory(asteriskSettings.getAsteriskIP(), asteriskSettings.getManagerUsername(), - asteriskSettings.getManagerPassword()); - } - else - { - factory = new ManagerConnectionFactory(asteriskSettings.getAsteriskIP(), asteriskSettings.getManagerPortNo(), - asteriskSettings.getManagerUsername(), asteriskSettings.getManagerPassword()); - - } - - this.managerConnection = factory.createManagerConnection(); - // this.managerConnection.setSocketReadTimeout(socketReadTimeout); - // this.managerConnection.setSocketTimeout(socketReadTimeout); - this.managerConnection.login(); - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/Dial.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/Dial.java deleted file mode 100644 index 1996b6dbd..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/Dial.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.util.HashSet; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.NewChannelListener; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.agi.AgiChannelActivityDial; -import org.asteriskjava.pbx.asterisk.wrap.events.BridgeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.LinkEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.UnlinkEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class Dial extends EventListenerBaseClass -{ - private final static Logger logger = Logger.getLogger(Dial.class); - - private final OriginateResult result[] = new OriginateResult[2]; - - private CountDownLatch _latch; - - public Dial(final String descriptiveName) - { - super(descriptiveName); - this.startListener(PBXFactory.getActivePBX()); - } - - /** - * Dials the targetEndPoint connecting the call to the localHandset. The - * dial is done in two parts as we need to set the auto answer header - * differently for each phone. For the localHandset we set auto answer on, - * whilst for the remote targetEndPoint we MUST not auto answer the phone. - * - * @param localHandset the users handset we are going to dial from (e.g. - * receptionist phone). - * @param targetEndPoint - the remote handset we are going to connect the - * localHandset to. - * @param dialContext - context we are going to dial from. - * @param hideCallerId - * @param channelVarsToSet - * @param callerId - the callerID to display on the targetEndPoint. - * @return - * @throws PBXException - */ - public OriginateResult[] dial(final NewChannelListener listener, final EndPoint localHandset, - final EndPoint targetEndPoint, final String dialContext, final CallerID callerID, final boolean hideCallerId, - Map channelVarsToSet) throws PBXException - { - final PBX pbx = PBXFactory.getActivePBX(); - - try (final OriginateToExtension originate = new OriginateToExtension(listener);) - { - - // First bring the operator's handset up and connect it to the - // 'njr-dial' extension where they can - // wait whilst we complete the second leg - final OriginateResult trcResult = originate.originate(localHandset, pbx.getExtensionAgi(), true, - ((AsteriskPBX) pbx).getManagementContext(), callerID, hideCallerId, channelVarsToSet); - - this.result[0] = trcResult; - if (trcResult.isSuccess() == true) - { - - try - { - if (targetEndPoint instanceof HoldAtAgi) - { - if (trcResult.getChannel().waitForChannelToReachAgi(30, TimeUnit.SECONDS)) - { - // call is now in agi - System.out.println("Call is in agi"); - } - else - { - // call never reached agi - System.out.println("Call never reached agi"); - } - } - else - { - - // The call is now up, so connect it to - // the - // destination. - this._latch = new CountDownLatch(1); - - trcResult.getChannel().setCurrentActivityAction( - new AgiChannelActivityDial(targetEndPoint.getFullyQualifiedName())); - - this._latch.await(30, TimeUnit.SECONDS); - - } - } - catch (final InterruptedException e) - { - // noop - } - } - - return this.result; - } - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(BridgeEvent.class); - // bridge event is a subclass of linkevent, so we need link & unlink in - // our list of events to support Asterisk 1.4 - required.add(LinkEvent.class); - required.add(UnlinkEvent.class); - required.add(HangupEvent.class); - - return required; - } - - @Override - public void onManagerEvent(final ManagerEvent event) - { - if (event instanceof BridgeEvent) - { - final BridgeEvent link = (BridgeEvent) event; - - if ((link.getChannel1() != null) && (this.result[0] != null) - && link.getChannel1().isSame(this.result[0].getChannel())) - { - - Dial.logger.debug("Dial out bridged on " + link.getChannel1() + " to " + link.getChannel2()); //$NON-NLS-1$ //$NON-NLS-2$ - this.result[1] = new OriginateResult(); - - this.result[1].setChannelData(link.getChannel2()); - this._latch.countDown(); - } - } - else if (event instanceof HangupEvent) - { - final HangupEvent hangup = (HangupEvent) event; - final Channel hangupChannel = hangup.getChannel(); - - if (Dial.logger.isDebugEnabled()) - { - Dial.logger.debug("hangup :" + hangupChannel); //$NON-NLS-1$ - Dial.logger.debug("channel 0:" + this.result[0]); //$NON-NLS-1$ - Dial.logger.debug("channel 1:" + this.result[1]); //$NON-NLS-1$ - } - if ((this.result[0] != null) && this.result[0].isSuccess() && hangupChannel.isSame(this.result[0].getChannel())) - { - if (this._latch != null) - { - this._latch.countDown(); - } - } - } - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/DialToAgi.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/DialToAgi.java deleted file mode 100644 index b4213599f..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/DialToAgi.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.util.HashSet; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.NewChannelListener; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class DialToAgi extends EventListenerBaseClass -{ - private final static Logger logger = Logger.getLogger(DialToAgi.class); - - private final OriginateResult result[] = new OriginateResult[2]; - - private volatile boolean hangupDetected = false; - - public DialToAgi(final String descriptiveName) - { - super(descriptiveName); - this.startListener(PBXFactory.getActivePBX()); - } - - /** - * Dials the targetEndPoint connecting the call to the localHandset. The - * dial is done in two parts as we need to set the auto answer header - * differently for each phone. For the localHandset we set auto answer on, - * whilst for the remote targetEndPoint we MUST not auto answer the phone. - * - * @param localHandset the users handset we are going to dial from (e.g. - * receptionist phone). - * @param targetEndPoint - the remote handset we are going to connect the - * localHandset to. - * @param dialContext - context we are going to dial from. - * @param hideCallerId - * @param channelVarsToSet - * @param callerId - the callerID to display on the targetEndPoint. - * @return - * @throws PBXException - */ - public OriginateResult[] dial(final NewChannelListener listener, final EndPoint localHandset, - final AgiChannelActivityAction action, final CallerID callerID, final boolean hideCallerId, - Map channelVarsToSet) throws PBXException, InterruptedException - { - final PBX pbx = PBXFactory.getActivePBX(); - - try (final OriginateToExtension originate = new OriginateToExtension(listener);) - { - - // First bring the operator's handset up and connect it to the - // 'njr-dial' extension where they can - // wait whilst we complete the second leg - final OriginateResult trcResult = originate.originate(localHandset, pbx.getExtensionAgi(), true, - ((AsteriskPBX) pbx).getManagementContext(), callerID, hideCallerId, channelVarsToSet); - - this.result[0] = trcResult; - if (trcResult.isSuccess() == true) - { - - trcResult.getChannel().setCurrentActivityAction(action); - if (trcResult.getChannel().waitForChannelToReachAgi(30, TimeUnit.SECONDS)) - { - logger.info("Call reached AGI"); - } - else - { - logger.error("Call never reached agi"); - } - - } - else - { - logger.error("Originate failed: " + trcResult.getAbortReason()); - } - logger.info("Hangup status is " + hangupDetected); - - return this.result; - } - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - required.add(HangupEvent.class); - - return required; - } - - @Override - public void onManagerEvent(final ManagerEvent event) - { - if (event instanceof HangupEvent) - { - final HangupEvent hangup = (HangupEvent) event; - final Channel hangupChannel = hangup.getChannel(); - - if (DialToAgi.logger.isDebugEnabled()) - { - DialToAgi.logger.debug("hangup :" + hangupChannel); //$NON-NLS-1$ - DialToAgi.logger.debug("channel 0:" + this.result[0]); //$NON-NLS-1$ - DialToAgi.logger.debug("channel 1:" + this.result[1]); //$NON-NLS-1$ - } - if ((this.result[0] != null) && this.result[0].isSuccess() && hangupChannel.isSame(this.result[0].getChannel())) - { - hangupDetected = true; - } - } - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/EventListenerBaseClass.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/EventListenerBaseClass.java deleted file mode 100644 index 89b04522f..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/EventListenerBaseClass.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; -import org.asteriskjava.pbx.internal.core.FilteredManagerListener; - -/* - * This is the basic abstract event listener class. It implements a thread - * and queue. - */ -public abstract class EventListenerBaseClass implements FilteredManagerListener, AutoCloseable -{ - - private final String name; - - protected EventListenerBaseClass(final String descriptiveName) - { - this.name = descriptiveName; - } - - @Override - public String getName() - { - return this.name; - } - - /** - * we have to take the pbx as an arg here as we sometimes this is called - * during the creation phase of for the pbx, and the factory can't give out - * the pbx at that point event though it is initialised. - */ - - public void startListener(PBX iPBX) - { - - ((AsteriskPBX) iPBX).addListener(this); - } - - /** - * Stops the listener. - */ - @Override - public void close() - { - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - pbx.removeListener(this); - } - - /** - * This class exists so we can start and stop the listener using the new - * try-with-resource of JRE7. Whilst the parent class is Autoclosable we - * can't always use it directly in a try block (e.g. it is the base class). - * In those cases you can use this class. - * - * @author bsutton - */ - public class AutoClose implements java.lang.AutoCloseable - { - EventListenerBaseClass listener; - - public AutoClose(final EventListenerBaseClass listener) - { - this(listener, true); - } - - public AutoClose(final EventListenerBaseClass listener, final boolean sendEvents) - { - if (listener == null) - { - throw new IllegalArgumentException("listener may not be null"); //$NON-NLS-1$ - } - - this.listener = listener; - if (sendEvents) - { - listener.startListener(PBXFactory.getActivePBX()); - } - } - - @Override - public void close() - { - this.listener.close(); - - } - } -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/HoldAtAgi.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/HoldAtAgi.java deleted file mode 100644 index 1483da224..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/HoldAtAgi.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.TechType; - -public class HoldAtAgi implements EndPoint -{ - - @Override - public int compareTo(EndPoint arg0) - { - // TODO Auto-generated method stub - return 0; - } - - @Override - public boolean isSame(EndPoint rhs) - { - return rhs instanceof HoldAtAgi; - } - - @Override - public boolean isLocal() - { - return false; - } - - @Override - public boolean isSIP() - { - return false; - } - - @Override - public String getFullyQualifiedName() - { - return ""; - } - - @Override - public String getSimpleName() - { - return ""; - } - - @Override - public String getSIPSimpleName() - { - return ""; - } - - @Override - public boolean isUnknown() - { - return false; - } - - @Override - public TechType getTech() - { - return null; - } - - @Override - public boolean isEmpty() - { - return true; - } - // Logger logger = LogManager.getLogger(); -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/MonitorCall.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/MonitorCall.java deleted file mode 100644 index 6cc7f2435..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/MonitorCall.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.util.Date; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Call; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.MonitorAction; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class MonitorCall -{ - static Logger logger = Logger.getLogger(MonitorCall.class); - - static long id = 1; - - private String file = null; - - public MonitorCall(final Call call) - { - super(); - - try - { - this.setFile(); - final MonitorAction monitorAction = new MonitorAction(call.getRemoteParty(), this.file, "gsm", true); //$NON-NLS-1$ - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - pbx.sendAction(monitorAction, 1000); - - } - catch (final Exception e) - { - MonitorCall.logger.error(e, e); - } - } - - public String getFilename() - { - return this.file + ".gsm"; //$NON-NLS-1$ - } - - private synchronized void setFile() - { - long no = (new Date()).getTime(); - no = no / 1000; - final String unq = Long.toHexString(no); - - this.file = "njr" + unq + "-" + MonitorCall.id; //$NON-NLS-1$ //$NON-NLS-2$ - MonitorCall.id++; - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateBaseClass.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateBaseClass.java deleted file mode 100644 index 05e23530f..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateBaseClass.java +++ /dev/null @@ -1,578 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.log4j.Logger; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.NewChannelListener; -import org.asteriskjava.pbx.PBX; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.asterisk.wrap.actions.GetVarAction; -import org.asteriskjava.pbx.asterisk.wrap.actions.OriginateAction; -import org.asteriskjava.pbx.asterisk.wrap.events.BridgeEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.HangupEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.LinkEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.ManagerEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.NewChannelEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.OriginateResponseEvent; -import org.asteriskjava.pbx.asterisk.wrap.events.UnlinkEvent; -import org.asteriskjava.pbx.asterisk.wrap.response.ManagerResponse; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public abstract class OriginateBaseClass extends EventListenerBaseClass -{ - // Used to set a - public static final String NJR_ORIGINATE_ID = "njrOriginateID"; //$NON-NLS-1$ - - /* - * this class generates and issues ActionEvents to asterisk through the - * manager. This is the asterisk coal face. - */ - static Logger logger = Logger.getLogger(OriginateBaseClass.class); - - private volatile String originateID; - - volatile private boolean originateSuccess; - - private final Channel monitorChannel1; - - private boolean hungup = false; - - private Channel newChannel; - - private final Channel monitorChannel2; - - private final OriginateResult result; - - /** - * The following two variables together are used to determine if the - * originated channel has come up. This is to overcome the problem that the - * OriginateResponseEvent and the NewChannelEvent can occur in any order - * (although the NewChannelEvent will occur first in most circumstances). - * Note: we get many NewChannelEvents but we are only interested in a very - * specific one. - */ - // Used to track if the originate event has been seen. - private boolean originateSeen = false; - - // Used to track if the new (final) channel has been seen. - private boolean channelSeen = false; - - private final NewChannelListener listener; - - private final CountDownLatch originateLatch = new CountDownLatch(1); - - protected OriginateBaseClass(final NewChannelListener listener, final Channel monitor, final Channel monitor2) - { - super("NewOrginateClass"); //$NON-NLS-1$ - this.listener = listener; - this.monitorChannel1 = monitor; - this.monitorChannel2 = monitor2; - this.result = new OriginateResult(); - - // Just add us as an asterisk event listener. - this.startListener(PBXFactory.getActivePBX()); - - } - - /** - * @param local - * @param target - * @param myVars - * @param callerId the caller id to set when initiating this call. - * @param hideCallerId - * @param context - * @return - */ - protected OriginateResult originate(final EndPoint local, final EndPoint target, final HashMap myVars, - final CallerID callerID, final Integer timeout, final boolean hideCallerId, final String context) - { - OriginateBaseClass.logger.debug("originate called"); //$NON-NLS-1$ - this.originateSeen = false; - this.channelSeen = false; - - if (this.hungup == true) - { - // the monitored channel already hungup so just return false and - // shutdown - this.close(); - return null; - } - - OriginateBaseClass.logger.debug("originate connection endPoint \n" + local + " to endPoint " + target //$NON-NLS-1$ //$NON-NLS-2$ - + " vars " + myVars); //$NON-NLS-1$ - ManagerResponse response = null; - - final AsteriskSettings settings = PBXFactory.getActiveProfile(); - - final OriginateAction originate = new OriginateAction(); - this.originateID = originate.getActionId(); - - // the double under score "__" is to cause the variable to propagate - // forward to the new channel when using local/ - myVars.put("__" + OriginateBaseClass.NJR_ORIGINATE_ID, this.originateID); //$NON-NLS-1$ - - Integer localTimeout = timeout; - - if (timeout == null) - { - localTimeout = 30000; - try - { - localTimeout = settings.getDialTimeout() * 1000; - } - catch (final Exception e) - { - OriginateBaseClass.logger.error("Invalid dial timeout value"); //$NON-NLS-1$ - } - } - - // Whilst the originate document says that it takes a channel it - // actually takes an - // end point. I haven't check but I'm skeptical that you can actually - // originate to - // a channel as the doco talks about 'dialing the channel'. I suspect - // this - // may be part of asterisk's sloppy terminology. - if (local.isLocal()) - { - originate.setEndPoint(local); - originate.setOption("/n"); //$NON-NLS-1$ - } - else - { - originate.setEndPoint(local); - } - - originate.setContext(context); - originate.setExten(target); - originate.setPriority(1); - - // Set the caller id. - if (hideCallerId) - { - // hide callerID - originate.setCallingPres(32); - } - else - { - originate.setCallerId(callerID); - } - - originate.setVariables(myVars); - originate.setAsync(true); - originate.setTimeout(localTimeout); - - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - try - { - response = pbx.sendAction(originate, localTimeout); - OriginateBaseClass.logger.debug("Originate.sendAction completed"); //$NON-NLS-1$ - if (response.getResponse().compareToIgnoreCase("Success") != 0)//$NON-NLS-1$ - { - OriginateBaseClass.logger - .error("Error Originating call" + originate.toString() + " : " + response.getMessage());//$NON-NLS-1$//$NON-NLS-2$ - throw new ManagerCommunicationException(response.getMessage(), null); - } - - originateLatch.await(localTimeout + 1000, TimeUnit.MILLISECONDS); // wait - // the - // set - // timeout - // +1 - // second to - // allow for - // asterisk to start the originate - } - catch (final InterruptedException e) - { - OriginateBaseClass.logger.debug(e, e); - } - catch (final Exception e) - { - OriginateBaseClass.logger.error(e, e); - } - finally - { - this.close(); - } - - if (this.originateSuccess == true) - { - this.result.setSuccess(true); - this.result.setChannelData(this.newChannel); - OriginateBaseClass.logger.debug("new channel ok: " + this.newChannel); //$NON-NLS-1$ - } - else - { - OriginateBaseClass.logger.error("originate failed connecting endPoint: " + local + " to ext " + target); //$NON-NLS-1$//$NON-NLS-2$ - - if (this.newChannel != null) - { - try - { - pbx.hangup(this.newChannel); - } - catch (IllegalArgumentException | IllegalStateException | PBXException e) - { - logger.error(e, e); - - } - } - } - return this.result; - } - - void abort(final String reason) - { - OriginateBaseClass.logger.debug("Aborting originate ");//$NON-NLS-1$ - this.close(); - this.originateSuccess = false; - this.result.setAbortReason(reason); - this.hungup = true; - if (this.newChannel != null) - { - OriginateBaseClass.logger.debug("Aborted, Hangup up on the way out");//$NON-NLS-1$ - this.result.setChannelHungup(true); - - PBX pbx = PBXFactory.getActivePBX(); - try - { - pbx.hangup(this.newChannel); - } - catch (IllegalArgumentException | IllegalStateException | PBXException e) - { - logger.error(e, e); - - } - } - originateLatch.countDown(); - - } - - @Override - public HashSet> requiredEvents() - { - HashSet> required = new HashSet<>(); - - required.add(OriginateResponseEvent.class); - required.add(BridgeEvent.class); - // bridge event is a subclass of linkevent, so we need link & unlink in - // our list of events to support Asterisk 1.4 - required.add(LinkEvent.class); - required.add(UnlinkEvent.class); - required.add(HangupEvent.class); - required.add(NewChannelEvent.class); - - return required; - } - - /** - * It is important that this method is synchronised as there is some - * interaction between the events and we need to ensure we process one at a - * time. - */ - @Override - synchronized public void onManagerEvent(final ManagerEvent event) - { - if (event instanceof HangupEvent) - { - final HangupEvent hangupEvt = (HangupEvent) event; - final Channel hangupChannel = hangupEvt.getChannel(); - - if ((this.newChannel != null) && (hangupChannel.isSame(this.newChannel))) - { - this.originateSuccess = false; - OriginateBaseClass.logger.error("Dest channel " + this.newChannel + " hungup after answer"); //$NON-NLS-1$//$NON-NLS-2$ - originateLatch.countDown(); - } - if ((this.monitorChannel1 != null) && (hangupChannel.isSame(this.monitorChannel1))) - { - this.originateSuccess = false; - this.hungup = true; - if (this.newChannel != null) - { - OriginateBaseClass.logger.debug("hanging up " + this.newChannel);//$NON-NLS-1$ - this.result.setChannelHungup(true); - - PBX pbx = PBXFactory.getActivePBX(); - try - { - pbx.hangup(this.newChannel); - } - catch (IllegalArgumentException | IllegalStateException | PBXException e) - { - logger.error(e, e); - - } - } - OriginateBaseClass.logger.debug("notify channel 1 hungup");//$NON-NLS-1$ - originateLatch.countDown(); - } - if ((this.monitorChannel2 != null) && (hangupChannel.isSame(this.monitorChannel2))) - { - this.originateSuccess = false; - this.hungup = true; - if (this.newChannel != null) - { - OriginateBaseClass.logger.debug("Hanging up channel " + this.newChannel);//$NON-NLS-1$ - this.result.setChannelHungup(true); - - PBX pbx = PBXFactory.getActivePBX(); - try - { - pbx.hangup(this.newChannel); - } - catch (IllegalArgumentException | IllegalStateException | PBXException e) - { - logger.error(e, e); - - } - } - OriginateBaseClass.logger.debug("Notify channel 2 (" + this.monitorChannel2 + ") hungup");//$NON-NLS-1$//$NON-NLS-2$ - originateLatch.countDown(); - } - - } - if (event instanceof OriginateResponseEvent) - { - OriginateBaseClass.logger.debug("response : " + this.newChannel); //$NON-NLS-1$ - - final OriginateResponseEvent response = (OriginateResponseEvent) event; - OriginateBaseClass.logger.debug("OriginateResponseEvent: channel=" //$NON-NLS-1$ - + (response.isChannel() ? response.getChannel() : response.getEndPoint()) + " originateID:" //$NON-NLS-1$ - + this.originateID); - OriginateBaseClass.logger.debug("{" + response.getReason() + ":" + response.getResponse() + "}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (this.originateID != null) - { - if (this.originateID.compareToIgnoreCase(response.getActionId()) == 0) - { - this.originateSuccess = response.isSuccess(); - OriginateBaseClass.logger.debug("OriginateResponse: matched actionId, success=" + this.originateSuccess //$NON-NLS-1$ - + " channelSeen=" + this.channelSeen); //$NON-NLS-1$ - - this.originateSeen = true; - - // if we have also seen the channel then we can notify - // the - // originate() method - // that the call is up. Otherwise we will rely on the - // NewChannelEvent doing the - // notify. - if (this.channelSeen == true) - { - OriginateBaseClass.logger.debug("notify originate response event 305 " + this.originateSuccess);//$NON-NLS-1$ - originateLatch.countDown(); - } - } - } - else - { - OriginateBaseClass.logger.warn("actionid is null");//$NON-NLS-1$ - } - } - - // Look for the channel events that tell us that both sides of the - // call - // are up. - // We will see a number of channels come up as the call progresses. - // The LOCAL/ channels are just internal workings of Asterisk so we - // need - // to ignore these. - if (event instanceof NewChannelEvent) - { - final NewChannelEvent newState = (NewChannelEvent) event; - final Channel channel = newState.getChannel(); - final GetVarAction var = new GetVarAction(channel, OriginateBaseClass.NJR_ORIGINATE_ID); - - OriginateBaseClass.logger.debug("new channel event :" + channel + " context = " + newState.getContext() //$NON-NLS-1$//$NON-NLS-2$ - + " state =" + newState.getChannelStateDesc() + " state =" + newState.getChannelState()); //$NON-NLS-1$ //$NON-NLS-2$ - - // Now try to get the NJR_ORIGINATE_ID's value to see if this is - // an - // event for our channel - // If it is for our channel then the NJR_ORIGINATE_ID will match - // our - // originateID. - // We need to try several times as it can take some time to - // appear - // within asterisk. - int ctr = 0; - String __originateID = null; - while ((ctr < 5) && (__originateID == null)) - { - try - { - ctr++; - /* - * wait 100ms to allow asterisk time to make the channel - * variables available. If you request the channel variables - * too soon asterisk responds with channel not found. - */ - Thread.sleep(100); - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - final ManagerResponse response = pbx.sendAction(var, 500); - __originateID = response.getAttribute("value"); //$NON-NLS-1$ - - if ((__originateID != null)) - { - // Check if the event is for our channel by checking - // the - // originateIDs match. - if (__originateID.compareToIgnoreCase(this.originateID) == 0) - { - if ((this.newChannel == null) && !channel.isLocal()) - { - this.newChannel = channel; - this.channelSeen = true; - - OriginateBaseClass.logger.debug("new channel name " + channel); //$NON-NLS-1$ } - if (this.listener != null) - { - /* - * sometimes it's not actually the NJR phone - * we're originating. Otherwise update the - * NJR phone channel to allow the call to be - * cancelled before it's answered. - */ - this.listener.channelUpdate(channel); - } - - if (this.originateSeen == true) - { - OriginateBaseClass.logger.debug("notifying success 362");//$NON-NLS-1$ - originateLatch.countDown(); - } - } - } - else - { - // So we got an originate but it wasn't for us which - // means this channel isn't ours. - // so we can ignore the event. - OriginateBaseClass.logger.debug("originateID " + __originateID); //$NON-NLS-1$ - } - } - } - catch (final Exception e) - { - // We only care about error if we are on the last - // attempt. - if ((this.originateSuccess == false) && (ctr == 4)) - { - OriginateBaseClass.logger.error(e, e); - } - } - } - } - - // Look for the channel events that tell us that both sides of the - // call - // are up. - // We will see a number of channels come up as the call progresses. - // The LOCAL/ channels are just internal workings of Asterisk so we - // need - // to ignore these. - if (event instanceof BridgeEvent) - { - final BridgeEvent bridgeEvent = (BridgeEvent) event; - Channel channel = bridgeEvent.getChannel1(); - if (bridgeEvent.getChannel1().isLocal()) - { - channel = bridgeEvent.getChannel2(); - } - final GetVarAction var = new GetVarAction(channel, OriginateBaseClass.NJR_ORIGINATE_ID); - - OriginateBaseClass.logger.debug("new channel event :" + channel + " channel1 = " + bridgeEvent.getChannel1() //$NON-NLS-1$//$NON-NLS-2$ - + " channel2 =" + bridgeEvent.getChannel2()); //$NON-NLS-1$ - - // Now try to get the NJR_ORIGINATE_ID's value to see if this is - // an - // event for our channel - // If it is for our channel then the NJR_ORIGINATE_ID will match - // our - // originateID. - // We need to try several times as it can take some time to - // appear - // within asterisk. - int ctr = 0; - String __originateID = null; - while ((ctr < 5) && (__originateID == null)) - { - try - { - ctr++; - /* - * wait 100ms to allow asterisk time to make the channel - * variables available. If you request the channel variables - * too soon asterisk responds with channel not found. - */ - Thread.sleep(100); - AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - final ManagerResponse response = pbx.sendAction(var, 500); - __originateID = response.getAttribute("value"); //$NON-NLS-1$ - - if ((__originateID != null)) - { - // Check if the event is for our channel by checking - // the - // originateIDs match. - if ((this.originateID != null) && (__originateID.compareToIgnoreCase(this.originateID) == 0)) - { - if ((this.newChannel == null) && !channel.isLocal()) - { - this.newChannel = channel; - this.channelSeen = true; - - OriginateBaseClass.logger.debug("new channel name " + channel); //$NON-NLS-1$ } - if (this.listener != null) - { - /* - * sometimes it's not actually the NJR phone - * we're originating. Otherwise update the - * NJR phone channel to allow the call to be - * cancelled before it's answered. - */ - this.listener.channelUpdate(channel); - } - - if (this.originateSeen == true) - { - OriginateBaseClass.logger.debug("notifying success 362");//$NON-NLS-1$ - originateLatch.countDown(); - } - } - } - } - else - { - // So we got an originate but it wasn't for us which - // means this channel isn't ours. - // so we can ignore the event. - OriginateBaseClass.logger.debug("originateID " + __originateID); //$NON-NLS-1$ - } - } - catch (final Exception e) - { - // We only care about error if we are on the last - // attempt. - if ((this.originateSuccess == false) && (ctr == 4)) - { - OriginateBaseClass.logger.error(e, e); - } - } - } - } - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateResult.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateResult.java deleted file mode 100644 index 880ccb07b..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateResult.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; - -public class OriginateResult -{ - static Logger logger = Logger.getLogger(OriginateResult.class); - - private boolean channelHungup = false; - - private boolean success = false; - - private Channel newChannel = null; - - private String abortReason; - - OriginateResult() - { - // not used - } - - public String getAbortReason() - { - return this.abortReason; - } - - void setAbortReason(final String reason) - { - this.abortReason = reason; - - } - - public void setChannelData(final Channel channel) - { - this.newChannel = channel; - } - - public Channel getChannel() - { - - return this.newChannel; - } - - public boolean isSuccess() - { - return this.success; - } - - public void setSuccess(boolean success) - { - this.success = success; - } - - public boolean isChannelHungup() - { - return this.channelHungup; - } - - public void setChannelHungup(boolean channel1Hungup) - { - this.channelHungup = channel1Hungup; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateToExtension.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateToExtension.java deleted file mode 100644 index 96262a2ab..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/OriginateToExtension.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.util.HashMap; -import java.util.Map; - -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.CallerID; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.ListenerPriority; -import org.asteriskjava.pbx.NewChannelListener; -import org.asteriskjava.pbx.PBXFactory; - -public class OriginateToExtension extends OriginateBaseClass -{ - - /* - * this class generates and issues ActionEvents to asterisk through the - * manager. This is the asterisk coal face. - */ - - public OriginateToExtension(final NewChannelListener listener) - { - super(listener, null, null); - - } - - public OriginateResult originate(final EndPoint localHandset, final EndPoint targetExtension, final boolean autoAnswer, - final CallerID callerID, final String context) - { - /* - * A new call is originated on the nominated channel to the specified - * extension. - */ - OriginateBaseClass.logger.debug("originate connecting localHandset " + localHandset + " to Extension " //$NON-NLS-1$ //$NON-NLS-2$ - + targetExtension + " autoAnswer " + autoAnswer); //$NON-NLS-1$ - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - final HashMap myVars = new HashMap<>(1); - if (autoAnswer == true) - { - RedirectCall.setAutoAnswer(myVars, profile); - } - - return this.originate(localHandset, targetExtension, myVars, callerID, null, false, context); - } - - public OriginateResult originate(final EndPoint localHandset, final EndPoint targetExtension, final boolean autoAnswer, - final String context, final CallerID callerID, final boolean hideCallerId, Map channelVarsToSet) - { - /* - * A new call is originated on the nominated channel to the specified - * extension. - */ - OriginateBaseClass.logger.debug("originate connection localHandset " + localHandset + " to Extension " //$NON-NLS-1$ //$NON-NLS-2$ - + targetExtension + " autoAnswer " + autoAnswer); //$NON-NLS-1$ - final AsteriskSettings profile = PBXFactory.getActiveProfile(); - - final HashMap myVars = new HashMap<>(1); - if (autoAnswer == true) - { - RedirectCall.setAutoAnswer(myVars, profile); - } - if (channelVarsToSet != null) - { - myVars.putAll(channelVarsToSet); - } - - return this.originate(localHandset, targetExtension, myVars, callerID, null, hideCallerId, context); - } - - @Override - public ListenerPriority getPriority() - { - return ListenerPriority.NORMAL; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/RedirectCall.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/RedirectCall.java deleted file mode 100644 index 0d5e3e5e5..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/RedirectCall.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import java.util.HashMap; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.AgiChannelActivityAction; -import org.asteriskjava.pbx.AsteriskSettings; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.EndPoint; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.agi.AgiChannelActivityDial; -import org.asteriskjava.pbx.agi.AgiChannelActivityVoicemail; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class RedirectCall -{ - /* - * this class generates and issues ActionEvents to asterisk through the - * manager. This is the asterisk coal face. - */ - static Logger logger = Logger.getLogger(RedirectCall.class); - - static public void setAutoAnswer(final HashMap myVars, final AsteriskSettings settings) - { - myVars.put(AsteriskPBX.getSIPADDHeader(false, true), settings.getAutoAnswer()); - RedirectCall.logger.debug("auto answer"); //$NON-NLS-1$ - } - - public boolean redirect(final Channel channel, final EndPoint targetEndPoint, final String context, - final boolean autoAnswer) throws PBXException - { - // Set or clear the auto answer header. - // Clearing is important as it may have been set during the - // initial answer sequence. If we don't clear it then then transfer - // target will be auto-answered, which is fun but bad. - String sipHeader = ""; - if (autoAnswer) - { - sipHeader = PBXFactory.getActiveProfile().getAutoAnswer(); - } - - /* - * redirects the specified channel to the specified extension. Returns - * true or false reflecting success. - */ - redirect(channel, new AgiChannelActivityDial(targetEndPoint.getFullyQualifiedName(), sipHeader)); - - RedirectCall.logger.debug("redirected " + channel + " to " + targetEndPoint); //$NON-NLS-1$ //$NON-NLS-2$ - return true; - } - - public boolean redirectToVoicemail(final Channel channel, final EndPoint mailbox) throws PBXException - { - - redirect(channel, new AgiChannelActivityVoicemail(mailbox.getFullyQualifiedName())); - return true; - } - - public void redirect(Channel channel, AgiChannelActivityAction channelActivityHold) throws PBXException - { - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - - if (!pbx.moveChannelToAgi(channel)) - { - throw new PBXException("Channel: " + channel + " couldn't be moved to agi"); - } - if (!pbx.waitForChannelToQuiescent(channel, 3000)) - throw new PBXException("Channel: " + channel + " cannot be redirected as it is still in transition."); - - channel.setCurrentActivityAction(channelActivityHold); - - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/RedirectToMeetMe.java b/src/main/java/org/asteriskjava/pbx/internal/managerAPI/RedirectToMeetMe.java deleted file mode 100644 index 2a439b5b2..000000000 --- a/src/main/java/org/asteriskjava/pbx/internal/managerAPI/RedirectToMeetMe.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.asteriskjava.pbx.internal.managerAPI; - -import org.apache.log4j.Logger; -import org.asteriskjava.pbx.Channel; -import org.asteriskjava.pbx.PBXException; -import org.asteriskjava.pbx.PBXFactory; -import org.asteriskjava.pbx.agi.AgiChannelActivityMeetme; -import org.asteriskjava.pbx.internal.core.AsteriskPBX; - -public class RedirectToMeetMe -{ - static Logger logger = Logger.getLogger(RedirectToMeetMe.class); - - public RedirectToMeetMe() - { - super(); - } - - public boolean redirectToMeetme(final Channel channel, final String room, final boolean markedUser) throws PBXException - { - final AsteriskPBX pbx = (AsteriskPBX) PBXFactory.getActivePBX(); - /* - * this procedure rediects the specified channel to the specified meetme - * room. This is achieved through the dial plan. q option - don't - * announce new members to meetme d option - dynamically create meetme x - * option - close the conference when last marked user exits A options - - * set marked user - */ - - RedirectToMeetMe.logger.info("redirect to Meetme channel " + channel + " room " + room //$NON-NLS-1$ //$NON-NLS-2$ - + " markedUser " + markedUser); //$NON-NLS-1$ - String options = new String(); - if (markedUser == true) - { - options = "qdxAF"; //$NON-NLS-1$ - } - else - { - options = "qdxF"; //$NON-NLS-1$ - } - - if (!pbx.moveChannelToAgi(channel)) - { - throw new PBXException("Channel: " + channel + " couldn't be moved to agi"); - } - channel.setCurrentActivityAction(new AgiChannelActivityMeetme(room, options)); - - return true; - } - -} diff --git a/src/main/java/org/asteriskjava/pbx/util/LogTime.java b/src/main/java/org/asteriskjava/pbx/util/LogTime.java deleted file mode 100644 index fd2261e4c..000000000 --- a/src/main/java/org/asteriskjava/pbx/util/LogTime.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Created on 2/03/2005 - * - */ -package org.asteriskjava.pbx.util; - -/** - * @author work shop - */ -public class LogTime -{ - public Long dStartTime = System.currentTimeMillis(); - - public long timeTaken() - { - // returns the time taken from construction til now in milliseconds - // Date dStartTime = new Date(); - - return System.currentTimeMillis() - this.dStartTime; - - } -} diff --git a/src/main/java/org/asteriskjava/tools/.gitignore b/src/main/java/org/asteriskjava/tools/.gitignore deleted file mode 100644 index 03106de55..000000000 --- a/src/main/java/org/asteriskjava/tools/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/HtmlEventTracer$1.class -/HtmlEventTracer.class diff --git a/src/main/java/org/asteriskjava/tools/HtmlEventTracer.java b/src/main/java/org/asteriskjava/tools/HtmlEventTracer.java deleted file mode 100644 index 660ddc3d6..000000000 --- a/src/main/java/org/asteriskjava/tools/HtmlEventTracer.java +++ /dev/null @@ -1,330 +0,0 @@ -package org.asteriskjava.tools; - -import java.beans.BeanInfo; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.asteriskjava.live.DefaultAsteriskServer; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.event.AbstractParkedCallEvent; -import org.asteriskjava.manager.event.AntennaLevelEvent; -import org.asteriskjava.manager.event.BridgeEvent; -import org.asteriskjava.manager.event.DialEvent; -import org.asteriskjava.manager.event.HangupEvent; -import org.asteriskjava.manager.event.HoldEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.NewChannelEvent; -import org.asteriskjava.manager.event.NewExtenEvent; -import org.asteriskjava.manager.event.NewStateEvent; -import org.asteriskjava.manager.event.PausedEvent; -import org.asteriskjava.manager.event.RenameEvent; -import org.asteriskjava.manager.event.UnpausedEvent; - -/** - * A diagnostic tool that creates an HTML file showing the state changing events - * received from Asterisk on the Manager API. - *

- * The following events are shown: - *

    - *
  • NewChannel
  • - *
  • NewState
  • - *
  • Rename
  • - *
  • Dial
  • - *
  • Bridge (Link and Unlink)
  • - *
  • Hangup
  • - *
- * Usage: java org.asteriskjava.tools.HtmlEventTracer host username password - * - * @version $Id$ - */ -public class HtmlEventTracer implements ManagerEventListener -{ - private String filename = "trace.html"; - private PrintWriter writer; - private final List uniqueIds; - private final List events; - private final Map, String> colors; - - public HtmlEventTracer() - { - uniqueIds = new ArrayList<>(); - events = new ArrayList<>(); - colors = new HashMap<>(); - - colors.put(NewChannelEvent.class, "#7cd300"); // green - colors.put(NewStateEvent.class, "#a4b6c8"); - colors.put(NewExtenEvent.class, "#efefef"); // grey - colors.put(RenameEvent.class, "#ddeeff"); // light blue - colors.put(DialEvent.class, "#feec30"); // yellow - colors.put(BridgeEvent.class, "#fff8ae"); // light yellow - colors.put(HangupEvent.class, "#ff6c17"); // orange - - try - { - writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(filename), StandardCharsets.UTF_8)); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - public static void main(String[] args) throws Exception - { - if (args.length != 3) - { - System.err.println("Usage: java org.asteriskjava.tools.HtmlEventTracer host username password"); - System.exit(1); - } - - final HtmlEventTracer tracer; - final DefaultAsteriskServer server; - - tracer = new HtmlEventTracer(); - server = new DefaultAsteriskServer(args[0], args[1], args[2]); - server.initialize(); - server.getManagerConnection().addEventListener(tracer); - - System.err.println("Event tracer successfully started. Press Ctrl-C to write trace file and exit."); - - Runtime.getRuntime().addShutdownHook(new Thread() - { - @Override - public void run() - { - tracer.write(); - server.shutdown(); - } - }); - - while (true) - { - Thread.sleep(1000); - } - } - - public void onManagerEvent(ManagerEvent event) - { - events.add(event); - System.out.println("> " + event); - for (String property : new String[]{"uniqueId", "uniqueId1", "uniqueId2", "srcUniqueId", "destUniqueId"}) - { - String uniqueId; - - uniqueId = getProperty(event, property); - if (uniqueId != null && !uniqueIds.contains(uniqueId)) - { - uniqueIds.add(uniqueId); - } - } - } - - public void write() - { - writer.append(""); - for (String uniqueId : uniqueIds) - { - writer.append(""); - } - writer.append(""); - writer.println(""); - - for (ManagerEvent event : events) - { - boolean print = false; - StringBuilder line = new StringBuilder(); - - line.append(""); - for (String uniqueId : uniqueIds) - { - String text; - text = getText(uniqueId, event); - if (text == null) - { - line.append(""); - } - else - { - String color = getColor(event.getClass()); - line.append(""); - print = true; - } - } - line.append(""); - if (print) - { - writer.println(line.toString()); - } - } - writer.append("
"); - writer.append(uniqueId.substring(0, uniqueId.lastIndexOf('.') + 1)); - writer.append(""); - writer.append(uniqueId.substring(uniqueId.lastIndexOf('.') + 1, uniqueId.length())); - writer.append("
"); - line.append(event.getClass().getSimpleName()); - line.append("
"); - line.append(event.getDateReceived()); - line.append("
").append(text).append("
"); - writer.close(); - System.err.println("Trace file successfully written to " + filename + "."); - } - - private String getColor(Class< ? extends ManagerEvent> clazz) - { - for (Map.Entry, String> entry : colors.entrySet()) - { - if (entry.getKey().isAssignableFrom(clazz)) - { - return entry.getValue(); - } - } - return "#ffffff"; - } - - protected String getProperty(Object obj, String property) - { - try - { - BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); - for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) - { - if (!propertyDescriptor.getName().equals(property)) - { - continue; - } - - final Object o = propertyDescriptor.getReadMethod().invoke(obj); - return o != null ? o.toString() : null; - } - } - catch (Exception e) - { - System.err.println("Unable to read property '" + property + "' from object " + obj + ": " + e.getMessage()); - return null; - } - - return null; - } - - protected String getText(String uniqueId, ManagerEvent event) - { - String format = null; - String[] properties = null; - - if (uniqueId.equals(getProperty(event, "uniqueId"))) - { - if (event instanceof NewChannelEvent) - { - format = "%s
%s"; - properties = new String[]{"channel", "state"}; - } - else if (event instanceof NewStateEvent) - { - format = "%s
%s"; - properties = new String[]{"channel", "state"}; - } - else if (event instanceof NewExtenEvent) - { - format = "%s,%s,%s
%s(%s)"; - properties = new String[]{"context", "extension", "priority", "application", "appData"}; - } - else if (event instanceof RenameEvent) - { - format = "old: %s
new: %s"; - properties = new String[]{"oldname", "newname"}; - } - else if (event instanceof HoldEvent) - { - format = "%s"; - properties = new String[]{"status"}; - } - else if (event instanceof AbstractParkedCallEvent) - { - format = "exten: %s
from: %s"; - properties = new String[]{"exten", "from"}; - } - else if (event instanceof HangupEvent) - { - format = "%s
%s (%s)"; - properties = new String[]{"channel", "cause", "causeTxt"}; - } - else if (event instanceof AntennaLevelEvent) - { - format = "%s"; - properties = new String[]{"signal"}; - } - else if (event instanceof PausedEvent) - { - format = "(%s) %s"; - properties = new String[]{"header", "extension"}; - } - else if (event instanceof UnpausedEvent) - { - format = "(%s) %s"; - properties = new String[]{"header", "extension"}; - } - } - - if (event instanceof BridgeEvent) - { - if (uniqueId.equals(getProperty(event, "uniqueId1"))) - { - format = "%s
%s
%s"; - properties = new String[]{"uniqueId2", "channel2", "bridgeState"}; - } - else if (uniqueId.equals(getProperty(event, "uniqueId2"))) - { - format = "%s
%s
%s"; - properties = new String[]{"uniqueId1", "channel1", "bridgeState"}; - } - } - - if (event instanceof DialEvent) - { - if (uniqueId.equals(getProperty(event, "srcUniqueId"))) - { - format = "To: %s"; - properties = new String[]{"destination"}; - } - else if (uniqueId.equals(getProperty(event, "destUniqueId"))) - { - format = "From: %s"; - properties = new String[]{"src"}; - } - } - - if (format != null && properties != null) - { - String[] args = new String[properties.length]; - - for (int i = 0; i < properties.length; i++) - { - String value; - - value = getProperty(event, properties[i]); - if (value == null) - { - args[i] = ""; - } - else - { - value = value.replace("<", "<"); - value = value.replace(">", ">"); - args[i] = value; - } - } - - return String.format(format, (Object[]) args); - } - return null; - } -} diff --git a/src/main/java/org/asteriskjava/tools/package.html b/src/main/java/org/asteriskjava/tools/package.html deleted file mode 100644 index 82bfc804c..000000000 --- a/src/main/java/org/asteriskjava/tools/package.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -

Tools for debugging Asterisk and Asterisk-Java.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/util/.gitignore b/src/main/java/org/asteriskjava/util/.gitignore deleted file mode 100644 index 844729c85..000000000 --- a/src/main/java/org/asteriskjava/util/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/AstState.class -/AstUtil.class -/Base64.class -/DaemonThreadFactory.class -/DateUtil.class -/Log.class -/LogFactory.class -/MixMonitorDirection.class -/ReflectionUtil.class -/ServerSocketFacade.class -/SocketConnectionFacade.class diff --git a/src/main/java/org/asteriskjava/util/AstState.java b/src/main/java/org/asteriskjava/util/AstState.java deleted file mode 100644 index 6cdd3b2e3..000000000 --- a/src/main/java/org/asteriskjava/util/AstState.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.asteriskjava.util; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Utility methods related to channel state handling in Asterisk's channel.c. - * - * @since 1.0.0 - */ -public class AstState -{ - /* from include/asterisk/channel.h */ - - /** - * Channel is down and available. - */ - public static final int AST_STATE_DOWN = 0; - - /** - * Channel is down, but reserved. - */ - public static final int AST_STATE_RSRVD = 1; - - /** - * Channel is off hook. - */ - public static final int AST_STATE_OFFHOOK = 2; - - /** - * Digits (or equivalent) have been dialed. - */ - public static final int AST_STATE_DIALING = 3; - - /** - * Line is ringing. - */ - public static final int AST_STATE_RING = 4; - - /** - * Remote end is ringing. - */ - public static final int AST_STATE_RINGING = 5; - - /** - * Line is up. - */ - public static final int AST_STATE_UP = 6; - - /** - * Line is busy. - */ - public static final int AST_STATE_BUSY = 7; - - /** - * Digits (or equivalent) have been dialed while offhook. - */ - public static final int AST_STATE_DIALING_OFFHOOK = 8; - - /** - * Channel has detected an incoming call and is waiting for ring. - */ - public static final int AST_STATE_PRERING = 9; - - private static final Map inverseStateMap; - - static - { - final Map tmpInverseStateMap = new HashMap<>(); - - tmpInverseStateMap.put("Down", AST_STATE_DOWN); - tmpInverseStateMap.put("Rsrvd", AST_STATE_RSRVD); - tmpInverseStateMap.put("OffHook", AST_STATE_OFFHOOK); - tmpInverseStateMap.put("Dialing", AST_STATE_DIALING); - tmpInverseStateMap.put("Ring", AST_STATE_RING); - tmpInverseStateMap.put("Ringing", AST_STATE_RINGING); - tmpInverseStateMap.put("Up", AST_STATE_UP); - tmpInverseStateMap.put("Busy", AST_STATE_BUSY); - tmpInverseStateMap.put("Dialing Offhook", AST_STATE_DIALING_OFFHOOK); - tmpInverseStateMap.put("Pre-ring", AST_STATE_PRERING); - - inverseStateMap = Collections.unmodifiableMap(tmpInverseStateMap); - } - - private static final Pattern UNKNOWN_STATE_PATTERN = Pattern.compile("^Unknown \\((\\d+)\\)$"); - - private AstState() - { - - } - - /** - * This is the inverse to ast_state2str in channel.c. - * - * @param str state as a descriptive text. - * @return numeric state. - */ - public static Integer str2state(String str) - { - Integer state; - - if (str == null) - { - return null; - } - - state = inverseStateMap.get(str); - - if (state == null) - { - Matcher matcher = UNKNOWN_STATE_PATTERN.matcher(str); - if (matcher.matches()) - { - try - { - state = Integer.valueOf(matcher.group(1)); - } - catch (NumberFormatException e) - { - // should not happen as the pattern requires \d+ for the state. - throw new IllegalArgumentException("Unable to convert state '" + str + "' to integer representation", e); - } - } - } - - return state; - } -} diff --git a/src/main/java/org/asteriskjava/util/AstUtil.java b/src/main/java/org/asteriskjava/util/AstUtil.java deleted file mode 100644 index a6a875bd6..000000000 --- a/src/main/java/org/asteriskjava/util/AstUtil.java +++ /dev/null @@ -1,211 +0,0 @@ -package org.asteriskjava.util; - -import java.util.HashSet; -import java.util.Locale; -import java.util.Set; - -/** - * Some static utility methods to imitate Asterisk specific logic.
- * See Asterisk's util.c.
- * Client code is not supposed to use this class. - * - * @author srt - * @version $Id$ - */ -public class AstUtil -{ - private static final Set TRUE_LITERALS; - private static final Set NULL_LITERALS; - - static - { - TRUE_LITERALS = new HashSet<>(20); - TRUE_LITERALS.add("yes"); - TRUE_LITERALS.add("true"); - TRUE_LITERALS.add("y"); - TRUE_LITERALS.add("t"); - TRUE_LITERALS.add("1"); - TRUE_LITERALS.add("on"); - TRUE_LITERALS.add("enabled"); - - NULL_LITERALS = new HashSet<>(20); - NULL_LITERALS.add(""); - NULL_LITERALS.add("unknown"); - NULL_LITERALS.add("none"); // VarSet event in pbx.c - NULL_LITERALS.add(""); - NULL_LITERALS.add("-none-"); // IPaddress in PeerEntryEvent - NULL_LITERALS.add("(none)"); - NULL_LITERALS.add(""); - NULL_LITERALS.add("(not set)"); - NULL_LITERALS.add(""); - NULL_LITERALS.add("n/a"); // channel in AgentsEvent - NULL_LITERALS.add(""); - NULL_LITERALS.add("(null)"); // appData in ListDialplanEvent - } - - private AstUtil() - { - // hide constructor - } - - /** - * Checks if a String represents true or false - * according to Asterisk's logic.
- * The original implementation is util.c is as follows:
- * - *
-     *     int ast_true(const char *s)
-     *     {
-     *         if (!s || ast_strlen_zero(s))
-     *             return 0;
-     * 
- * if (!strcasecmp(s, "yes") || - * !strcasecmp(s, "true") || - * !strcasecmp(s, "y") || - * !strcasecmp(s, "t") || - * !strcasecmp(s, "1") || - * !strcasecmp(s, "on")) - * return -1; - *
- * return 0; - * } - *
- * - *
- * To support the dnd property of - * {@link org.asteriskjava.manager.event.ZapShowChannelsEvent} this method - * also consideres the string "Enabled" as true. - * - * @param o the Object (usually a String) to check for true. - * @return true if s represents true, - * false otherwise. - */ - public static boolean isTrue(Object o) - { - if (o == null) - { - return false; - } - - if (o instanceof Boolean) - { - return (Boolean) o; - } - - final String s; - if (o instanceof String) - { - s = (String) o; - } - else - { - s = o.toString(); - } - return TRUE_LITERALS.contains(s.toLowerCase(Locale.US)); - } - - /** - * @param a an object - * @param b an object to be compared with {@code a} for equality - * @return {@code true} if the arguments are equal to each other and - * {@code false} otherwise - */ - public static boolean isEqual(Object a, Object b) - { - return a == b || a != null && a.equals(b); - } - - /** - * Parses a string for caller id information.
- * The caller id string should be in the form - * "Some Name" <1234>.
- * This resembles ast_callerid_parse in callerid.c - * but strips any whitespace. - * - * @param s the string to parse - * @return a String[] with name (index 0) and number (index 1) - */ - public static String[] parseCallerId(String s) - { - final String[] result = new String[2]; - final int lbPosition; - final int rbPosition; - String name; - String number; - - if (s == null) - { - return result; - } - - lbPosition = s.lastIndexOf('<'); - rbPosition = s.lastIndexOf('>'); - - // no opening and closing brace? use value as CallerId name - if (lbPosition < 0 || rbPosition < 0) - { - name = s.trim(); - if (name.length() == 0) - { - name = null; - } - result[0] = name; - return result; - } - number = s.substring(lbPosition + 1, rbPosition).trim(); - if (number.length() == 0) - { - number = null; - } - - name = s.substring(0, lbPosition).trim(); - if (name.startsWith("\"") && name.endsWith("\"") && name.length() > 1) - { - name = name.substring(1, name.length() - 1).trim(); - } - if (name.length() == 0) - { - name = null; - } - - result[0] = name; - result[1] = number; - return result; - } - - /** - * Checks if the value of s was null in Asterisk.
- * This method is useful as Asterisk likes to replace null - * values with different string values like "unknown", "<unknown>" or - * "<null>".
- * To find such replacements search for S_OR in Asterisk's - * source code. You will find things like - * - *
-     * S_OR(chan->cid.cid_num, "<unknown>")
-     * fdprintf(fd, "agi_callerid: %s\n", S_OR(chan->cid.cid_num, "unknown"));
-     * 
- * - * and more... - * - * @param s the string to test, may be null. If s is not a - * string the only test that is performed is a check for - * null. - * @return true if the s was null in Asterisk; - * false otherwise. - */ - public static boolean isNull(Object s) - { - if (s == null) - { - return true; - } - - if (!(s instanceof String)) - { - return false; - } - - return NULL_LITERALS.contains(((String) s).toLowerCase(Locale.US)); - } -} diff --git a/src/main/java/org/asteriskjava/util/Base64.java b/src/main/java/org/asteriskjava/util/Base64.java deleted file mode 100644 index 3f053f778..000000000 --- a/src/main/java/org/asteriskjava/util/Base64.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * %W% %E% - * - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. - * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. - */ - -package org.asteriskjava.util; - -/** - * Static methods for translating Base64 encoded strings to byte arrays - * and vice-versa.

- * From java.util.prefs. - * - * @author Josh Bloch - */ -public class Base64 { - - private Base64() { - - } - - /** - * Translates the specified byte array into a Base64 string as per - * Preferences.put(byte[]). - */ - public static String byteArrayToBase64(byte[] a) { - return byteArrayToBase64(a, false); - } - - /** - * Translates the specified byte array into an "alternate representation" - * Base64 string. This non-standard variant uses an alphabet that does - * not contain the uppercase alphabetic characters, which makes it - * suitable for use in situations where case-folding occurs. - */ - public static String byteArrayToAltBase64(byte[] a) { - return byteArrayToBase64(a, true); - } - - private static String byteArrayToBase64(byte[] a, boolean alternate) { - int aLen = a.length; - int numFullGroups = aLen/3; - int numBytesInPartialGroup = aLen - 3*numFullGroups; - int resultLen = 4*((aLen + 2)/3); - StringBuilder result = new StringBuilder(resultLen); - char[] intToAlpha = alternate ? intToAltBase64 : intToBase64; - - // Translate all full groups from byte array elements to Base64 - int inCursor = 0; - for (int i=0; i> 2]); - result.append(intToAlpha[(byte0 << 4)&0x3f | (byte1 >> 4)]); - result.append(intToAlpha[(byte1 << 2)&0x3f | (byte2 >> 6)]); - result.append(intToAlpha[byte2 & 0x3f]); - } - - // Translate partial group if present - if (numBytesInPartialGroup != 0) { - int byte0 = a[inCursor++] & 0xff; - result.append(intToAlpha[byte0 >> 2]); - if (numBytesInPartialGroup == 1) { - result.append(intToAlpha[(byte0 << 4) & 0x3f]); - result.append("=="); - } else { - // assert numBytesInPartialGroup == 2; - int byte1 = a[inCursor++] & 0xff; - result.append(intToAlpha[(byte0 << 4)&0x3f | (byte1 >> 4)]); - result.append(intToAlpha[(byte1 << 2)&0x3f]); - result.append('='); - } - } - // assert inCursor == a.length; - // assert result.length() == resultLen; - return result.toString(); - } - - /** - * This array is a lookup table that translates 6-bit positive integer - * index values into their "Base64 Alphabet" equivalents as specified - * in Table 1 of RFC 2045. - */ - private static final char[] intToBase64 = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' - }; - - /** - * This array is a lookup table that translates 6-bit positive integer - * index values into their "Alternate Base64 Alphabet" equivalents. - * This is NOT the real Base64 Alphabet as per in Table 1 of RFC 2045. - * This alternate alphabet does not use the capital letters. It is - * designed for use in environments where "case folding" occurs. - */ - private static final char[] intToAltBase64 = { - '!', '"', '#', '$', '%', '&', '\'', '(', ')', ',', '-', '.', ':', - ';', '<', '>', '@', '[', ']', '^', '`', '_', '{', '|', '}', '~', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '?' - }; - - /** - * Translates the specified Base64 string (as per Preferences.get(byte[])) - * into a byte array. - * - * @throws IllegalArgumentException if s is not a valid Base64 - * string. - */ - public static byte[] base64ToByteArray(String s) { - return base64ToByteArray(s, false); - } - - /** - * Translates the specified "alternate representation" Base64 string - * into a byte array. - * - * @throws IllegalArgumentException or ArrayOutOfBoundsException - * if s is not a valid alternate representation - * Base64 string. - */ - public static byte[] altBase64ToByteArray(String s) { - return base64ToByteArray(s, true); - } - - private static byte[] base64ToByteArray(String s, boolean alternate) { - byte[] alphaToInt = alternate ? altBase64ToInt : base64ToInt; - int sLen = s.length(); - int numGroups = sLen/4; - if (4*numGroups != sLen) - throw new IllegalArgumentException( - "String length must be a multiple of four."); - int missingBytesInLastGroup = 0; - int numFullGroups = numGroups; - if (sLen != 0) { - if (s.charAt(sLen-1) == '=') { - missingBytesInLastGroup++; - numFullGroups--; - } - if (s.charAt(sLen-2) == '=') - missingBytesInLastGroup++; - } - byte[] result = new byte[3*numGroups - missingBytesInLastGroup]; - - // Translate all full groups from base64 to byte array elements - int inCursor = 0, outCursor = 0; - for (int i=0; i> 4)); - result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2)); - result[outCursor++] = (byte) ((ch2 << 6) | ch3); - } - - // Translate partial group, if present - if (missingBytesInLastGroup != 0) { - int ch0 = base64toInt(s.charAt(inCursor++), alphaToInt); - int ch1 = base64toInt(s.charAt(inCursor++), alphaToInt); - result[outCursor++] = (byte) ((ch0 << 2) | (ch1 >> 4)); - - if (missingBytesInLastGroup == 1) { - int ch2 = base64toInt(s.charAt(inCursor++), alphaToInt); - result[outCursor++] = (byte) ((ch1 << 4) | (ch2 >> 2)); - } - } - // assert inCursor == s.length()-missingBytesInLastGroup; - // assert outCursor == result.length; - return result; - } - - /** - * Translates the specified character, which is assumed to be in the - * "Base 64 Alphabet" into its equivalent 6-bit positive integer. - * - * @throw IllegalArgumentException or ArrayOutOfBoundsException if - * c is not in the Base64 Alphabet. - */ - private static int base64toInt(char c, byte[] alphaToInt) { - int result = alphaToInt[c]; - if (result < 0) - throw new IllegalArgumentException("Illegal character " + c); - return result; - } - - /** - * This array is a lookup table that translates unicode characters - * drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) - * into their 6-bit positive integer equivalents. Characters that - * are not in the Base64 alphabet but fall within the bounds of the - * array are translated to -1. - */ - private static final byte[] base64ToInt = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 - }; - - /** - * This array is the analogue of base64ToInt, but for the nonstandard - * variant that avoids the use of uppercase alphabetic characters. - */ - private static final byte[] altBase64ToInt = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, - 2, 3, 4, 5, 6, 7, 8, -1, 62, 9, 10, 11, -1 , 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 12, 13, 14, -1, 15, 63, 16, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 17, -1, 18, 19, 21, 20, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 22, 23, 24, 25 - }; -} diff --git a/src/main/java/org/asteriskjava/util/DaemonThreadFactory.java b/src/main/java/org/asteriskjava/util/DaemonThreadFactory.java deleted file mode 100644 index c54139b6c..000000000 --- a/src/main/java/org/asteriskjava/util/DaemonThreadFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.asteriskjava.util; - -import java.util.concurrent.Executor; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * A ThreadFactory that creates daemon threads for use with an {@link Executor}. - * - * @author srt - * @version $Id$ - * @since 0.3 - */ -public class DaemonThreadFactory implements ThreadFactory -{ - private static final AtomicInteger poolNumber = new AtomicInteger(1); - private final AtomicInteger threadNumber = new AtomicInteger(1); - private final String namePrefix; - - /** - * Creates a new instance. - */ - public DaemonThreadFactory() { - namePrefix = "AJ DaemonPool-"+ poolNumber.getAndIncrement() +'.'; - }//new - - - @Override public Thread newThread (Runnable r) { - final Thread thread = new Thread(r); - thread.setDaemon(true); - thread.setName(namePrefix + threadNumber.getAndIncrement()); - - return thread; - } -} \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/util/DateUtil.java b/src/main/java/org/asteriskjava/util/DateUtil.java deleted file mode 100644 index f765af844..000000000 --- a/src/main/java/org/asteriskjava/util/DateUtil.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -/** - * Utility class to obtain the current date and allows to override with a fixed - * value for unit testing. Includes some convenience methods for date - * conversion. - *

- * Client code is not supposed to use this class. - * - * @author srt - * @version $Id$ - */ -public class DateUtil -{ - private static final String DATE_TIME_PATTERN = "yy-MM-dd HH:mm:ss"; - - private static Date currentDate; - - private DateUtil() - { - // hide constructor - } - - /** - * If set to a non null value uses the date given as current date on calls - * to getDate(). Set to null to restore the normal behavior. - * - * @param currentDate the date to return on calls to getDate() or - * null to return the real current date. - */ - public static void overrideCurrentDate(Date currentDate) - { - DateUtil.currentDate = currentDate; - } - - /** - * Returns the real current date or the date set with overrideCurrentDate(). - * - * @return the real current date or the date set with overrideCurrentDate(). - */ - public static Date getDate() - { - if (currentDate == null) - { - return new Date(); - } - return currentDate; - } - - /** - * Converts a date in the form of "yy-MM-dd HH:mm:ss" to a Date object using - * the default time zone. - * - * @param s date string in the form of "yy-MM-dd HH:mm:ss" - * @return the corresponding Java date object or null if it is - * not parsable. - */ - public static Date parseDateTime(String s) - { - return parseDateTime(s, null); - } - - /** - * Converts a date in the form of "yy-MM-dd HH:mm:ss" to a Date object using - * the given time zone. - * - * @param s date string in the form of "yy-MM-dd HH:mm:ss" - * @param tz the timezone to use or null for the default time - * zone. - * @return the corresponding Java date object or null if it is - * not parsable. - */ - public static Date parseDateTime(String s, TimeZone tz) - { - DateFormat df; - - if (s == null) - { - return null; - } - - df = new SimpleDateFormat(DATE_TIME_PATTERN); - if (tz != null) - { - df.setTimeZone(tz); - } - try - { - return df.parse(s); - } - catch (ParseException e) - { - return null; - } - } -} diff --git a/src/main/java/org/asteriskjava/util/Log.java b/src/main/java/org/asteriskjava/util/Log.java deleted file mode 100644 index 4c9ca4389..000000000 --- a/src/main/java/org/asteriskjava/util/Log.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util; - -/** - * Main interface used for logging throughout Asterisk-Java. - *

- * Concrete instances of this interface are obtained by calling - * {@link org.asteriskjava.util.LogFactory#getLog(Class)}. - * - * @author srt - * @see org.asteriskjava.util.LogFactory - */ -public interface Log -{ - void debug(Object obj); - - void info(Object obj); - - void warn(Object obj); - - void warn(Object obj, Throwable exception); - - void error(Object obj); - - void error(Object obj, Throwable exception); - - public boolean isDebugEnabled(); -} diff --git a/src/main/java/org/asteriskjava/util/LogFactory.java b/src/main/java/org/asteriskjava/util/LogFactory.java deleted file mode 100644 index 356b8787e..000000000 --- a/src/main/java/org/asteriskjava/util/LogFactory.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util; - -import org.asteriskjava.util.internal.JavaLoggingLog; -import org.asteriskjava.util.internal.Log4JLogger; -import org.asteriskjava.util.internal.NullLog; -import org.asteriskjava.util.internal.Slf4JLogger; - -/** - * Facade to hide details of the underlying logging system. - *

- * If you want to reuse Asterisk-Java's logging abstraction layer add a private - * attribute to your class like this: - * - *

- * private final Log logger = LogFactory.getLog(getClass());
- * 
- * - * and then use the methods defined in {@link org.asteriskjava.util.Log}: - * - *
- * logger.error("Unable to create new instance of " + eventClass, ex);
- * 
- * - * Asterisk-Java's logging abstraction layer uses log4j when available and falls - * back to java.util.logging otherwise. - * - * @author srt - * @version $Id$ - */ -public final class LogFactory -{ - private static Boolean slf4jLoggingAvailable = null; - - /** - * Indicates if log4j is available on the classpath or not. If the check has - * not yet performed this is null. - */ - private static Boolean log4jLoggingAvailable = null; - - /** - * Indicates if java.util.logging is available on the classpath or not. If - * the check has not yet performed this is null. - */ - private static Boolean javaLoggingAvailable = null; - - private static ClassLoader classLoader = LogFactory.class.getClassLoader(); - - private LogFactory() { - - } - - public static void setClassLoader(ClassLoader classLoader) - { - LogFactory.classLoader = classLoader; - } - - /** - * Returns an instance of Log suitable for logging from the given class. - * - * @param clazz the class to create the logger for. - * @return the created logger. - */ - public synchronized static Log getLog(Class< ? > clazz) - { - if (slf4jLoggingAvailable == null) - { - try - { - classLoader.loadClass("org.slf4j.Logger"); - slf4jLoggingAvailable = Boolean.TRUE; - } - catch (Exception e) - { - slf4jLoggingAvailable = Boolean.FALSE; - } - } - - if (slf4jLoggingAvailable) - { - try - { - return new Slf4JLogger(clazz); - } - catch (Throwable e) - { - slf4jLoggingAvailable = Boolean.FALSE; - } - } - - if (log4jLoggingAvailable == null) - { - try - { - classLoader.loadClass("org.apache.log4j.Logger"); - log4jLoggingAvailable = Boolean.TRUE; - } - catch (Exception e) - { - log4jLoggingAvailable = Boolean.FALSE; - } - } - - if (log4jLoggingAvailable) - { - return new Log4JLogger(clazz); - } - - if (javaLoggingAvailable == null) - { - try - { - classLoader.loadClass("java.util.logging.Logger"); - javaLoggingAvailable = Boolean.TRUE; - } - catch (Exception e) - { - javaLoggingAvailable = Boolean.FALSE; - } - } - if (javaLoggingAvailable) - { - return new JavaLoggingLog(clazz); - } - return new NullLog(); - } -} diff --git a/src/main/java/org/asteriskjava/util/MixMonitorDirection.java b/src/main/java/org/asteriskjava/util/MixMonitorDirection.java deleted file mode 100644 index 69892378b..000000000 --- a/src/main/java/org/asteriskjava/util/MixMonitorDirection.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.asteriskjava.util; - -/** - * MixMonitorDirection Which part of the recording to mute: read, write or both - * (from channel, to channel or both channels). - * - * @author adrian.videanu - */ -public enum MixMonitorDirection -{ - - FROM_CHANNEL("read"), TO_CHANNEL("write"), BOTH("both"); - - String stateName; - - private MixMonitorDirection(String name) - { - this.stateName = name; - } - - public String getStateName() - { - return stateName; - } - - public void setStateName(String stateName) - { - this.stateName = stateName; - } - -} diff --git a/src/main/java/org/asteriskjava/util/ReflectionUtil.java b/src/main/java/org/asteriskjava/util/ReflectionUtil.java deleted file mode 100644 index b2db5fb20..000000000 --- a/src/main/java/org/asteriskjava/util/ReflectionUtil.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * Utility class that provides helper methods for reflection that is used by the - * fastagi and manager packages to access getter and setter methods.

- * Client code is not supposed to use this class. - * - * @author srt - */ -public class ReflectionUtil -{ - private ReflectionUtil() - { - // hide constructor - } - - /** - * Returns a Map of getter methods of the given class.

- * The key of the map contains the name of the attribute that can be - * accessed by the getter, the value the getter itself (an instance of - * java.lang.reflect.Method). A method is considered a getter if its name - * starts with "get", it is declared public and takes no arguments. - * - * @param clazz the class to return the getters for - * @return a Map of attributes and their accessor methods (getters) - */ - public static Map getGetters(final Class clazz) - { - final Map accessors = new HashMap<>(); - final Method[] methods = clazz.getMethods(); - - for (Method method : methods) - { - String name = null; - String methodName = method.getName(); - - if (methodName.startsWith("get")) - { - name = methodName.substring(3); - } - else if (methodName.startsWith("is")) - { - name = methodName.substring(2); - } - - if (name == null || name.length() == 0) - { - continue; - } - - // skip methods with != 0 parameters - if (method.getParameterTypes().length != 0) - { - continue; - } - - accessors.put(name.toLowerCase(Locale.ENGLISH), method); - } - - return accessors; - } - - /** - * Returns a Map of setter methods of the given class.

- * The key of the map contains the name of the attribute that can be - * accessed by the setter, the value the setter itself (an instance of - * java.lang.reflect.Method). A method is considered a setter if its name - * starts with "set", it is declared public and takes exactly one argument. - * - * @param clazz the class to return the setters for - * @return a Map of attributes and their accessor methods (setters) - */ - public static Map getSetters(Class clazz) - { - final Map accessors = new HashMap<>(); - final Method[] methods = clazz.getMethods(); - - for (Method method : methods) - { - String name; - String methodName; - - methodName = method.getName(); - if (!methodName.startsWith("set")) - { - continue; - } - - // skip methods with != 1 parameters - if (method.getParameterTypes().length != 1) - { - continue; - } - - // ok seems to be an accessor - name = methodName.substring("set".length()).toLowerCase(Locale.US); - accessors.put(name, method); - } - - return accessors; - } - - - /** - * Strips all illegal charaters from the given lower case string. - * Illegal characters are all characters that are neither characters ('a' to 'z') nor digits ('0' to '9'). - * - * @param s the original string - * @return the string with all illegal characters stripped - */ - public static String stripIllegalCharacters(String s) - { - char c; - boolean needsStrip = false; - StringBuilder sb; - - if (s == null) - { - return null; - } - - for (int i = 0; i < s.length(); i++) - { - c = s.charAt(i); - if (c >= '0' && c <= '9') - { - // continue - } // NOPMD - else if (c >= 'a' && c <= 'z') - { - // continue - } // NOPMD - else - { - needsStrip = true; - break; - } - } - - if (!needsStrip) - { - return s; - } - - sb = new StringBuilder(s.length()); - for (int i = 0; i < s.length(); i++) - { - c = s.charAt(i); - if (c >= '0' && c <= '9') - { - sb.append(c); - } - else if (c >= 'a' && c <= 'z') - { - sb.append(c); - } - } - - return sb.toString(); - } - - /** - * Checks if the class is available on the current thread's context class loader. - * - * @param s fully qualified name of the class to check. - * @return true if the class is available, false otherwise. - */ - public static boolean isClassAvailable(String s) - { - final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - - try - { - classLoader.loadClass(s); - return true; - } - catch (ClassNotFoundException e) - { - return false; - } - } - - /** - * Creates a new instance of the given class. The class is loaded using the current thread's context - * class loader and instantiated using its default constructor. - * - * @param s fully qualified name of the class to instantiate. - * @return the new instance or null on failure. - */ - public static Object newInstance(String s) - { - final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - - try - { - Class clazz = classLoader.loadClass(s); - Constructor constructor = clazz.getConstructor(); - return constructor.newInstance(); - } - catch (ClassNotFoundException e) - { - return null; - } - catch (IllegalAccessException e) - { - return null; - } - catch (InstantiationException e) - { - return null; - } - catch (NoSuchMethodException e) - { - // no default constructor - return null; - } - catch (InvocationTargetException e) - { - // constructor threw an exception - return null; - } - } -} diff --git a/src/main/java/org/asteriskjava/util/ServerSocketFacade.java b/src/main/java/org/asteriskjava/util/ServerSocketFacade.java deleted file mode 100644 index 196602ea2..000000000 --- a/src/main/java/org/asteriskjava/util/ServerSocketFacade.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util; - -import java.io.IOException; - -/** - * The ServerSocketFacade provides operations to accept client connections over - * TCP/IP sockets.

- * It hides the details of the underlying I/O system used for server socket - * communication. - * - * @author srt - * @version $Id$ - */ -public interface ServerSocketFacade -{ - /** - * Waits for a new incoming connection. - * - * @return the new connection. - * @throws IOException if an I/O error occurs when waiting for a connection. - */ - SocketConnectionFacade accept() throws IOException; - - /** - * Unbinds and closes the server socket. - * - * @throws IOException if the server socket cannot be closed. - */ - void close() throws IOException; -} diff --git a/src/main/java/org/asteriskjava/util/SocketConnectionFacade.java b/src/main/java/org/asteriskjava/util/SocketConnectionFacade.java deleted file mode 100644 index a383c253c..000000000 --- a/src/main/java/org/asteriskjava/util/SocketConnectionFacade.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util; - -import java.io.IOException; -import java.net.InetAddress; - -/** - * The SocketConnectionFacade provides read and write operation for - * communication over TCP/IP sockets.

- * It hides the details of the underlying I/O system used for socket - * communication. - * - * @author srt - * @version $Id$ - */ -public interface SocketConnectionFacade -{ - /** - * Reads a line of text from the socket connection. The current thread is - * blocked until either the next line is received or an IOException - * encounters.

- * Depending on the implementation different newline delimiters are used - * ("\r\n" for the Manager API and "\n" for AGI). - * - * @return the line of text received excluding the newline delimiter. - * @throws IOException if the connection has been closed. - */ - String readLine() throws IOException; - - /** - * Sends a given String to the socket connection. - * - * @param s the String to send. - * @throws IOException if the String cannot be sent, maybe because the - * connection has already been closed. - */ - void write(String s) throws IOException; - - /** - * Flushes the socket connection by sending any buffered but yet unsent - * data. - * - * @throws IOException if the connection cannot be flushed. - */ - void flush() throws IOException; - - /** - * Closes the socket connection including its input and output stream and - * frees all associated ressources.

- * When calling close() any Thread currently blocked by a call to readLine() - * will be unblocked and receive an IOException. - * - * @throws IOException if the socket connection cannot be closed. - */ - void close() throws IOException; - - /** - * Returns the connection state of the socket. - * - * @return true if the socket successfuly connected to a - * server - */ - boolean isConnected(); - - /** - * Returns the local address this socket connection. - * - * @return the local address this socket connection. - * @since 0.2 - */ - InetAddress getLocalAddress(); - - /** - * Returns the local port of this socket connection. - * - * @return the local port of this socket connection. - * @since 0.2 - */ - int getLocalPort(); - - /** - * Returns the remote address of this socket connection. - * - * @return the remote address of this socket connection. - * @since 0.2 - */ - InetAddress getRemoteAddress(); - - /** - * Returns the remote port of this socket connection. - * - * @return the remote port of this socket connection. - * @since 0.2 - */ - int getRemotePort(); -} diff --git a/src/main/java/org/asteriskjava/util/internal/.gitignore b/src/main/java/org/asteriskjava/util/internal/.gitignore deleted file mode 100644 index 7c5754050..000000000 --- a/src/main/java/org/asteriskjava/util/internal/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/FileTrace.class -/JavaLoggingLog.class -/Log4JLogger.class -/NullLog.class -/ServerSocketFacadeImpl.class -/Slf4JLogger.class -/SocketConnectionFacadeImpl.class -/Trace.class diff --git a/src/main/java/org/asteriskjava/util/internal/FileTrace.java b/src/main/java/org/asteriskjava/util/internal/FileTrace.java deleted file mode 100644 index aeb21b7a9..000000000 --- a/src/main/java/org/asteriskjava/util/internal/FileTrace.java +++ /dev/null @@ -1,174 +0,0 @@ -package org.asteriskjava.util.internal; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.net.Socket; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.channels.FileChannel; -import java.nio.charset.Charset; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.asteriskjava.util.Log; -import org.asteriskjava.util.LogFactory; - -/** - * Writes a trace file to the file system. - */ -public class FileTrace implements Trace -{ - public static final String TRACE_DIRECTORY_PROPERTY = "org.asteriskjava.trace.directory"; - protected static final String FILE_PREFIX = "aj-trace"; - protected static final String FILE_SUFFIX = ".txt"; - - private final Log logger = LogFactory.getLog(FileTrace.class); - - // ok to share instance as access to this object is synchronized anyway - private final DateFormat df = new SimpleDateFormat("yyyyMMddHHmmsszzz"); - private Charset charset = Charset.forName("UTF-8"); - private FileChannel channel; - private boolean exceptionLogged = false; - private RandomAccessFile randomAccessFile; - - public FileTrace(Socket socket) throws IOException - { - randomAccessFile = new RandomAccessFile(getFile(socket), "rw"); - channel = randomAccessFile.getChannel(); - print(getHeader(socket)); - } - - private String getHeader(Socket socket) - { - final StringBuilder sb = new StringBuilder(); - sb.append("Local: "); - sb.append(socket.getLocalAddress()); - sb.append(":"); - sb.append(socket.getLocalPort()); - sb.append("\n"); - sb.append("Remote: "); - sb.append(socket.getInetAddress()); - sb.append(":"); - sb.append(socket.getPort()); - sb.append("\n"); - sb.append("\n"); - - return sb.toString(); - } - - private File getFile(Socket socket) - { - final String directory = System.getProperty(TRACE_DIRECTORY_PROPERTY, System.getProperty("java.io.tmpdir")); - final String fileName = getFileName(socket); - - logger.info("Writing trace to " + directory + File.separator + fileName); - return new File(directory, fileName); - } - - private String getFileName(Socket socket) - { - final StringBuilder sb = new StringBuilder(FILE_PREFIX); - sb.append("_"); - sb.append(df.format(new Date())); - sb.append("_"); - sb.append(socket.getLocalAddress().getHostAddress()); - sb.append("_"); - sb.append(socket.getLocalPort()); - sb.append("_"); - sb.append(socket.getInetAddress().getHostAddress()); - sb.append("_"); - sb.append(socket.getPort()); - sb.append(FILE_SUFFIX); - return sb.toString(); - } - - public synchronized void received(String s) - { - try - { - print(format("<<< ", s)); - } - catch (IOException e) - { - logException(e); - } - } - - public synchronized void sent(String s) - { - try - { - print(format(">>> ", s)); - } - catch (IOException e) - { - logException(e); - } - } - - private void logException(IOException e) - { - // avoid excessive failure logging - if (exceptionLogged) - { - return; - } - logger.warn("Unable to write trace to disk", e); - exceptionLogged = true; - } - - protected String format(String prefix, String s) - { - final StringBuilder sb = new StringBuilder(df.format(new Date())); - final String filler = String.format("%" + sb.length() + "s", ""); - String[] lines = s.split("\n"); - for (int i = 0; i < lines.length; i++) - { - if (i != 0) - { - sb.append(filler); - } - sb.append(" "); - sb.append(prefix); - sb.append(lines[i]); - sb.append("\n"); - } - return sb.toString(); - } - - protected void print(String s) throws IOException - { - final CharBuffer charBuffer = CharBuffer.allocate(s.length()); - charBuffer.put(s); - charBuffer.flip(); - print(charset.encode(charBuffer)); - } - - private void print(ByteBuffer byteBuffer) throws IOException - { - int bytesWritten = 0; - while (bytesWritten < byteBuffer.remaining()) - { - // Loop if only part of the buffer contents get written. - bytesWritten = channel.write(byteBuffer); - if (bytesWritten == 0) - { - throw new IOException("Unable to write trace to channel. Media may be full."); - } - } - } - - public void close() - { - try - { - randomAccessFile.close(); - } - catch (IOException e) - { - logException(e); - } - } -} diff --git a/src/main/java/org/asteriskjava/util/internal/JavaLoggingLog.java b/src/main/java/org/asteriskjava/util/internal/JavaLoggingLog.java deleted file mode 100644 index c1967132e..000000000 --- a/src/main/java/org/asteriskjava/util/internal/JavaLoggingLog.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.asteriskjava.util.internal; - -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.asteriskjava.util.Log; - -/** - * Implementation of {@link Log} that maps to the Logger of the - * java.util.logging package. - *

- * Kindly donated by Sun's Steve Drach. - * - * @author drach - */ -public class JavaLoggingLog implements Log -{ - /** - * The underlying commons-logging Log object to use. - */ - private final Logger log; // NOPMD by srt on 7/5/06 11:18 PM - - /** - * Creates a new JavaLoggingLog obtained from java.util.logging for the - * given class. - * - * @param clazz the class to log for. - */ - public JavaLoggingLog(Class< ? > clazz) - { - log = Logger.getLogger(clazz.getName()); - } - - public void debug(Object obj) - { - StackTraceElement ste = getInvokerSTE(); - - if (ste != null) - { - log.logp(Level.FINE, ste.getClassName(), ste.getMethodName(), obj.toString()); - } - else - { - log.fine(obj.toString()); - } - } - - public void info(Object obj) - { - StackTraceElement ste = getInvokerSTE(); - - if (ste != null) - { - log.logp(Level.INFO, ste.getClassName(), ste.getMethodName(), obj.toString()); - } - else - { - log.info(obj.toString()); - } - } - - public void warn(Object obj) - { - StackTraceElement ste = getInvokerSTE(); - - if (ste != null) - { - log.logp(Level.WARNING, ste.getClassName(), ste.getMethodName(), obj.toString()); - } - else - { - log.warning(obj.toString()); - } - } - - public void warn(Object obj, Throwable ex) - { - StackTraceElement ste = getInvokerSTE(); - - if (ste != null) - { - log.logp(Level.WARNING, ste.getClassName(), ste.getMethodName(), obj.toString(), ex); - } - else - { - log.log(Level.WARNING, obj.toString(), ex); - } - } - - public void error(Object obj) - { - StackTraceElement ste = getInvokerSTE(); - - if (ste != null) - { - log.logp(Level.SEVERE, ste.getClassName(), ste.getMethodName(), obj.toString()); - } - else - { - log.severe(obj.toString()); - } - } - - public void error(Object obj, Throwable ex) - { - StackTraceElement ste = getInvokerSTE(); - - if (ste != null) - { - log.logp(Level.SEVERE, ste.getClassName(), ste.getMethodName(), obj.toString(), ex); - } - else - { - log.log(Level.SEVERE, obj.toString(), ex); - } - } - - private StackTraceElement getInvokerSTE() - { - StackTraceElement[] stack = (new Throwable()).getStackTrace(); - - if (stack.length > 2) - { - return stack[2]; - } - - return null; - } - - @Override - public boolean isDebugEnabled() - { - return log.isLoggable(Level.FINE); - } - -} diff --git a/src/main/java/org/asteriskjava/util/internal/LocationAwareWrapper.java b/src/main/java/org/asteriskjava/util/internal/LocationAwareWrapper.java deleted file mode 100644 index 33a7c03cf..000000000 --- a/src/main/java/org/asteriskjava/util/internal/LocationAwareWrapper.java +++ /dev/null @@ -1,435 +0,0 @@ -package org.asteriskjava.util.internal; - -import org.slf4j.Logger; -import org.slf4j.Marker; -import org.slf4j.spi.LocationAwareLogger; - -public class LocationAwareWrapper implements Logger -{ - - private String FQCN; - private LocationAwareLogger logger; - - public LocationAwareWrapper(String FQCN, LocationAwareLogger logger) - { - this.FQCN = FQCN; - this.logger = logger; - } - - @Override - public String getName() - { - return logger.getName(); - } - - @Override - public boolean isTraceEnabled() - { - return logger.isTraceEnabled(); - } - - @Override - public void trace(String msg) - { - logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, null); - - } - - @Override - public void trace(String format, Object arg) - { - logger.trace(format, arg); - - } - - @Override - public void trace(String format, Object arg1, Object arg2) - { - logger.trace(format, arg1, arg2); - - } - - @Override - public void trace(String format, Object... arguments) - { - logger.trace(format, arguments); - - } - - @Override - public void trace(String msg, Throwable t) - { - logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t); - - } - - @Override - public boolean isTraceEnabled(Marker marker) - { - return logger.isTraceEnabled(marker); - } - - @Override - public void trace(Marker marker, String msg) - { - logger.log(marker, FQCN, LocationAwareLogger.TRACE_INT, msg, null, null); - - } - - @Override - public void trace(Marker marker, String format, Object arg) - { - logger.trace(marker, format, arg); - - } - - @Override - public void trace(Marker marker, String format, Object arg1, Object arg2) - { - logger.trace(marker, format, arg1, arg2); - - } - - @Override - public void trace(Marker marker, String format, Object... arguments) - { - logger.trace(marker, format, arguments); - - } - - @Override - public void trace(Marker marker, String msg, Throwable t) - { - logger.log(marker, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t); - - } - - @Override - public boolean isDebugEnabled() - { - return logger.isDebugEnabled(); - } - - @Override - public void debug(String msg) - { - logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null); - - } - - @Override - public void debug(String format, Object arg) - { - logger.debug(format, arg); - - } - - @Override - public void debug(String format, Object arg1, Object arg2) - { - logger.debug(format, arg1, arg2); - - } - - @Override - public void debug(String format, Object... arguments) - { - logger.debug(format, arguments); - - } - - @Override - public void debug(String msg, Throwable t) - { - logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t); - - } - - @Override - public boolean isDebugEnabled(Marker marker) - { - return logger.isDebugEnabled(marker); - } - - @Override - public void debug(Marker marker, String msg) - { - logger.log(marker, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null); - - } - - @Override - public void debug(Marker marker, String format, Object arg) - { - logger.debug(marker, format, arg); - - } - - @Override - public void debug(Marker marker, String format, Object arg1, Object arg2) - { - logger.debug(marker, format, arg1, arg2); - - } - - @Override - public void debug(Marker marker, String format, Object... arguments) - { - logger.debug(marker, format, arguments); - - } - - @Override - public void debug(Marker marker, String msg, Throwable t) - { - logger.log(marker, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t); - - } - - @Override - public boolean isInfoEnabled() - { - return logger.isInfoEnabled(); - } - - @Override - public void info(String msg) - { - logger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, null); - - } - - @Override - public void info(String format, Object arg) - { - logger.info(format, arg); - - } - - @Override - public void info(String format, Object arg1, Object arg2) - { - logger.info(format, arg1, arg2); - - } - - @Override - public void info(String format, Object... arguments) - { - logger.info(format, arguments); - - } - - @Override - public void info(String msg, Throwable t) - { - logger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, t); - - } - - @Override - public boolean isInfoEnabled(Marker marker) - { - return logger.isInfoEnabled(marker); - } - - @Override - public void info(Marker marker, String msg) - { - logger.log(marker, FQCN, LocationAwareLogger.INFO_INT, msg, null, null); - - } - - @Override - public void info(Marker marker, String format, Object arg) - { - logger.info(marker, format, arg); - - } - - @Override - public void info(Marker marker, String format, Object arg1, Object arg2) - { - logger.info(marker, format, arg1, arg2); - - } - - @Override - public void info(Marker marker, String format, Object... arguments) - { - logger.info(marker, format, arguments); - - } - - @Override - public void info(Marker marker, String msg, Throwable t) - { - logger.log(marker, FQCN, LocationAwareLogger.INFO_INT, msg, null, t); - - } - - @Override - public boolean isWarnEnabled() - { - return logger.isWarnEnabled(); - } - - @Override - public void warn(String msg) - { - logger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, null); - - } - - @Override - public void warn(String format, Object arg) - { - logger.warn(format, arg); - - } - - @Override - public void warn(String format, Object arg1, Object arg2) - { - logger.warn(format, arg1, arg2); - - } - - @Override - public void warn(String format, Object... arguments) - { - logger.warn(format, arguments); - - } - - @Override - public void warn(String msg, Throwable t) - { - logger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, t); - - } - - @Override - public boolean isWarnEnabled(Marker marker) - { - return logger.isWarnEnabled(marker); - } - - @Override - public void warn(Marker marker, String msg) - { - logger.log(marker, FQCN, LocationAwareLogger.WARN_INT, msg, null, null); - - } - - @Override - public void warn(Marker marker, String format, Object arg) - { - logger.warn(marker, format, arg); - - } - - @Override - public void warn(Marker marker, String format, Object arg1, Object arg2) - { - logger.warn(marker, format, arg1, arg2); - - } - - @Override - public void warn(Marker marker, String format, Object... arguments) - { - logger.warn(marker, format, arguments); - - } - - @Override - public void warn(Marker marker, String msg, Throwable t) - { - logger.log(marker, FQCN, LocationAwareLogger.WARN_INT, msg, null, t); - - } - - @Override - public boolean isErrorEnabled() - { - return logger.isErrorEnabled(); - } - - @Override - public void error(String msg) - { - logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null); - - } - - @Override - public void error(String format, Object arg) - { - logger.error(format, arg); - - } - - @Override - public void error(String format, Object arg1, Object arg2) - { - logger.error(format, arg1, arg2); - - } - - @Override - public void error(String format, Object... arguments) - { - logger.error(format, arguments); - - } - - @Override - public void error(String msg, Throwable t) - { - logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t); - - } - - @Override - public boolean isErrorEnabled(Marker marker) - { - return logger.isErrorEnabled(marker); - } - - @Override - public void error(Marker marker, String msg) - { - logger.log(marker, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null); - - } - - @Override - public void error(Marker marker, String format, Object arg) - { - logger.error(marker, format, arg); - - } - - @Override - public void error(Marker marker, String format, Object arg1, Object arg2) - { - logger.error(marker, format, arg1, arg2); - - } - - @Override - public void error(Marker marker, String format, Object... arguments) - { - logger.error(marker, format, arguments); - - } - - @Override - public void error(Marker marker, String msg, Throwable t) - { - logger.log(marker, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t); - - } - // Logger logger = LogManager.getLogger(); -} diff --git a/src/main/java/org/asteriskjava/util/internal/Log4JLogger.java b/src/main/java/org/asteriskjava/util/internal/Log4JLogger.java deleted file mode 100644 index 96c05fb0b..000000000 --- a/src/main/java/org/asteriskjava/util/internal/Log4JLogger.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.asteriskjava.util.internal; - -import java.io.Serializable; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.Priority; -import org.asteriskjava.util.Log; - -/** - * Implementation of {@link Log} that maps directly to a Log4J - * Logger. - *

- * Initial configuration of the corresponding Logger instances should be done in - * the usual manner, as outlined in the Log4J documentation. - *

- * More or less "stolen" from Apache's commons-logging. - * - * @author Scott Sanders - * @author Rod Waldhoff - * @author Robert Burrell Donkin - * @version $Id$ - */ -public class Log4JLogger implements Log, Serializable -{ - - // ------------------------------------------------------------- Attributes - - /** - * The serial version identifier. - */ - private static final long serialVersionUID = 3545240215095883829L; - - /** The fully qualified name of the Log4JLogger class. */ - private static final String FQCN = Log4JLogger.class.getName(); - - private static final boolean IS12 = Priority.class.isAssignableFrom(Level.class); - - /** Log to this logger */ - private transient Logger logger = null; // NOPMD by srt on 7/5/06 11:18 PM - - /** Logger name */ - private String name = null; - - // ------------------------------------------------------------ Constructor - - public Log4JLogger() - { - } - - /** - * Base constructor. - */ - public Log4JLogger(Class< ? > clazz) - { - this.name = clazz.getName(); - this.logger = getLogger(); - } - - // --------------------------------------------------------- Implementation - - /** - * Log a message to the Log4j Logger with TRACE priority. - * Currently logs to DEBUG level in Log4J. - */ - public void trace(Object message) - { - if (IS12) - { - getLogger().log(FQCN, Level.DEBUG, message, null); - } - else - { - getLogger().log(FQCN, Level.DEBUG, message, null); - } - } - - /** - * Log an error to the Log4j Logger with TRACE priority. - * Currently logs to DEBUG level in Log4J. - */ - public void trace(Object message, Throwable t) - { - if (IS12) - { - getLogger().log(FQCN, Level.DEBUG, message, t); - } - else - { - getLogger().log(FQCN, Level.DEBUG, message, t); - } - } - - /** - * Log a message to the Log4j Logger with DEBUG priority. - */ - public void debug(Object message) - { - if (IS12) - { - getLogger().log(FQCN, Level.DEBUG, message, null); - } - else - { - getLogger().log(FQCN, Level.DEBUG, message, null); - } - } - - /** - * Log an error to the Log4j Logger with DEBUG priority. - */ - public void debug(Object message, Throwable t) - { - if (IS12) - { - getLogger().log(FQCN, Level.DEBUG, message, t); - } - else - { - getLogger().log(FQCN, Level.DEBUG, message, t); - } - } - - /** - * Log a message to the Log4j Logger with INFO priority. - */ - public void info(Object message) - { - if (IS12) - { - getLogger().log(FQCN, Level.INFO, message, null); - } - else - { - getLogger().log(FQCN, Level.INFO, message, null); - } - } - - /** - * Log an error to the Log4j Logger with INFO priority. - */ - public void info(Object message, Throwable t) - { - if (IS12) - { - getLogger().log(FQCN, Level.INFO, message, t); - } - else - { - getLogger().log(FQCN, Level.INFO, message, t); - } - } - - /** - * Log a message to the Log4j Logger with WARN priority. - */ - public void warn(Object message) - { - if (IS12) - { - getLogger().log(FQCN, Level.WARN, message, null); - } - else - { - getLogger().log(FQCN, Level.WARN, message, null); - } - } - - /** - * Log an error to the Log4j Logger with WARN priority. - */ - public void warn(Object message, Throwable t) - { - if (IS12) - { - getLogger().log(FQCN, Level.WARN, message, t); - } - else - { - getLogger().log(FQCN, Level.WARN, message, t); - } - } - - /** - * Log a message to the Log4j Logger with ERROR priority. - */ - public void error(Object message) - { - if (IS12) - { - getLogger().log(FQCN, Level.ERROR, message, null); - } - else - { - getLogger().log(FQCN, Level.ERROR, message, null); - } - } - - /** - * Log an error to the Log4j Logger with ERROR priority. - */ - public void error(Object message, Throwable t) - { - if (IS12) - { - getLogger().log(FQCN, Level.ERROR, message, t); - } - else - { - getLogger().log(FQCN, Level.ERROR, message, t); - } - } - - /** - * Log a message to the Log4j Logger with FATAL priority. - */ - public void fatal(Object message) - { - if (IS12) - { - getLogger().log(FQCN, Level.FATAL, message, null); - } - else - { - getLogger().log(FQCN, Level.FATAL, message, null); - } - } - - /** - * Log an error to the Log4j Logger with FATAL priority. - */ - public void fatal(Object message, Throwable t) - { - if (IS12) - { - getLogger().log(FQCN, Level.FATAL, message, t); - } - else - { - getLogger().log(FQCN, Level.FATAL, message, t); - } - } - - /** - * Return the native Logger instance we are using. - */ - public final Logger getLogger() - { - if (logger == null) - { - logger = Logger.getLogger(name); - } - return this.logger; - } - - /** - * Check whether the Log4j Logger used is enabled for DEBUG - * priority. - */ - public boolean isDebugEnabled() - { - return getLogger().isDebugEnabled(); - } - - /** - * Check whether the Log4j Logger used is enabled for ERROR - * priority. - */ - public boolean isErrorEnabled() - { - if (IS12) - { - return getLogger().isEnabledFor(Level.ERROR); - } - return getLogger().isEnabledFor(Level.ERROR); - } - - /** - * Check whether the Log4j Logger used is enabled for FATAL - * priority. - */ - public boolean isFatalEnabled() - { - if (IS12) - { - return getLogger().isEnabledFor(Level.FATAL); - } - return getLogger().isEnabledFor(Level.FATAL); - } - - /** - * Check whether the Log4j Logger used is enabled for INFO - * priority. - */ - public boolean isInfoEnabled() - { - return getLogger().isInfoEnabled(); - } - - /** - * Check whether the Log4j Logger used is enabled for TRACE - * priority. For Log4J, this returns the value of - * isDebugEnabled() - */ - public boolean isTraceEnabled() - { - return getLogger().isDebugEnabled(); - } - - /** - * Check whether the Log4j Logger used is enabled for WARN - * priority. - */ - public boolean isWarnEnabled() - { - if (IS12) - { - return getLogger().isEnabledFor(Level.WARN); - } - return getLogger().isEnabledFor(Level.WARN); - } -} diff --git a/src/main/java/org/asteriskjava/util/internal/NullLog.java b/src/main/java/org/asteriskjava/util/internal/NullLog.java deleted file mode 100644 index bf4d8f43c..000000000 --- a/src/main/java/org/asteriskjava/util/internal/NullLog.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util.internal; - -import org.asteriskjava.util.Log; - -/** - * A Log implementation that does nothing. - *

- * This logger is only used if neither log4j nor java.util.logging are available - * which should not happen anyway as Asterisk-Java depends on at least JDK 1.5. - * - * @author srt - * @version $Id$ - */ -public class NullLog implements Log -{ - /** - * Creates a new NullLog. - */ - public NullLog() - { - } - - public void debug(Object obj) - { - } - - public void info(Object obj) - { - } - - public void warn(Object obj) - { - } - - public void warn(Object obj, Throwable ex) - { - } - - public void error(Object obj) - { - } - - public void error(Object obj, Throwable ex) - { - } - - @Override - public boolean isDebugEnabled() - { - return false; - } -} diff --git a/src/main/java/org/asteriskjava/util/internal/ServerSocketFacadeImpl.java b/src/main/java/org/asteriskjava/util/internal/ServerSocketFacadeImpl.java deleted file mode 100644 index a947ba014..000000000 --- a/src/main/java/org/asteriskjava/util/internal/ServerSocketFacadeImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util.internal; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.ServerSocket; -import java.net.Socket; - -import org.asteriskjava.util.ServerSocketFacade; -import org.asteriskjava.util.SocketConnectionFacade; - - -/** - * Default implementation of the ServerSocketFacade interface using standard - * java.io classes (ServerSocket in this case). - * - * @author srt - * @version $Id$ - */ -public class ServerSocketFacadeImpl implements ServerSocketFacade -{ - private ServerSocket serverSocket; - - public ServerSocketFacadeImpl(int port, int backlog, InetAddress bindAddress) - throws IOException - { - this.serverSocket = new ServerSocket(port, backlog, bindAddress); - } - - public SocketConnectionFacade accept() throws IOException - { - Socket socket; - - socket = serverSocket.accept(); - - return new SocketConnectionFacadeImpl(socket); - } - - public void close() throws IOException - { - serverSocket.close(); - } -} diff --git a/src/main/java/org/asteriskjava/util/internal/Slf4JLogger.java b/src/main/java/org/asteriskjava/util/internal/Slf4JLogger.java deleted file mode 100644 index 3374debb9..000000000 --- a/src/main/java/org/asteriskjava/util/internal/Slf4JLogger.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.asteriskjava.util.internal; - -import java.io.Serializable; - -import org.asteriskjava.util.Log; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.spi.LocationAwareLogger; - -/** - * Implementation of {@link org.asteriskjava.util.Log} that maps to a SLF4J - * Logger. - *

- * - * @version $Id$ - */ -public class Slf4JLogger implements Log, Serializable -{ - /** - * The serial version identifier. - */ - private static final long serialVersionUID = 0L; - - /** Log to this logger */ - private transient Logger logger = null; - - static String FQCN = Slf4JLogger.class.getName(); - - /** Logger name */ - private Class< ? > clazz = null; - - public Slf4JLogger() - { - } - - /** - * Base constructor. - */ - public Slf4JLogger(Class< ? > clazz) - { - this.clazz = clazz; - this.logger = getLogger(); - } - - /** - * Log a message to the SLF4J Logger with TRACE priority. - * Currently logs to DEBUG level in SLF4J. - */ - public void trace(Object message) - { - getLogger().trace(message.toString()); - } - - /** - * Log an error to the SLF4J Logger with TRACE priority. - */ - public void trace(Object message, Throwable t) - { - getLogger().trace(message.toString(), t); - } - - /** - * Log a message to the SLF4J Logger with DEBUG priority. - */ - public void debug(Object message) - { - getLogger().debug(message.toString()); - } - - /** - * Log an error to the SLF4J Logger with DEBUG priority. - */ - public void debug(Object message, Throwable t) - { - getLogger().debug(message.toString(), t); - } - - /** - * Log a message to the SLF4J Logger with INFO priority. - */ - public void info(Object message) - { - getLogger().info(message.toString()); - } - - /** - * Log an error to the SLF4J Logger with INFO priority. - */ - public void info(Object message, Throwable t) - { - getLogger().info(message.toString(), t); - } - - /** - * Log a message to the SLF4J Logger with WARN priority. - */ - public void warn(Object message) - { - getLogger().warn(message.toString()); - } - - /** - * Log an error to the SLF4J Logger with WARN priority. - */ - public void warn(Object message, Throwable t) - { - getLogger().warn(message.toString(), t); - } - - /** - * Log a message to the SLF4J Logger with ERROR priority. - */ - public void error(Object message) - { - getLogger().error(message.toString()); - } - - /** - * Log an error to the SLF4J Logger with ERROR priority. - */ - public void error(Object message, Throwable t) - { - getLogger().error(message.toString(), t); - } - - /** - * Log a message to the SLF4J Logger with FATAL priority. - *

- * Currently uses the ERROR priority in SLF4J. - */ - public void fatal(Object message) - { - getLogger().error(message.toString()); - } - - /** - * Log an error to the SLF4J Logger with FATAL priority. - *

- * Currently uses the ERROR priority in SLF4J. - */ - public void fatal(Object message, Throwable t) - { - getLogger().error(message.toString(), t); - } - - /** - * Return the native Logger instance we are using. - */ - public final Logger getLogger() - { - if (logger == null) - { - logger = LoggerFactory.getLogger(clazz); - } - if (logger instanceof LocationAwareLogger) - { - return new LocationAwareWrapper(FQCN, (LocationAwareLogger) logger); - } - return this.logger; - } - - /** - * Check whether the SLF4J Logger used is enabled for DEBUG - * priority. - */ - public boolean isDebugEnabled() - { - return getLogger().isDebugEnabled(); - } - - /** - * Check whether the SLF4J Logger used is enabled for ERROR - * priority. - */ - public boolean isErrorEnabled() - { - return getLogger().isErrorEnabled(); - } - - /** - * Check whether the SLF4J Logger used is enabled for FATAL - * priority. For SLF4J, this returns the value of - * isErrorEnabled() - */ - public boolean isFatalEnabled() - { - return isErrorEnabled(); - } - - /** - * Check whether the SLF4J Logger used is enabled for INFO - * priority. - */ - public boolean isInfoEnabled() - { - return getLogger().isInfoEnabled(); - } - - /** - * Check whether the SLF4J Logger used is enabled for TRACE - * priority. - */ - public boolean isTraceEnabled() - { - return getLogger().isDebugEnabled(); - } - - /** - * Check whether the SLF4J Logger used is enabled for WARN - * priority. - */ - public boolean isWarnEnabled() - { - return getLogger().isWarnEnabled(); - } -} diff --git a/src/main/java/org/asteriskjava/util/internal/SocketConnectionFacadeImpl.java b/src/main/java/org/asteriskjava/util/internal/SocketConnectionFacadeImpl.java deleted file mode 100644 index a08ba44f1..000000000 --- a/src/main/java/org/asteriskjava/util/internal/SocketConnectionFacadeImpl.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.util.internal; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.NoSuchElementException; -import java.util.Scanner; -import java.util.regex.Pattern; - -import javax.net.SocketFactory; -import javax.net.ssl.SSLSocketFactory; - -import org.asteriskjava.util.SocketConnectionFacade; - -/** - * Default implementation of the SocketConnectionFacade interface using java.io. - * - * @author srt - * @version $Id$ - */ -public class SocketConnectionFacadeImpl implements SocketConnectionFacade -{ - public static final Pattern CRNL_PATTERN = Pattern.compile("\r\n"); - public static final Pattern NL_PATTERN = Pattern.compile("\n"); - private Socket socket; - private Scanner scanner; - private BufferedWriter writer; - private Trace trace; - - /** - * <<<<<<< HEAD Creates a new instance for use with the Manager API that - * uses UTF-8 as encoding and CRNL ("\r\n") as line delimiter. ======= - * Creates a new instance for use with the Manager API that uses CRNL - * ("\r\n") as line delimiter. >>>>>>> refs/heads/release-1.1 - * - * @param host the foreign host to connect to. - * @param port the foreign port to connect to. - * @param ssl true to use SSL, false otherwise. - * @param timeout 0 incidcates default - * @param readTimeout see {@link Socket#setSoTimeout(int)} - * @throws IOException if the connection cannot be established. - */ - public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout) throws IOException - { - this(host, port, ssl, timeout, readTimeout, StandardCharsets.UTF_8, CRNL_PATTERN); - } - - /** - * Creates a new instance for use with the Manager API that uses the given - * encoding and CRNL ("\r\n") as line delimiter. - * - * @param host the foreign host to connect to. - * @param port the foreign port to connect to. - * @param ssl true to use SSL, false otherwise. - * @param timeout 0 incidcates default - * @param readTimeout see {@link Socket#setSoTimeout(int)} - * @param encoding the encoding used for transmission of strings (all - * connections should use the same encoding) - * @throws IOException if the connection cannot be established. - */ - public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout, Charset encoding) - throws IOException - { - this(host, port, ssl, timeout, readTimeout, encoding, CRNL_PATTERN); - } - - /** - * Creates a new instance for use with the Manager API that uses UTF-8 as - * encoding and the given line delimiter. - * - * @param host the foreign host to connect to. - * @param port the foreign port to connect to. - * @param ssl true to use SSL, false otherwise. - * @param timeout 0 incidcates default - * @param readTimeout see {@link Socket#setSoTimeout(int)} - * @param lineDelimiter a {@link Pattern} for matching the line delimiter - * for the socket - * @throws IOException if the connection cannot be established. - */ - public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout, - Pattern lineDelimiter) throws IOException - { - this(host, port, ssl, timeout, readTimeout, StandardCharsets.UTF_8, lineDelimiter); - } - - /** - * Creates a new instance for use with the Manager API that uses the given - * encoding and line delimiter. - * - * @param host the foreign host to connect to. - * @param port the foreign port to connect to. - * @param ssl true to use SSL, false otherwise. - * @param timeout 0 incidcates default - * @param readTimeout see {@link Socket#setSoTimeout(int)} - * @param encoding the encoding used for transmission of strings (all - * connections should use the same encoding) - * @param lineDelimiter a {@link Pattern} for matching the line delimiter - * for the socket - * @throws IOException if the connection cannot be established. - */ - public SocketConnectionFacadeImpl(String host, int port, boolean ssl, int timeout, int readTimeout, Charset encoding, - Pattern lineDelimiter) throws IOException - { - Socket socket; - - if (ssl) - { - socket = SSLSocketFactory.getDefault().createSocket(); - } - else - { - socket = SocketFactory.getDefault().createSocket(); - } - socket.setSoTimeout(readTimeout); - socket.connect(new InetSocketAddress(host, port), timeout); - - initialize(socket, encoding, lineDelimiter); - if (System.getProperty(Trace.TRACE_PROPERTY, "false").equalsIgnoreCase("true")) - { - trace = new FileTrace(socket); - } - } - - /** - * Creates a new instance for use with FastAGI that uses NL ("\n") as line - * delimiter. - * - * @param socket the underlying socket. - * @throws IOException if the connection cannot be initialized. - */ - SocketConnectionFacadeImpl(Socket socket) throws IOException - { - socket.setSoTimeout(MAX_SOCKET_READ_TIMEOUT_MILLIS); - initialize(socket, StandardCharsets.UTF_8, NL_PATTERN); - } - - /** 70 mi = 70 * 60 * 1000 */ - private static final int MAX_SOCKET_READ_TIMEOUT_MILLIS = 4200000; - - private void initialize(Socket socket, Charset encoding, Pattern pattern) throws IOException - { - this.socket = socket; - - InputStream inputStream = socket.getInputStream(); - OutputStream outputStream = socket.getOutputStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, encoding)); - - this.scanner = new Scanner(reader); - this.scanner.useDelimiter(pattern); - this.writer = new BufferedWriter(new OutputStreamWriter(outputStream, encoding)); - } - - @Override - public String readLine() throws IOException - { - String line; - try - { - line = scanner.next(); - } - catch (IllegalStateException e) - { - if (scanner.ioException() != null) - { - throw scanner.ioException(); - } - // throw new IOException("No more lines available", e); // JDK6 - throw new IOException("No more lines available: " + e.getMessage()); - } - catch (NoSuchElementException e) - { - if (scanner.ioException() != null) - { - throw scanner.ioException(); - } - // throw new IOException("No more lines available", e); // JDK6 - throw new IOException("No more lines available: " + e.getMessage()); - } - - if (trace != null) - { - trace.received(line); - } - return line; - } - - public void write(String s) throws IOException - { - writer.write(s); - if (trace != null) - { - trace.sent(s); - } - } - - public void flush() throws IOException - { - writer.flush(); - } - - public void close() throws IOException - { - socket.close(); - scanner.close(); - // close the trace only if it was activated (the object is not null) - if (trace != null) - { - trace.close(); - } - } - - public boolean isConnected() - { - return socket.isConnected(); - } - - public InetAddress getLocalAddress() - { - return socket.getLocalAddress(); - } - - public int getLocalPort() - { - return socket.getLocalPort(); - } - - public InetAddress getRemoteAddress() - { - return socket.getInetAddress(); - } - - public int getRemotePort() - { - return socket.getPort(); - } -} diff --git a/src/main/java/org/asteriskjava/util/internal/Trace.java b/src/main/java/org/asteriskjava/util/internal/Trace.java deleted file mode 100644 index eb8314908..000000000 --- a/src/main/java/org/asteriskjava/util/internal/Trace.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.asteriskjava.util.internal; - -/** - * Interface for tracing network traffic. - */ -public interface Trace -{ - /** - * Name of the system property to enable tracing.

- * To enable tracing add -Dorg.asteriskjava.trace=true to the vm parameters when running Asterisk-Java. - */ - String TRACE_PROPERTY = "org.asteriskjava.trace"; - - /** - * Writes data that has been received from the network to the trace. - * @param s the String that has been received. - */ - void received(String s); - - /** - * Writes data that has been sent to the network to the trace. - * @param s the String that has been sent. - */ - void sent(String s); - - - /** - * Closes allocated resources by trace implementation. - */ - void close(); -} diff --git a/src/main/java/org/asteriskjava/util/internal/package.html b/src/main/java/org/asteriskjava/util/internal/package.html deleted file mode 100644 index e3b52ed3f..000000000 --- a/src/main/java/org/asteriskjava/util/internal/package.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Provides private implementations for interfaces defined in the - org.asteriskjava.util package.

- - - \ No newline at end of file diff --git a/src/main/java/org/asteriskjava/util/package.html b/src/main/java/org/asteriskjava/util/package.html deleted file mode 100644 index 73afd0d9c..000000000 --- a/src/main/java/org/asteriskjava/util/package.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - -

Provides various utility classes used throughout the library.

-

Client code is generally not supposed to use classes or interfaces in this packages - with the exception of the logging support if they want to reuse Asterisk-Java's - logging abstraction layer.

- - - \ No newline at end of file diff --git a/src/site/apt/building.apt b/src/site/apt/building.apt deleted file mode 100644 index ea0e45dfa..000000000 --- a/src/site/apt/building.apt +++ /dev/null @@ -1,25 +0,0 @@ - --- - Building with Maven - --- - Stefan Reuter - --- - $Id$ - -Building with Maven - - Retrieve the latest version of Asterisk-Java from github: - ---- -git clone https://github.com/srt/asterisk-java.git ---- - - Then change to the created asterisk-java directory and use Maven 3 to - build the project - ---- -cd asterisk-java -mvn install ---- - - This will create the asterisk-java-${VERSION}.jar in the target subdirectory - as well as in your local maven repository. \ No newline at end of file diff --git a/src/site/apt/design.apt b/src/site/apt/design.apt deleted file mode 100644 index f52d4c3db..000000000 --- a/src/site/apt/design.apt +++ /dev/null @@ -1,285 +0,0 @@ - --- - Design - --- - Stefan Reuter - --- - $Id$ - -Design - - This document gives a brief overview of the design of - Asterisk-Java and the requirements that lead to this - design. - -* Introduction - - When I first stumbled upon Asterisk there haven't been - many options to integrate your own applications. - - First of all you had the possibility to write your own - Asterisk applications. That's the way many internal - functions are implemented, for example Asterisk's - Dial, Voicemail and Queue commands. - This approach usually requires writing a small - module in C that uses Asterisk's internal API. It is - compiled into a shared object that is loaded when - Asterisk starts. Your application is then tightly - coupled to Asterisk but has access to any internal - structure. - - The second approach is to write AGI (Asterisk Gateway Interface) - scripts. An AGI script is to Asterisk what a CGI script is to an - HTTP server. You can think of AGI as a means to - make your dialplan more dynamic by handing control - to an external process. As with CGI in its early - days Asterisk had to spawn a new short - lived process for each AGI request. When using - external application that consume a lot of resources - at startup (like spawning a Java Virtual Machine - when launching a Java application) this approach - has major drawbacks. These shortcoming have been - mitigated with the introduction of FastAGI that - doesn't spawn a new process for each request but - communicates with a long running process via - TCP/IP. - - The third approach is to use Asterisk's Manager API. - The Manager API allows an external application to - query and change Asterisk's state by sending actions - and listening to responses and events. Communication - occurs via TCP/IP. Compared to AGI the Manager API - works without the need to operate on a concrete call - in Asterisk parlance a channel). - - The last approach is to talk to Asterisk via IAX - (Inter Asterisk eXchange protocol), a - UDP based protocol used by Asterisk to communicate - with other Asterisk servers and IAX enabled phones. - In contrast to AGI and the Manager API IAX allows - passing media streams, for example sending and - receiving audio. - - Regarding the first approach a JNI (Java Native Interface) - based solution (JAsterisk) is available that spawns a - Java Virtual Machine from within Asterisk and exposes Asterisk's - internal API. Development of JAsterisk seems to be - discontinued. Due to the involved tight coupling this - approach is questionable anyway. - - Regarding option two and three I realized - there were two implementations of FastAGI for Java - but none for the Manager API. So I decided to build - a library to make those interfaces accessible from - Java applications. This is what became Asterisk-Java. - - Regarding IAX there is a C library available and a - Java wrapper using Java Native Interface (JNI). - Several people are working on a pure Java - implementation though up to now no usable implementation - is available to the public. - -* Requirements - - So what are the requirements for a library like - Asterisk-Java that focuses on AGI and the Manager API? - - In one sentence: Asterisk-Java must be flexible, robust - and easy to use and maintain. - - Flexible means you should be able to use it in a variety - of different environments, like standalone Java GUI - applications running on a user's desktop, servlets running - in a J2EE servlet container, Java webstart applications, - or maybe even applets if anybody is still using them. - Being flexible also means you should have access to any - feature exposed by the corresponding Asterisk interface - and not be limited in any way due to using Asterisk-Java. - And finally being flexible also means it should be easy to - extend Asterisk-Java to support additional features. - This extensibility is important when you choose to run a - modified version of Asterisk that supports additional - actions and events through the Manager API or additional - commands via AGI. - - Robust means you can focus on your own - application and rest asured that Asterisk-Java "just - works". This implies you don't have to worry about things - like reconnecting after restarting Asterisk. Being robust - also means that Asterisk-Java must still work as expected - when put under heavy load. - - Easy to use means there should only be a small number of - well defined and easy to understand classes and interfaces - that an application developer must be aware of. The - programming model should follow the style Java developers - are used to. - - And finally easy to maintain means being well structured and - allowing for automated testing. Of course being easy to - maintain also requires extensibility as stated above as - Asterisk itself is in active development and new features - that Asterisk-Java must keep track of are added all - the time. - -* Overall Design - - Let's have a look at Asterisk-Java's overall design. - - You might have noticed that Asterisk-Java is composed - of two packages: one to support AGI and one to support - the Manager API. - Although these two packages are quite different (due to - the conceptual differences in the Asterisk interfaces - they support) they share several common design - principles. This section will highlight them before we - dive into the details of the two packages. - - Asterisk-Java is based on interfaces. As you will see - below starting to use Asterisk-Java usually implies - getting an implementation of the interface you want to - use (i.e. AGI-based or Manager API-based). This - approach allows you to easily integrate Asterisk-Java into - IoC (inversion of control) containers like the Spring - Framework. It decouples your application from the internal - implementation of Asterisk-Java and supports testability as - you can easily substitue Asterisk-Java by some mock objects. - You can see examples of what that means when looking at - the source of Asterisk-Java's unit tests where I am using - {{{http://www.easymock.org}EasyMock}} for that - purpose. - - To provide extensibility the commands and replies (for - AGI) and actions, repsonses and events (for Manager API) are - designed as class hierarchies with one abstract base - class at the top of each one. Asterisk-Java does not need to know - the concrete classes upfront so you are free to extend these - hierarchies as needed. There is a little difference in how - the two packages implement this strategy, but the general - concept is the same.\ - Note that this looks like the GoF Command Pattern and in - fact both are fairly similar. The - difference is that Asterisk-Java's commands and - actions are not self-executable. Instead of an - execute method there is a uniform way to "render" them - to the format Asterisk understands (i.e. convert them to a - String that can be sent over the wire). When using AGI this - is done by the AgiCommands themselves that provide - a <<>> method, when using the - Manager API there is an ActionBuilder that renders - ManagerActions by using reflection. - - Asterisk-Java depends on no external libraries at runtime. - This decision is crucial when using Asterisk-Java in special - environments where size matters. It also ensures that no - conflicts arise from different components requiring different - version of the same external library. - -* AGI - - This section describes the design of Asterisk-Java's support - for FastAGI. The corresponding Java package is called - <<>>. - -[images/agi-thumb.png] - - {{{images/agi.png}AGI Package Overview}} - - As you can see on the diagram the AGI package of - Asterisk-Java consists of three fundamental interfaces: - AgiServer, AgiScript and MappingStrategy. - - The responsibility of an AgiServer is to listen for new - incoming AGI requests that an Asterisk server directs to - that server. The AgiServer must then choose the right - processor for that request, invoke it and provide it with - a means to send commands to Asterisk and receive the - corresponding reply.\ - Asterisk-Java includes DefaultAgiServer that contains the - default implementation of this interface. - - To choose the right processor for an AgiRequest, the - AgiServer uses a MappingStrategy that returns an executable - AgiScript based on the request.\ - Asterisk-Java includes a - simple implementation of a MappingStrategy that is - based on reading a resource bundle and matching the URL. - It is called ResourceBundleMappingStrategy. If you - have other requirements regarding the mapping you can provide - your own implementation of the MappingStrategy interface. - - The third important interface in this package is the - AgiScript. An AGI Script is the piece of code that is - invoked to service the request. An AgiScript is to - Asterisk-Java what a servlet is to a servlet container. - So when you want to expose your own Java based services - to Asterisk you must implement this interface. The AgiScript - interface is really simple: It contains only one method called - <<>> that is passed the AgiRequest and an - AgiChannel, that allows you to send AgiCommands back to - Asterisk.\ - Asterisk-Java also includes an abstract base class that - implements the AgiScript interface and provides convenience - methods for sending commands. You can choose whatever - you like more: either implementing AgiScript or extending - BaseAgiScript works fine. - -* Manager API - - This section describes the design of Asterisk-Java's support - for the Manager API. The corresponding Java package is called - <<>>. - -[images/manager-thumb.png] - - {{{images/manager.png}Manager API Package Overview}} - - The important interfaces of Asterisk-Java's Manager - API package are ManagerConnection, ManagerEventHandler - and AsteriskManager. - - In contrast to AGI communication between the Asterisk - server and your application is not initiated by Asterisk - when using the Manager API but has to be initiated by you. - Asterisk-Java provides the ManagerConnection interface that - is well suited for this purpose. Its responsibility is to - establish a TCP/IP connection to Asterisk (and reestablish - that connection in case of a restart of Asterisk or a network - failure), to enable its clients to send ManagerActions - and receive the corresponding ManagerResponses and to - dispatch events received from Asterisk.\ - Once you are connected to - Asterisk you can not only actively send ManagerActions but - you will also receive MangerEvents from Asterisk. - ManagerEvents usually inform your application about state - changes that occur within your Asterisk server, for - example due to a user dialing an extension or hanging - up the phone. To recieve these events you can implement - the ManagerEventHandler interface and register your - handler with the corresponding ManagerConnection. - - Instances of the MangerConnection interface are usually - obtained from the ManagerConnectionFactory unless you are - using an IoC container. Asterisk-Java provides a default - implementation of the ManagerConnection interface called - DefaultManagerConnection. - - Finally there is the AsteriskManager interface that - provides a higher level abstraction on top of the - ManagerConnection. It keeps track of Asterisk's state - by listening to all state changing events and provides - support for domain objects like Channel, Call and Queue - that make it easier for your application to interact - with Asterisk without diving into details.\ - Asterisk-Java provides a default implementation of the - AsteriskManager interface called DefaultAsteriskManager - that is initialized by passing a ManagerConnection.\ - You can use both interfaces at the same time thus using - the abstracted AsteriskManager where it is sufficient and - going back to ManagerConnection where needed. If you choose - to do so be sure to initialize the AsteriskManager before - you register any of your own ManagerEventHandlers. - - Please note that the AsteriskManager interface is still - in an early state and the functionality exposed through it - is rather limited. This interface will certainly change - in the future so be aware of that when using it. diff --git a/src/site/apt/faq.apt b/src/site/apt/faq.apt deleted file mode 100644 index 0d77fc374..000000000 --- a/src/site/apt/faq.apt +++ /dev/null @@ -1,170 +0,0 @@ - --- - Frequently Asked Questions - --- - Martin Smith - --- - $Id$ - -Frequently Asked Questions - -* Where is the mailing list? - - From {{{http://blogs.reucon.com/asterisk-java/2008/01/17/faq_where_is_the_mailing_list.html}this blog post}}: - - It seems we've hidden the link to our mailing lists a bit too well. - - We have two mailing lists: - - * Asterisk-Java Users for users of Asterisk-Java seeking help - - * Asterisk-Java Devel for developers of Asterisk-Java, i.e. the guys enhancing the library code itself. This list not intended to provide support regarding the use of Asterisk-Java. - - You can find the subscription details for both lists {{{http://asterisk-java.org/development/mail-lists.html}here}}. - - You might also be interested in our {{{http://jira.reucon.org}Bug Tracker}} where you can look for known issues, post new bug reports and submit patches. - -* What are the different components I can use to integrate my application with Asterisk? Which one should I choose for my particular task? - -*-----------------------*---*---*---*--------* -|Feature |AMI|AGI|IAX|C Module| -*-----------------------*---*---*---*--------* -|Make/redirect calls |x |- |x |x | -|Query active calls |x |- |- |x | -|Query extension status |x |- |- |x | -|Stop/start recording |x |x |- |x | -|Receive/send media |- |- |x |x | -|Modify/add dialplan |x |- |- |x | -|Act as IVR application |- |x |- |x | -|Act as soft phone |- |- |x |x | -|Act as endpoint/caller |- |x |x |x | -|Click to call |x |- |- |- | -|Dashboard/status |x |- |- |x | -*-----------------------*---*---*---*--------* - -* How do I produce trace files that be sent to the mailing list for help? - - We recommend you use NetCat (http://netcat.sourceforge.net/) or Wireshark (http://www.wireshark.org/). Wireshark is a better option for less technically adept users. Either way, we need a capture of the conversation between your program and the Asterisk server, and we'd also like the output from Asterisk-Java's logging. Furthermore, it usually helps to see the source in order to follow what we're seeing in the traces. - -* How can I track a call I've originated through the Manager interface? - - With the Live API, you can use the originateToXXXAsync methods in org.asteriskjava.live.DefaultAsteriskServer and provide a unique call-back for your originates. When initiating a call using the Manager API and the Originate command, set a variable on that call. Then track the events the Manager API emits, if you encounter a NewChannelEvent get the variable from that channel and match it to a call. From there on you can use the channel name to track events. - -* How do I disable the debug or "INFO" output from asterisk-java? - - Asterisk-Java uses commons-logging and log4j (http://logging.apache.org/log4j/docs/) so you can easily configure what kind of messages you want to log and where the messages should be written to. If you configure log4j to the OFF level for Asterisk-Java classes, you should get the behavior you are looking for. - Basically there are two options: By default commons-logging uses java.util logging so you can have a look at the JDK documentation on how to configure it. The second option is to put a log4j.jar on your classpath along with a log4j.properties file to configure it. - -* How do I prevent Asterisk-Java from deadlocking when I fire actions in response to a received event? - - Asterisk-Java dispatches events to your classes on an event-dispatch thread. You must use the Live API or send actions on another thread if you don't want actions to block incoming events. - -* Can I send media or files through Manager interface? - - Currently, there is no support for sending media or files across the Manager interface or the Gateway interface. Having access to the media stream without participating in the call would require saving it to a file or modifications to Asterisk itself, and you can expose any files (media or otherwise) through some other means (HTTP, SSH, etc). - -* Does Asterisk-Java work with Java 6? Java 5? - - Asterisk-Java does work with Java 6. Stefan has used it while running Java 6 and 7 for development, and Martin uses Asterisk-Java inside a JBoss service bean all running under Java 6. Asterisk-Java currently supports Java 5 as well, and all source should remain 1.5-compatible for the time being. - -* Can I use Asterisk-Java with AstMan Proxy? - - AstMan proxy requires some modifications in order to be successfully used with Asterisk-Java. Gaetan Minet has created a patch to AstMan Proxy that he has offered for download, with some documentation, at {{http://dev.mcit.be/various/astmanproxy-asterisk-java.html}}. - - As of AstManProxy 1.23 most of the issues have been fixed and the patch is no longer required. You will not be - able to use the CommandAction however as AstManProxy currently converts all NL characters to CR/NL. This issue still - has to be fixed by AstManProxy in a future version. - -* What are some ways of securing an AGI script? - - The FastAGI protocol itself has no support for authentication and encryption. You can add authentication at the application level using username and password parameters and verifying those. For encryption you have to revert to a VPN or other network-layer solutions. - You could also consider writing a FastAGI 'proxy' which sits on the Asterisk server so that the clear unauthenticated text is only transmitted locally. The proxy could then demand authentication/encryption using something like SOAP to the actual end point. - -* Can I have an example of using an AGI server in a container like JBoss? - - Yes. Here's a JBoss EJB3 MBean that creates and destroys an AGI server. - -+-- -@Depends({"JNDI name of anything your Agi scripts depend on"}) -@Management(AgiManagement.class) -@Service -public class AgiMBean implements AgiManagement -{ - - private static final Logger log = Logger.getLogger(AgiMBean.class); - - private AgiServerThread agiServerThread = null; - - class AgiServerThread extends Thread implements Runnable - { - private AgiServer agiServer; - - public AgiServerThread(AgiServer agiServer) { this.agiServer = agiServer; } - - public void run() - { - try - { - agiServer.startup(); - log.info("Asterisk Gatway Interface server MBean has been started"); - } catch (IOException e) // NOPMD - { - // nothing we can do about that and exceptions have already been - // logged by startup(). - log.trace("Exception from startUp(), probably already logged", e); - } - - } - - public AgiServer getAgiServer() { return agiServer; } - } - - public void start() throws Exception - { - try - { - // get agi server & start it - DefaultAgiServer agiServer = new DefaultAgiServer(); - agiServer.setMappingStrategy(new ClassNameMappingStrategy(false)); - agiServerThread = new AgiServerThread(agiServer); - agiServerThread.start(); - } catch (Exception ex) - { - log.error("Startup failed in MBean AgiMBean -- attempting to continue", ex); - } - } - - /** - * Note that on JBoss 4.0.5, this method is accidentally called twice by JBoss. It is a known bug; reports can be found at: - *

- * http://jira.jboss.org/jira/browse/EJBTHREE-711
- * http://jira.jboss.org/jira/browse/EJBTHREE-766
- * http://jira.jboss.org/jira/browse/EJBTHREE-781
- */ - public void stop() throws Exception - { - if (agiServerThread != null && agiServerThread.getAgiServer() != null) - { - agiServerThread.getAgiServer().shutdown(); - } - } -} - -public interface AgiManagement -{ - public void start() throws Exception; - public void stop() throws Exception; -} -+-- - -* What happens when using the Manager API and Asterisk-Java loses the connection to Asterisk? - - Asterisk-Java automatically reconnects if it looses the connection to Asterisk. Automatic reconnection attempts - happens quite fast (with a 50 msec delay) for the first 10 attempts and at 5 seconds intervals later on. - This is to make sure Asterisk-Java reconnects instantly when you reload Asterisk and does not consume too much - resources for longer downtimes of Asterisk. Your application is notified of disconnects and reconnects by the - two pseudo events DisconnectEvent and ConnectEvent so you can take appropriate action like clearing internal - caches. By calling getState() on the ManagerConnection you can determine whether the connection is currently - established or not and whether Asterisk-Java tries to reconnect. - -[images/managerconnection-state.png] - diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt deleted file mode 100644 index 808d2fa88..000000000 --- a/src/site/apt/index.apt +++ /dev/null @@ -1,182 +0,0 @@ - --- - Asterisk-Java - --- - Stefan Reuter - --- - $Id$ - -Asterisk-Java - - The Asterisk-Java package consists of a set of Java classes - that allow you to easily build Java applications that interact with an - {{{http://www.asterisk.org/}Asterisk PBX Server}}. - - Asterisk-Java supports most features of the following Asterisk interfaces: - - * {{{http://www.voip-info.org/wiki-Asterisk+AGI}Fast Asterisk Gateway Interface}} (FastAGI) ({{{apidocs/org/asteriskjava/manager/event/package-summary.html}javadocs}}) - - * {{{http://www.voip-info.org/wiki-Asterisk+manager+API}Asterisk Manager interface}} (AMI) ({{{apidocs/org/asteriskjava/fastagi/command/package-summary.html}javadocs}}). - - * Inter-Asterisk eXchange (IAX) Protocol (<>) - - <> - -* License - - Asterisk-Java is provided under the terms of the - {{{http://www.apache.org/licenses/LICENSE-2.0}Apache License, Version 2.0}}. - -* Status - - We plan to release Asterisk-Java 1.0.0 shortly after Asterisk 1.6. It will be - available at the - {{{http://maven.reucon.com/public/org/asteriskjava/asterisk-java/}distribution site}} - where you can also find the previous releases. - - Asterisk-Java 1.0.0 will further enhance the new stateful higher level API - with operations like "get list of currently active calls" or "place call" - with objects like "Channel" or "Agent" that are transparently updated - as the state of the corresponding object within the Asterisk server - changes. You can have a look at - {{{apidocs/org/asteriskjava/live/package-summary.html}org.asteriskjava.live}} - that represents its current state. - -* Download - - Official releases and release candidates are available from the our - {{{http://maven.reucon.com/public/org/asteriskjava/asterisk-java/}distribution site}}. - - The - {{{http://maven.reucon.com/public-snapshot/org/asteriskjava/asterisk-java/}snapshot distribution site}} - hosts the latest snapshot releases. - - Please feel free to provide any feedback or ask for support via the - {{{mail-lists.html}Asterisk-Java users mailing list}}. - - The latest development version of Asterisk-Java is always available via SVN: - -+-----------------------------------------------------------------------+ - svn co http://svn.reucon.net/repos/asterisk-java/trunk asterisk-java -+-----------------------------------------------------------------------+ - -* Requirements - - Asterisk-Java is compatible with Asterisk 1.0, 1.2 and 1.4. The upcoming - 1.0.0 release will add full support for Asterisk 1.6. - - At runtime Asterisk-Java requires a Java Runtime - Environment (JRE) of at least version 1.6 (Java SE 6). - - Of course you also need a working Asterisk server. When - using the Manager API be sure that it has been enabled (see - {{{http://www.voip-info.org/tiki-index.php?page=Asterisk%20config%20manager.conf}Asterisk config manager.conf}}). - - For logging Asterisk-Java will use - {{{http://logging.apache.org/log4j/}log4j}} when - available. If you do not include log4j in your Classpath - Asterisk-Java will use java.util.logging. - - If you choose to compile Asterisk-Java on your own you need a - Java Developer Kit (JDK) of at least version 1.6 (Java SE 6). To run the unit - tests you need {{{http://www.junit.org/}JUnit}} and - {{{http://www.easymock.org/}EasyMock}} in addition. - -* Related Projects - - {{{http://adm.hamnett.org/}Asterisk Desktop Manager}}, or - ADM for short, brings the power of Asterisk to the user's desktop. It - is written in Java, uses the Eclipse SWT library for its GUI and - Asterisk-Java to provide Asterisk connectivity.\ - Available under the GNU General Public License (GPL). - - {{{http://jivesoftware.org/asterisk-im/}Asterisk-IM}} is a plugin - for the Wildfire XMPP (Jabber) server. It provides integrated - presence between your IM client and phone, notification of incoming calls by IM - and originate calls from the IM client - and of course it is based on - Asterisk-Java.\ - Available under the GNU General Public License (GPL). - - {{{http://asterfax.sourceforge.net/}AsterFax}} provides an - SMTP Fax gateway for the transmission of faxes using Asterisk and - is based on Asterisk-Java.\ - Available under a modified GNU General Public License - (Organizations with more than one fax lines must purchase a - commercial licence). - - {{{http://asterisk-jtapi.sourceforge.net/}Asterisk-JTAPI}} - is a JTAPI implementation for the Asterisk software PBX system. JTAPI is - a provider independent programming interface for Java to build applications - for computer telephony or to add support for it. JTAPI covers a wide range - of usage scenarios starting from controlling a single telephone to a - whole PBX system for example in call-centers.\ - Asterisk-JTAPI builds on top of two other projects: Asterisk-Java, which - provides a Java interface to the Asterisk Manager API, and GJTAPI, which - provides a general framework for JTAPI interfaces.\ - Available under Apache License. - - {{{http://www.voip-info.org/wiki/view/Asterisk+.NET}Asterisk .NET}} - is a full port of Asterisk-Java to .NET. It supports both the Manager API - and FastAGI. The latest version is available from - {{{http://asterisk-dotnet.sourceforge.net}SourceForge}}.\ - Available under Apache License. - - {{{http://www3.mb.sympatico.ca/~chadk/}Asterisk-Java for Mono/.NET}} - is a port of Asterisk-Java to C# for Mono, Microsoft's .NET - Framework and anything else that implements the basic - portions of the framework. It currently only supports the Manager API and - is based on a pre-0.1 snapshot of Asterisk-Java.\ - Available under Apache License. - - {{{http://www.mobicents.org}Mobicents}} is a VoIP - Middleware based on the - {{{http://java.sun.com/products/jain/article_slee_principles.html}JAIN SLEE}} - standard. It includes an - {{{http://wiki.java.net/bin/view/Communications/MobicentsAsteriskRA}Asterisk RA}} - that is based on Asterisk-Java.\ - Available under Lesser GNU General Public License (LGPL) - - {{{http://tanesha.net/Wiki/JastAgi.html}Jast Agi}} - is another toolkit for writing Java applications that connect to - Asterisk using the FastAGI protocol. The lastest version introduces - a statemachine approach to handle AGI requests and uses java.nio to - process all requests in one Thread.\ - Available under Apache License. - - {{{http://orderlycalls.sourceforge.net/}OrderlyCalls}} - supports writing Java based AGI Scripts using FastAGI. Support - for the Manager API was recently added.\ - Available under a modified Lesser GNU General Public License - (It is prohibited to use it for automating 'cold-calling' and you - need prior written permission to provide or augment call queuing). - - {{{http://sourceforge.net/projects/jasterisk/}JAsterisk}} - is a set of JNI classes providing direct access to Asterisk - PBX functionality from Java. It is not a socket-level - interface to Asterisk (like Asterisk-Java) but a true Java-Asterisk - integration at the Thread level.\ - Available under GNU General Public License. - -* Sponsors - - Thanks to our sponsors: - - * JetBrains for providing a free license of - {{{http://www.jetbrains.com/idea/}IntelliJ Idea}}. - - * {{{http://www.atlassian.com/}Atlassian}} for providing a free license of - the excellent {{{http://www.atlassian.com/software/jira/}JIRA}} Bug tracker - as well as {{{http://www.cenqua.com/clover/}Clover}} and - {{{http://www.cenqua.com/fisheye/}FishEye}}. - - * YourKit {{{http://www.yourkit.com/}Java Profiler}}. - - * ej-technologies for providing free licenses - of {{{http://www.ej-technologies.com/products/jprofiler/overview.html}JProfiler}} - and {{{http://www.ej-technologies.com/products/install4j/overview.html}install4j}}. - - * {{{http://www.sourceforge.net}Sourceforge.net}} for hosting - the original development infrastructure for Asterisk-Java. - -* Contact - - You can reach me at <<>> at <<>> dot <<>>. diff --git a/src/site/apt/patch.apt b/src/site/apt/patch.apt deleted file mode 100644 index dc25a7289..000000000 --- a/src/site/apt/patch.apt +++ /dev/null @@ -1,60 +0,0 @@ - --- - How To Create and Submit a Patch - --- - Stefan Reuter - --- - $Id$ - -How To Create and Submit a Patch - - This documents how to create and submit patches for Asterisk-Java. - -* Introduction - - A patch is exactly what the word says: a small piece of code used to - repair a breach. It is normally a plain text file containing only - the differences between the current version of the code and the - fixed version. - - Often patches are also used to submit enhancements. - -* Generating a Patch - - The preferred way of creating a patch is to create it against latest - development branch. This ensures that the patch works with the latest - version of the source code and makes it easier to apply the patch. - - To generate the patch you need to check out a copy of the source code - from SVN. Look a the {{{cvs-usage.html}CVS Howto}} for - the details. - - After you have made the changes to the source code and - made sure it compiles and works as expected, you can create the - patch file using the command - -+-----------------------------------------+ -svn diff > /path/to/patchfile.patch -+-----------------------------------------+ - - If you do not have access to SVN you can generate the patch against - the latest release. - - To generate the patch you will need two copies of the source code: - one that is unmodified and one containing your changes to the source. - Start by downloading the source code of the latest release, extract - it and make a copy of the entire source directory. After you have - made your changes to one of the source directories and made sure it - compiles and works as expected, you can create the patch file using - the command - -+-----------------------------------------+ -diff -ru /path/to/unmodified/source /path/to/modified/source > /path/to/patchfile.patch -+-----------------------------------------+ - -* Sending a Patch - - The preferred way to submit a patch is via the - {{{http://jira.reucon.com/browse/AJ}Bug Tracker}}. - - The patch can be reviewed there in public and other suggestions - can be discussed. diff --git a/src/site/apt/tutorial.apt b/src/site/apt/tutorial.apt deleted file mode 100644 index 087483ff2..000000000 --- a/src/site/apt/tutorial.apt +++ /dev/null @@ -1,609 +0,0 @@ - --- - Tutorial - --- - Stefan Reuter - --- - $Id$ - - This page provides a basic introduction and some sample code for - {{{#The FastAGI Protocol}The FastAGI Protocol}}, {{{#The Manager API}The Manager API}}, and {{{#The Live API}The Live API}}. If - you don't see a tutorial for the part of Asterisk-Java that you're - interested in, please scroll down to make sure it isn't further down the - page, or send us more examples that you would like to see included. - -{The FastAGI Protocol} - - The easiest way to interact with Asterisk from Java applications is via - the FastAGI protocol. AGI scripts can handle either incoming calls or - calls originated via the Manager API (see below for an example on how to - use Asterisk-Java to originate a call from your Java application). - - The AGI (Asterisk Gateway Interface) facility allows you to launch scripts, - from the Asterisk dial plan. Traditionally communication between the scripts - and Asterisk was via standard input and standard output and scripts had to run - on the same machine as Asterisk. Due to the large amount of time a Java - Virtual Machine needs for startup and the discomfort of having to install - a Java environment on the PBX box(es) Java has not been the language - of choice for writing AGI scripts. - - These drawbacks have been addressed by the addition of FastAGI to Asterisk. - FastAGI is basically AGI over TCP/IP socket connections instead of using - standard input and standard output as communication medium. - - Using FastAGI you can run a Java application (on the same machine that runs - Asterisk or on a separate machine) that is only started once and serves AGI - scripts until it is shut down. Combined with Java's multithreading support - you can build pretty fast AGI scripts using this protocol. - - Asterisk-Java helps you with running your Java based AGI scripts by providing - a container that receives connections from the Asterisk server, parses the - request and calls your scripts mapped to the called URL. - -* Hello AGI! - - To write your own AGI scripts you must implement the AgiScript interface. - You can do so by simply extending BaseAgiScript that provides - some convenience methods that further simplify that task. - - A simple AgiScript might look as follows: - -+-- -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiException; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.BaseAgiScript; - -public class HelloAgiScript extends BaseAgiScript -{ - public void service(AgiRequest request, AgiChannel channel) - throws AgiException - { - // Answer the channel... - answer(); - - // ...say hello... - streamFile("welcome"); - - // ...and hangup. - hangup(); - } -} -+-- - - Put this Java source file into a directory of your choice, - add the <<>> and compile it: - -+-- -$ javac -cp asterisk-java.jar HelloAgiScript.java -$ -+-- - - Next you have to add a call to your script to your dialplan in Asterisk. - - You might want to add an extension 1300 to the default section of your - <<>>: - -+-- -[default] -... -exten => 1300,1,Agi(agi://localhost/hello.agi) -+-- - - Replace localhost with the hostname of the machine that runs Asterisk-Java. - - Be sure to reload Asterisk for this change to take effect. You can do so - by executing <<>> on the Asterisk CLI. - - Now you must map the script name <<>> to the HelloAgiScript - we just created. By default this is done in a properties file called - <<>> that must be on the classpath - when we start the AgiServer. In this case it looks like: - -+-- -hello.agi = HelloAgiScript -+-- - - Your directory should now contain the following files: - -+-- -$ ls -l --rw-r--r-- 1 srt srt 163689 2005-03-11 22:07 asterisk-java.jar --rw-r--r-- 1 srt srt 26 2005-03-11 20:50 fastagi-mapping.properties --rw-r--r-- 1 srt srt 624 2005-03-11 22:07 HelloAgiScript.class --rw-r--r-- 1 srt srt 438 2005-03-11 20:50 HelloAgiScript.java -+-- - - Finally we start the AgiServer: - -+-- -$ java -jar asterisk-java.jar -+-- - - For Asterisk-Java 0.3.1 and earlier you would use - -+-- -$ java -cp asterisk-java.jar:. org.asteriskjava.fastagi.DefaultAgiServer -+-- - - or on Windows: - -+-- -$ java -cp asterisk-java.jar;. org.asteriskjava.fastagi.DefaultAgiServer -+-- - - You should see some logging output indicating that the AgiServer has - been successfully started and is listening for incoming connections: - -+-- -Mar 11, 2005 10:20:12 PM org.asteriskjava.fastagi.DefaultAgiServer run -INFO: Thread pool started. -Mar 11, 2005 10:20:12 PM org.asteriskjava.fastagi.DefaultAgiServer run -INFO: Listening on *:4573. -+-- - - When you call extension 1300 you will see the AGI script being launched: - -+-- -Mar 11, 2005 10:22:47 PM org.asteriskjava.fastagi.DefaultAgiServer run -INFO: Received connection. -Mar 11, 2005 10:22:47 PM org.asteriskjava.fastagi.AgiConnectionHandler run -INFO: Begin AgiScript HelloAgiScript on AgiServer-TaskThread-0 -Mar 11, 2005 10:22:48 PM org.asteriskjava.fastagi.AGIConnectionHandler run -INFO: End AgiScript HelloAgiScript on AgiServer-TaskThread-0 -+-- - -* Extending the Example - - Have a look at the documentation of - {{{apidocs/org/asteriskjava/fastagi/BaseAgiScript.html}BaseAgiScript}} - there you will find additional methods that you can use for your own scripts. - If you want to use commands that do not yet have a corresponding method in - BaseAgiScript or if you want to extend the FastAGI protocol by adding your - own commands you can also use the - {{{apidocs/org/asteriskjava/fastagi/AgiChannel.html}channel}}.sendCommand({{{apidocs/org/asteriskjava/fastagi/command/AgiCommand.html}AgiCommand}}) - method to send arbitrary commands. - - You can pass parameters to your scripts by including them in the URL used with - the AGI command. These parameters can be read by the getParameter(String) and - getParameterValues(String) methods in - {{{apidocs/org/asteriskjava/fastagi/AgiRequest.html}AgiRequest}}. - - If you want to pass a parameter named user with a value of "john" to your - script called hello.agi running on localhost your call to the AGI application - looks like this: - -+-- -exten => 1300,1,Agi(agi://localhost/hello.agi?user=john) -+-- - - You can also pass multiple parameters. Parameters containing special characters - must be URL encoded. - - If you are about to write more complex scripts please note that your AgiScript - must be thread-safe. Only one instance will be used to serve all requests. - This is kind of similar to the constraints a servlet engine places on the - implementation of servlets. - -* Configuration - - You can tune the DefaultAgiServer by setting two properties: The bindPort - and the poolSize. - - The bindPort determines the TCP port the server will listen on. By default - this is the FastAGI port 4573. If you change it make sure to include the - new port in the URLs used in <<>>. When using - bindPort 1234 your <<>> will contain: - -+-- -exten => 1300,1,Agi(agi://localhost:1234/hello.agi) -+-- - - To understand the poolSize property you need to know that the - DefaultAgiServer uses a fixed size thread pool to serve your AgiScripts. - The poolSize determines how many threads are spawned at startup and thus - limits the number of AgiScripts that can run at the same time. So you - should set the poolSize to at least the number of concurrent calls the - AgiServer should be able to handle. The default value is 10. - - These configuration properties can be set by providing a - <<>> file on the classpath. - - This might look like: - -+-- -bindPort = 1234 -poolSize = 20 -+-- - -{The Manager API} - - The Manager API is the other way for remote interaction with an Asterisk server. - In contrast to the FastAGI protocol Asterisk does not explicitly pass control - to your application when using the Manager API but allows you to - query and change its state at any time. - - The Manager API is made up of three concepts: Actions, Responses and Events. - Actions can be sent to Asterisk and instruct it to do someting. For example your - application can send an Action to Asterisk requesting it to dial a number and - direct the dialed party to one of your phones. In reply to an - Action Asterisk sends a Reply that contains the results of the operation - performed. - - Events are sent by Asterisk without a direct relation to the Actions your - application is sending. - Events inform you about the relevant changes in Asterisk's state. For example - Events are used to inform your application about incoming calls or users joining - or leaving MeetMe conference rooms. - - The connection to the Asterisk server via Manager API occurs over TCP/IP usually - on the default port 5038. - - To enable the Manager API on Asterisk you must edit your <<>> - configuration file and restart Asterisk. The <<>> also contains - constraints on the range of IP addresses that are allowed to connect and username - and passwords for authentication. A sample might look like: - -+-- -[general] -enabled = yes -port = 5038 -bindaddr = 0.0.0.0 - -[manager] -secret=pa55w0rd -permit=0.0.0.0/0.0.0.0 -read=all -write=all -+-- - - This will enable the Manager AP, allow access from any IP address using the - username "manager" and the password "pa55w0rd". - -* Hello Manager! - - Assume we have a phone connected via SIP that is available at SIP/john and - we want to initiate a call from that phone to extension 1300 in the default - context. - - We have to obtain a - {{{apidocs/org/asteriskjava/manager/ManagerConnection.html}ManagerConnection}} - providing the hostname Asterisk is running on and the username and password - as configured in <<>>. Next we log in and send an - {{{apidocs/org/asteriskjava/manager/action/OriginateAction.html}OriginateAction}} - and finally we disconnect. - - An example that does this is shown below. - -+-- -import java.io.IOException; - -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerConnectionFactory; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.manager.action.OriginateAction; -import org.asteriskjava.manager.response.ManagerResponse; - -public class HelloManager -{ - private ManagerConnection managerConnection; - - public HelloManager() throws IOException - { - ManagerConnectionFactory factory = new ManagerConnectionFactory( - "localhost", "manager", "pa55w0rd"); - - this.managerConnection = factory.createManagerConnection(); - } - - public void run() throws IOException, AuthenticationFailedException, - TimeoutException - { - OriginateAction originateAction; - ManagerResponse originateResponse; - - originateAction = new OriginateAction(); - originateAction.setChannel("SIP/John"); - originateAction.setContext("default"); - originateAction.setExten("1300"); - originateAction.setPriority(new Integer(1)); - originateAction.setTimeout(new Integer(30000)); - - // connect to Asterisk and log in - managerConnection.login(); - - // send the originate action and wait for a maximum of 30 seconds for Asterisk - // to send a reply - originateResponse = managerConnection.sendAction(originateAction, 30000); - - // print out whether the originate succeeded or not - System.out.println(originateResponse.getResponse()); - - // and finally log off and disconnect - managerConnection.logoff(); - } - - public static void main(String[] args) throws Exception - { - HelloManager helloManager; - - helloManager = new HelloManager(); - helloManager.run(); - } -} -+-- - - A list of the other {{{apidocs/org/asteriskjava/manager/action/package-summary.html}Actions}} - provided by the Manager API is available in the {{{apidocs/index.html}javadocs}}. - -* Hello Events! - - To receive events from Asterisk you have to implement the - {{{apidocs/org/asteriskjava/manager/ManagerEventListener.html}ManagerEventListener}} - interface and add it to the - {{{apidocs/org/asteriskjava/manager/ManagerConnection.html}ManagerConnection}}. - - The following code shows a simple example of how to do this: - -+-- -import java.io.IOException; - -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.ManagerConnection; -import org.asteriskjava.manager.ManagerConnectionFactory; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.event.ManagerEvent; - -public class HelloEvents implements ManagerEventListener -{ - private ManagerConnection managerConnection; - - public HelloEvents() throws IOException - { - ManagerConnectionFactory factory = new ManagerConnectionFactory( - "localhost", "manager", "pa55w0rd"); - - this.managerConnection = factory.createManagerConnection(); - } - - public void run() throws IOException, AuthenticationFailedException, - TimeoutException, InterruptedException - { - // register for events - managerConnection.addEventListener(this); - - // connect to Asterisk and log in - managerConnection.login(); - - // request channel state - managerConnection.sendAction(new StatusAction()); - - // wait 10 seconds for events to come in - Thread.sleep(10000); - - // and finally log off and disconnect - managerConnection.logoff(); - } - - public void onManagerEvent(ManagerEvent event) - { - // just print received events - System.out.println(event); - } - - public static void main(String[] args) throws Exception - { - HelloEvents helloEvents; - - helloEvents = new HelloEvents(); - helloEvents.run(); - } -} -+-- - - A list of the other {{{apidocs/org/asteriskjava/manager/event/package-summary.html}Events}} - povided by the Manager API is available in the - {{{apidocs/index.html}javadocs}}. - -{The Live API} - - The live API is built on top of the Manager API and provides additional abstraction. - Instead of directly using actions and events to interact with Asterisk you can use - active domain objects (live objects) that represent Asterisk concepts like a channel - or an extension. The behavior of live objects follows the pattern of the - {{{http://java.sun.com/products/javabeans/reference/api/index.html}JavaBeans specification}} by Sun. - - To get started, have a look at the the {{{apidocs/org/asteriskjava/live/package-summary.html}live package}} - in the {{{apidocs/index.html}javadocs}}, especially the interfaces for {{{apidocs/org/asteriskjava/live/AsteriskServer.html}AsteriskServer}}, - {{{apidocs/org/asteriskjava/live/AsteriskChannel.html}AsteriskChannel}}, and - {{{apidocs/org/asteriskjava/live/AsteriskQueue.html}AsteriskQueue}}. Asterisk-Java provides implementations - for these interfaces, such as {{{apidocs/org/asteriskjava/live/DefaultAsteriskServer.html}DefaultAsteriskServer}} - for {{{apidocs/org/asteriskjava/live/AsteriskServer.html}AsteriskServer}}. DefaultAsteriskServer, in turn, relies - on other implementation classes provided. - -* HelloLive - - To run commands using the live API, you need to create an AsteriskServer using the DefaultAsteriskServer implementation. - Alternatively, if you already have a manager connection (see "The Manager API" above), you can pass that to the DefaultAsteriskServer. - Once connected, this sample program prints all channels, queues, and meet me objects. In a real project, you will probably do this at - the start, and perhaps perform some actions based on the current state of Asterisk. Continue below to see how to use events in the live package. - - The following code shows a simple example of how to connect to Asterisk using the live API: - -+-- -import org.asteriskjava.live.AsteriskServer; -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.AsteriskQueue; -import org.asteriskjava.live.MeetMeRoom; -import org.asteriskjava.live.DefaultAsteriskServer; - -import org.asteriskjava.live.ManagerCommunicationException; - -public class HelloLive -{ - private AsteriskServer asteriskServer; - - public HelloLive() - { - asteriskServer = new DefaultAsteriskServer("localhost", "manager", "pa55w0rd"); - } - - public void run() throws ManagerCommunicationException - { - for (AsteriskChannel asteriskChannel : asteriskServer.getChannels()) - { - System.out.println(asteriskChannel); - } - - for (AsteriskQueue asteriskQueue : asteriskServer.getQueues()) - { - System.out.println(asteriskQueue); - } - - for (MeetMeRoom meetMeRoom : asteriskServer.getMeetMeRooms()) - { - System.out.println(meetMeRoom); - } - } - - public static void main(String[] args) throws Exception - { - HelloLive helloLive = new HelloLive(); - helloLive.run(); - } -} -+-- - -* HelloLiveEvents - - To process events using the live API, you need to implement an {{{apidocs/org/asteriskjava/live/AsteriskServerListener.html}AsteriskServerListener}}. - Once you have a class that implements that interface, you can add it via the DefaultAsteriskServer in order to hear about new channels. - - The following code snippet shows a simple example of how to listen for new channels or meet me users: - -+-- -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.AsteriskServer; -import org.asteriskjava.live.AsteriskServerListener; -import org.asteriskjava.live.DefaultAsteriskServer; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.MeetMeUser; - -public class HelloLiveEvents implements AsteriskServerListener -{ - private AsteriskServer asteriskServer; - - public HelloLiveEvents() - { - asteriskServer = new DefaultAsteriskServer("localhost", "manager", "pa55w0rd"); - } - - public void run() throws ManagerCommunicationException - { - asteriskServer.addAsteriskServerListener(this); - } - - public void onNewAsteriskChannel(AsteriskChannel channel) - { - System.out.println(channel); - } - - public void onNewMeetMeUser(MeetMeUser user) - { - System.out.println(user); - } - - public static void main(String[] args) throws Exception - { - HelloLiveEvents helloLiveEvents = new HelloLiveEvents(); - helloLiveEvents.run(); - } -} -+-- - -* HelloLiveEverything - - Finally, for every AsteriskChannel or MeetMeUser you can get examine through the live API, you can also add a listener - for properties that change on that object. - - The following code snippet shows a longer example that adds event listeners for new channels or meet me users, and - property change listeners to new and old channels and users: - -+-- -import org.asteriskjava.live.AsteriskChannel; -import org.asteriskjava.live.AsteriskQueue; -import org.asteriskjava.live.AsteriskServer; -import org.asteriskjava.live.AsteriskServerListener; -import org.asteriskjava.live.DefaultAsteriskServer; -import org.asteriskjava.live.ManagerCommunicationException; -import org.asteriskjava.live.MeetMeRoom; -import org.asteriskjava.live.MeetMeUser; -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeEvent; - -public class HelloLiveEverything implements AsteriskServerListener, PropertyChangeListener -{ - private AsteriskServer asteriskServer; - - public HelloLiveEverything() - { - asteriskServer = new DefaultAsteriskServer("localhost", "manager", "pa55w0rd"); - } - - public void run() throws ManagerCommunicationException - { - // listen for new events - asteriskServer.addAsteriskServerListener(this); - - // add property change listeners to existing objects - for (AsteriskChannel asteriskChannel : asteriskServer.getChannels()) - { - System.out.println(asteriskChannel); - asteriskChannel.addPropertyChangeListener(this); - } - - for (AsteriskQueue asteriskQueue : asteriskServer.getQueues()) - { - System.out.println(asteriskQueue); - for (AsteriskChannel asteriskChannel : asteriskQueue.getEntries()) - { - asteriskChannel.addPropertyChangeListener(this); - } - } - - for (MeetMeRoom meetMeRoom : asteriskServer.getMeetMeRooms()) - { - System.out.println(meetMeRoom); - for (MeetMeUser user : meetMeRoom.getUsers()) - { - user.addPropertyChangeListener(this); - } - } - } - - public void onNewAsteriskChannel(AsteriskChannel channel) - { - System.out.println(channel); - channel.addPropertyChangeListener(this); - } - - public void onNewMeetMeUser(MeetMeUser user) - { - System.out.println(user); - user.addPropertyChangeListener(this); - } - - public void propertyChange(PropertyChangeEvent propertyChangeEvent) - { - System.out.println(propertyChangeEvent); - } - - public static void main(String[] args) throws Exception - { - HelloLiveEverything helloLiveEverything = new HelloLiveEverything(); - helloLiveEverything.run(); - } -} -+-- diff --git a/src/site/resources/images/agi-thumb.png b/src/site/resources/images/agi-thumb.png deleted file mode 100644 index 3bf71b317..000000000 Binary files a/src/site/resources/images/agi-thumb.png and /dev/null differ diff --git a/src/site/resources/images/agi.png b/src/site/resources/images/agi.png deleted file mode 100644 index 038d8554f..000000000 Binary files a/src/site/resources/images/agi.png and /dev/null differ diff --git a/src/site/resources/images/asterisk-java.png b/src/site/resources/images/asterisk-java.png deleted file mode 100644 index 8fb26edef..000000000 Binary files a/src/site/resources/images/asterisk-java.png and /dev/null differ diff --git a/src/site/resources/images/manager-thumb.png b/src/site/resources/images/manager-thumb.png deleted file mode 100644 index a064203b5..000000000 Binary files a/src/site/resources/images/manager-thumb.png and /dev/null differ diff --git a/src/site/resources/images/manager.png b/src/site/resources/images/manager.png deleted file mode 100644 index c75c906e3..000000000 Binary files a/src/site/resources/images/manager.png and /dev/null differ diff --git a/src/site/resources/images/managerconnection-state.png b/src/site/resources/images/managerconnection-state.png deleted file mode 100644 index 8d3fdb6ac..000000000 Binary files a/src/site/resources/images/managerconnection-state.png and /dev/null differ diff --git a/src/site/site.xml b/src/site/site.xml deleted file mode 100644 index c4d42660a..000000000 --- a/src/site/site.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - Asterisk-Java-Banner - images/asterisk-java.png - http://asterisk-java.org/ - Asterisk-Java - - - - org.asteriskjava - asterisk-java-skin - 1.0.1 - - - - - - - - - -

- - - - - - - - - - - - - ${reports} - - diff --git a/src/test/java/org/asteriskjava/config/ConfigFileParserTest.java b/src/test/java/org/asteriskjava/config/ConfigFileParserTest.java deleted file mode 100644 index c35a43564..000000000 --- a/src/test/java/org/asteriskjava/config/ConfigFileParserTest.java +++ /dev/null @@ -1,166 +0,0 @@ -package org.asteriskjava.config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.nio.CharBuffer; - -import org.junit.Before; -import org.junit.Test; - -public class ConfigFileParserTest -{ - ConfigFileReader configFileReader; - - @Before - public void setUp() - { - configFileReader = new ConfigFileReader(); - } - - @Test - public void testProcessLine() throws Exception - { - String s = " a ;-- comment --; = b ; a line comment"; - CharBuffer buffer = CharBuffer.allocate(s.length()); - - buffer.put(s); - buffer.flip(); - - configFileReader.appendCategory(new Category("cat")); - ConfigElement configElement = configFileReader.processLine("test.conf", 1, buffer); - assertEquals("Incorrect type of configElement", ConfigVariable.class, configElement.getClass()); - - ConfigVariable configVariable = (ConfigVariable) configElement; - assertEquals("Incorrect variable name", "a", configVariable.getName()); - assertEquals("Incorrect variable value", "b", configVariable.getValue()); - assertEquals("Incorrect comment", "a line comment", configElement.getComment()); - } - - @Test - public void testParseCategoryHeader() throws Exception - { - Category category; - - category = configFileReader.parseCategoryHeader("test.conf", 1, "[foo]"); - assertEquals("Incorrect category name", "foo", category.getName()); - assertEquals("Incorrect line number", 1, category.getLineNumber()); - assertEquals("Incorrect file name", "test.conf", category.getFileName()); - - category = configFileReader.parseCategoryHeader("test.conf", 1, "[foo](!)"); - assertEquals("Incorrect category name", "foo", category.getName()); - assertTrue("Category not flagged as template", category.isTemplate()); - - category = configFileReader.parseCategoryHeader("test.conf", 1, "[foo](+)"); - assertEquals("Incorrect category name", "foo", category.getName()); - - try - { - configFileReader.parseCategoryHeader("test.conf", 1, "[foo](a)"); - fail("Expected exception when requesting inheritance from a non-existing catagory"); - } - catch (ConfigParseException e) - { - assertEquals("Inheritance requested, but category 'a' does not exist, line 1 of test.conf", e.getMessage()); - assertEquals("Incorrect line number", 1, e.getLineNumber()); - assertEquals("Incorrect file name", "test.conf", e.getFileName()); - } - - try - { - configFileReader.parseCategoryHeader("test.conf", 1, "[foo"); - fail("Expected exception when closing ']' is missing"); - } - catch (ConfigParseException e) - { - assertEquals(e.getMessage(), "parse error: no closing ']', line 1 of test.conf"); - } - - try - { - configFileReader.parseCategoryHeader("test.conf", 1, "[foo](bar"); - fail("Expected exception when closing ')' is missing"); - } - catch (ConfigParseException e) - { - assertEquals(e.getMessage(), "parse error: no closing ')', line 1 of test.conf"); - } - } - - @Test - public void testParseDirective() throws ConfigParseException - { - ConfigDirective configDirective; - - configDirective = configFileReader.parseDirective("abc.conf", 20, "#include \"/etc/asterisk/inc.conf\""); - assertEquals("Incorrect type of configDirective", IncludeDirective.class, configDirective.getClass()); - assertEquals("Incorrect include file", "/etc/asterisk/inc.conf", - ((IncludeDirective) configDirective).getIncludeFile()); - assertEquals("Incorrect line number", 20, configDirective.getLineNumber()); - assertEquals("Incorrect file name", "abc.conf", configDirective.getFileName()); - - configDirective = configFileReader.parseDirective("abc.conf", 20, "#exec "); - assertEquals("Incorrect type of configDirective", ExecDirective.class, configDirective.getClass()); - assertEquals("Incorrect exec file", "/usr/local/test.sh", ((ExecDirective) configDirective).getExecFile()); - assertEquals("Incorrect line number", 20, configDirective.getLineNumber()); - assertEquals("Incorrect file name", "abc.conf", configDirective.getFileName()); - - try - { - configFileReader.parseDirective("abc.conf", 20, "#foo"); - fail("Expected exception when parsing a line with an unknown directive"); - } - catch (UnknownDirectiveException e) - { - assertEquals("Unknown directive 'foo' at line 20 of abc.conf", e.getMessage()); - } - - try - { - configFileReader.parseDirective("/etc/asterisk/sip.conf", 805, "#include "); - fail("Expected exception when parsing a line with a directive but no parameter"); - } - catch (MissingDirectiveParameterException e) - { - assertEquals("Directive '#include' needs an argument (filename) at line 805 of /etc/asterisk/sip.conf", - e.getMessage()); - } - } - - @Test - public void testParseVariable() throws ConfigParseException - { - ConfigVariable variable; - - variable = configFileReader.parseVariable("extensions.conf", 20, "exten => s-NOANSWER,1,Hangup"); - assertEquals("Incorrect name", "exten", variable.getName()); - assertEquals("Incorrect value", "s-NOANSWER,1,Hangup", variable.getValue()); - assertEquals("Incorrect line number", 20, variable.getLineNumber()); - assertEquals("Incorrect file name", "extensions.conf", variable.getFileName()); - - variable = configFileReader.parseVariable("extensions.conf", 20, "foo="); - assertEquals("Incorrect name", "foo", variable.getName()); - assertEquals("Incorrect value", "", variable.getValue()); - - try - { - configFileReader.parseVariable("extensions.conf", 20, "foo"); - fail("Expected exception when parsing a line without a '='"); - } - catch (MissingEqualSignException e) - { - assertEquals("No '=' (equal sign) in line 20 of extensions.conf", e.getMessage()); - } - } - - public void XtestReadConfig() - { - configFileReader.readFile("/etc/asterisk/sip2.conf"); - - for (Category category : configFileReader.getCategories()) - { - System.out.println(category.format()); - } - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/ClassNameMappingStrategyTest.java b/src/test/java/org/asteriskjava/fastagi/ClassNameMappingStrategyTest.java deleted file mode 100644 index 5b990ae5e..000000000 --- a/src/test/java/org/asteriskjava/fastagi/ClassNameMappingStrategyTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - -public class ClassNameMappingStrategyTest -{ - private ClassNameMappingStrategy mappingStrategy; - - @Before - public void setUp() - { - this.mappingStrategy = new ClassNameMappingStrategy(); - } - - @Test - public void testDetermineScript() - { - AgiScript scriptFirstPass; - AgiScript scriptSecondPass; - AgiRequest request; - - request = new SimpleAgiRequest() - { - @Override - public String getScript() - { - return "org.asteriskjava.fastagi.HelloAgiScript"; - } - }; - - scriptFirstPass = mappingStrategy.determineScript(request); - scriptSecondPass = mappingStrategy.determineScript(request); - - assertEquals("incorrect script determined", scriptFirstPass.getClass(), HelloAgiScript.class); - - assertTrue("script instances are not cached", scriptFirstPass == scriptSecondPass); - } - - @Test - public void testDetermineScriptWithNonSharedInstance() - { - AgiScript scriptFirstPass; - AgiScript scriptSecondPass; - AgiRequest request; - - mappingStrategy.setShareInstances(false); - request = new SimpleAgiRequest() - { - @Override - public String getScript() - { - return "org.asteriskjava.fastagi.HelloAgiScript"; - } - }; - - scriptFirstPass = mappingStrategy.determineScript(request); - scriptSecondPass = mappingStrategy.determineScript(request); - - assertEquals("incorrect script determined", scriptFirstPass.getClass(), HelloAgiScript.class); - - assertTrue("returned a shared instance", scriptFirstPass != scriptSecondPass); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/CompositeMappingStrategyTest.java b/src/test/java/org/asteriskjava/fastagi/CompositeMappingStrategyTest.java deleted file mode 100644 index 8878415d0..000000000 --- a/src/test/java/org/asteriskjava/fastagi/CompositeMappingStrategyTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.asteriskjava.fastagi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Before; -import org.junit.Test; - -public class CompositeMappingStrategyTest -{ - private CompositeMappingStrategy strategy; - - @Before - public void setUp() - { - strategy = new CompositeMappingStrategy(new ResourceBundleMappingStrategy("test-mapping"), - new ClassNameMappingStrategy()); - } - - @Test - public void testAJ37ResourceBundle() - { - AgiRequest request = new SimpleAgiRequest(); - AgiScript script = strategy.determineScript(request, null); - - assertNotNull("no script determined", script); - assertEquals("incorrect script determined", script.getClass(), HelloAgiScript.class); - } - - @Test - public void testAJ37ClassName() - { - AgiRequest request = new SimpleAgiRequest("org.asteriskjava.fastagi.HelloAgiScript"); - AgiScript script = strategy.determineScript(request, null); - - assertNotNull("no script determined", script); - assertEquals("incorrect script determined", script.getClass(), HelloAgiScript.class); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/DefaultAgiServerTest.java b/src/test/java/org/asteriskjava/fastagi/DefaultAgiServerTest.java deleted file mode 100644 index a07921314..000000000 --- a/src/test/java/org/asteriskjava/fastagi/DefaultAgiServerTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; - -import java.io.IOException; - -import org.asteriskjava.util.ServerSocketFacade; -import org.asteriskjava.util.SocketConnectionFacade; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class DefaultAgiServerTest -{ - private DefaultAgiServer server; - private MockedServerSocketFacade serverSocket; - private SocketConnectionFacade socket; - - @Before - public void setUp() - { - serverSocket = new MockedServerSocketFacade(); - server = new MockedDefaultAgiServer(); - } - - @After - public void tearDown() throws Exception - { - server.shutdown(); - } - - @Test - public void testDummy() - { - - } - - public void XtestStartup() throws Exception - { - socket = createMock(SocketConnectionFacade.class); - - expect(socket.readLine()).andReturn(null); - expect(socket.getLocalAddress()).andReturn(null); - expect(socket.getLocalPort()).andReturn(1); - expect(socket.getRemoteAddress()).andReturn(null); - expect(socket.getRemotePort()).andReturn(2); - socket.write("VERBOSE \"No script configured for null\" 1\n"); - socket.flush(); - expect(socket.readLine()).andReturn(null); - socket.close(); - replay(socket); - - try - { - server.startup(); - } - catch (IOException e) - { - // swallow - } - Thread.sleep(500); - - assertEquals("serverSocket.accept() not called 2 times", 2, serverSocket.acceptCalls); - assertEquals("serverSocket.close() not called", 1, serverSocket.closeCalls); - - verify(socket); - } - - class MockedDefaultAgiServer extends DefaultAgiServer - { - @Override - protected ServerSocketFacade createServerSocket() - { - return serverSocket; - } - } - - class MockedServerSocketFacade implements ServerSocketFacade - { - public int acceptCalls = 0; - public int closeCalls = 0; - - public SocketConnectionFacade accept() throws IOException - { - acceptCalls++; - try - { - Thread.sleep(100); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - - if (acceptCalls == 1) - { - return socket; - } - throw new IOException("Provoked IOException"); - } - - public void close() throws IOException - { - closeCalls++; - } - } - - @Test - public void testLoadConfigWithDefaultPort() - { - DefaultAgiServer defaultAgiServer; - - defaultAgiServer = new DefaultAgiServer(); - assertEquals("Invalid default port", 4573, defaultAgiServer.getPort()); - } - - @Test - public void testLoadConfigWithPort() - { - DefaultAgiServer defaultAgiServer; - - defaultAgiServer = new DefaultAgiServer("test1-fastagi"); - assertEquals("Port property not recognized", 1234, defaultAgiServer.getPort()); - - } - - @Test - public void testLoadConfigWithBindPort() - { - DefaultAgiServer defaultAgiServer; - - defaultAgiServer = new DefaultAgiServer("test2-fastagi"); - assertEquals("BindPort property not recognized", 2345, defaultAgiServer.getPort()); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/HelloAgiScript.java b/src/test/java/org/asteriskjava/fastagi/HelloAgiScript.java deleted file mode 100644 index b12c10cb6..000000000 --- a/src/test/java/org/asteriskjava/fastagi/HelloAgiScript.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -/** - * Test script for use with the ResourceBundleMappingStrategyTest. - * - * @author srt - * @version $Id$ - */ -public class HelloAgiScript implements AgiScript -{ - public HelloAgiScript() - { - - } - - public void service(AgiRequest request, AgiChannel channel) throws AgiException - { - channel.streamFile("tt-monkeysintro"); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/ResourceBundleMappingStrategyTest.java b/src/test/java/org/asteriskjava/fastagi/ResourceBundleMappingStrategyTest.java deleted file mode 100644 index c235f290a..000000000 --- a/src/test/java/org/asteriskjava/fastagi/ResourceBundleMappingStrategyTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - -public class ResourceBundleMappingStrategyTest -{ - private ResourceBundleMappingStrategy mappingStrategy; - - @Before - public void setUp() - { - this.mappingStrategy = new ResourceBundleMappingStrategy(); - this.mappingStrategy.setResourceBundleName("test-mapping"); - } - - @Test - public void testDetermineScript() - { - AgiScript scriptFirstPass; - AgiScript scriptSecondPass; - AgiRequest request; - - request = new SimpleAgiRequest(); - - scriptFirstPass = mappingStrategy.determineScript(request); - scriptSecondPass = mappingStrategy.determineScript(request); - - assertNotNull("no script determined", scriptFirstPass); - assertEquals("incorrect script determined", scriptFirstPass.getClass(), HelloAgiScript.class); - - assertTrue("script instances are not cached", scriptFirstPass == scriptSecondPass); - } - - @Test - public void testDetermineScriptWithResourceBundleUnavailable() - { - AgiRequest request; - - request = new SimpleAgiRequest(); - - mappingStrategy.setResourceBundleName("net.sf.asterisk.fastagi.unavailable"); - assertNull(mappingStrategy.determineScript(request)); - } - - @Test - public void testDetermineScriptWithNonSharedInstance() - { - AgiScript scriptFirstPass; - AgiScript scriptSecondPass; - AgiRequest request; - - mappingStrategy.setShareInstances(false); - request = new SimpleAgiRequest(); - - scriptFirstPass = mappingStrategy.determineScript(request); - scriptSecondPass = mappingStrategy.determineScript(request); - - assertEquals("incorrect script determined", scriptFirstPass.getClass(), HelloAgiScript.class); - - assertTrue("returned a shared instance", scriptFirstPass != scriptSecondPass); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/ScriptEngineMappingStrategyTest.java b/src/test/java/org/asteriskjava/fastagi/ScriptEngineMappingStrategyTest.java deleted file mode 100644 index 205ec0988..000000000 --- a/src/test/java/org/asteriskjava/fastagi/ScriptEngineMappingStrategyTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.asteriskjava.fastagi; - -import static org.asteriskjava.fastagi.ScriptEngineMappingStrategy.getExtension; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.io.File; -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; - -public class ScriptEngineMappingStrategyTest -{ - private ScriptEngineMappingStrategy scriptEngineMappingStrategy; - - @Before - public void setUp() - { - this.scriptEngineMappingStrategy = new ScriptEngineMappingStrategy(); - } - - @Test - public void testSearchFile() throws IOException - { - assertNull(scriptEngineMappingStrategy.searchFile(null, new String[]{"src", "test", "."})); - assertNull(scriptEngineMappingStrategy.searchFile("pom.xml", null)); - assertNull(scriptEngineMappingStrategy.searchFile("pom.xml", new String[]{})); - assertNull(scriptEngineMappingStrategy.searchFile("pom.xml", new String[]{"src", "test"})); - assertEquals(new File("pom.xml").getCanonicalPath(), - scriptEngineMappingStrategy.searchFile("pom.xml", new String[]{"bla", "src", "."}).getPath()); - } - - @Test - public void testSearchFileOutsidePath() - { - // file should not be found for security reasons if it is not below the - // path - assertNull(scriptEngineMappingStrategy.searchFile("../pom.xml", new String[]{"src"})); - } - - @Test - public void testGetExtension() - { - assertEquals("txt", getExtension("hello.txt")); - assertEquals("txt", getExtension("/some/path/hello.txt")); - assertEquals("txt", getExtension("C:\\some\\path\\hello.txt")); - assertEquals("txt", getExtension("C:\\some\\path\\hel.lo.txt")); - assertEquals("txt", getExtension("C:\\some\\pa.th\\hel.lo.txt")); - assertEquals("txt", getExtension(".txt")); - - assertEquals(null, getExtension(null)); - assertEquals(null, getExtension("")); - - assertEquals(null, getExtension("hello")); - assertEquals(null, getExtension("/some/path/hello")); - assertEquals(null, getExtension("/some/pa.th/hello")); - assertEquals(null, getExtension("C:\\some\\path\\hello")); - assertEquals(null, getExtension("C:\\some\\pa.th\\hello")); - - assertEquals(null, getExtension("/some/pa.th\\hello")); - assertEquals(null, getExtension("C:\\some\\pa.th/hello")); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/SimpleAgiRequest.java b/src/test/java/org/asteriskjava/fastagi/SimpleAgiRequest.java deleted file mode 100644 index 2667479a6..000000000 --- a/src/test/java/org/asteriskjava/fastagi/SimpleAgiRequest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2005-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi; - -import java.net.InetAddress; -import java.util.Map; - -public class SimpleAgiRequest implements AgiRequest -{ - InetAddress localAddress; - int localPort; - InetAddress remoteAddress; - int remotePort; - private String script; - - public SimpleAgiRequest() - { - this.script = "hello.agi"; - } - - public SimpleAgiRequest(String script) - { - this.script = script; - } - - public Map getRequest() - { - throw new UnsupportedOperationException(); - } - - public String getScript() - { - return script; - } - - public String getRequestURL() - { - throw new UnsupportedOperationException(); - } - - public String getChannel() - { - throw new UnsupportedOperationException(); - } - - public String getUniqueId() - { - throw new UnsupportedOperationException(); - } - - public String getType() - { - throw new UnsupportedOperationException(); - } - - public String getLanguage() - { - throw new UnsupportedOperationException(); - } - - /** - * Returns the Caller*ID number, for example "1234".

- * Note: even with Asterisk 1.0 is contains only the numerical part - * of the Caller ID. - * - * @return the Caller*ID number, for example "1234", if no Caller*ID is set or it - * is "unknown" null is returned. - * @deprecated as of 0.3, use {@link #getCallerIdNumber()} instead. - */ - public String getCallerId() - { - throw new UnsupportedOperationException(); - } - - public String getCallerIdNumber() - { - throw new UnsupportedOperationException(); - } - - public String getCallerIdName() - { - throw new UnsupportedOperationException(); - } - - public String getDnid() - { - throw new UnsupportedOperationException(); - } - - public String getRdnis() - { - throw new UnsupportedOperationException(); - } - - public String getContext() - { - throw new UnsupportedOperationException(); - } - - public String getExtension() - { - throw new UnsupportedOperationException(); - } - - public Integer getPriority() - { - throw new UnsupportedOperationException(); - } - - public Boolean getEnhanced() - { - throw new UnsupportedOperationException(); - } - - public String getAccountCode() - { - throw new UnsupportedOperationException(); - } - - public Integer getCallingAni2() - { - throw new UnsupportedOperationException(); - } - - public Integer getCallingPres() - { - throw new UnsupportedOperationException(); - } - - public Integer getCallingTns() - { - throw new UnsupportedOperationException(); - } - - public Integer getCallingTon() - { - throw new UnsupportedOperationException(); - } - - public String getParameter(String name) - { - throw new UnsupportedOperationException(); - } - - public String[] getParameterValues(String name) - { - throw new UnsupportedOperationException(); - } - - public Map getParameterMap() - { - throw new UnsupportedOperationException(); - } - - public String[] getArguments() - { - throw new UnsupportedOperationException(); - } - - public InetAddress getLocalAddress() - { - return localAddress; - } - - public void setLocalAddress(InetAddress localAddress) - { - this.localAddress = localAddress; - } - - public int getLocalPort() - { - return localPort; - } - - public void setLocalPort(int localPort) - { - this.localPort = localPort; - } - - public InetAddress getRemoteAddress() - { - return remoteAddress; - } - - public void setRemoteAddress(InetAddress remoteAddress) - { - this.remoteAddress = remoteAddress; - } - - public int getRemotePort() - { - return remotePort; - } - - public void setRemotePort(int remotePort) - { - this.remotePort = remotePort; - } -} \ No newline at end of file diff --git a/src/test/java/org/asteriskjava/fastagi/command/AbstractAgiCommandTest.java b/src/test/java/org/asteriskjava/fastagi/command/AbstractAgiCommandTest.java deleted file mode 100644 index d15e6ec28..000000000 --- a/src/test/java/org/asteriskjava/fastagi/command/AbstractAgiCommandTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class AbstractAgiCommandTest -{ - private MyCommand myCommand; - - @Test - public void testEscapeAndQuote() - { - myCommand = new MyCommand("just a string"); - - assertEquals("MY \"just a string\"", myCommand.buildCommand()); - } - - @Test - public void testEscapeAndQuoteWithNullString() - { - myCommand = new MyCommand(null); - - assertEquals("MY \"\"", myCommand.buildCommand()); - } - - @Test - public void testEscapeAndQuoteWithEmptyString() - { - myCommand = new MyCommand(""); - - assertEquals("MY \"\"", myCommand.buildCommand()); - } - - @Test - public void testEscapeAndQuoteWithStringContainingQuotes() - { - myCommand = new MyCommand("\"John Doe\" is calling"); - - assertEquals("MY \"\\\"John Doe\\\" is calling\"", myCommand.buildCommand()); - } - - @Test - public void testEscapeAndQuoteWithStringContainingNewline() - { - myCommand = new MyCommand("Caller is:\nJohn Doe"); - - assertEquals("MY \"Caller is:John Doe\"", myCommand.buildCommand()); - } - - @Test - public void testEscapedQuotesAJ192() { - myCommand = new MyCommand("first \\\" second \\\" third"); - - assertEquals("MY \"first \\\\\\\" second \\\\\\\" third\"", myCommand.buildCommand()); - } - - public class MyCommand extends AbstractAgiCommand - { - private static final long serialVersionUID = 3976731484641833012L; - private String s; - - public MyCommand(String s) - { - this.s = s; - } - - @Override - public String buildCommand() - { - return "MY " + escapeAndQuote(s); - } - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/command/ExecCommandTest.java b/src/test/java/org/asteriskjava/fastagi/command/ExecCommandTest.java deleted file mode 100644 index be722d18c..000000000 --- a/src/test/java/org/asteriskjava/fastagi/command/ExecCommandTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class ExecCommandTest -{ - private ExecCommand execCommand; - - @Test - public void testDefault() - { - execCommand = new ExecCommand("DIAL"); - assertEquals("EXEC \"DIAL\" \"\"", execCommand.buildCommand()); - } - - @Test - public void testWithSingleOption() - { - execCommand = new ExecCommand("DIAL", "SIP/1234"); - assertEquals("EXEC \"DIAL\" \"SIP/1234\"", execCommand.buildCommand()); - } - - @Test - public void testWithMultipleOptionsSingleParameterPipeSeparated() - { - execCommand = new ExecCommand("DIAL", "SIP/1234|30"); - assertEquals("EXEC \"DIAL\" \"SIP/1234|30\"", execCommand.buildCommand()); - } - - @Test - public void testWithMultipleOptionsSingleParameterCommaSeparated() - { - execCommand = new ExecCommand("DIAL", "SIP/1234,30"); - assertEquals("EXEC \"DIAL\" \"SIP/1234,30\"", execCommand.buildCommand()); - } - - @Test - public void testWithMultipleOptionsMultipleParameters() - { - execCommand = new ExecCommand("DIAL", "SIP/1234", "30"); - assertEquals("EXEC \"DIAL\" \"SIP/1234,30\"", execCommand.buildCommand()); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/command/GetDataCommandTest.java b/src/test/java/org/asteriskjava/fastagi/command/GetDataCommandTest.java deleted file mode 100644 index c6a1430a2..000000000 --- a/src/test/java/org/asteriskjava/fastagi/command/GetDataCommandTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.command; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class GetDataCommandTest -{ - private GetDataCommand getDataCommand; - - @Test - public void testDefault() - { - getDataCommand = new GetDataCommand("VAR1"); - assertEquals("GET DATA \"VAR1\"", getDataCommand.buildCommand()); - } - - @Test - public void testSetTimeout() - { - getDataCommand = new GetDataCommand("VAR1"); - getDataCommand.setTimeout(10000); - assertEquals(10000, getDataCommand.getTimeout()); - assertEquals(1024, getDataCommand.getMaxDigits()); - assertEquals("GET DATA \"VAR1\" 10000", getDataCommand.buildCommand()); - } - - @Test - public void testSetMaxDigits() - { - getDataCommand = new GetDataCommand("VAR1"); - getDataCommand.setMaxDigits(10); - assertEquals(0, getDataCommand.getTimeout()); - assertEquals(10, getDataCommand.getMaxDigits()); - assertEquals("GET DATA \"VAR1\" 0 10", getDataCommand.buildCommand()); - } - - @Test - public void testSetTimeoutAndMaxDigits() - { - getDataCommand = new GetDataCommand("VAR1"); - getDataCommand.setTimeout(10000); - getDataCommand.setMaxDigits(20); - assertEquals(10000, getDataCommand.getTimeout()); - assertEquals(20, getDataCommand.getMaxDigits()); - assertEquals("GET DATA \"VAR1\" 10000 20", getDataCommand.buildCommand()); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/internal/AgiChannelImplTest.java b/src/test/java/org/asteriskjava/fastagi/internal/AgiChannelImplTest.java deleted file mode 100644 index 83d5228a1..000000000 --- a/src/test/java/org/asteriskjava/fastagi/internal/AgiChannelImplTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.List; - -import org.asteriskjava.fastagi.AgiChannel; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.InvalidCommandSyntaxException; -import org.asteriskjava.fastagi.InvalidOrUnknownCommandException; -import org.asteriskjava.fastagi.command.NoopCommand; -import org.asteriskjava.fastagi.reply.AgiReply; -import org.junit.Before; -import org.junit.Test; - -public class AgiChannelImplTest -{ - private AgiWriter agiWriter; - private AgiReader agiReader; - private AgiChannel agiChannel; - - @Before - public void setUp() - { - this.agiWriter = createMock(AgiWriter.class); - this.agiReader = createMock(AgiReader.class); - this.agiChannel = new AgiChannelImpl(null, agiWriter, agiReader); - } - - @Test - public void testSendCommand() throws Exception - { - SimpleAgiReply reply; - NoopCommand command; - - reply = new SimpleAgiReply(); - reply.setStatus(AgiReply.SC_SUCCESS); - reply.setResult("0"); - - command = new NoopCommand(); - - agiWriter.sendCommand(command); - expect(agiReader.readReply()).andReturn(reply); - - replay(agiWriter); - replay(agiReader); - - assertEquals(reply, agiChannel.sendCommand(command)); - - verify(agiWriter); - verify(agiReader); - } - - @Test - public void testSendCommandWithInvalidOrUnknownCommandResponse() throws Exception - { - SimpleAgiReply reply; - NoopCommand command; - - reply = new SimpleAgiReply(); - reply.setStatus(AgiReply.SC_INVALID_OR_UNKNOWN_COMMAND); - reply.setResult("0"); - - command = new NoopCommand(); - - agiWriter.sendCommand(command); - expect(agiReader.readReply()).andReturn(reply); - - replay(agiWriter); - replay(agiReader); - - try - { - agiChannel.sendCommand(command); - fail("must throw InvalidOrUnknownCommandException"); - } - catch (InvalidOrUnknownCommandException e) - { - assertEquals("Incorrect message", "Invalid or unknown command: NOOP", e.getMessage()); - } - - verify(agiWriter); - verify(agiReader); - } - - @Test - public void testSendCommandWithInvalidCommandSyntaxResponse() throws Exception - { - SimpleAgiReply reply; - NoopCommand command; - - reply = new SimpleAgiReply(); - reply.setStatus(AgiReply.SC_INVALID_COMMAND_SYNTAX); - reply.setSynopsis("NOOP Synopsis"); - reply.setUsage("NOOP Usage"); - reply.setResult("0"); - - command = new NoopCommand(); - - agiWriter.sendCommand(command); - expect(agiReader.readReply()).andReturn(reply); - - replay(agiWriter); - replay(agiReader); - - try - { - agiChannel.sendCommand(command); - fail("must throw InvalidCommandSyntaxException"); - } - catch (InvalidCommandSyntaxException e) - { - assertEquals("Incorrect message", "Invalid command syntax: NOOP Synopsis", e.getMessage()); - assertEquals("Incorrect sysnopsis", "NOOP Synopsis", e.getSynopsis()); - assertEquals("Incorrect usage", "NOOP Usage", e.getUsage()); - } - - verify(agiWriter); - verify(agiReader); - } - - public class SimpleAgiReply implements AgiReply - { - private static final long serialVersionUID = 1L; - private int status; - private String result; - private String synopsis; - private String usage; - - public String getFirstLine() - { - throw new UnsupportedOperationException(); - } - - public void setUsage(String usage) - { - this.usage = usage; - } - - public void setSynopsis(String synopsis) - { - this.synopsis = synopsis; - } - - public void setResult(String result) - { - this.result = result; - } - - public void setStatus(int status) - { - this.status = status; - } - - public List getLines() - { - throw new UnsupportedOperationException(); - } - - public int getResultCode() - { - throw new UnsupportedOperationException(); - } - - public char getResultCodeAsChar() - { - throw new UnsupportedOperationException(); - } - - public String getResult() - { - return result; - } - - public int getStatus() - { - return status; - } - - public String getAttribute(String name) - { - throw new UnsupportedOperationException(); - } - - public String getExtra() - { - throw new UnsupportedOperationException(); - } - - public String getSynopsis() - { - return synopsis; - } - - public String getUsage() - { - return usage; - } - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/internal/AgiReaderImplTest.java b/src/test/java/org/asteriskjava/fastagi/internal/AgiReaderImplTest.java deleted file mode 100644 index fbf3a3b6a..000000000 --- a/src/test/java/org/asteriskjava/fastagi/internal/AgiReaderImplTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.net.InetAddress; - -import org.asteriskjava.fastagi.AgiHangupException; -import org.asteriskjava.fastagi.AgiReader; -import org.asteriskjava.fastagi.AgiRequest; -import org.asteriskjava.fastagi.reply.AgiReply; -import org.asteriskjava.util.SocketConnectionFacade; -import org.junit.Before; -import org.junit.Test; - -public class AgiReaderImplTest -{ - private AgiReader agiReader; - private SocketConnectionFacade socket; - - @Before - public void setUp() - { - this.socket = createMock(SocketConnectionFacade.class); - this.agiReader = new FastAgiReader(socket); - } - - @Test - public void testReadRequest() throws Exception - { - AgiRequest request; - - expect(socket.readLine()).andReturn("agi_network: yes"); - expect(socket.readLine()).andReturn("agi_network_script: myscript.agi"); - expect(socket.readLine()).andReturn("agi_request: agi://host/myscript.agi"); - expect(socket.readLine()).andReturn("agi_channel: SIP/1234-d715"); - expect(socket.readLine()).andReturn(""); - - byte[] ipLocal = new byte[4]; - ipLocal[0] = Integer.valueOf(192).byteValue(); - ipLocal[1] = Integer.valueOf(168).byteValue(); - ipLocal[2] = Integer.valueOf(0).byteValue(); - ipLocal[3] = Integer.valueOf(1).byteValue(); - expect(socket.getLocalAddress()).andReturn(InetAddress.getByAddress(ipLocal)); - expect(socket.getLocalPort()).andReturn(1234); - - byte[] ipRemote = new byte[4]; - ipRemote[0] = Integer.valueOf(192).byteValue(); - ipRemote[1] = Integer.valueOf(168).byteValue(); - ipRemote[2] = Integer.valueOf(0).byteValue(); - ipRemote[3] = Integer.valueOf(2).byteValue(); - expect(socket.getRemoteAddress()).andReturn(InetAddress.getByAddress(ipRemote)); - expect(socket.getRemotePort()).andReturn(1235); - - replay(socket); - - request = agiReader.readRequest(); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL()); - assertEquals("incorrect channel", "SIP/1234-d715", request.getChannel()); - assertEquals("incorrect local address", ipLocal[0], request.getLocalAddress().getAddress()[0]); - assertEquals("incorrect local address", ipLocal[1], request.getLocalAddress().getAddress()[1]); - assertEquals("incorrect local address", ipLocal[2], request.getLocalAddress().getAddress()[2]); - assertEquals("incorrect local address", ipLocal[3], request.getLocalAddress().getAddress()[3]); - assertEquals("incorrect local port", 1234, request.getLocalPort()); - assertEquals("incorrect remote address", ipRemote[0], request.getRemoteAddress().getAddress()[0]); - assertEquals("incorrect remote address", ipRemote[1], request.getRemoteAddress().getAddress()[1]); - assertEquals("incorrect remote address", ipRemote[2], request.getRemoteAddress().getAddress()[2]); - assertEquals("incorrect remote address", ipRemote[3], request.getRemoteAddress().getAddress()[3]); - assertEquals("incorrect remote port", 1235, request.getRemotePort()); - - verify(socket); - } - - @Test - public void testReadReply() throws Exception - { - AgiReply reply; - - expect(socket.readLine()).andReturn("200 result=49 endpos=2240"); - - replay(socket); - - reply = agiReader.readReply(); - - assertEquals("Incorrect status", AgiReply.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 49, reply.getResultCode()); - - verify(socket); - } - - @Test - public void testReadReplyInvalidOrUnknownCommand() throws Exception - { - AgiReply reply; - - expect(socket.readLine()).andReturn("510 Invalid or unknown command"); - - replay(socket); - - reply = agiReader.readReply(); - - assertEquals("Incorrect status", AgiReply.SC_INVALID_OR_UNKNOWN_COMMAND, reply.getStatus()); - - verify(socket); - } - - @Test - public void testReadReplyInvalidCommandSyntax() throws Exception - { - AgiReply reply; - - expect(socket.readLine()).andReturn("520-Invalid command syntax. Proper usage follows:"); - expect(socket.readLine()).andReturn(" Usage: DATABASE DEL "); - expect(socket.readLine()).andReturn(" Deletes an entry in the Asterisk database for a"); - expect(socket.readLine()).andReturn(" given family and key."); - expect(socket.readLine()).andReturn(" Returns 1 if succesful, 0 otherwise"); - expect(socket.readLine()).andReturn("520 End of proper usage."); - - replay(socket); - - reply = agiReader.readReply(); - - assertEquals("Incorrect status", AgiReply.SC_INVALID_COMMAND_SYNTAX, reply.getStatus()); - assertEquals("Incorrect synopsis", "DATABASE DEL ", reply.getSynopsis()); - - verify(socket); - } - - @Test - public void testReadReplyWhenHungUp() throws Exception - { - expect(socket.readLine()).andReturn(null); - - replay(socket); - - try - { - agiReader.readReply(); - fail("Must throw AgiHangupException"); - } - catch (AgiHangupException e) - { - } - - verify(socket); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/internal/AgiReplyImplTest.java b/src/test/java/org/asteriskjava/fastagi/internal/AgiReplyImplTest.java deleted file mode 100644 index 7690bb8e7..000000000 --- a/src/test/java/org/asteriskjava/fastagi/internal/AgiReplyImplTest.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -public class AgiReplyImplTest -{ - private List lines; - - @Before - public void setUp() - { - this.lines = new ArrayList(); - } - - @Test - public void testBuildReply() - { - AgiReplyImpl reply; - - lines.add("200 result=49"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 49, reply.getResultCode()); - assertEquals("Incorrect result as character", '1', reply.getResultCodeAsChar()); - assertEquals("Incorrect result when get via getAttribute()", "49", reply.getAttribute("result")); - } - - @Test - public void testBuildReplyWithAdditionalAttribute() - { - AgiReplyImpl reply; - - lines.add("200 result=49 endpos=2240"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 49, reply.getResultCode()); - assertEquals("Incorrect result as character", '1', reply.getResultCodeAsChar()); - assertEquals("Incorrect result when get via getAttribute()", "49", reply.getAttribute("result")); - assertEquals("Incorrect endpos attribute", "2240", reply.getAttribute("endpos")); - } - - @Test - public void testBuildReplyWithMultipleAdditionalAttribute() - { - AgiReplyImpl reply; - - lines.add("200 result=49 startpos=1234 endpos=2240"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 49, reply.getResultCode()); - assertEquals("Incorrect result as character", '1', reply.getResultCodeAsChar()); - assertEquals("Incorrect result when get via getAttribute()", "49", reply.getAttribute("result")); - assertEquals("Incorrect startpos attribute", "1234", reply.getAttribute("startpos")); - assertEquals("Incorrect endpos attribute", "2240", reply.getAttribute("endpos")); - } - - @Test - public void testBuildReplyWithQuotedAttribute() - { - AgiReplyImpl reply; - - lines.add("200 result=1 (speech) endpos=0 results=1 score0=969 text0=\"123456789\" grammar0=digits"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 1, reply.getResultCode()); - assertEquals("Incorrect result when get via getAttribute()", "1", reply.getAttribute("result")); - assertEquals("Incorrect endpos attribute", "0", reply.getAttribute("endpos")); - assertEquals("Incorrect extra", "speech", reply.getExtra()); - assertEquals("Incorrect text0 attribute", "123456789", reply.getAttribute("text0")); - } - - @Test - public void testBuildReplyWithQuotedAttribute2() - { - AgiReplyImpl reply; - - lines.add("200 result=1 (speech) endpos=0 results=1 score0=969 text0=\"hi \\\"joe!\\\"\" grammar0=digits"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 1, reply.getResultCode()); - assertEquals("Incorrect result when get via getAttribute()", "1", reply.getAttribute("result")); - assertEquals("Incorrect endpos attribute", "0", reply.getAttribute("endpos")); - assertEquals("Incorrect extra", "speech", reply.getExtra()); - assertEquals("Incorrect text0 attribute", "hi \"joe!\"", reply.getAttribute("text0")); - } - - public void testBla() - { - System.out.println(005); - } - - @Test - public void testBuildReplyWithParenthesis() - { - AgiReplyImpl reply; - - lines.add("200 result=1 ((hello)(world))"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 1, reply.getResultCode()); - assertEquals("Incorrect parenthesis", "(hello)(world)", reply.getExtra()); - } - - @Test - public void testBuildReplyWithAdditionalAttributeAndParenthesis() - { - AgiReplyImpl reply; - - lines.add("200 result=1 ((hello)(world)) endpos=2240"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect result", 1, reply.getResultCode()); - assertEquals("Incorrect parenthesis", "(hello)(world)", reply.getExtra()); - assertEquals("Incorrect endpos attribute", "2240", reply.getAttribute("endpos")); - } - - @Test - public void testBuildReplyInvalidOrUnknownCommand() - { - AgiReplyImpl reply; - - lines.add("510 Invalid or unknown command"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_INVALID_OR_UNKNOWN_COMMAND, reply.getStatus()); - } - - @Test - public void testBuildReplyInvalidCommandSyntax() - { - AgiReplyImpl reply; - - lines.add("520-Invalid command syntax. Proper usage follows:"); - lines.add(" Usage: DATABASE DEL "); - lines.add(" Deletes an entry in the Asterisk database for a"); - lines.add(" given family and key."); - lines.add(" Returns 1 if succesful, 0 otherwise"); - lines.add("520 End of proper usage."); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_INVALID_COMMAND_SYNTAX, reply.getStatus()); - assertEquals("Incorrect synopsis", "DATABASE DEL ", reply.getSynopsis()); - assertEquals("Incorrect usage", - "Deletes an entry in the Asterisk database for a given family and key. Returns 1 if succesful, 0 otherwise", - reply.getUsage()); - } - - @Test - public void testBuildReplyInvalidCommandSyntaxWithOnlyUsage() - { - AgiReplyImpl reply; - - lines.add("520-Invalid command syntax. Proper usage follows:"); - lines.add(" Usage: DATABASE DEL "); - lines.add(" Deletes an entry in the Asterisk database for a"); - lines.add(" given family and key."); - lines.add(" Returns 1 if succesful, 0 otherwise"); - lines.add("520 End of proper usage."); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_INVALID_COMMAND_SYNTAX, reply.getStatus()); - // due to the lazy initialization in use this getUsage() could fail if - // we don't call it before getSynopsis() - assertEquals("Incorrect usage", - "Deletes an entry in the Asterisk database for a given family and key. Returns 1 if succesful, 0 otherwise", - reply.getUsage()); - assertEquals("Incorrect synopsis", "DATABASE DEL ", reply.getSynopsis()); - } - - @Test - public void testBuildReplyWithLeadingSpace() - { - AgiReplyImpl reply; - - lines.add("200 result= (timeout)"); - - reply = new AgiReplyImpl(lines); - - assertEquals("Incorrect status", AgiReplyImpl.SC_SUCCESS, reply.getStatus()); - assertEquals("Incorrect extra", "timeout", reply.getExtra()); - } - - @Test - public void testBuildReplyWithEmptyResultAndTimeout() - { - AgiReplyImpl reply; - - lines.add("200 result= (timeout)"); - - reply = new AgiReplyImpl(lines); - - assertFalse("Incorrect result", reply.getResult().equals("timeout")); - assertEquals("Incorrect result", "", reply.getResult()); - assertEquals("Incorrect extra", "timeout", reply.getExtra()); - - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/internal/AgiRequestImplTest.java b/src/test/java/org/asteriskjava/fastagi/internal/AgiRequestImplTest.java deleted file mode 100644 index 4d62c8a7e..000000000 --- a/src/test/java/org/asteriskjava/fastagi/internal/AgiRequestImplTest.java +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; - -import org.asteriskjava.fastagi.AgiRequest; -import org.junit.Test; - -public class AgiRequestImplTest -{ - @SuppressWarnings("deprecation") - @Test - public void testBuildRequest() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network: yes"); - lines.add("agi_network_script: myscript.agi"); - lines.add("agi_request: agi://host/myscript.agi"); - lines.add("agi_channel: SIP/1234-d715"); - lines.add("agi_language: en"); - lines.add("agi_type: SIP"); - lines.add("agi_uniqueid: 1110023416.6"); - lines.add("agi_callerid: John Doe<1234>"); - lines.add("agi_dnid: 8870"); - lines.add("agi_rdnis: 9876"); - lines.add("agi_context: local"); - lines.add("agi_extension: 8870"); - lines.add("agi_priority: 1"); - lines.add("agi_enhanced: 0.0"); - lines.add("agi_accountcode: "); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL()); - assertEquals("incorrect channel", "SIP/1234-d715", request.getChannel()); - assertEquals("incorrect uniqueId", "SIP/1234-d715", request.getChannel()); - assertEquals("incorrect type", "SIP", request.getType()); - assertEquals("incorrect uniqueId", "1110023416.6", request.getUniqueId()); - assertEquals("incorrect language", "en", request.getLanguage()); - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdName", "John Doe", request.getCallerIdName()); - assertEquals("incorrect dnid", "8870", request.getDnid()); - assertEquals("incorrect rdnis", "9876", request.getRdnis()); - assertEquals("incorrect context", "local", request.getContext()); - assertEquals("incorrect extension", "8870", request.getExtension()); - assertEquals("incorrect priority", new Integer(1), request.getPriority()); - assertEquals("incorrect enhanced", Boolean.FALSE, request.getEnhanced()); - assertNull("incorrect accountCode must not be set", request.getAccountCode()); - } - - @Test - public void testBuildRequestWithAccountCode() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network: yes"); - lines.add("agi_network_script: myscript.agi"); - lines.add("agi_accountcode: 12345"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect accountCode", "12345", request.getAccountCode()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestWithoutCallerIdName() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: 1234"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - // assertNull("callerIdName must not be set", - // request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestWithoutCallerIdNameButBracket() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: <1234>"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - assertNull("callerIdName must not be set", request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestWithoutCallerIdNameButBracketAndQuotesAndSpace() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: \"\" <1234>"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - assertNull("callerIdName must not be set", request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestWithQuotedCallerIdName() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: \"John Doe\"<1234>"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - assertEquals("incorrect callerIdName", "John Doe", request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestWithQuotedCallerIdNameAndSpace() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: \"John Doe\" <1234>"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - assertEquals("incorrect callerIdName", "John Doe", request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestWithoutCallerId() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: "); - - request = new AgiRequestImpl(lines); - - assertNull("callerId must not be set", request.getCallerId()); - assertNull("callerIdNumber must not be set", request.getCallerIdNumber()); - assertNull("callerIdName must not be set", request.getCallerIdName()); - } - - /* - * Asterisk 1.2 now uses agi_callerid and agi_calleridname so we don't need - * to process it ourselves. - */ - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestCallerIdAsterisk12() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: 1234"); - lines.add("agi_calleridname: John Doe"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - assertEquals("incorrect callerIdName", "John Doe", request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestCallerIdAsterisk12WithUnknownCallerId() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: unknown"); - lines.add("agi_calleridname: John Doe"); - - request = new AgiRequestImpl(lines); - - assertNull("callerId must not be set if \"unknown\"", request.getCallerId()); - assertNull("callerIdNumber must not be set if \"unknown\"", request.getCallerIdNumber()); - assertEquals("incorrect callerIdName", "John Doe", request.getCallerIdName()); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildRequestCallerIdAsterisk12WithUnknownCallerIdName() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_callerid: 1234"); - lines.add("agi_calleridname: unknown"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect callerId", "1234", request.getCallerId()); - assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber()); - assertNull("callerIdName must not be set if \"unknown\"", request.getCallerIdName()); - } - - @Test - public void testBuildRequestCallerIdWithUnknownDnid() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_dnid: unknown"); - - request = new AgiRequestImpl(lines); - - assertNull("dnid must not be set if \"unknown\"", request.getDnid()); - } - - @Test - public void testBuildRequestCallerIdWithUnknownRdnis() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_rdnis: unknown"); - - request = new AgiRequestImpl(lines); - - assertNull("rdnis must not be set if \"unknown\"", request.getRdnis()); - } - - @Test - public void testBuildRequestWithNullEnvironment() - { - try - { - new AgiRequestImpl(null); - fail("No IllegalArgumentException thrown."); - } - catch (IllegalArgumentException e) - { - } - } - - @Test - public void testBuildRequestWithUnusualInput() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("var without agi prefix: a value"); - lines.add("agi_without_colon another value"); - lines.add("agi_without_space_after_colon:"); - lines.add("agi_channel: SIP/1234-a892"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect channel", "SIP/1234-a892", request.getChannel()); - } - - @Test - public void testBuildRequestWithoutParameters() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi"); - lines.add("agi_request: agi://host/myscript.agi"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL()); - assertEquals("incorrect value for unset parameter 'param1'", null, request.getParameter("param1")); - assertNotNull("getParameterValues() must not return null", request.getParameterValues("param1")); - assertEquals("incorrect size of values for unset parameter 'param1'", 0, - request.getParameterValues("param1").length); - assertNotNull("getParameterMap() must not return null", request.getParameterMap()); - assertEquals("incorrect size of getParameterMap()", 0, request.getParameterMap().size()); - } - - @Test - public void testBuildRequestWithSingleValueParameters() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi?param1=value1¶m2=value2"); - lines.add("agi_request: agi://host/myscript.agi?param1=value1¶m2=value2"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=value1¶m2=value2", request.getRequestURL()); - assertEquals("incorrect value for parameter 'param1'", "value1", request.getParameter("param1")); - assertEquals("incorrect value for parameter 'param2'", "value2", request.getParameter("param2")); - assertEquals("incorrect value for unset parameter 'param3'", null, request.getParameter("param3")); - assertEquals("incorrect size of getParameterMap()", 2, request.getParameterMap().size()); - assertEquals("incorrect value for parameter 'param1' when obtained from map", "value1", - request.getParameterMap().get("param1")[0]); - } - - @Test - public void testBuildRequestWithMultiValueParameter() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi?param1=value1¶m1=value2"); - lines.add("agi_request: agi://host/myscript.agi?param1=value1¶m1=value2"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=value1¶m1=value2", request.getRequestURL()); - assertEquals("incorrect number of values for parameter 'param1'", 2, request.getParameterValues("param1").length); - assertEquals("incorrect value[0] for parameter 'param1'", "value1", request.getParameterValues("param1")[0]); - assertEquals("incorrect value[1] for parameter 'param1'", "value2", request.getParameterValues("param1")[1]); - } - - @Test - public void testBuildRequestWithEmptyValueParameter() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi?param1"); - lines.add("agi_request: agi://host/myscript.agi?param1"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1", request.getRequestURL()); - assertEquals("incorrect value for parameter 'param1'", "", request.getParameter("param1")); - assertEquals("incorrect number of values for parameter 'param1'", 1, request.getParameterValues("param1").length); - assertEquals("incorrect value[0] for parameter 'param1'", "", request.getParameterValues("param1")[0]); - } - - @Test - public void testBuildRequestWithUrlEncodedParameter() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi?param1=my%20value"); - lines.add("agi_request: agi://host/myscript.agi?param1=my%20value"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect script", "myscript.agi", request.getScript()); - assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=my%20value", request.getRequestURL()); - assertEquals("incorrect value for parameter 'param1'", "my value", request.getParameter("param1")); - } - - @Test - public void testGetParameter() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi?param1=my%20value"); - lines.add("agi_request: agi://host/myscript.agi?param1=my%20value"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=my%20value", request.getRequestURL()); - assertEquals("incorrect value for parameter 'param1'", "my value", request.getParameter("param1")); - } - - @Test - public void testGetArguments() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi"); - lines.add("agi_request: agi://host/myscript.agi"); - lines.add("agi_arg_1: value1"); - lines.add("agi_arg_2: value2"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL()); - assertEquals("invalid number of arguments", 2, request.getArguments().length); - assertEquals("incorrect value for first argument", "value1", request.getArguments()[0]); - assertEquals("incorrect value for second argument", "value2", request.getArguments()[1]); - } - - @Test - public void testGetArgumentsWithEmptyArgument() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi"); - lines.add("agi_request: agi://host/myscript.agi"); - lines.add("agi_arg_1: value1"); - lines.add("agi_arg_2: "); - lines.add("agi_arg_3: value3"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL()); - assertEquals("invalid number of arguments", 3, request.getArguments().length); - assertEquals("incorrect value for first argument", "value1", request.getArguments()[0]); - assertEquals("incorrect value for second argument", null, request.getArguments()[1]); - assertEquals("incorrect value for third argument", "value3", request.getArguments()[2]); - } - - @Test - public void testGetArgumentsWithNoArgumentsPassed() - { - List lines; - AgiRequest request; - - lines = new ArrayList(); - - lines.add("agi_network_script: myscript.agi"); - lines.add("agi_request: agi://host/myscript.agi"); - - request = new AgiRequestImpl(lines); - - assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL()); - assertNotNull("getArguments() must never return null", request.getArguments()); - assertEquals("invalid number of arguments", 0, request.getArguments().length); - } -} diff --git a/src/test/java/org/asteriskjava/fastagi/internal/AgiWriterImplTest.java b/src/test/java/org/asteriskjava/fastagi/internal/AgiWriterImplTest.java deleted file mode 100644 index 1c934bab3..000000000 --- a/src/test/java/org/asteriskjava/fastagi/internal/AgiWriterImplTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.fastagi.internal; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; - -import org.asteriskjava.fastagi.AgiWriter; -import org.asteriskjava.fastagi.command.StreamFileCommand; -import org.asteriskjava.util.SocketConnectionFacade; -import org.junit.Before; -import org.junit.Test; - -public class AgiWriterImplTest -{ - private AgiWriter agiWriter; - private SocketConnectionFacade socket; - - @Before - public void setUp() - { - this.socket = createMock(SocketConnectionFacade.class); - this.agiWriter = new FastAgiWriter(socket); - } - - @Test - public void testSendCommand() throws Exception - { - StreamFileCommand command; - - command = new StreamFileCommand("welcome"); - - socket.write("STREAM FILE \"welcome\" \"\"\n"); - socket.flush(); - - replay(socket); - - agiWriter.sendCommand(command); - - verify(socket); - } -} diff --git a/src/test/java/org/asteriskjava/live/CallerIdTest.java b/src/test/java/org/asteriskjava/live/CallerIdTest.java deleted file mode 100644 index 06070ecbb..000000000 --- a/src/test/java/org/asteriskjava/live/CallerIdTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.asteriskjava.live; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class CallerIdTest -{ - @Test - public void testEquals() - { - CallerId callerId1; - CallerId callerId2; - - callerId1 = new CallerId("Hans Wurst", "1234"); - callerId2 = new CallerId("Hans Wurst", "1234"); - assertEquals(callerId1, callerId2); - - callerId1 = new CallerId("Hans Wurst", null); - callerId2 = new CallerId("Hans Wurst", null); - assertEquals(callerId1, callerId2); - - callerId1 = new CallerId(null, "1234"); - callerId2 = new CallerId(null, "1234"); - assertEquals(callerId1, callerId2); - - callerId1 = new CallerId(null, null); - callerId2 = new CallerId(null, null); - assertEquals(callerId1, callerId2); - } - - @Test - public void testValueOf() - { - CallerId callerId = new CallerId("Hans Wurst", "1234"); - assertEquals(callerId, CallerId.valueOf("\"Hans Wurst\" <1234>")); - assertEquals(callerId, CallerId.valueOf("Hans Wurst <1234>")); - assertEquals(callerId, CallerId.valueOf(callerId.toString())); - } - - @Test - public void testValueOfWithNullLiteralInName() - { - CallerId callerId = new CallerId(null, "1234"); - assertEquals(callerId, CallerId.valueOf("\"\" <1234>")); - assertEquals(callerId, CallerId.valueOf("\"\" <1234>")); - assertEquals(callerId, CallerId.valueOf("<1234>")); - assertEquals(callerId, CallerId.valueOf(callerId.toString())); - } - - @Test - public void testValueOfWithNullLiteralInNumber() - { - CallerId callerId = new CallerId("Hans Wurst", null); - assertEquals(callerId, CallerId.valueOf("\"Hans Wurst\" <>")); - // assertEquals(callerId, - // CallerId.valueOf("\"Hans Wurst\" <>")); - // assertEquals(callerId, CallerId.valueOf("Hans Wurst <>")); - } - - @Test - public void testValueOfWithNullLiteralInNameAndNumber() - { - CallerId callerId = new CallerId(null, null); - assertEquals(callerId, CallerId.valueOf("\"\" <>")); - // assertEquals(callerId, CallerId.valueOf("<>")); - // assertEquals(callerId, - // CallerId.valueOf("\"\" <>")); - // assertEquals(callerId, CallerId.valueOf(" <>")); - assertEquals(callerId, CallerId.valueOf("")); - // assertEquals(callerId, CallerId.valueOf("\"\"")); - } - - @Test - public void testConstructorWithNullLiteral() - { - assertEquals(new CallerId(null, "1234"), new CallerId("", "1234")); - } - - @Test - public void testToString() - { - assertEquals("\"Hans Wurst\" <1234>", new CallerId("Hans Wurst", "1234").toString()); - assertEquals("<1234>", new CallerId(null, "1234").toString()); - assertEquals("\"Hans Wurst\"", new CallerId("Hans Wurst", null).toString()); - } -} diff --git a/src/test/java/org/asteriskjava/live/HangupCauseTest.java b/src/test/java/org/asteriskjava/live/HangupCauseTest.java deleted file mode 100644 index 562a1a5c5..000000000 --- a/src/test/java/org/asteriskjava/live/HangupCauseTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.asteriskjava.live; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class HangupCauseTest -{ - @Test - public void testGetByCode() - { - assertEquals("Valid enum for cause code 18", HangupCause.AST_CAUSE_NO_USER_RESPONSE, HangupCause.getByCode(18)); - } -} diff --git a/src/test/java/org/asteriskjava/live/QueueMemberStateTest.java b/src/test/java/org/asteriskjava/live/QueueMemberStateTest.java deleted file mode 100644 index c02581595..000000000 --- a/src/test/java/org/asteriskjava/live/QueueMemberStateTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.asteriskjava.live; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class QueueMemberStateTest -{ - @Test - public void testValueOf() - { - assertEquals(QueueMemberState.DEVICE_INUSE, QueueMemberState.valueOf("DEVICE_INUSE")); - assertEquals(QueueMemberState.DEVICE_INUSE, QueueMemberState.valueOf(2)); - } - - @Test - public void testToString() - { - assertEquals("DEVICE_INUSE", QueueMemberState.DEVICE_INUSE.toString()); - } -} diff --git a/src/test/java/org/asteriskjava/live/internal/AsteriskAgentImplTest.java b/src/test/java/org/asteriskjava/live/internal/AsteriskAgentImplTest.java deleted file mode 100644 index 28e0ddbb1..000000000 --- a/src/test/java/org/asteriskjava/live/internal/AsteriskAgentImplTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This code is property of GONICUS GmbH - * - * (c) 2007 - * - * SVN-Information - * Author: $LastChangedBy$ - * Revision: $LastChangedRevision$ - * Last change: $LastChangedDate$ - * - * File: AsteriskAgentImplTest.java - * Package: org.asteriskjava.live.internal - * - * Change History: - * - * 0001 breucking Sep 12, 2007 File created - */ -package org.asteriskjava.live.internal; - -import static org.junit.Assert.assertEquals; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.asteriskjava.live.AgentState; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Patrick Breucking - * @since 0.1 - * @version $Id$ - */ -public class AsteriskAgentImplTest -{ - private AsteriskAgentImpl agent; - private int numberOfChanges; - - @Before - public void setUp() - { - AsteriskServerImpl server = new AsteriskServerImpl(); - agent = new AsteriskAgentImpl(server, "Testagent", "Agent/999", AgentState.AGENT_IDLE); - numberOfChanges = 0; - } - - @Test - public void testUpdateStatus() - { - assertEquals(AgentState.AGENT_IDLE, agent.getState()); - agent.addPropertyChangeListener(new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - assertEquals("wrong propertyName", "state", evt.getPropertyName()); - assertEquals("wrong oldValue", AgentState.AGENT_IDLE, evt.getOldValue()); - assertEquals("wrong newValue", AgentState.AGENT_RINGING, evt.getNewValue()); - assertEquals("wrong queue", agent, evt.getSource()); - numberOfChanges++; - } - - }); - agent.updateState(AgentState.AGENT_RINGING); - assertEquals("wrong number of propagated changes", 1, numberOfChanges); - } -} diff --git a/src/test/java/org/asteriskjava/live/internal/AsteriskChannelImplTest.java b/src/test/java/org/asteriskjava/live/internal/AsteriskChannelImplTest.java deleted file mode 100644 index 3c00156d3..000000000 --- a/src/test/java/org/asteriskjava/live/internal/AsteriskChannelImplTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.asteriskjava.live.internal; - -import static org.junit.Assert.assertEquals; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.asteriskjava.live.ChannelState; -import org.asteriskjava.util.DateUtil; -import org.junit.Before; -import org.junit.Test; - -public class AsteriskChannelImplTest -{ - private AsteriskChannelImpl channel; - private int numberOfChanges; - - @Before - public void setUp() - { - AsteriskServerImpl server = new AsteriskServerImpl(); - channel = new AsteriskChannelImpl(server, "SIP/1234", "0123456789.123", DateUtil.getDate()); - channel.stateChanged(DateUtil.getDate(), ChannelState.DOWN); - numberOfChanges = 0; - } - - @Test - public void testStateChange() - { - channel.addPropertyChangeListener(new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - assertEquals("wrong propertyName", "state", evt.getPropertyName()); - assertEquals("wrong oldValue", ChannelState.DOWN, evt.getOldValue()); - assertEquals("wrong newValue", ChannelState.DIALING, evt.getNewValue()); - assertEquals("wrong source", channel, evt.getSource()); - numberOfChanges++; - } - }); - - channel.stateChanged(DateUtil.getDate(), ChannelState.DIALING); - assertEquals("wrong number of propagated changes", 1, numberOfChanges); - } -} diff --git a/src/test/java/org/asteriskjava/live/internal/AsteriskQueueMemberImplTest.java b/src/test/java/org/asteriskjava/live/internal/AsteriskQueueMemberImplTest.java deleted file mode 100644 index a77c53380..000000000 --- a/src/test/java/org/asteriskjava/live/internal/AsteriskQueueMemberImplTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.live.internal; - -import static org.junit.Assert.assertEquals; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; - -import org.asteriskjava.live.QueueMemberState; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Patrick Breucking - * @version $Id$ - * @since 0.1 - */ -public class AsteriskQueueMemberImplTest -{ - - private AsteriskQueueMemberImpl queueMember; - private int numberOfChanges; - private AsteriskServerImpl server; - // private QueueManager qManager; - private AsteriskQueueImpl queue; - - @Before - public void setUp() - { - server = new AsteriskServerImpl(); - // ChannelManager channelManager = new ChannelManager(server); - // qManager = new QueueManager(server, channelManager); - queue = new AsteriskQueueImpl(server, "test", 25, "RoundRobin", 15, 5, - 0, 0, 1, 1, 1, 1.0); - queueMember = new AsteriskQueueMemberImpl(server, queue, "Agent/777", QueueMemberState.DEVICE_UNKNOWN, false, 10, - "dynamic", 3, 6000l); - - numberOfChanges = 0; - } - - @Test - public void testQueueMemberEvents() - { - /* - * Test should generate a new member like queueMember = new - */ - // queueMember = new AsteriskQueueMemberImpl(server, queue, "Agent/777", - // QueueMemberState.DEVICE_UNKNOWN); - // QueueParamsEvent qpe = new QueueParamsEvent(new Object()); - // qpe.setQueue("test"); - // server.onManagerEvent(qpe); - // qManager.handleQueueParamsEvent(qpe); - // QueueMemberEvent qme = new QueueMemberEvent(new Object()); - // qme.setLocation("Agent/777"); - // qme.setQueue("test"); - // qme.setStatus(0); - // server.onManagerEvent(qme); - // qManager.handleQueueMemberEvent(qme); - // Collection queues = server.getQueues(); - // assertEquals(1, queues.size()); - // AsteriskQueue queue = queues.iterator().next(); - // - // Collection members = queue.getMembers(); - // assertEquals(1, members.size()); - // AsteriskQueueMember member = members.iterator().next(); - // assertEquals("Agent/777", member.getLocation()); - assertEquals(QueueMemberState.DEVICE_UNKNOWN, queueMember.getState()); - queueMember.addPropertyChangeListener(new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - assertEquals("wrong propertyName", "state", evt.getPropertyName()); - assertEquals("wrong oldValue", QueueMemberState.DEVICE_UNKNOWN, evt.getOldValue()); - assertEquals("wrong newValue", QueueMemberState.DEVICE_BUSY, evt.getNewValue()); - assertEquals("wrong queue member", queueMember, evt.getSource()); - numberOfChanges++; - } - - }); - - // queue.addAsteriskQueueListener(new AsteriskQueueListener() - // { - // - // public void onEntryLeave(AsteriskChannel channel) - // { - // // TODO Auto-generated method stub - // - // } - // - // public void onMemberStateChange(AsteriskQueueMember member) - // { - // assertEquals("wrong newValue", QueueMemberState.DEVICE_BUSY, - // member.getState()); - // assertEquals("wrong queue member", queueMember, member); - // System.err.println("foo"); - // numberOfChanges++; - // - // } - // - // public void onNewEntry(AsteriskChannel channel) - // { - // // TODO Auto-generated method stub - // - // } - // - // }); - // queueMember.stateChanged(QueueMemberState.DEVICE_BUSY); - // QueueMemberStatusEvent qmse = new QueueMemberStatusEvent(new - // Object()); - // qmse.setLocation(queueMember.getLocation()); - // qmse.setStatus(3); - // server.onManagerEvent(qmse); - queueMember.stateChanged(QueueMemberState.DEVICE_BUSY); - assertEquals("wrong number of propagated changes", 1, numberOfChanges); - } -} diff --git a/src/test/java/org/asteriskjava/manager/AbstractManagerEventListenerTest.java b/src/test/java/org/asteriskjava/manager/AbstractManagerEventListenerTest.java deleted file mode 100644 index 9a3d72f07..000000000 --- a/src/test/java/org/asteriskjava/manager/AbstractManagerEventListenerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.asteriskjava.manager; - -import static org.junit.Assert.assertTrue; - -import org.asteriskjava.manager.event.JoinEvent; -import org.asteriskjava.manager.event.LeaveEvent; -import org.junit.Test; - -public class AbstractManagerEventListenerTest { - - @Test - public void shouldHandleJoinEvent() { - //given - EventListener listener = new EventListener(); - - //when - listener.onManagerEvent(new JoinEvent(this)); - - //then - assertTrue(listener.joinEventHandled); - } - - @Test - public void shouldHandleLeaveEvent() { - //given - EventListener listener = new EventListener(); - - //when - listener.onManagerEvent(new LeaveEvent(this)); - - //then - assertTrue(listener.leaveEventHandled); - } - - private static class EventListener extends AbstractManagerEventListener { - public boolean joinEventHandled; - public boolean leaveEventHandled; - - @Override - protected void handleEvent(JoinEvent event) { - this.joinEventHandled = true; - } - - @Override - protected void handleEvent(LeaveEvent event) { - this.leaveEventHandled = true; - } - } -} \ No newline at end of file diff --git a/src/test/java/org/asteriskjava/manager/event/AsyncAgiEventTest.java b/src/test/java/org/asteriskjava/manager/event/AsyncAgiEventTest.java deleted file mode 100644 index 588c0b855..000000000 --- a/src/test/java/org/asteriskjava/manager/event/AsyncAgiEventTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.junit.Test; - -public class AsyncAgiEventTest -{ - @Test - public void testDecodeEnv() - { - AsyncAgiEvent event = new AsyncAgiEvent(this); - List env; - - event.setEnv("agi_request%3a%20async\n" + - "agi_channel%3a%20SIP%2f1312-b70020a8\n" + - "agi_language%3a%20en\n" + - "agi_type%3a%20SIP\n" + - "agi_uniqueid%3a%201207271023.41\n" + - "agi_version%3a%20SVN-branch-1.6.0-r110832\n" + - "agi_callerid%3a%201312\n" + - "agi_calleridname%3a%20Stefan%20Reuter\n" + - "agi_callingpres%3a%200\n" + - "agi_callingani2%3a%200\n" + - "agi_callington%3a%200\n" + - "agi_callingtns%3a%200\n" + - "agi_dnid%3a%203115\n" + - "agi_rdnis%3a%20unknown\n" + - "agi_context%3a%20from-local\n" + - "agi_extension%3a%203115\n" + - "agi_priority%3a%201\n" + - "agi_enhanced%3a%200.0\n" + - "agi_accountcode%3a%20\n" + - "agi_threadid%3a%20-1231783024\n"); - - env = event.decodeEnv(); - assertEquals("agi_calleridname: Stefan Reuter", env.get(7)); - assertEquals("agi_threadid: -1231783024", env.get(19)); - } - - @Test - public void testDecodeEnvWithMoreThanTwoDelimiters() - { - AsyncAgiEvent event = new AsyncAgiEvent(this); - List env; - - event.setEnv("agi_request%3a%20async%3a%20bla\n"); - - env = event.decodeEnv(); - assertEquals("agi_request: async: bla", env.get(0)); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/CdrEventTest.java b/src/test/java/org/asteriskjava/manager/event/CdrEventTest.java deleted file mode 100644 index f5ddb39fb..000000000 --- a/src/test/java/org/asteriskjava/manager/event/CdrEventTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class CdrEventTest -{ - CdrEvent cdrEvent; - TimeZone defaultTimeZone; - - @Before - public void setUp() - { - cdrEvent = new CdrEvent(this); - cdrEvent.setStartTime("2006-05-19 11:54:48"); - defaultTimeZone = TimeZone.getDefault(); - TimeZone.setDefault(TimeZone.getTimeZone("GMT")); - } - - @After - public void tearDown() - { - TimeZone.setDefault(defaultTimeZone); - } - - @Test - public void testGetStartTimeAsDate() - { - assertEquals(1148039688000L, cdrEvent.getStartTimeAsDate().getTime()); - } - - @Test - public void testGetStartTimeAsDateWithTimeZone() - { - TimeZone tz = TimeZone.getTimeZone("GMT+2"); - assertEquals(1148032488000L, cdrEvent.getStartTimeAsDate(tz).getTime()); - } - - @Test - public void testBug() - { - TimeZone.setDefault(TimeZone.getTimeZone("Europe/Monaco")); - - cdrEvent.setStartTime("2006-05-29 13:17:21"); - assertEquals("Mon May 29 13:17:21 CEST 2006", cdrEvent.getStartTimeAsDate().toString()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/ChannelReloadEventTest.java b/src/test/java/org/asteriskjava/manager/event/ChannelReloadEventTest.java deleted file mode 100644 index 3dddbf562..000000000 --- a/src/test/java/org/asteriskjava/manager/event/ChannelReloadEventTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Before; -import org.junit.Test; - -public class ChannelReloadEventTest -{ - private ChannelReloadEvent event; - - @Before - public void setUp() - { - this.event = new ChannelReloadEvent(this); - } - - @Test - public void testNullReloadReason() - { - event.setReloadReason(null); - assertNull(event.getReloadReasonCode()); - assertNull(event.getReloadReasonDescription()); - } - - @Test - public void testGetReloadReasonCode() - { - event.setReloadReason("CLIRELOAD (Channel module reload by CLI command)"); - assertEquals("CLIRELOAD", event.getReloadReasonCode()); - assertEquals(ChannelReloadEvent.REASON_CLI_RELOAD, event.getReloadReasonCode()); - } - - @Test - public void testGetReloadReasonDescription() - { - event.setReloadReason("CLIRELOAD (Channel module reload by CLI command)"); - assertEquals("Channel module reload by CLI command", event.getReloadReasonDescription()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/NewStateEventTest.java b/src/test/java/org/asteriskjava/manager/event/NewStateEventTest.java deleted file mode 100644 index d07c1e05f..000000000 --- a/src/test/java/org/asteriskjava/manager/event/NewStateEventTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -public class NewStateEventTest -{ - private NewStateEvent newStateEvent; - - @Before - public void setUp() - { - newStateEvent = new NewStateEvent(this); - } - - @Test - public void testWithState() - { - newStateEvent.setState("Ring"); - assertEquals(new Integer(4), newStateEvent.getChannelState()); - assertEquals("Ring", newStateEvent.getChannelStateDesc()); - } - - @Test - public void testWithUnknownState() - { - newStateEvent.setState("Unknown (4)"); - assertEquals(new Integer(4), newStateEvent.getChannelState()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/RtcpReceivedEventTest.java b/src/test/java/org/asteriskjava/manager/event/RtcpReceivedEventTest.java deleted file mode 100644 index f9b81e27b..000000000 --- a/src/test/java/org/asteriskjava/manager/event/RtcpReceivedEventTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -public class RtcpReceivedEventTest -{ - private RtcpReceivedEvent rtcpReceivedEvent; - - @Before - public void setUp() - { - rtcpReceivedEvent = new RtcpReceivedEvent(this); - } - - @Test - public void testFrom() - { - rtcpReceivedEvent.setFrom("192.168.0.1:1234"); - assertEquals("192.168.0.1", rtcpReceivedEvent.getFromAddress().getHostAddress()); - assertEquals(new Integer(1234), rtcpReceivedEvent.getFromPort()); - } - - @Test - public void testPt() - { - rtcpReceivedEvent.setPt("200(Sender Report)"); - assertEquals(new Long(200), rtcpReceivedEvent.getPt()); - assertEquals(new Long(RtcpReceivedEvent.PT_SENDER_REPORT), rtcpReceivedEvent.getPt()); - } - - @Test - public void testDlSr() - { - rtcpReceivedEvent.setDlSr("1.2345(sec)"); - assertEquals(1.2345, rtcpReceivedEvent.getDlSr(), 0.00001); - } - - @Test - public void testDlSrWithSpace() - { - rtcpReceivedEvent.setDlSr("1.2345 (sec)"); // as used in RTCPSent - assertEquals(1.2345, rtcpReceivedEvent.getDlSr(), 0.00001); - } - - @Test - public void testRtt() - { - rtcpReceivedEvent.setRtt("12345(sec)"); - assertEquals(new Double(12345), rtcpReceivedEvent.getRtt()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/SkypeBuddyStatusEventTest.java b/src/test/java/org/asteriskjava/manager/event/SkypeBuddyStatusEventTest.java deleted file mode 100644 index 5fb8e1c12..000000000 --- a/src/test/java/org/asteriskjava/manager/event/SkypeBuddyStatusEventTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -public class SkypeBuddyStatusEventTest -{ - private SkypeBuddyStatusEvent event; - - @Before - public void setUp() - { - event = new SkypeBuddyStatusEvent(this); - event.setBuddy("Skype/user@the.buddy"); - } - - @Test - public void testGetUser() - { - assertEquals("user", event.getUser()); - } - - @Test - public void testGetBuddySkypename() - { - assertEquals("the.buddy", event.getBuddySkypename()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/SkypeChatMessageEventTest.java b/src/test/java/org/asteriskjava/manager/event/SkypeChatMessageEventTest.java deleted file mode 100644 index 786e26d89..000000000 --- a/src/test/java/org/asteriskjava/manager/event/SkypeChatMessageEventTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class SkypeChatMessageEventTest -{ - @Test - public void testGetDecodedMessage() - { - final SkypeChatMessageEvent event = new SkypeChatMessageEvent(this); - event.setMessage("aMO2w7bDtj8="); - assertEquals("Inocrrectly decoded message", "h\u00F6\u00F6\u00F6?", event.getDecodedMessage()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/event/T38FaxStatusEventTest.java b/src/test/java/org/asteriskjava/manager/event/T38FaxStatusEventTest.java deleted file mode 100644 index 966bb2c7f..000000000 --- a/src/test/java/org/asteriskjava/manager/event/T38FaxStatusEventTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.asteriskjava.manager.event; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -/** - * - */ -public class T38FaxStatusEventTest -{ - @Test - public void testStripUnit() - { - T38FaxStatusEvent event = new T38FaxStatusEvent(this); - assertEquals("0.022", event.stripUnit("0.022 sec.")); - } - - @Test - public void testParseProperties() - { - T38FaxStatusEvent event = new T38FaxStatusEvent(this); - event.setTotalLag("-9 ms"); - event.setMaxLag("4 ms"); - event.setT38SessionDuration("0.022 sec."); - event.setAverageLag("-1.80 ms"); - event.setAverageTxDataRate("363 bps"); - event.setAverageRxDataRate("0 bps"); - - assertEquals(-9, event.getTotalLagInMilliSeconds().intValue()); - assertEquals(4, event.getMaxLagInMilliSeconds().intValue()); - assertEquals(0.022, event.getT38SessionDurationInSeconds(), 0.00001); - assertEquals(-1.8, event.getAverageLagInMilliSeconds(), 0.00001); - assertEquals(363, event.getAverageTxDataRateInBps().intValue()); - assertEquals(0, event.getAverageRxDataRateInBps().intValue()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/A.java b/src/test/java/org/asteriskjava/manager/internal/A.java deleted file mode 100644 index d657fe93c..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/A.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.manager.event.UserEvent; - -public class A extends UserEvent -{ - private static final long serialVersionUID = 3545240219457894199L; - - public A(Object source) - { - super(source); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ActionBuilderImplTest.java b/src/test/java/org/asteriskjava/manager/internal/ActionBuilderImplTest.java deleted file mode 100644 index de6e1a015..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ActionBuilderImplTest.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.LinkedHashMap; -import java.util.Map; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.AbstractManagerAction; -import org.asteriskjava.manager.action.AgentsAction; -import org.asteriskjava.manager.action.OriginateAction; -import org.asteriskjava.manager.action.SipNotifyAction; -import org.asteriskjava.manager.action.UpdateConfigAction; -import org.asteriskjava.manager.action.UserEventAction; -import org.junit.Before; -import org.junit.Test; - -public class ActionBuilderImplTest -{ - private ActionBuilderImpl actionBuilder; - - @Before - public void setUp() - { - this.actionBuilder = new ActionBuilderImpl(); - } - - @Test - public void testBuildAction() - { - MyAction myAction; - String actual; - - myAction = new MyAction(); - myAction.setFirstProperty("first value"); - myAction.setSecondProperty(2); - myAction.setNonPublicProperty("private"); - - actual = actionBuilder.buildAction(myAction); - - assertTrue("Action name missing", actual.indexOf("action: My\r\n") >= 0); - assertTrue("First property missing", actual.indexOf("firstproperty: first value\r\n") >= 0); - assertTrue("Second property missing", actual.indexOf("secondproperty: 2\r\n") >= 0); - assertTrue("Missing trailing CRNL CRNL", actual.endsWith("\r\n\r\n")); - assertEquals("Incorrect length", 61, actual.length()); - } - - @Test - public void testBuildActionWithNullValue() - { - MyAction myAction; - String actual; - - myAction = new MyAction(); - myAction.setFirstProperty("first value"); - - actual = actionBuilder.buildAction(myAction); - - assertTrue("Action name missing", actual.indexOf("action: My\r\n") >= 0); - assertTrue("First property missing", actual.indexOf("firstproperty: first value\r\n") >= 0); - assertTrue("Missing trailing CRNL CRNL", actual.endsWith("\r\n\r\n")); - assertEquals("Incorrect length", 42, actual.length()); - } - - @Test - public void testBuildEventGeneratingAction() - { - AgentsAction action; - String actual; - - action = new AgentsAction(); - - actual = actionBuilder.buildAction(action); - - assertTrue("Action name missing", actual.indexOf("action: Agents\r\n") >= 0); - assertTrue("Action contains actionCompleteEventClass property", actual.indexOf("actioncompleteeventclass:") == -1); - assertTrue("Missing trailing CRNL CRNL", actual.endsWith("\r\n\r\n")); - } - - @Test - public void testBuildUpdateConfigAction() - { - UpdateConfigAction action; - action = new UpdateConfigAction(); - action.setSrcFilename("sourcefile.conf"); - action.setDstFilename("destfile.conf"); - action.setReload(true); - action.addCommand(UpdateConfigAction.ACTION_NEWCAT, "testcategory", null, null, null); - - String actual = actionBuilder.buildAction(action); - - assertTrue("Action name missing", actual.indexOf("action: UpdateConfig") >= 0); - assertTrue("Source filename missing", actual.indexOf("srcfilename: sourcefile.conf") >= 0); - assertTrue("Destination filename missing", actual.indexOf("dstfilename: destfile.conf") >= 0); - assertTrue("Correct reload setting missing", actual.indexOf("reload: Yes") >= 0); - - assertFalse("Action must have zero-padded 6 digit numbering", actual.indexOf("Action-0:") >= 0); - assertFalse("UpdateConfig actions must not have more than one 'action' header", actual.indexOf("action: Action") >= 0); - assertTrue("Action missing category testcategory - " + actual, actual.indexOf("Cat-000000: testcategory") >= 0); - } - - @Test - public void testBuildUserEventAction() - { - UserEventAction action; - action = new UserEventAction(); - - MyUserEvent event; - event = new MyUserEvent(this); - action.setUserEvent(event); - - Map mapMemberTest = new LinkedHashMap(); - mapMemberTest.put("Key1", "Value1"); - mapMemberTest.put("Key2", "Value2"); - mapMemberTest.put("Key3", "Value3"); - - event.setStringMember("stringMemberValue"); - event.setMapMember(mapMemberTest); - - String actual = actionBuilder.buildAction(action); - assertTrue("Action name missing", actual.indexOf("action: UserEvent\r\n") >= 0); - assertTrue("Event name missing", actual.indexOf("UserEvent: myuser\r\n") >= 0); - assertTrue("Regular member missing", actual.indexOf("stringmember: stringMemberValue\r\n") >= 0); - assertTrue("Map member missing", actual.indexOf("mapmember: Key1=Value1|Key2=Value2|Key3=Value3\r\n") >= 0); - assertTrue("Missing trailing CRNL CRNL", actual.endsWith("\r\n\r\n")); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildActionWithVariablesForAsterisk10() - { - OriginateAction originateAction; - String actual; - - originateAction = new OriginateAction(); - originateAction.setVariable("var1=value1|var2=value2"); - - actual = actionBuilder.buildAction(originateAction); - - assertTrue("Incorrect mapping of variable property for Asterisk 1.0", - actual.indexOf("variable: var1=value1|var2=value2\r\n") >= 0); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildActionWithVariablesForAsterisk10WithNullValues() - { - OriginateAction originateAction; - String actual; - - originateAction = new OriginateAction(); - originateAction.setVariable("var1=value1|var2=|var3=value3"); - - actual = actionBuilder.buildAction(originateAction); - - assertTrue("Incorrect mapping of variable property for Asterisk 1.0", - actual.indexOf("variable: var1=value1|var2=|var3=value3\r\n") >= 0); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildActionWithVariablesForAsterisk12() - { - OriginateAction originateAction; - String actual; - - originateAction = new OriginateAction(); - originateAction.setVariable("var1=value1|var2=value2"); - - actionBuilder.setTargetVersion(AsteriskVersion.ASTERISK_1_2); - actual = actionBuilder.buildAction(originateAction); - - assertTrue("Incorrect mapping of variable property for Asterisk 1.2", - actual.indexOf("variable: var1=value1\r\nvariable: var2=value2\r\n") >= 0); - } - - @SuppressWarnings("deprecation") - @Test - public void testBuildActionWithVariablesForAsterisk12WithNullValues() - { - OriginateAction originateAction; - String actual; - - originateAction = new OriginateAction(); - originateAction.setVariable("var1=value1|var2=|var3=value3"); - - actionBuilder.setTargetVersion(AsteriskVersion.ASTERISK_1_2); - actual = actionBuilder.buildAction(originateAction); - - assertTrue("Incorrect mapping of variable property for Asterisk 1.2", - actual.indexOf("variable: var1=value1\r\nvariable: var2=\r\nvariable: var3=value3\r\n") >= 0); - } - - @Test - public void testBuildActionWithVariableMapForAsterisk12() - { - OriginateAction originateAction; - Map map; - String actual; - - originateAction = new OriginateAction(); - - map = new LinkedHashMap(); - map.put("var1", "value1"); - map.put("VAR2", "value2"); - - originateAction.setVariables(map); - - actionBuilder.setTargetVersion(AsteriskVersion.ASTERISK_1_2); - actual = actionBuilder.buildAction(originateAction); - - assertTrue("Incorrect mapping of variable property for Asterisk 1.2", - actual.indexOf("variable: var1=value1\r\nvariable: VAR2=value2\r\n") >= 0); - } - - @Test - public void testBuildActionForSipNotifyAction() - { - SipNotifyAction action; - String actual; - - action = new SipNotifyAction("peer"); - action.setVariable("var1", "value1"); - action.setVariable("var2", "value2"); - - actionBuilder.setTargetVersion(AsteriskVersion.ASTERISK_1_6); - actual = actionBuilder.buildAction(action); - - assertTrue("Incorrect mapping of variable property", - actual.indexOf("variable: var1=value1\r\nvariable: var2=value2\r\n") >= 0); - } - - @Test - public void testBuildActionWithAnnotatedGetter() - { - AnnotatedAction action = new AnnotatedAction("value1", "value2", "value3"); - String actual = actionBuilder.buildAction(action); - - assertTrue("Incorrect mapping of property with annotated getter", - actual.indexOf("property-1: value1\r\n") >= 0); - } - - @Test - public void testDetermineSetterName() - { - assertEquals("setProperty1", ActionBuilderImpl.determineSetterName("getProperty1")); - assertEquals("setProperty1", ActionBuilderImpl.determineSetterName("isProperty1")); - } - - @Test - public void testBuildActionWithAnnotatedSetter() - { - AnnotatedAction action = new AnnotatedAction("value1", "value2", "value3"); - String actual = actionBuilder.buildAction(action); - - assertTrue("Incorrect mapping of property with annotated setter", - actual.indexOf("property-2: value2\r\n") >= 0); - } - - @Test - public void testDetermineFieldName() - { - assertEquals("property1", ActionBuilderImpl.determineFieldName("getProperty1")); - assertEquals("property1", ActionBuilderImpl.determineFieldName("isProperty1")); - assertEquals("property1", ActionBuilderImpl.determineFieldName("setProperty1")); - } - - @Test - public void testBuildActionWithAnnotatedField() - { - AnnotatedAction action = new AnnotatedAction("value1", "value2", "value3"); - String actual = actionBuilder.buildAction(action); - - assertTrue("Incorrect mapping of property with annotated field", - actual.indexOf("property-3: value3\r\n") >= 0); - } - - class MyAction extends AbstractManagerAction - { - private static final long serialVersionUID = 3257568425345102641L; - private String firstProperty; - private Integer secondProperty; - private String nonPublicProperty; - - @Override - public String getAction() - { - return "My"; - } - - public String getFirstProperty() - { - return firstProperty; - } - - public void setFirstProperty(String firstProperty) - { - this.firstProperty = firstProperty; - } - - public Integer getSecondProperty() - { - return secondProperty; - } - - public void setSecondProperty(Integer secondProperty) - { - this.secondProperty = secondProperty; - } - - protected String getNonPublicProperty() - { - return nonPublicProperty; - } - - protected void setNonPublicProperty(String privateProperty) - { - this.nonPublicProperty = privateProperty; - } - - public String get() - { - return "This method must not be considered a getter"; - } - - public String getIndexedProperty(int i) - { - return "This method must not be considered a getter relevant for building the action"; - } - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/AnnotatedAction.java b/src/test/java/org/asteriskjava/manager/internal/AnnotatedAction.java deleted file mode 100644 index f476b5c4c..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/AnnotatedAction.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.manager.AsteriskMapping; -import org.asteriskjava.manager.action.AbstractManagerAction; - -public class AnnotatedAction extends AbstractManagerAction -{ - private static final long serialVersionUID = 1L; - private String property1; - private String property2; - - @AsteriskMapping("property-3") // annotated field - private String property3; - - public AnnotatedAction() - { - } - - public AnnotatedAction(String property1, String property2, String property3) - { - this.property1 = property1; - this.property2 = property2; - this.property3 = property3; - } - - @Override - public String getAction() - { - return "Custom"; - } - - @AsteriskMapping("property-1") // annotated getter - public String getProperty1() - { - return property1; - } - - public void setProperty1(String property1) - { - this.property1 = property1; - } - - public String getProperty2() - { - return property2; - } - - @AsteriskMapping("property-2") // annotated setter - public void setProperty2(String property2) - { - this.property2 = property2; - } - - public String getProperty3() - { - return property3; - } - - public void setProperty3(String property3) - { - this.property3 = property3; - } -} \ No newline at end of file diff --git a/src/test/java/org/asteriskjava/manager/internal/BEvent.java b/src/test/java/org/asteriskjava/manager/internal/BEvent.java deleted file mode 100644 index 51c34c70d..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/BEvent.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.manager.event.UserEvent; - -public class BEvent extends UserEvent -{ - private static final long serialVersionUID = 3545240219457894199L; - - public BEvent(Object source) - { - super(source); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/EventBuilderImplTest.java b/src/test/java/org/asteriskjava/manager/internal/EventBuilderImplTest.java deleted file mode 100644 index 5a238802c..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/EventBuilderImplTest.java +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.asteriskjava.manager.event.AbstractChannelEvent; -import org.asteriskjava.manager.event.AgentCalledEvent; -import org.asteriskjava.manager.event.CdrEvent; -import org.asteriskjava.manager.event.HangupEvent; -import org.asteriskjava.manager.event.LogChannelEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.MeetMeLeaveEvent; -import org.asteriskjava.manager.event.MusicOnHoldEvent; -import org.asteriskjava.manager.event.NewCallerIdEvent; -import org.asteriskjava.manager.event.NewChannelEvent; -import org.asteriskjava.manager.event.NewExtenEvent; -import org.asteriskjava.manager.event.PeersEvent; -import org.asteriskjava.manager.event.ResponseEvent; -import org.asteriskjava.manager.event.RtpReceiverStatEvent; -import org.asteriskjava.manager.event.ShutdownEvent; -import org.asteriskjava.manager.event.StatusCompleteEvent; -import org.asteriskjava.manager.event.T38FaxStatusEvent; -import org.asteriskjava.manager.event.TransferEvent; -import org.junit.Before; -import org.junit.Test; - -public class EventBuilderImplTest -{ - private EventBuilder eventBuilder; - private Map properties; - - @Before - public void setUp() - { - this.eventBuilder = new EventBuilderImpl(); - this.properties = new HashMap(); - } - - @Test - public void testRegisterEvent() - { - eventBuilder.registerEventClass(NewChannelEvent.class); - } - - @Test - public void testRegisterUserEventWithA() - { - ManagerEvent event; - - eventBuilder.registerEventClass(A.class); - properties.put("event", "UserEventA"); - event = eventBuilder.buildEvent(this, properties); - - assertTrue("Wrong type", event instanceof A); - } - - @Test - public void testRegisterUserEventWithBEvent() - { - ManagerEvent event; - - eventBuilder.registerEventClass(BEvent.class); - properties.put("event", "UserEventB"); - event = eventBuilder.buildEvent(this, properties); - - assertTrue("Wrong type", event instanceof BEvent); - } - - @Test - public void testRegisterUserEventWithUserEventC() - { - ManagerEvent event; - - eventBuilder.registerEventClass(UserEventC.class); - properties.put("event", "UserEventC"); - event = eventBuilder.buildEvent(this, properties); - - assertTrue("Wrong type", event instanceof UserEventC); - } - - @Test - public void testRegisterUserEventWithUserEventCAndAsterisk14() - { - ManagerEvent event; - - eventBuilder.registerEventClass(UserEventC.class); - properties.put("event", "UserEvent"); - properties.put("userevent", "C"); - event = eventBuilder.buildEvent(this, properties); - - assertTrue("Wrong type", event instanceof UserEventC); - } - - @Test - public void testRegisterUserEventWithUserEventDEvent() - { - ManagerEvent event; - - eventBuilder.registerEventClass(UserEventDEvent.class); - properties.put("event", "UserEventD"); - event = eventBuilder.buildEvent(this, properties); - - assertTrue("Wrong type", event instanceof UserEventDEvent); - } - - @Test - public void testRegisterEventWithAbstractEvent() - { - try - { - eventBuilder.registerEventClass(AbstractChannelEvent.class); - fail("registerEvent() must not accept abstract classes"); - } - catch (IllegalArgumentException ex) - { - } - } - - /* - * public void testGetSetters() { Map setters; EventBuilderImpl eventBuilder - * = getEventBuilder(); setters = - * eventBuilder.getSetters(NewChannelEvent.class); assertTrue("Setter not - * found", setters.containsKey("callerid")); } - */ - - @Test - public void testBuildEventWithMixedCaseSetter() - { - String callerid = "1234"; - NewChannelEvent event; - - properties.put("event", "Newchannel"); - properties.put("callerid", callerid); - event = (NewChannelEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", NewChannelEvent.class, event.getClass()); - assertEquals("String property not set correctly", callerid, event.getCallerIdNum()); - assertEquals("Source not set correctly", this, event.getSource()); - } - - @Test - public void testBuildEventWithIntegerProperty() - { - String channel = "SIP/1234"; - Integer priority = 1; - NewExtenEvent event; - - properties.put("event", "newexten"); - properties.put("channel", channel); - properties.put("priority", priority.toString()); - event = (NewExtenEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", NewExtenEvent.class, event.getClass()); - assertEquals("String property not set correctly", channel, event.getChannel()); - assertEquals("Integer property not set correctly", priority, event.getPriority()); - } - - @Test - public void testBuildEventWithBooleanProperty() - { - ShutdownEvent event; - - eventBuilder.registerEventClass(ShutdownEvent.class); - properties.put("event", "shutdown"); - properties.put("restart", "True"); - event = (ShutdownEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", ShutdownEvent.class, event.getClass()); - assertEquals("Boolean property not set correctly", Boolean.TRUE, event.getRestart()); - } - - @Test - public void testBuildEventWithBooleanPropertyOfValueYes() - { - ShutdownEvent event; - - eventBuilder.registerEventClass(ShutdownEvent.class); - properties.put("event", "shutdown"); - properties.put("restart", "yes"); - event = (ShutdownEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", ShutdownEvent.class, event.getClass()); - assertEquals("Boolean property not set correctly", Boolean.TRUE, event.getRestart()); - } - - @Test - public void testBuildEventWithBooleanPropertyOfValueNo() - { - ShutdownEvent event; - - eventBuilder.registerEventClass(ShutdownEvent.class); - properties.put("event", "shutdown"); - properties.put("restart", "NO"); - event = (ShutdownEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", ShutdownEvent.class, event.getClass()); - assertEquals("Boolean property not set correctly", Boolean.FALSE, event.getRestart()); - } - - @Test - public void testBuildEventWithUnregisteredEvent() - { - ManagerEvent event; - - properties.put("event", "Nonexisting"); - event = eventBuilder.buildEvent(this, properties); - - assertNull(event); - } - - @Test - public void testBuildEventWithEmptyAttributes() - { - ManagerEvent event; - - event = eventBuilder.buildEvent(this, properties); - - assertNull(event); - } - - @Test - public void testBuildEventWithResponseEvent() - { - ManagerEvent event; - - properties.put("event", "StatusComplete"); - properties.put("actionid", "1234#origId"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", StatusCompleteEvent.class, event.getClass()); - assertEquals("ActionId not set correctly", "origId", ((ResponseEvent) event).getActionId()); - } - - @Test - public void testBuildEventWithSourceProperty() - { - ManagerEvent event; - - properties.put("event", "Cdr"); - properties.put("source", "source value"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Src property not set correctly", "source value", ((CdrEvent) event).getSrc()); - } - - @Test - public void testBuildEventWithClassProperty() - { - ManagerEvent event; - - properties.put("event", "MusicOnHold"); - properties.put("class", "default"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("ClassName property not set correctly", "default", ((MusicOnHoldEvent) event).getClassName()); - } - - @Test - public void testBuildEventWithSpecialCharacterProperty() - { - ManagerEvent event; - - properties.put("event", "Hangup"); - properties.put("cause-txt", "some text"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("CauseTxt property not set correctly", "some text", ((HangupEvent) event).getCauseTxt()); - } - - @Test - public void testBuildEventWithCidCallingPres() - { - ManagerEvent event; - - properties.put("event", "Newcallerid"); - properties.put("cid-callingpres", "123 (nice description)"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("CidCallingPres property not set correctly", Integer.valueOf(123), - ((NewCallerIdEvent) event).getCidCallingPres()); - assertEquals("CidCallingPresTxt property not set correctly", "nice description", - ((NewCallerIdEvent) event).getCidCallingPresTxt()); - } - - @Test - public void testBuildEventWithCidCallingPresAndEmptyTxt() - { - ManagerEvent event; - - properties.put("event", "Newcallerid"); - properties.put("cid-callingpres", "123 ()"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("CidCallingPres property not set correctly", Integer.valueOf(123), - ((NewCallerIdEvent) event).getCidCallingPres()); - assertNull("CidCallingPresTxt property not set correctly (must be null)", - ((NewCallerIdEvent) event).getCidCallingPresTxt()); - } - - @Test - public void testBuildEventWithCidCallingPresAndMissingTxt() - { - ManagerEvent event; - - properties.put("event", "Newcallerid"); - properties.put("cid-callingpres", "123"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("CidCallingPres property not set correctly", Integer.valueOf(123), - ((NewCallerIdEvent) event).getCidCallingPres()); - assertNull("CidCallingPresTxt property not set correctly (must be null)", - ((NewCallerIdEvent) event).getCidCallingPresTxt()); - } - - @Test - public void testBuildEventWithInvalidCidCallingPres() - { - ManagerEvent event; - - properties.put("event", "Newcallerid"); - properties.put("cid-callingpres", "abc"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertNull("CidCallingPres property not set correctly (must be null)", - ((NewCallerIdEvent) event).getCidCallingPres()); - assertNull("CidCallingPresTxt property not set correctly (must be null)", - ((NewCallerIdEvent) event).getCidCallingPresTxt()); - } - - @Test - public void testBuildEventWithReason() - { - ManagerEvent event; - - properties.put("event", "LogChannel"); - properties.put("reason", "123 - a reason"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Reason property not set correctly", Integer.valueOf(123), ((LogChannelEvent) event).getReason()); - assertEquals("ReasonTxt property not set correctly", "a reason", ((LogChannelEvent) event).getReasonTxt()); - } - - @Test - public void testBuildEventWithTimestamp() - { - ManagerEvent event; - - properties.put("event", "NewChannel"); - properties.put("timestamp", "1159310429.569108"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Timestamp property not set correctly", 1159310429.569108D, event.getTimestamp(), 0.0001); - } - - @Test - public void testBuildEventWithLong() - { - ManagerEvent event; - - properties.put("event", "MeetmeLeave"); - properties.put("duration", "569108"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Duration property not set correctly", new Long(569108), ((MeetMeLeaveEvent) event).getDuration()); - } - - @Test - public void testBuildEventWithDouble() - { - ManagerEvent event; - - properties.put("event", "RTPReceiverStat"); - properties.put("transit", "12.3456"); - event = eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Transit property not set correctly", 12.3456, ((RtpReceiverStatEvent) event).getTransit(), 0.0001); - } - - @Test - public void testBuildEventWithNullLiteral() - { - CdrEvent event; - - properties.put("event", "Cdr"); - properties.put("channel", ""); - event = (CdrEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", CdrEvent.class, event.getClass()); - assertNull("Property with value \"\" is not null", event.getChannel()); - } - - @Test - public void testBuildEventWithDashInPropertyName() - { - TransferEvent event; - - properties.put("event", "Transfer"); - properties.put("sip-callid", "12345"); - event = (TransferEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", TransferEvent.class, event.getClass()); - assertEquals("Property SIP-Callid is not set correctly", "12345", event.getSipCallId()); - } - - @Test - public void testBuildEventForRtpReceiverStatEventAJ162() - { - RtpReceiverStatEvent event; - - properties.put("event", "RtpReceiverStat"); - properties.put("ssrc", "3776236237"); - properties.put("receivedpackets", "0"); - event = (RtpReceiverStatEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", RtpReceiverStatEvent.class, event.getClass()); - assertEquals("Property SSRC is not set correctly", 3776236237l, (long) event.getSsrc()); - } - - @Test - public void testBuildEventForRtpReceiverStatEventAJ139() - { - RtpReceiverStatEvent event; - - properties.put("event", "RtpReceiverStat"); - properties.put("receivedpackets", "0"); - event = (RtpReceiverStatEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", RtpReceiverStatEvent.class, event.getClass()); - assertEquals("Property receivedPacket is not set correctly", 0, (long) event.getReceivedPackets()); - } - - @Test - public void testBuildEventWithMapProperty() - { - AgentCalledEvent event; - - properties.put("event", "AgentCalled"); - properties.put("variable", Arrays.asList("var1=val1", "var2=val2")); - event = (AgentCalledEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", AgentCalledEvent.class, event.getClass()); - assertEquals("Property variables[var1] is not set correctly", "val1", event.getVariables().get("var1")); - assertEquals("Property variables[var2] is not set correctly", "val2", event.getVariables().get("var2")); - assertEquals("Invalid size of variables property", 2, event.getVariables().size()); - } - - @Test - public void testBuildEventWithMapPropertyAndOnlyOneEntry() - { - AgentCalledEvent event; - - properties.put("event", "AgentCalled"); - properties.put("variable", "var1=val1"); - event = (AgentCalledEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", AgentCalledEvent.class, event.getClass()); - assertEquals("Property variables[var1] is not set correctly", "val1", event.getVariables().get("var1")); - assertEquals("Invalid size of variables property", 1, event.getVariables().size()); - } - - @Test - public void testBuildEventWithSpace() - { - T38FaxStatusEvent event; - - properties.put("event", "T38FaxStatus"); - properties.put("t38 session duration", "120"); - event = (T38FaxStatusEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", T38FaxStatusEvent.class, event.getClass()); - assertEquals("Property 'T38 Session Duration' is not set correctly", "120", event.getT38SessionDuration()); - } - - @Test - public void testBuildEventWithPeerEntryEventList() - { - PeersEvent event; - - properties.put("event", Arrays.asList("PeerEntry", "PeerEntry", "PeerEntry", "PeerlistComplete")); - properties.put("actionid", Arrays.asList("1378144905_4#123", "1378144905_4#123", "1378144905_4#123")); - properties.put("objectname", Arrays.asList("a101", "a102", "a103")); - properties.put("status", Arrays.asList("OK", "UNKNOWN", "LAGGED")); - properties.put("listitems", "3"); - event = (PeersEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", PeersEvent.class, event.getClass()); - assertEquals("ActionId is invalid", "123", event.getActionId()); - assertEquals("Property events[objectname] is not set correctly", "a101", - event.getChildEvents().get(0).getObjectName()); - assertEquals("Property events[status] is not set correctly", "OK", event.getChildEvents().get(0).getStatus()); - assertEquals("Property events[objectname] is not set correctly", "a102", - event.getChildEvents().get(1).getObjectName()); - assertNull("UNKNOWN literal returns NULL status", event.getChildEvents().get(1).getStatus()); - assertEquals("Property events[objectname] is not set correctly", "a103", - event.getChildEvents().get(2).getObjectName()); - assertEquals("Property events[status] is not set correctly", "LAGGED", event.getChildEvents().get(2).getStatus()); - assertEquals("Invalid size of peers property", 3, event.getChildEvents().size()); - } - - @Test - public void testBuildEventWithOnePeerEntryEventList() - { - PeersEvent event; - - properties.put("event", Arrays.asList("PeerEntry", "PeerlistComplete")); - properties.put("actionid", "1378144905_4#123"); - properties.put("objectname", "a101"); - properties.put("status", "OK"); - properties.put("listitems", "1"); - event = (PeersEvent) eventBuilder.buildEvent(this, properties); - - assertNotNull(event); - assertEquals("Returned event is of wrong type", PeersEvent.class, event.getClass()); - assertEquals("ActionId is invalid", "123", event.getActionId()); - assertEquals("Property events[objectname] is not set correctly", "a101", - event.getChildEvents().get(0).getObjectName()); - assertEquals("Property events[status] is not set correctly", "OK", event.getChildEvents().get(0).getStatus()); - assertEquals("Invalid size of peers property", 1, event.getChildEvents().size()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ManagerConnectionImplTest.java b/src/test/java/org/asteriskjava/manager/internal/ManagerConnectionImplTest.java deleted file mode 100644 index d8585981c..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ManagerConnectionImplTest.java +++ /dev/null @@ -1,736 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.AuthenticationFailedException; -import org.asteriskjava.manager.ManagerConnectionState; -import org.asteriskjava.manager.ManagerEventListener; -import org.asteriskjava.manager.TimeoutException; -import org.asteriskjava.manager.action.CommandAction; -import org.asteriskjava.manager.action.PingAction; -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.manager.event.ConnectEvent; -import org.asteriskjava.manager.event.DisconnectEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.NewChannelEvent; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.SocketConnectionFacade; -import org.junit.Before; -import org.junit.Test; - -public class ManagerConnectionImplTest -{ - protected SocketConnectionFacade mockSocket; - protected ManagerWriterMock mockWriter; - protected ManagerReaderMock mockReader; - protected MockedManagerConnectionImpl mc; - - @Before - public void setUp() - { - mockWriter = new ManagerWriterMock(); - mockWriter.setExpectedUsername("username"); - // md5 sum of 12345password - mockWriter.setExpectedKey("40b1b887502902a8ce61a16e44630f7c"); - - mockReader = new ManagerReaderMock(); - mockSocket = createMock(SocketConnectionFacade.class); - mc = new MockedManagerConnectionImpl(mockReader, mockWriter, mockSocket); - mockWriter.setDispatcher(mc); - } - - @Test - public void testDefaultConstructor() - { - assertEquals("Invalid default hostname", "localhost", mc.getHostname()); - assertEquals("Invalid default port", 5038, mc.getPort()); - } - - @Test - public void testRegisterUserEventClass() - { - ManagerReader managerReader; - - managerReader = createMock(ManagerReader.class); - - managerReader.registerEventClass(MyUserEvent.class); - replay(managerReader); - - mc = new MockedManagerConnectionImpl(managerReader, mockWriter, mockSocket); - mc.registerUserEventClass(MyUserEvent.class); - - assertEquals("unexpected call to createSocket", 0, mc.createSocketCalls); - assertEquals("unexpected call to createWriter", 0, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - verify(managerReader); - } - - @Test - public void testLogin() throws Exception - { - MockedManagerEventListener listener; - long startTime; - long endTime; - long duration; - - listener = new MockedManagerEventListener(); - - replay(mockSocket); - - mc.setUsername("username"); - mc.setPassword("password"); - mc.addEventListener(listener); - mc.setDefaultResponseTimeout(5000); - - startTime = System.currentTimeMillis(); - mc.login(); - endTime = System.currentTimeMillis(); - duration = endTime - startTime; - - assertEquals("createSocket not called 1 time", 1, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might - // not yet have been - // called. - try - { - Thread.sleep(100); - } - catch (InterruptedException e) - { - // ugly hack to make this work when the thread is interrupted coz a - // response has been received but the ManagerConnection was not yet - // sleeping - Thread.sleep(100); - } - assertEquals("run() not called 1 time", 1, mockReader.runCalls); - assertEquals("unexpected call to die()", 0, mockReader.dieCalls); - - assertEquals("state is not CONNECTED", ManagerConnectionState.CONNECTED, mc.getState()); - - assertEquals("must have handled exactly one events", 1, listener.eventsHandled.size()); - /* - * assertTrue( - * "first event handled must be a ProtocolIdentifierReceivedEvent", - * listener.eventsHandled.get(0) instanceof - * ProtocolIdentifierReceivedEvent); - */ - assertTrue("event handled must be a ConnectEvent", listener.eventsHandled.get(0) instanceof ConnectEvent); - - verify(mockSocket); - assertTrue("login() took longer than 2 second, probably a notify error (duration was " + duration + " is msec)", - duration <= 2000); - } - - @Test - public void testLoginIncorrectKey() throws Exception - { - mockSocket.close(); - replay(mockSocket); - - mockWriter.setExpectedUsername("username"); - // md5 sum of 12345password - mockWriter.setExpectedKey("40b1b887502902a8ce61a16e44630f7c"); - - mc.setUsername("username"); - mc.setPassword("wrong password"); - - try - { - mc.login(); - fail("No AuthenticationFailedException thrown"); - } - catch (AuthenticationFailedException e) - { - } - - assertEquals("createSocket not called 1 time", 1, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might - // not yet have been - // called. - try - { - Thread.sleep(100); - } - catch (InterruptedException e) - { - // ugly hack to make this work when the thread is interrupted coz a - // response has been received but the ManagerConnection was not yet - // sleeping - Thread.sleep(100); - } - assertEquals("run() not called 1 time", 1, mockReader.runCalls); - assertEquals("unexpected call to die()", 0, mockReader.dieCalls); - - verify(mockSocket); - } - - @Test - public void testLoginIOExceptionOnConnect() throws Exception - { - replay(mockSocket); - - mc.setThrowIOExceptionOnFirstSocketCreate(true); - try - { - mc.login(); - fail("No IOException thrown"); - } - catch (IOException e) - { - } - - assertEquals("createSocket not called 1 time", 1, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("unexpected challenge action sent", 0, mockWriter.challengeActionsSent); - assertEquals("unexpected login action sent", 0, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - - assertEquals("unexpected call to setSocket()", 0, mockReader.setSocketCalls); - assertEquals("unexpected call to run()", 0, mockReader.runCalls); - assertEquals("unexpected call to die()", 0, mockReader.dieCalls); - - verify(mockSocket); - } - - @Test - public void testLoginTimeoutOnConnect() throws Exception - { - mc.setDefaultResponseTimeout(50); - - mockSocket.close(); - replay(mockSocket); - - // provoke timeout - mockWriter.setSendProtocolIdentifierReceivedEvent(false); - - try - { - mc.login(); - fail("No TimeoutException on login()"); - } - catch (TimeoutException e) - { - assertEquals("Timeout waiting for protocol identifier", e.getMessage()); - } - - assertEquals("createSocket not called 1 time", 1, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("unexpected challenge action sent", 0, mockWriter.challengeActionsSent); - assertEquals("unexpected login action sent", 0, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might - // not yet have been - // called. - Thread.sleep(10); - assertEquals("run() not called 1 time", 1, mockReader.runCalls); - assertEquals("unexpected call to die()", 0, mockReader.dieCalls); - - verify(mockSocket); - } - - @Test - public void testLoginTimeoutOnChallengeAction() throws Exception - { - mc.setDefaultResponseTimeout(200); - - mockSocket.close(); - replay(mockSocket); - - // provoke timeout - mockWriter.setSendResponse(false); - - try - { - mc.login(); - fail("No TimeoutException on login()"); - } - catch (AuthenticationFailedException e) - { - assertEquals("Unable to send challenge action", e.getMessage()); - assertEquals("Timeout waiting for response to Challenge", e.getCause().getMessage()); - assertTrue(e.getCause() instanceof TimeoutException); - } - - assertEquals("createSocket not called 1 time", 1, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("unexpected login action sent", 0, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - - assertEquals("setSocket() not called 1 time", 1, mockReader.setSocketCalls); - // Some time for the reader thread to be started. Otherwise run() might - // not yet have been - // called. - Thread.sleep(10); - assertEquals("run() not called 1 time", 1, mockReader.runCalls); - assertEquals("unexpected call to die()", 0, mockReader.dieCalls); - - verify(mockSocket); - } - - @Test - public void testLogoffWhenConnected() throws Exception - { - mockSocket.close(); - replay(mockSocket); - - // fake connect - mc.connect(); - mc.setState(ManagerConnectionState.CONNECTED); - - mc.logoff(); - - assertEquals("logoff action not sent 1 time", 1, mockWriter.logoffActionsSent); - verify(mockSocket); - } - - @Test - public void testLogoffWhenNotConnected() - { - replay(mockSocket); - - try - { - mc.logoff(); - fail("Expected IllegalStateException when calling logoff when not connected"); - } - catch (IllegalStateException e) - { - // fine - } - - assertEquals("unexpected logoff action sent", 0, mockWriter.logoffActionsSent); - verify(mockSocket); - } - - @Test - public void testSendActionWithNullAction() throws Exception - { - // fake connect - mc.connect(); - try - { - mc.sendAction(null); - fail("No IllgealArgumentException thrown"); - } - catch (IllegalArgumentException e) - { - } - } - - @Test - public void testSendActionWhenNotConnected() throws Exception - { - StatusAction statusAction; - - statusAction = new StatusAction(); - - try - { - mc.sendAction(statusAction); - fail("No IllegalStateException thrown"); - } - catch (IllegalStateException e) - { - } - } - - @Test - public void testSendAction() throws Exception - { - StatusAction statusAction; - ManagerResponse response; - - statusAction = new StatusAction(); - statusAction.setActionId("123"); - - // fake connect - mc.connect(); - mc.setState(ManagerConnectionState.CONNECTED); - response = mc.sendAction(statusAction); - - assertEquals("incorrect actionId in action", "123", statusAction.getActionId()); - assertEquals("incorrect actionId in response", "123", response.getActionId()); - assertEquals("incorrect response", "Success", response.getResponse()); - - assertEquals("other actions not sent 1 time", 1, mockWriter.otherActionsSent); - } - - @Test - public void testSendActionTimeout() throws Exception - { - StatusAction statusAction; - - statusAction = new StatusAction(); - statusAction.setActionId("123"); - - mc.setDefaultResponseTimeout(200); - // fake connect - mc.connect(); - mc.setState(ManagerConnectionState.CONNECTED); - - // provoke timeout - mockWriter.setSendResponse(false); - try - { - mc.sendAction(statusAction); - fail("No TimeoutException thrown"); - } - catch (TimeoutException e) - { - } - - assertEquals("other actions not sent 1 time", 1, mockWriter.otherActionsSent); - } - - @Test - public void testDispatchResponseUnexpectedResponse() - { - ManagerResponse response; - - response = new ManagerResponse(); - // internalActionId: 123_0 - response.setActionId("123_0-abc"); - response.setResponse("Success"); - - // expected result is ignoring the response and logging - mc.dispatchResponse(response); - } - - @Test - public void testDispatchResponseMissingInternalActionId() - { - ManagerResponse response; - - response = new ManagerResponse(); - response.setActionId("abc"); - response.setResponse("Success"); - - // expected result is ignoring the response and logging - mc.dispatchResponse(response); - } - - @Test - public void testDispatchResponseNullActionId() - { - ManagerResponse response; - - response = new ManagerResponse(); - response.setActionId(null); - response.setResponse("Success"); - - // expected result is ignoring the response and logging - mc.dispatchResponse(response); - } - - @Test - public void testDispatchResponseNullResponse() - { - // expected result is ignoring and logging - mc.dispatchResponse(null); - } - - @Test - public void testReconnect() throws Exception - { - DisconnectEvent disconnectEvent; - - replay(mockSocket); - disconnectEvent = new DisconnectEvent(this); - - // fake successful login - mc.setState(ManagerConnectionState.CONNECTED); - - mc.setUsername("username"); - mc.setPassword("password"); - - mc.dispatchEvent(disconnectEvent); - - // wait for reconnect thread to do its work - Thread.sleep(1000); - - assertEquals("createSocket not called 1 time", 1, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - - assertEquals("state is not CONNECTED", ManagerConnectionState.CONNECTED, mc.getState()); - - verify(mockSocket); - } - - @Test - public void testReconnectWithIOException() throws Exception - { - DisconnectEvent disconnectEvent; - - replay(mockSocket); - disconnectEvent = new DisconnectEvent(this); - - // fake successful login - mc.setState(ManagerConnectionState.CONNECTED); - - mc.setThrowIOExceptionOnFirstSocketCreate(true); - - mc.setUsername("username"); - mc.setPassword("password"); - - mc.dispatchEvent(disconnectEvent); - - // wait for reconnect thread to do its work - Thread.sleep(1000); - assertEquals("createSocket not called 1 time", 2, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - - assertEquals("state is not CONNECTED", ManagerConnectionState.CONNECTED, mc.getState()); - - verify(mockSocket); - - } - - @Test - public void testReconnectWithTimeoutException() throws Exception - { - DisconnectEvent disconnectEvent; - - mockSocket.close(); - replay(mockSocket); - disconnectEvent = new DisconnectEvent(this); - - // fake successful login - mc.setState(ManagerConnectionState.CONNECTED); - - mc.setThrowTimeoutExceptionOnFirstLogin(true); - - mc.setUsername("username"); - mc.setPassword("password"); - - mc.dispatchEvent(disconnectEvent); - - // wait for reconnect thread to do its work - Thread.sleep(1000); - - assertEquals("createSocket not called 2 time", 2, mc.createSocketCalls); - assertEquals("createWriter not called 1 time", 1, mc.createWriterCalls); - assertEquals("createReader not called 1 time", 1, mc.createReaderCalls); - - assertEquals("challenge action not sent 1 time", 1, mockWriter.challengeActionsSent); - assertEquals("login action not sent 1 time", 1, mockWriter.loginActionsSent); - assertEquals("unexpected other actions sent", 0, mockWriter.otherActionsSent); - - assertEquals("state is not CONNECTED", ManagerConnectionState.CONNECTED, mc.getState()); - - verify(mockSocket); - } - - @SuppressWarnings("unchecked") - @Test - public void testDispatchEventWithMultipleEventHandlers() - { - final int count = 20; - ManagerEvent event; - final List list; - - // verify that event handlers are called in the correct order - event = new NewChannelEvent(this); - list = createMock(List.class); - for (int i = 0; i < count; i++) - { - final int index = i; - expect(list.add(index)).andReturn(true); - mc.addEventListener(new ManagerEventListener() - { - public void onManagerEvent(ManagerEvent event) - { - list.add(index); - } - }); - } - - replay(list); - mc.dispatchEvent(event); - verify(list); - } - - @Test - public void testIsShowVersionCommandAction() - { - assertTrue(mc.isShowVersionCommandAction(new CommandAction("show version"))); - assertTrue(mc.isShowVersionCommandAction(new CommandAction("core show version"))); - assertTrue(mc.isShowVersionCommandAction(new CommandAction("core show version foo bar"))); - assertFalse(mc.isShowVersionCommandAction(new CommandAction("foo show version"))); - assertFalse(mc.isShowVersionCommandAction(new PingAction())); - } - - private class MockedManagerEventListener implements ManagerEventListener - { - List eventsHandled; - - public MockedManagerEventListener() - { - this.eventsHandled = new ArrayList(); - } - - public void onManagerEvent(ManagerEvent event) - { - eventsHandled.add(event); - } - } - - private class MockedManagerConnectionImpl extends ManagerConnectionImpl - { - ManagerReader mockReader; - ManagerWriter mockWriter; - SocketConnectionFacade mockSocket; - - private boolean throwIOExceptionOnFirstSocketCreate = false; - private boolean throwTimeoutExceptionOnFirstLogin = false; - - public int createReaderCalls = 0; - public int createWriterCalls = 0; - public int createSocketCalls = 0; - - public int loginCalls = 0; - - public MockedManagerConnectionImpl(ManagerReader mockReader, ManagerWriter mockWriter, - SocketConnectionFacade mockSocket) - { - super(); - this.mockReader = mockReader; - this.mockWriter = mockWriter; - this.mockSocket = mockSocket; - } - - public void setThrowTimeoutExceptionOnFirstLogin(boolean b) - { - this.throwTimeoutExceptionOnFirstLogin = b; - } - - public void setThrowIOExceptionOnFirstSocketCreate(boolean b) - { - this.throwIOExceptionOnFirstSocketCreate = b; - } - - @Override - public String getUsername() - { - return username; - } - - @Override - public String getPassword() - { - return password; - } - - public void setState(ManagerConnectionState state) - { - this.state = state; - } - - @Override - protected ManagerReader createReader(Dispatcher d, Object source) - { - createReaderCalls++; - return mockReader; - } - - @Override - protected ManagerWriter createWriter() - { - createWriterCalls++; - return mockWriter; - } - - @Override - protected SocketConnectionFacade createSocket() throws IOException - { - createSocketCalls++; - - if (throwIOExceptionOnFirstSocketCreate && createSocketCalls == 1) - { - throw new IOException(); - } - return mockSocket; - } - - @Override - protected synchronized void doLogin(long timeout, String events) - throws IOException, AuthenticationFailedException, TimeoutException - { - loginCalls++; - - if (throwTimeoutExceptionOnFirstLogin && loginCalls == 1) - { - disconnect(); - throw new TimeoutException("Provoked timeout"); - } - super.doLogin(timeout, events); - } - - @Override - protected AsteriskVersion determineVersion() - { - return null; - } - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ManagerReaderImplTest.java b/src/test/java/org/asteriskjava/manager/internal/ManagerReaderImplTest.java deleted file mode 100644 index 6dac7843a..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ManagerReaderImplTest.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.asteriskjava.manager.event.AgentCalledEvent; -import org.asteriskjava.manager.event.DisconnectEvent; -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.event.ProtocolIdentifierReceivedEvent; -import org.asteriskjava.manager.event.RtcpReceivedEvent; -import org.asteriskjava.manager.event.StatusCompleteEvent; -import org.asteriskjava.manager.response.CommandResponse; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.SocketConnectionFacade; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ManagerReaderImplTest -{ - private Date now; - private MockedDispatcher dispatcher; - private SocketConnectionFacade socketConnectionFacade; - private ManagerReader managerReader; - - @Before - public void setUp() - { - now = new Date(); - DateUtil.overrideCurrentDate(now); - dispatcher = new MockedDispatcher(); - managerReader = new ManagerReaderImpl(dispatcher, this); - - socketConnectionFacade = createMock(SocketConnectionFacade.class); - } - - @After - public void tearDown() - { - DateUtil.overrideCurrentDate(null); - } - - @SuppressWarnings("cast") - @Test - public void testRunWithoutSocket() - { - try - { - managerReader.run(); - fail("Must throw IllegalStateException"); - } - catch (IllegalStateException e) - { - assertTrue("Exception must be of type IllegalStateException", e instanceof IllegalStateException); - } - } - - @Test - public void testRunReceivingProtocolIdentifier() throws Exception - { - expect(socketConnectionFacade.readLine()).andReturn("Asterisk Call Manager/1.0"); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly two events dispatched", 2, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a ProtocolIdentifierReceivedEvent", ProtocolIdentifierReceivedEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - - assertEquals("ProtocolIdentifierReceivedEvent contains incorrect protocol identifier", "Asterisk Call Manager/1.0", - ((ProtocolIdentifierReceivedEvent) dispatcher.dispatchedEvents.get(0)).getProtocolIdentifier()); - - assertEquals("ProtocolIdentifierReceivedEvent contains incorrect dateReceived", now, - dispatcher.dispatchedEvents.get(0).getDateReceived()); - - assertEquals("second event must be a DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(1).getClass()); - - assertEquals("DisconnectEvent contains incorrect dateReceived", now, - dispatcher.dispatchedEvents.get(1).getDateReceived()); - } - - @Test - public void testRunReceivingEvent() throws Exception - { - expect(socketConnectionFacade.readLine()).andReturn("Event: StatusComplete"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly two events dispatched", 2, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a StatusCompleteEvent", StatusCompleteEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - - assertEquals("second event must be a DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(1).getClass()); - } - - @Test - public void testRunReceivingEventWithMapProperty() throws Exception - { - expect(socketConnectionFacade.readLine()).andReturn("Event: AgentCalled"); - expect(socketConnectionFacade.readLine()).andReturn("Variable: var1=val1"); - expect(socketConnectionFacade.readLine()).andReturn("Variable: var2=val2"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly two events dispatched", 2, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a AgentCalledEvent", AgentCalledEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - - AgentCalledEvent event = (AgentCalledEvent) dispatcher.dispatchedEvents.get(0); - assertEquals("Returned event is of wrong type", AgentCalledEvent.class, event.getClass()); - assertEquals("Property variables[var1] is not set correctly", "val1", event.getVariables().get("var1")); - assertEquals("Property variables[var2] is not set correctly", "val2", event.getVariables().get("var2")); - assertEquals("Invalid size of variables property", 2, event.getVariables().size()); - - assertEquals("second event must be an DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(1).getClass()); - } - - @Test - public void testRunReceivingEventWithMapPropertyAndOnlyOneEntry() throws Exception - { - expect(socketConnectionFacade.readLine()).andReturn("Event: AgentCalled"); - expect(socketConnectionFacade.readLine()).andReturn("Variable: var1=val1"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly two events dispatched", 2, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a AgentCalledEvent", AgentCalledEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - - AgentCalledEvent event = (AgentCalledEvent) dispatcher.dispatchedEvents.get(0); - assertEquals("Returned event is of wrong type", AgentCalledEvent.class, event.getClass()); - assertEquals("Property variables[var1] is not set correctly", "val1", event.getVariables().get("var1")); - assertEquals("Invalid size of variables property", 1, event.getVariables().size()); - - assertEquals("second event must be an DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(1).getClass()); - } - - @Test - public void testWorkaroundForAsteriskBug13319() throws Exception - { - expect(socketConnectionFacade.readLine()).andReturn("Event: RTCPReceived"); - expect(socketConnectionFacade.readLine()).andReturn("From 192.168.0.1:1234"); - expect(socketConnectionFacade.readLine()).andReturn("HighestSequence: 999"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly two events dispatched", 2, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a RtcpReceivedEvent", RtcpReceivedEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - - RtcpReceivedEvent rtcpReceivedEvent = (RtcpReceivedEvent) dispatcher.dispatchedEvents.get(0); - assertEquals("Invalid from address on RtcpReceivedEvent", "192.168.0.1", - rtcpReceivedEvent.getFromAddress().getHostAddress()); - assertEquals("Invalid from port on RtcpReceivedEvent", new Integer(1234), rtcpReceivedEvent.getFromPort()); - assertEquals("Invalid highest sequence on RtcpReceivedEvent", new Long(999), rtcpReceivedEvent.getHighestSequence()); - - assertEquals("second event must be a DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(1).getClass()); - } - - // todo fix testRunReceivingUserEvent - public void XtestRunReceivingUserEvent() throws Exception - { - managerReader.registerEventClass(MyUserEvent.class); - - expect(socketConnectionFacade.readLine()).andReturn("Event: MyUser"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly two events dispatched", 2, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a MyUserEvent", MyUserEvent.class, dispatcher.dispatchedEvents.get(0).getClass()); - - assertEquals("second event must be a DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(1).getClass()); - } - - @Test - public void testRunReceivingResponse() throws Exception - { - expect(socketConnectionFacade.readLine()).andReturn("Response: Success"); - expect(socketConnectionFacade.readLine()).andReturn("Message: Authentication accepted"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly one response dispatched", 1, dispatcher.dispatchedResponses.size()); - - assertEquals("first response must be a ManagerResponse", ManagerResponse.class, - dispatcher.dispatchedResponses.get(0).getClass()); - - assertEquals("ManagerResponse contains incorrect response", "Success", - dispatcher.dispatchedResponses.get(0).getResponse()); - - assertEquals("ManagerResponse contains incorrect message", "Authentication accepted", - dispatcher.dispatchedResponses.get(0).getMessage()); - - assertEquals("ManagerResponse contains incorrect message (via getAttribute)", "Authentication accepted", - dispatcher.dispatchedResponses.get(0).getAttribute("MESSAGE")); - - assertEquals("ManagerResponse contains incorrect dateReceived", now, - dispatcher.dispatchedResponses.get(0).getDateReceived()); - - assertEquals("not exactly one events dispatched", 1, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - } - - @Test - public void testRunReceivingCommandResponse() throws Exception - { - List result = new ArrayList(); - - expect(socketConnectionFacade.readLine()).andReturn("Response: Follows"); - expect(socketConnectionFacade.readLine()).andReturn("ActionID: 678#12345"); - expect(socketConnectionFacade.readLine()).andReturn("Line1\nLine2\n--END COMMAND--"); - expect(socketConnectionFacade.readLine()).andReturn(""); - expect(socketConnectionFacade.readLine()).andReturn(null); - - result.add("Line1"); - result.add("Line2"); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.expectResponseClass("678", CommandResponse.class); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("not exactly one response dispatched", 1, dispatcher.dispatchedResponses.size()); - - assertEquals("first response must be a CommandResponse", CommandResponse.class, - dispatcher.dispatchedResponses.get(0).getClass()); - - assertEquals("CommandResponse contains incorrect response", "Follows", - dispatcher.dispatchedResponses.get(0).getResponse()); - - assertEquals("CommandResponse contains incorrect actionId", "678#12345", - dispatcher.dispatchedResponses.get(0).getActionId()); - - assertEquals("CommandResponse contains incorrect actionId (via getAttribute)", "678#12345", - dispatcher.dispatchedResponses.get(0).getAttribute("actionId")); - - assertEquals("CommandResponse contains incorrect result", result, - ((CommandResponse) dispatcher.dispatchedResponses.get(0)).getResult()); - - assertEquals("CommandResponse contains incorrect dateReceived", now, - dispatcher.dispatchedResponses.get(0).getDateReceived()); - } - - @Test - public void testRunCatchingIOException() throws Exception - { - expect(socketConnectionFacade.readLine()).andThrow(new IOException("Something happened to the network...")); - - replay(socketConnectionFacade); - - managerReader.setSocket(socketConnectionFacade); - managerReader.run(); - - verify(socketConnectionFacade); - - assertEquals("must not dispatch a response", 0, dispatcher.dispatchedResponses.size()); - - assertEquals("not exactly one events dispatched", 1, dispatcher.dispatchedEvents.size()); - - assertEquals("first event must be a DisconnectEvent", DisconnectEvent.class, - dispatcher.dispatchedEvents.get(0).getClass()); - } - - private class MockedDispatcher implements Dispatcher - { - List dispatchedEvents; - List dispatchedResponses; - - public MockedDispatcher() - { - this.dispatchedEvents = new ArrayList(); - this.dispatchedResponses = new ArrayList(); - } - - public void dispatchResponse(ManagerResponse response) - { - dispatchedResponses.add(response); - } - - public void dispatchEvent(ManagerEvent event) - { - dispatchedEvents.add(event); - } - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ManagerReaderMock.java b/src/test/java/org/asteriskjava/manager/internal/ManagerReaderMock.java deleted file mode 100644 index d3c8f0a0f..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ManagerReaderMock.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.io.IOException; - -import org.asteriskjava.manager.event.ManagerEvent; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.SocketConnectionFacade; - -public class ManagerReaderMock implements ManagerReader -{ - public int setSocketCalls = 0; - public int dieCalls = 0; - public int runCalls = 0; - - public ManagerReaderMock() - { - - } - - public void registerEventClass(Class< ? extends ManagerEvent> event) - { - throw new UnsupportedOperationException(); - } - - public void setSocket(SocketConnectionFacade socket) - { - setSocketCalls++; - } - - public void expectResponseClass(String actionId, Class< ? extends ManagerResponse> responseClass) - { - - } - - public void die() - { - dieCalls++; - } - - public boolean isDead() - { - return false; - } - - public void run() - { - runCalls++; - } - - public IOException getTerminationException() - { - return null; - } - - @Override - public void deregisterEventClass(Class< ? extends ManagerEvent> eventClass) - { - - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ManagerWriterImplTest.java b/src/test/java/org/asteriskjava/manager/internal/ManagerWriterImplTest.java deleted file mode 100644 index ba2289038..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ManagerWriterImplTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.asteriskjava.manager.action.StatusAction; -import org.asteriskjava.util.SocketConnectionFacade; -import org.junit.Before; -import org.junit.Test; - -public class ManagerWriterImplTest -{ - private ManagerWriter managerWriter; - - @Before - public void setUp() - { - managerWriter = new ManagerWriterImpl(); - } - - @SuppressWarnings("cast") - @Test - public void testSendActionWithoutSocket() throws Exception - { - try - { - managerWriter.sendAction(new StatusAction(), null); - fail("Must throw IllegalStateException"); - } - catch (IllegalStateException e) - { - assertTrue("Exception must be of type IllegalStateException", e instanceof IllegalStateException); - } - } - - @Test - public void testSendAction() throws Exception - { - SocketConnectionFacade socketConnectionFacade; - - socketConnectionFacade = createMock(SocketConnectionFacade.class); - socketConnectionFacade.write("action: Status\r\n\r\n"); - socketConnectionFacade.flush(); - replay(socketConnectionFacade); - - managerWriter.setSocket(socketConnectionFacade); - managerWriter.sendAction(new StatusAction(), null); - verify(socketConnectionFacade); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ManagerWriterMock.java b/src/test/java/org/asteriskjava/manager/internal/ManagerWriterMock.java deleted file mode 100644 index fa8383ce6..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ManagerWriterMock.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.io.IOException; - -import org.asteriskjava.AsteriskVersion; -import org.asteriskjava.manager.action.ChallengeAction; -import org.asteriskjava.manager.action.LoginAction; -import org.asteriskjava.manager.action.LogoffAction; -import org.asteriskjava.manager.action.ManagerAction; -import org.asteriskjava.manager.event.ProtocolIdentifierReceivedEvent; -import org.asteriskjava.manager.response.ChallengeResponse; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.asteriskjava.util.DateUtil; -import org.asteriskjava.util.SocketConnectionFacade; - -public class ManagerWriterMock implements ManagerWriter -{ - private static final String CHALLENGE = "12345"; - private static final long CONNECT_LATENCY = 50; - private static final long RESPONSE_LATENCY = 20; - - private Dispatcher dispatcher; - - private String expectedKey; - private String expectedUsername; - private boolean sendResponse = true; - private boolean sendProtocolIdentifierReceivedEvent = true; - - public int challengeActionsSent = 0; - public int loginActionsSent = 0; - public int logoffActionsSent = 0; - public int otherActionsSent = 0; - - public ManagerWriterMock() - { - } - - public void setTargetVersion(AsteriskVersion version) - { - } - - public void setDispatcher(Dispatcher dispatcher) - { - this.dispatcher = dispatcher; - } - - public void setExpectedKey(String key) - { - this.expectedKey = key; - } - - public void setExpectedUsername(String username) - { - this.expectedUsername = username; - } - - public void setSendResponse(boolean sendResponse) - { - this.sendResponse = sendResponse; - } - - public void setSendProtocolIdentifierReceivedEvent(boolean sendConnectEvent) - { - this.sendProtocolIdentifierReceivedEvent = sendConnectEvent; - } - - public void setSocket(SocketConnectionFacade socket) - { - if (sendProtocolIdentifierReceivedEvent) - { - Thread future = new Thread(new Runnable() - { - public void run() - { - try - { - Thread.sleep(CONNECT_LATENCY); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - ProtocolIdentifierReceivedEvent protocolIdentifierReceivedEvent; - protocolIdentifierReceivedEvent = new ProtocolIdentifierReceivedEvent(this); - protocolIdentifierReceivedEvent.setProtocolIdentifier("Asterisk Call Manager/1.0"); - protocolIdentifierReceivedEvent.setDateReceived(DateUtil.getDate()); - dispatcher.dispatchEvent(protocolIdentifierReceivedEvent); - } - }); - future.start(); - } - } - - public void sendAction(ManagerAction action, String internalActionId) throws IOException - { - if (action instanceof ChallengeAction) - { - ChallengeAction challengeAction = (ChallengeAction) action; - String authType = challengeAction.getAuthType(); - - if (!authType.equals("MD5")) - { - throw new RuntimeException("Expected authType 'MD5' got '" + authType + "'"); - } - - challengeActionsSent++; - - if (sendResponse) - { - ChallengeResponse challengeResponse; - - challengeResponse = new ChallengeResponse(); - challengeResponse.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId)); - challengeResponse.setChallenge(CHALLENGE); - dispatchLater(challengeResponse); - } - } - else if (action instanceof LoginAction) - { - - LoginAction loginAction = (LoginAction) action; - String username = loginAction.getUsername(); - String key = loginAction.getKey(); - String authType = loginAction.getAuthType(); - - if (!"MD5".equals(authType)) - { - throw new RuntimeException("Expected authType 'MD5' got '" + authType + "'"); - } - - if (!expectedUsername.equals(username)) - { - throw new RuntimeException("Expected username '" + expectedUsername + "' got '" + username + "'"); - } - - loginActionsSent++; - - if (sendResponse) - { - ManagerResponse loginResponse; - - // let testReconnectWithKeepAliveAfterAuthenticationFailure - // succeed after - // 3 unsuccessful attempts - if (key.equals(expectedKey) || loginActionsSent > 2) - { - loginResponse = new ManagerResponse(); - loginResponse.setResponse("Success"); - } - else - { - loginResponse = new ManagerError(); - loginResponse.setResponse("Error"); - loginResponse.setMessage("Authentication failed"); - } - loginResponse.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId)); - dispatchLater(loginResponse); - } - } - else if (action instanceof LogoffAction) - { - logoffActionsSent++; - - if (sendResponse) - { - ManagerResponse response; - - response = new ManagerResponse(); - response.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId)); - response.setResponse("Success"); - dispatchLater(response); - } - } - else - { - otherActionsSent++; - - if (sendResponse) - { - ManagerResponse response; - - response = new ManagerResponse(); - response.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId)); - response.setResponse("Success"); - dispatchLater(response); - } - } - } - - private void dispatchLater(final ManagerResponse response) - { - Thread future = new Thread(new Runnable() - { - public void run() - { - try - { - Thread.sleep(RESPONSE_LATENCY); - } - catch (InterruptedException e) - { - Thread.currentThread().interrupt(); - } - dispatcher.dispatchResponse(response); - } - }); - future.start(); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/MyUserEvent.java b/src/test/java/org/asteriskjava/manager/internal/MyUserEvent.java deleted file mode 100644 index aedd4176a..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/MyUserEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import java.util.Map; - -import org.asteriskjava.manager.event.UserEvent; - -public class MyUserEvent extends UserEvent -{ - private static final long serialVersionUID = 3689913989471418169L; - - private String stringMember; - private Map mapMember; - - public MyUserEvent(Object source) - { - super(source); - } - - /** - * @return the mapMember - */ - public Map getMapMember() - { - return mapMember; - } - - /** - * @param mapMember the mapMember to set - */ - public void setMapMember(Map mapMember) - { - this.mapMember = mapMember; - } - - /** - * @return the stringMember - */ - public String getStringMember() - { - return stringMember; - } - - /** - * @param stringMember the stringMember to set - */ - public void setStringMember(String stringMember) - { - this.stringMember = stringMember; - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/ResponseBuilderImplTest.java b/src/test/java/org/asteriskjava/manager/internal/ResponseBuilderImplTest.java deleted file mode 100644 index 31a0ec9f0..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/ResponseBuilderImplTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; - -import org.asteriskjava.manager.response.ChallengeResponse; -import org.asteriskjava.manager.response.ExtensionStateResponse; -import org.asteriskjava.manager.response.MailboxCountResponse; -import org.asteriskjava.manager.response.MailboxStatusResponse; -import org.asteriskjava.manager.response.ManagerError; -import org.asteriskjava.manager.response.ManagerResponse; -import org.junit.Before; -import org.junit.Test; - -public class ResponseBuilderImplTest -{ - private ResponseBuilderImpl responseBuilder; - private Map attributes; - - @Before - public void setUp() - { - this.responseBuilder = new ResponseBuilderImpl(); - this.attributes = new HashMap(); - } - - @Test - public void testBuildResponse() - { - ManagerResponse response; - - attributes.put("response", "Success"); - - response = responseBuilder.buildResponse(ManagerResponse.class, attributes); - assertEquals("Response of wrong type", ManagerResponse.class, response.getClass()); - assertEquals("Response not set correctly", "Success", response.getResponse()); - } - - @Test - public void testBuildResponseWithoutResponseClass() - { - ManagerResponse response; - - attributes.put("response", "Success"); - - response = responseBuilder.buildResponse(null, attributes); - assertEquals("Response of wrong type", ManagerResponse.class, response.getClass()); - assertEquals("Response not set correctly", "Success", response.getResponse()); - } - - @Test - public void testBuildError() - { - ManagerResponse response; - - attributes.put("response", "Error"); - attributes.put("message", "Missing action in request"); - - response = responseBuilder.buildResponse(ManagerResponse.class, attributes); - assertEquals("Response of wrong type", ManagerError.class, response.getClass()); - assertEquals("Message not set correctly", "Missing action in request", response.getMessage()); - } - - @Test - public void testBuildErrorWithActionId() - { - ManagerResponse response; - - attributes.put("response", "Error"); - attributes.put("actionid", "1234"); - attributes.put("message", "Missing action in request"); - - response = responseBuilder.buildResponse(ManagerResponse.class, attributes); - assertEquals("ActionId not set correctly", "1234", response.getActionId()); - } - - @Test - public void testBuildChallengeResponse() - { - ManagerResponse response; - - attributes.put("response", "Success"); - attributes.put("challenge", "131494410"); - - response = responseBuilder.buildResponse(ChallengeResponse.class, attributes); - assertEquals("Response of wrong type", ChallengeResponse.class, response.getClass()); - assertEquals("Challenge not set correctly", "131494410", ((ChallengeResponse) response).getChallenge()); - } - - @Test - public void testBuildMailboxStatusResponse() - { - ManagerResponse response; - - attributes.put("response", "Success"); - attributes.put("message", "Mailbox Status"); - attributes.put("mailbox", "123"); - attributes.put("waiting", "1"); - - response = responseBuilder.buildResponse(MailboxStatusResponse.class, attributes); - assertEquals("Response of wrong type", MailboxStatusResponse.class, response.getClass()); - - MailboxStatusResponse mailboxStatusResponse = (MailboxStatusResponse) response; - assertEquals("Mailbox not set correctly", "123", mailboxStatusResponse.getMailbox()); - assertEquals("Waiting not set correctly", Boolean.TRUE, mailboxStatusResponse.getWaiting()); - } - - @Test - public void testBuildMailboxStatusResponseWithNoWaiting() - { - ManagerResponse response; - - attributes.put("response", "Success"); - attributes.put("message", "Mailbox Status"); - attributes.put("mailbox", "123,user2"); - attributes.put("waiting", "0"); - - response = responseBuilder.buildResponse(MailboxStatusResponse.class, attributes); - assertEquals("Response of wrong type", MailboxStatusResponse.class, response.getClass()); - - MailboxStatusResponse mailboxStatusResponse = (MailboxStatusResponse) response; - assertEquals("Mailbox not set correctly", "123,user2", mailboxStatusResponse.getMailbox()); - assertEquals("Waiting not set correctly", Boolean.FALSE, mailboxStatusResponse.getWaiting()); - } - - @Test - public void testBuildMailboxCountResponse() - { - ManagerResponse response; - - attributes.put("response", "Success"); - attributes.put("message", "Mailbox Message Count"); - attributes.put("mailbox", "123@myctx"); - attributes.put("newmessages", "2"); - attributes.put("oldmessages", "5"); - - response = responseBuilder.buildResponse(MailboxCountResponse.class, attributes); - assertEquals("Response of wrong type", MailboxCountResponse.class, response.getClass()); - - MailboxCountResponse mailboxCountResponse = (MailboxCountResponse) response; - assertEquals("Mailbox not set correctly", "123@myctx", mailboxCountResponse.getMailbox()); - assertEquals("New messages not set correctly", Integer.valueOf(2), mailboxCountResponse.getNewMessages()); - assertEquals("Old messages set correctly", Integer.valueOf(5), mailboxCountResponse.getOldMessages()); - } - - @Test - public void testBuildExtensionStateResponse() - { - ManagerResponse response; - - attributes.put("response", "Success"); - attributes.put("message", "Extension Status"); - attributes.put("exten", "1"); - attributes.put("context", "default"); - attributes.put("hint", ""); - attributes.put("status", "-1"); - - response = responseBuilder.buildResponse(ExtensionStateResponse.class, attributes); - assertEquals("Response of wrong type", ExtensionStateResponse.class, response.getClass()); - - ExtensionStateResponse extensionStateResponse = (ExtensionStateResponse) response; - assertEquals("Exten not set correctly", "1", extensionStateResponse.getExten()); - assertEquals("Context not set correctly", "default", extensionStateResponse.getContext()); - assertEquals("Hint not set correctly", "", extensionStateResponse.getHint()); - assertEquals("Status not set correctly", Integer.valueOf(-1), extensionStateResponse.getStatus()); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/UserEventC.java b/src/test/java/org/asteriskjava/manager/internal/UserEventC.java deleted file mode 100644 index 389ca1318..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/UserEventC.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.manager.event.UserEvent; - -public class UserEventC extends UserEvent -{ - private static final long serialVersionUID = 3545240219457894199L; - - public UserEventC(Object source) - { - super(source); - } -} diff --git a/src/test/java/org/asteriskjava/manager/internal/UserEventDEvent.java b/src/test/java/org/asteriskjava/manager/internal/UserEventDEvent.java deleted file mode 100644 index 0e4324b79..000000000 --- a/src/test/java/org/asteriskjava/manager/internal/UserEventDEvent.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2004-2006 Stefan Reuter - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.asteriskjava.manager.internal; - -import org.asteriskjava.manager.event.UserEvent; - -public class UserEventDEvent extends UserEvent -{ - private static final long serialVersionUID = 3545240219457894199L; - - public UserEventDEvent(Object source) - { - super(source); - } -} diff --git a/src/test/java/org/asteriskjava/manager/response/CoreStatusResponseTest.java b/src/test/java/org/asteriskjava/manager/response/CoreStatusResponseTest.java deleted file mode 100644 index 16529b8c5..000000000 --- a/src/test/java/org/asteriskjava/manager/response/CoreStatusResponseTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.asteriskjava.manager.response; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class CoreStatusResponseTest -{ - private TimeZone tz = TimeZone.getTimeZone("Europe/Berlin"); - private CoreStatusResponse response; - private TimeZone defaultTimeZone; - - @Before - public void setUp() - { - this.response = new CoreStatusResponse(); - defaultTimeZone = TimeZone.getDefault(); - TimeZone.setDefault(tz); - } - - @After - public void tearDown() - { - TimeZone.setDefault(defaultTimeZone); - } - - @Test - public void testGetCoreStartupTimeAsDate() - { - assertNotNull("TimeZone not found", tz); - response.setCoreStartupDate("2009-05-27"); - response.setCoreStartupTime("02:49:15"); - - assertEquals("Wed May 27 02:49:15 CEST 2009", response.getCoreStartupDateTimeAsDate(tz).toString()); - } - - @Test - public void testGetCoreStartupTimeAsDateIfDateIsNull() - { - assertNotNull("TimeZone not found", tz); - response.setCoreStartupDate(null); // before Asterisk 1.6.2 - response.setCoreStartupTime("02:49:15"); - - assertNull(response.getCoreStartupDateTimeAsDate(tz)); - } -} diff --git a/src/test/java/org/asteriskjava/manager/response/SipShowPeerResponseTest.java b/src/test/java/org/asteriskjava/manager/response/SipShowPeerResponseTest.java deleted file mode 100644 index 9002a77b0..000000000 --- a/src/test/java/org/asteriskjava/manager/response/SipShowPeerResponseTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.asteriskjava.manager.response; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -public class SipShowPeerResponseTest -{ - private SipShowPeerResponse response; - - @Before - public void setUp() - { - response = new SipShowPeerResponse(); - } - - @Test - public void testSetQualifyFreq() - { - response.setQualifyFreq("6000 ms"); - assertEquals("Incorrect qualifyFreq", 6000, (int) response.getQualifyFreq()); - } - - @Test - public void testSetQualifyFreqWithWorkaround() - { - response.setQualifyFreq(": 6000 ms\n"); - assertEquals("Incorrect qualifyFreq", 6000, (int) response.getQualifyFreq()); - } - - @Test - public void testSetQualifyFreqWithWorkaroundAndChanVariable() - { - response.setQualifyFreq(": 60000 ms\nChanVariable:\n PHBX_ID,191"); - assertEquals("Incorrect qualifyFreq", 60000, (int) response.getQualifyFreq()); - } - - @Test - public void testSetMohsuggest() - { - response.setMohsuggest("default"); - assertEquals("Incorrect mohsuggest", "default",response.getMohsuggest()); - } - - -} diff --git a/src/test/java/org/asteriskjava/pbx/agi/RateLimiterTest.java b/src/test/java/org/asteriskjava/pbx/agi/RateLimiterTest.java deleted file mode 100644 index bbd63098c..000000000 --- a/src/test/java/org/asteriskjava/pbx/agi/RateLimiterTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.asteriskjava.pbx.agi; - -import static org.junit.Assert.assertTrue; - -import org.asteriskjava.pbx.agi.RateLimiter; -import org.junit.Test; - -public class RateLimiterTest -{ - - @Test - public void test() throws InterruptedException - { - long now = System.currentTimeMillis(); - RateLimiter limiter = new RateLimiter(3); - for (int i = 0; i < 15; i++) - { - limiter.acquire(); - - System.out.println(System.currentTimeMillis()); - Thread.sleep(100); - } - - // this should have taken around 5 seconds - assertTrue(System.currentTimeMillis() - now > 4000L); - } - -} diff --git a/src/test/java/org/asteriskjava/util/AstUtilTest.java b/src/test/java/org/asteriskjava/util/AstUtilTest.java deleted file mode 100644 index 381ae54f4..000000000 --- a/src/test/java/org/asteriskjava/util/AstUtilTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.asteriskjava.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class AstUtilTest -{ - @Test - public void testIsTrue() - { - assertTrue("on must be true", AstUtil.isTrue("on")); - assertTrue("ON must be true", AstUtil.isTrue("ON")); - assertTrue("Enabled must be true", AstUtil.isTrue("Enabled")); - assertTrue("true must be true", AstUtil.isTrue("true")); - assertFalse("false must be false", AstUtil.isTrue("false")); - assertFalse("null must be false", AstUtil.isTrue(null)); - } - - @Test - public void testParseCallerIdName() - { - assertEquals("Hans Wurst", AstUtil.parseCallerId("\"Hans Wurst\"<1234>")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId("\"Hans Wurst\" <1234>")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId("\" Hans Wurst \" <1234>")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId(" \"Hans Wurst \" <1234> ")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId(" \" Hans Wurst \" <1234> ")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId("Hans Wurst <1234>")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId(" Hans Wurst <1234> ")[0]); - assertEquals("Hans ", AstUtil.parseCallerId("\"Hans \" <1234>")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId("Hans Wurst")[0]); - assertEquals("Hans Wurst", AstUtil.parseCallerId(" Hans Wurst ")[0]); - assertEquals(null, AstUtil.parseCallerId("<1234>")[0]); - assertEquals(null, AstUtil.parseCallerId(" <1234> ")[0]); - assertEquals("<1234", AstUtil.parseCallerId(" <1234 ")[0]); - assertEquals("1234>", AstUtil.parseCallerId(" 1234> ")[0]); - assertEquals(null, AstUtil.parseCallerId(null)[0]); - assertEquals(null, AstUtil.parseCallerId("")[0]); - assertEquals(null, AstUtil.parseCallerId(" ")[0]); - } - - @Test - public void testParseCallerIdNumber() - { - assertEquals("1234", AstUtil.parseCallerId("\"Hans Wurst\"<1234>")[1]); - assertEquals("1234", AstUtil.parseCallerId("\"Hans Wurst\" <1234>")[1]); - assertEquals("1234", AstUtil.parseCallerId("Hans Wurst < 1234 > ")[1]); - assertEquals(null, AstUtil.parseCallerId("\"Hans Wurst\"")[1]); - assertEquals(null, AstUtil.parseCallerId("Hans Wurst")[1]); - assertEquals(null, AstUtil.parseCallerId("Hans Wurst <>")[1]); - assertEquals(null, AstUtil.parseCallerId("Hans Wurst < > ")[1]); - assertEquals(null, AstUtil.parseCallerId(null)[1]); - assertEquals(null, AstUtil.parseCallerId("")[1]); - assertEquals(null, AstUtil.parseCallerId(" ")[1]); - } - - @Test - public void testAJ120() - { - String s = "\"3496853210\" <3496853210>"; - assertEquals("3496853210", AstUtil.parseCallerId(s)[0]); - assertEquals("3496853210", AstUtil.parseCallerId(s)[1]); - } - - @Test - public void testIsNull() - { - assertTrue("null must be null", AstUtil.isNull(null)); - assertTrue("unknown must be null", AstUtil.isNull("unknown")); - assertTrue(" must be null", AstUtil.isNull("")); - } - - @Test - public void testIsNullForIpAddressInPeerEntryEvent() - { - assertTrue("\"-none-\" must be considered null", AstUtil.isNull("-none-")); - } -} diff --git a/src/test/java/org/asteriskjava/util/DateUtilTest.java b/src/test/java/org/asteriskjava/util/DateUtilTest.java deleted file mode 100644 index 081adf121..000000000 --- a/src/test/java/org/asteriskjava/util/DateUtilTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.asteriskjava.util; - -import static org.junit.Assert.assertEquals; - -import java.util.Date; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class DateUtilTest -{ - TimeZone defaultTimeZone; - final String dateString = "2006-05-19 11:54:48"; - - @Before - public void setUp() - { - defaultTimeZone = TimeZone.getDefault(); - TimeZone.setDefault(TimeZone.getTimeZone("GMT")); - } - - @After - public void tearDown() - { - TimeZone.setDefault(defaultTimeZone); - } - - @Test - public void testGetStartTimeAsDate() - { - final Date result = DateUtil.parseDateTime(dateString); - assertEquals(1148039688000L, result.getTime()); - assertEquals("Fri May 19 11:54:48 GMT 2006", result.toString()); - } - - @Test - public void testGetStartTimeAsDateWithTimeZone() - { - final TimeZone tz = TimeZone.getTimeZone("GMT+2"); - final Date result = DateUtil.parseDateTime(dateString, tz); - assertEquals(1148032488000L, result.getTime()); - assertEquals("Fri May 19 09:54:48 GMT 2006", result.toString()); - } -} diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties deleted file mode 100644 index d35b4c93b..000000000 --- a/src/test/resources/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootCategory=INFO, Console -log4j.category.org.asteriskjava.live=DEBUG - -log4j.appender.Console=org.apache.log4j.ConsoleAppender -log4j.appender.Console.layout=org.apache.log4j.PatternLayout -log4j.appender.Console.layout.ConversionPattern=%d %c %p [%t] - %m\n \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml deleted file mode 100644 index 757aa32de..000000000 --- a/src/test/resources/logback.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - \ No newline at end of file diff --git a/src/test/resources/test-mapping.properties b/src/test/resources/test-mapping.properties deleted file mode 100644 index 4d8bace3b..000000000 --- a/src/test/resources/test-mapping.properties +++ /dev/null @@ -1,3 +0,0 @@ -hello.agi = org.asteriskjava.fastagi.HelloAgiScript -string.agi = java.lang.String -nonexisting.agi = org.asteriskjava.fastagi.NonExistingAgiScript \ No newline at end of file diff --git a/src/test/resources/test1-fastagi.properties b/src/test/resources/test1-fastagi.properties deleted file mode 100644 index aa40f3e71..000000000 --- a/src/test/resources/test1-fastagi.properties +++ /dev/null @@ -1 +0,0 @@ -port = 1234 \ No newline at end of file diff --git a/src/test/resources/test2-fastagi.properties b/src/test/resources/test2-fastagi.properties deleted file mode 100644 index ea1b81e91..000000000 --- a/src/test/resources/test2-fastagi.properties +++ /dev/null @@ -1 +0,0 @@ -bindPort = 2345 \ No newline at end of file