asterisk-java-cvs Mailing List for Asterisk-Java Library (Page 79)
Brought to you by:
srt
You can subscribe to this list here.
2005 |
Jan
(4) |
Feb
(75) |
Mar
(211) |
Apr
(70) |
May
(12) |
Jun
(7) |
Jul
(96) |
Aug
(90) |
Sep
(11) |
Oct
(42) |
Nov
(45) |
Dec
(4) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(20) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(32) |
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(10) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(3) |
Aug
(73) |
Sep
(13) |
Oct
(4) |
Nov
(1) |
Dec
(7) |
2009 |
Jan
(1) |
Feb
(2) |
Mar
(48) |
Apr
(21) |
May
(14) |
Jun
(11) |
Jul
(9) |
Aug
(2) |
Sep
(11) |
Oct
(14) |
Nov
(6) |
Dec
(4) |
2010 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
|
Dec
(12) |
2011 |
Jan
(1) |
Feb
(5) |
Mar
(7) |
Apr
(1) |
May
(1) |
Jun
|
Jul
|
Aug
(10) |
Sep
|
Oct
(5) |
Nov
|
Dec
|
2012 |
Jan
(3) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
(2) |
Dec
(2) |
2013 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(5) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(25) |
May
(10) |
Jun
(4) |
Jul
(7) |
Aug
(4) |
Sep
(1) |
Oct
(1) |
Nov
(3) |
Dec
(1) |
2016 |
Jan
|
Feb
(42) |
Mar
(6) |
Apr
(15) |
May
(3) |
Jun
(1) |
Jul
(11) |
Aug
|
Sep
|
Oct
(17) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
(4) |
Mar
(1) |
Apr
(3) |
May
(2) |
Jun
(3) |
Jul
(7) |
Aug
(11) |
Sep
(5) |
Oct
(7) |
Nov
(4) |
Dec
(4) |
2018 |
Jan
(11) |
Feb
(11) |
Mar
(3) |
Apr
|
May
(9) |
Jun
(6) |
Jul
(17) |
Aug
(9) |
Sep
(2) |
Oct
(4) |
Nov
(3) |
Dec
(3) |
2019 |
Jan
(13) |
Feb
(1) |
Mar
(1) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(6) |
Sep
|
Oct
|
Nov
(3) |
Dec
|
2020 |
Jan
(2) |
Feb
(72) |
Mar
(8) |
Apr
(11) |
May
(12) |
Jun
(3) |
Jul
(12) |
Aug
(3) |
Sep
(5) |
Oct
(4) |
Nov
|
Dec
(9) |
2021 |
Jan
|
Feb
(31) |
Mar
(6) |
Apr
(3) |
May
|
Jun
(2) |
Jul
|
Aug
(2) |
Sep
|
Oct
(9) |
Nov
|
Dec
(32) |
2022 |
Jan
(5) |
Feb
(7) |
Mar
(2) |
Apr
(3) |
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
(2) |
Oct
(111) |
Nov
(105) |
Dec
(26) |
2023 |
Jan
(25) |
Feb
(6) |
Mar
(10) |
Apr
(54) |
May
(41) |
Jun
(24) |
Jul
(6) |
Aug
(11) |
Sep
(9) |
Oct
(8) |
Nov
(55) |
Dec
(34) |
2024 |
Jan
(6) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(89) |
Sep
(48) |
Oct
(31) |
Nov
(9) |
Dec
(19) |
2025 |
Jan
(12) |
Feb
(18) |
Mar
(9) |
Apr
(7) |
May
|
Jun
(7) |
Jul
(7) |
Aug
(3) |
Sep
(22) |
Oct
(2) |
Nov
|
Dec
|
From: Stefan R. <sr...@us...> - 2005-08-15 12:34:22
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14217/src/java/net/sf/asterisk/manager Modified Files: DefaultAsteriskManager.java Channel.java Log Message: Added callerid name to Channel Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -p -r1.17 -r1.18 --- DefaultAsteriskManager.java 8 Aug 2005 05:36:57 -0000 1.17 +++ DefaultAsteriskManager.java 15 Aug 2005 12:34:13 -0000 1.18 @@ -416,22 +416,34 @@ public class DefaultAsteriskManager protected void addChannel(Channel channel) { - channels.put(channel.getId(), channel); + synchronized (channels) + { + channels.put(channel.getId(), channel); + } } protected void removeChannel(Channel channel) { - channels.remove(channel.getId()); + synchronized (channels) + { + channels.remove(channel.getId()); + } } protected void addQueue(Queue queue) { - queues.put(queue.getName(), queue); + synchronized (queues) + { + queues.put(queue.getName(), queue); + } } protected void removeQueue(Queue queue) { - queues.remove(queue.getName()); + synchronized (queues) + { + queues.remove(queue.getName()); + } } protected void handleStatusEvent(StatusEvent event) @@ -440,7 +452,7 @@ public class DefaultAsteriskManager Extension extension; boolean isNew = false; - channel = (Channel) channels.get(event.getUniqueId()); + channel = getChannelById(event.getUniqueId()); if (channel == null) { channel = new Channel(event.getChannel(), event.getUniqueId()); @@ -466,6 +478,7 @@ public class DefaultAsteriskManager synchronized (channel) { channel.setCallerId(event.getCallerId()); + channel.setCallerIdName(event.getCallerIdName()); channel.setAccount(event.getAccount()); channel.setState(ChannelStateEnum.getEnum(event.getState())); channel.addExtension(extension); @@ -499,11 +512,11 @@ public class DefaultAsteriskManager { // reset version information as it might have changed while Asterisk // restarted - this.version = null; - this.versions = null; + version = null; + versions = null; - this.channels.clear(); - this.queues.clear(); + channels.clear(); + queues.clear(); } /** @@ -591,7 +604,7 @@ public class DefaultAsteriskManager * @param name name of the channel to return * @return the channel with the given name */ - private Channel getChannelByName(String name) + public Channel getChannelByName(String name) { Channel channel = null; @@ -610,11 +623,29 @@ public class DefaultAsteriskManager return channel; } + /** + * 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 + */ + public Channel getChannelById(String id) + { + Channel channel = null; + + synchronized (channels) + { + channel = (Channel) channels.get(id); + } + return channel; + } + protected void handleNewChannelEvent(NewChannelEvent event) { Channel channel = new Channel(event.getChannel(), event.getUniqueId()); channel.setCallerId(event.getCallerId()); + channel.setCallerIdName(event.getCallerIdName()); channel.setState(ChannelStateEnum.getEnum(event.getState())); logger.info("Adding channel " + channel.getName()); @@ -626,7 +657,7 @@ public class DefaultAsteriskManager Channel channel; Extension extension; - channel = (Channel) channels.get(event.getUniqueId()); + channel = getChannelById(event.getUniqueId()); if (channel == null) { logger.error("Ignored NewExtenEvent for unknown channel " @@ -646,7 +677,7 @@ public class DefaultAsteriskManager protected void handleNewStateEvent(NewStateEvent event) { - Channel channel = (Channel) channels.get(event.getUniqueId()); + Channel channel = getChannelById(event.getUniqueId()); if (channel == null) { @@ -660,7 +691,7 @@ public class DefaultAsteriskManager protected void handleHangupEvent(HangupEvent event) { - Channel channel = (Channel) channels.get(event.getUniqueId()); + Channel channel = getChannelById(event.getUniqueId()); if (channel == null) { logger.error("Ignored HangupEvent for unknown channel " @@ -737,7 +768,15 @@ public class DefaultAsteriskManager protected void handleRenameEvent(RenameEvent event) { - Channel channel = (Channel) channels.get(event.getUniqueId()); + Channel channel = getChannelById(event.getUniqueId()); + + if (channel == null) + { + logger + .error("Ignored RenameEvent for unknown channel with uniqueId " + + event.getUniqueId()); + return; + } logger.info("Renaming channel '" + channel.getName() + "' to '" + event.getNewname() + "'"); Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -p -r1.9 -r1.10 --- Channel.java 9 Aug 2005 00:08:48 -0000 1.9 +++ Channel.java 15 Aug 2005 12:34:13 -0000 1.10 @@ -50,6 +50,11 @@ public class Channel implements Serializ private String callerId; /** + * Caller ID Name of this channel. + */ + private String callerIdName; + + /** * State of this channel. */ private ChannelStateEnum state; @@ -161,7 +166,7 @@ public class Channel implements Serializ /** * Sets the caller id of this channel. * - * @param callerId the calleid id of this channel. + * @param callerId the caller id of this channel. */ public final void setCallerId(final String callerId) { @@ -169,6 +174,26 @@ public class Channel implements Serializ } /** + * Returns the caller id name of this channel. + * + * @return the caller id name of this channel. + */ + public final String getCallerIdName() + { + return callerIdName; + } + + /** + * Sets the caller id of this channel. + * + * @param callerIdName the caller id name of this channel. + */ + public final void setCallerIdName(final String callerIdName) + { + this.callerIdName = callerIdName; + } + + /** * Returns the state of this channel. * * @return the state of this channel. |
From: Stefan R. <sr...@us...> - 2005-08-12 22:48:42
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28941/src/java/net/sf/asterisk/fastagi Modified Files: Tag: RB_0_1 ResourceBundleMappingStrategy.java Log Message: Added logging for successful mappings Index: ResourceBundleMappingStrategy.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/ResourceBundleMappingStrategy.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -p -r1.2 -r1.2.2.1 --- ResourceBundleMappingStrategy.java 31 Mar 2005 22:29:52 -0000 1.2 +++ ResourceBundleMappingStrategy.java 12 Aug 2005 22:48:31 -0000 1.2.2.1 @@ -98,6 +98,7 @@ public class ResourceBundleMappingStrate } mapping.put(scriptName, agiScript); + logger.info("Added mapping for '" + scriptName + "' to " + scriptName); } } |
From: Stefan R. <sr...@us...> - 2005-08-10 03:52:40
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20946/src/java/net/sf/asterisk/manager Modified Files: Channel.java Log Message: Added javadoc for extension history Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -p -r1.8 -r1.9 --- Channel.java 8 Aug 2005 06:08:27 -0000 1.8 +++ Channel.java 9 Aug 2005 00:08:48 -0000 1.9 @@ -208,6 +208,12 @@ public class Channel implements Serializ this.account = account; } + /** + * Returns the last visited dialplan entry. + * + * @return the last visited dialplan entry. + * @since 0.2 + */ public final Extension getCurrentExtension() { Extension extension; @@ -227,6 +233,12 @@ public class Channel implements Serializ return extension; } + /** + * Returns the first visited dialplan entry. + * + * @return the first visited dialplan entry. + * @since 0.2 + */ public Extension getFirstExtension() { Extension extension; @@ -245,19 +257,31 @@ public class Channel implements Serializ return extension; } - + + /** + * Returns a list of all visited dialplan entries. + * + * @return a list of all visited dialplan entries. + * @since 0.2 + */ public List getExtensions() { List extensionsCopy; - + synchronized (extensions) { extensionsCopy = new ArrayList(extensions); } - + return extensionsCopy; } + /** + * Adds a visted dialplan entry to the history. + * + * @param extension the visted dialplan entry to add. + * @since 0.2 + */ public void addExtension(Extension extension) { synchronized (extensions) @@ -314,7 +338,7 @@ public class Channel implements Serializ int systemHashcode; sb = new StringBuffer(getClass().getName() + ": "); - + synchronized (this) { sb.append("id='" + getId() + "'; "); |
From: Stefan R. <sr...@us...> - 2005-08-08 06:10:27
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4691/src/java/net/sf/asterisk/manager Modified Files: Extension.java Log Message: No need for Extension.toString() to be synchronized as Extension is immutable... Index: Extension.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Extension.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- Extension.java 8 Aug 2005 06:09:09 -0000 1.4 +++ Extension.java 8 Aug 2005 06:10:18 -0000 1.5 @@ -99,22 +99,18 @@ public class Extension implements Serial return appData; } - public String toString() { StringBuffer sb; sb = new StringBuffer(getClass().getName() + ": "); - synchronized (this) - { - sb.append("date='" + getDate() + "'; "); - sb.append("context='" + getContext() + "'; "); - sb.append("extension='" + getExtension() + "'; "); - sb.append("priority='" + getPriority() + "'; "); - sb.append("application='" + getApplication() + "'; "); - sb.append("appData=" + getAppData() + "; "); - sb.append("systemHashcode=" + System.identityHashCode(this)); - } + sb.append("date='" + getDate() + "'; "); + sb.append("context='" + getContext() + "'; "); + sb.append("extension='" + getExtension() + "'; "); + sb.append("priority='" + getPriority() + "'; "); + sb.append("application='" + getApplication() + "'; "); + sb.append("appData=" + getAppData() + "; "); + sb.append("systemHashcode=" + System.identityHashCode(this)); return sb.toString(); } |
From: Stefan R. <sr...@us...> - 2005-08-08 06:09:18
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4517/src/java/net/sf/asterisk/manager Modified Files: Extension.java Log Message: Made toString() threadsafe Index: Extension.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Extension.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- Extension.java 8 Aug 2005 05:58:38 -0000 1.3 +++ Extension.java 8 Aug 2005 06:09:09 -0000 1.4 @@ -105,13 +105,16 @@ public class Extension implements Serial StringBuffer sb; sb = new StringBuffer(getClass().getName() + ": "); - sb.append("date='" + getDate() + "'; "); - sb.append("context='" + getContext() + "'; "); - sb.append("extension='" + getExtension() + "'; "); - sb.append("priority='" + getPriority() + "'; "); - sb.append("application='" + getApplication() + "'; "); - sb.append("appData=" + getAppData() + "; "); - sb.append("systemHashcode=" + System.identityHashCode(this)); + synchronized (this) + { + sb.append("date='" + getDate() + "'; "); + sb.append("context='" + getContext() + "'; "); + sb.append("extension='" + getExtension() + "'; "); + sb.append("priority='" + getPriority() + "'; "); + sb.append("application='" + getApplication() + "'; "); + sb.append("appData=" + getAppData() + "; "); + sb.append("systemHashcode=" + System.identityHashCode(this)); + } return sb.toString(); } |
From: Stefan R. <sr...@us...> - 2005-08-08 06:08:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4438/src/java/net/sf/asterisk/manager Modified Files: Channel.java Log Message: Made toString() threadsafe Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -p -r1.7 -r1.8 --- Channel.java 8 Aug 2005 05:59:16 -0000 1.7 +++ Channel.java 8 Aug 2005 06:08:27 -0000 1.8 @@ -310,14 +310,22 @@ public class Channel implements Serializ public String toString() { StringBuffer sb; + Channel linkedChannel; + int systemHashcode; sb = new StringBuffer(getClass().getName() + ": "); - sb.append("id='" + getId() + "'; "); - sb.append("name='" + getName() + "'; "); - sb.append("callerId='" + getCallerId() + "'; "); - sb.append("state='" + getState() + "'; "); - sb.append("account='" + getAccount() + "'; "); - sb.append("dateOfCreation=" + getDateOfCreation() + "; "); + + synchronized (this) + { + sb.append("id='" + getId() + "'; "); + sb.append("name='" + getName() + "'; "); + sb.append("callerId='" + getCallerId() + "'; "); + sb.append("state='" + getState() + "'; "); + sb.append("account='" + getAccount() + "'; "); + sb.append("dateOfCreation=" + getDateOfCreation() + "; "); + linkedChannel = this.linkedChannel; + systemHashcode = System.identityHashCode(this); + } if (linkedChannel == null) { sb.append("linkedChannel=null; "); @@ -325,14 +333,17 @@ public class Channel implements Serializ else { sb.append("linkedChannel=["); - sb.append(linkedChannel.getClass().getName() + ": "); - sb.append("id='" + linkedChannel.getId() + "'; "); - sb.append("name='" + linkedChannel.getName() + "'; "); - sb.append("systemHashcode=" - + System.identityHashCode(linkedChannel)); + synchronized (linkedChannel) + { + sb.append(linkedChannel.getClass().getName() + ": "); + sb.append("id='" + linkedChannel.getId() + "'; "); + sb.append("name='" + linkedChannel.getName() + "'; "); + sb.append("systemHashcode=" + + System.identityHashCode(linkedChannel)); + } sb.append("]; "); } - sb.append("systemHashcode=" + System.identityHashCode(this)); + sb.append("systemHashcode=" + systemHashcode); return sb.toString(); } |
From: Stefan R. <sr...@us...> - 2005-08-08 05:59:58
|
Update of /cvsroot/asterisk-java/asterisk-java/src/integrationtest/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3245/src/integrationtest/net/sf/asterisk/manager Added Files: TestExtensionHistory.java Log Message: Added to manual test extension history --- NEW FILE: TestExtensionHistory.java --- /* * (c) 2004 Stefan Reuter * * Created on Oct 28, 2004 */ package net.sf.asterisk.manager; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author srt * @version $Id: TestDefaultAsteriskManager.java,v 1.3 2005/07/16 13:19:34 srt * Exp $ */ public class TestExtensionHistory extends AsteriskManagerTestCase { public void testGetHistory() throws Exception { List channels; try { Thread.sleep(5000); } catch (InterruptedException e) { } channels = new ArrayList(manager.getChannels().values()); System.out.println("# of active channels: " + channels.size()); Iterator channelsIterator = channels.iterator(); while (channelsIterator.hasNext()) { Channel channel = (Channel) channelsIterator.next(); System.out.println(channel); System.out.println(" first extension: " + channel.getFirstExtension()); System.out.println(" current extension: " + channel.getCurrentExtension()); Iterator historyIterator = channel.getExtensions().iterator(); while (historyIterator.hasNext()) { Extension extension = (Extension) historyIterator.next(); System.out.println(" " + extension); } } } } |
From: Stefan R. <sr...@us...> - 2005-08-08 05:59:26
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3174/src/java/net/sf/asterisk/manager Modified Files: Channel.java Log Message: Added getExtension() that returns the extension history of this channel Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- Channel.java 8 Aug 2005 05:36:57 -0000 1.6 +++ Channel.java 8 Aug 2005 05:59:16 -0000 1.7 @@ -245,6 +245,18 @@ public class Channel implements Serializ return extension; } + + public List getExtensions() + { + List extensionsCopy; + + synchronized (extensions) + { + extensionsCopy = new ArrayList(extensions); + } + + return extensionsCopy; + } public void addExtension(Extension extension) { |
From: Stefan R. <sr...@us...> - 2005-08-08 05:58:49
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3116/src/java/net/sf/asterisk/manager Modified Files: Extension.java Log Message: Added toString() Index: Extension.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Extension.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- Extension.java 8 Aug 2005 05:31:11 -0000 1.2 +++ Extension.java 8 Aug 2005 05:58:38 -0000 1.3 @@ -69,6 +69,11 @@ public class Extension implements Serial this.appData = appData; } + public Date getDate() + { + return date; + } + public String getContext() { return context; @@ -93,4 +98,21 @@ public class Extension implements Serial { return appData; } + + + public String toString() + { + StringBuffer sb; + + sb = new StringBuffer(getClass().getName() + ": "); + sb.append("date='" + getDate() + "'; "); + sb.append("context='" + getContext() + "'; "); + sb.append("extension='" + getExtension() + "'; "); + sb.append("priority='" + getPriority() + "'; "); + sb.append("application='" + getApplication() + "'; "); + sb.append("appData=" + getAppData() + "; "); + sb.append("systemHashcode=" + System.identityHashCode(this)); + + return sb.toString(); + } } |
From: Stefan R. <sr...@us...> - 2005-08-08 05:37:08
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv864/src/java/net/sf/asterisk/manager Modified Files: DefaultAsteriskManager.java Channel.java Log Message: Included full extension history in Channel Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -p -r1.16 -r1.17 --- DefaultAsteriskManager.java 8 Aug 2005 05:31:11 -0000 1.16 +++ DefaultAsteriskManager.java 8 Aug 2005 05:36:57 -0000 1.17 @@ -468,11 +468,7 @@ public class DefaultAsteriskManager channel.setCallerId(event.getCallerId()); channel.setAccount(event.getAccount()); channel.setState(ChannelStateEnum.getEnum(event.getState())); - channel.setCurrentExtension(extension); - if (channel.getFirstExtension() == null) - { - channel.setFirstExtension(extension); - } + channel.addExtension(extension); if (event.getLink() != null) { @@ -644,11 +640,7 @@ public class DefaultAsteriskManager synchronized (channel) { - channel.setCurrentExtension(extension); - if (channel.getFirstExtension() == null) - { - channel.setFirstExtension(extension); - } + channel.addExtension(extension); } } Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- Channel.java 8 Aug 2005 05:22:07 -0000 1.5 +++ Channel.java 8 Aug 2005 05:36:57 -0000 1.6 @@ -17,7 +17,9 @@ package net.sf.asterisk.manager; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @author srt @@ -35,7 +37,7 @@ public class Channel implements Serializ /** * Unique id of this channel. */ - private String id; + private final String id; /** * Name of this channel. @@ -56,8 +58,7 @@ public class Channel implements Serializ * Account code used to bill this channel. */ private String account; - private Extension firstExtension; - private Extension currentExtension; + private final List extensions; /** * Date this channel has been created. @@ -78,8 +79,7 @@ public class Channel implements Serializ */ public Channel(final String name, final String id) { - this.name = name; - this.id = id; + this(name, id, null); } /** @@ -95,6 +95,7 @@ public class Channel implements Serializ this.name = name; this.id = id; this.asteriskServer = server; + this.extensions = new ArrayList(); } /** @@ -209,22 +210,48 @@ public class Channel implements Serializ public final Extension getCurrentExtension() { - return currentExtension; - } - - public void setCurrentExtension(Extension currentExtension) - { - this.currentExtension = currentExtension; + Extension extension; + + synchronized (extensions) + { + if (extensions.isEmpty()) + { + extension = null; + } + else + { + extension = (Extension) extensions.get(extensions.size() - 1); + } + } + + return extension; } - + public Extension getFirstExtension() { - return firstExtension; + Extension extension; + + synchronized (extensions) + { + if (extensions.isEmpty()) + { + extension = null; + } + else + { + extension = (Extension) extensions.get(0); + } + } + + return extension; } - public void setFirstExtension(Extension firstExtension) + public void addExtension(Extension extension) { - this.firstExtension = firstExtension; + synchronized (extensions) + { + extensions.add(extension); + } } /** |
From: Stefan R. <sr...@us...> - 2005-08-08 05:31:34
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32732/src/java/net/sf/asterisk/manager Modified Files: Extension.java DefaultAsteriskManager.java Log Message: Added date attribute to Extension Made Extension immutable Index: Extension.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Extension.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- Extension.java 8 Aug 2005 05:22:07 -0000 1.1 +++ Extension.java 8 Aug 2005 05:31:11 -0000 1.2 @@ -17,6 +17,7 @@ package net.sf.asterisk.manager; import java.io.Serializable; +import java.util.Date; /** * Represents an Asterisk dialplan entry. @@ -30,36 +31,37 @@ public class Extension implements Serial * Serial version identifier. */ private static final long serialVersionUID = 768239042942945744L; - private String context; - private String extension; - private Integer priority; - private String application; - private String appData; + private final Date date; + private final String context; + private final String extension; + private final Integer priority; + private final String application; + private final String appData; /** + * @param date * @param context * @param extension * @param priority */ - public Extension(String context, String extension, Integer priority) + public Extension(Date date, String context, String extension, + Integer priority) { - super(); - // TODO Auto-generated constructor stub - this.context = context; - this.extension = extension; - this.priority = priority; + this(date, context, extension, priority, null, null); } /** + * @param date * @param context * @param extension * @param priority * @param application * @param appData */ - public Extension(String context, String extension, Integer priority, - String application, String appData) + public Extension(Date date, String context, String extension, + Integer priority, String application, String appData) { + this.date = date; this.context = context; this.extension = extension; this.priority = priority; @@ -72,48 +74,23 @@ public class Extension implements Serial return context; } - public void setContext(String context) - { - this.context = context; - } - public String getExtension() { return extension; } - public void setExtension(String extension) - { - this.extension = extension; - } - public Integer getPriority() { return priority; } - public void setPriority(Integer priority) - { - this.priority = priority; - } - 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; - } } Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- DefaultAsteriskManager.java 8 Aug 2005 05:22:07 -0000 1.15 +++ DefaultAsteriskManager.java 8 Aug 2005 05:31:11 -0000 1.16 @@ -459,8 +459,8 @@ public class DefaultAsteriskManager } else { - extension = new Extension(event.getContext(), event.getExtension(), - event.getPriority()); + extension = new Extension(event.getDateReceived(), event + .getContext(), event.getExtension(), event.getPriority()); } synchronized (channel) @@ -638,8 +638,9 @@ public class DefaultAsteriskManager return; } - extension = new Extension(event.getContext(), event.getExtension(), - event.getPriority(), event.getApplication(), event.getAppData()); + extension = new Extension(event.getDateReceived(), event.getContext(), + event.getExtension(), event.getPriority(), event + .getApplication(), event.getAppData()); synchronized (channel) { |
From: Stefan R. <sr...@us...> - 2005-08-08 05:22:20
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31762/src/java/net/sf/asterisk/manager Modified Files: DefaultAsteriskManager.java Channel.java MultiAsterisksManager.java Added Files: Extension.java Log Message: Introduced Extension class that represents an Asterisk dialplan entry. --- NEW FILE: Extension.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.manager; import java.io.Serializable; /** * Represents an Asterisk dialplan entry. * * @author srt * @version $Id: Extension.java,v 1.1 2005/08/08 05:22:07 srt Exp $ */ public class Extension implements Serializable { /** * Serial version identifier. */ private static final long serialVersionUID = 768239042942945744L; private String context; private String extension; private Integer priority; private String application; private String appData; /** * @param context * @param extension * @param priority */ public Extension(String context, String extension, Integer priority) { super(); // TODO Auto-generated constructor stub this.context = context; this.extension = extension; this.priority = priority; } /** * @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 void setContext(String context) { this.context = context; } public String getExtension() { return extension; } public void setExtension(String extension) { this.extension = extension; } public Integer getPriority() { return priority; } public void setPriority(Integer priority) { this.priority = priority; } 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; } } Index: DefaultAsteriskManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultAsteriskManager.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -p -r1.14 -r1.15 --- DefaultAsteriskManager.java 28 Jul 2005 23:05:21 -0000 1.14 +++ DefaultAsteriskManager.java 8 Aug 2005 05:22:07 -0000 1.15 @@ -437,6 +437,7 @@ public class DefaultAsteriskManager protected void handleStatusEvent(StatusEvent event) { Channel channel; + Extension extension; boolean isNew = false; channel = (Channel) channels.get(event.getUniqueId()); @@ -451,14 +452,28 @@ public class DefaultAsteriskManager isNew = true; } + 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(event.getCallerId()); channel.setAccount(event.getAccount()); channel.setState(ChannelStateEnum.getEnum(event.getState())); - channel.setContext(event.getContext()); - channel.setExtension(event.getExtension()); - channel.setPriority(event.getPriority()); + channel.setCurrentExtension(extension); + if (channel.getFirstExtension() == null) + { + channel.setFirstExtension(extension); + } + if (event.getLink() != null) { Channel linkedChannel = getChannelByName(event.getLink()); @@ -612,7 +627,10 @@ public class DefaultAsteriskManager protected void handleNewExtenEvent(NewExtenEvent event) { - Channel channel = (Channel) channels.get(event.getUniqueId()); + Channel channel; + Extension extension; + + channel = (Channel) channels.get(event.getUniqueId()); if (channel == null) { logger.error("Ignored NewExtenEvent for unknown channel " @@ -620,19 +638,23 @@ public class DefaultAsteriskManager return; } + extension = new Extension(event.getContext(), event.getExtension(), + event.getPriority(), event.getApplication(), event.getAppData()); + synchronized (channel) { - channel.setContext(event.getContext()); - channel.setExtension(event.getExtension()); - channel.setPriority(event.getPriority()); - channel.setApplication(event.getApplication()); - channel.setAppData(event.getAppData()); + channel.setCurrentExtension(extension); + if (channel.getFirstExtension() == null) + { + channel.setFirstExtension(extension); + } } } protected void handleNewStateEvent(NewStateEvent event) { Channel channel = (Channel) channels.get(event.getUniqueId()); + if (channel == null) { logger.error("Ignored NewStateEvent for unknown channel " Index: Channel.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/Channel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- Channel.java 13 Mar 2005 11:26:48 -0000 1.4 +++ Channel.java 8 Aug 2005 05:22:07 -0000 1.5 @@ -56,11 +56,8 @@ public class Channel implements Serializ * Account code used to bill this channel. */ private String account; - private String context; - private String extension; - private Integer priority; - private String application; - private String appData; + private Extension firstExtension; + private Extension currentExtension; /** * Date this channel has been created. @@ -210,54 +207,24 @@ public class Channel implements Serializ this.account = account; } - public final String getContext() - { - return context; - } - - public final void setContext(final String context) - { - this.context = context; - } - - public final String getExtension() - { - return extension; - } - - public final void setExtension(final String extension) - { - this.extension = extension; - } - - public final Integer getPriority() - { - return priority; - } - - public final void setPriority(final Integer priority) - { - this.priority = priority; - } - - public final String getApplication() + public final Extension getCurrentExtension() { - return application; + return currentExtension; } - - public final void setApplication(final String application) + + public void setCurrentExtension(Extension currentExtension) { - this.application = application; + this.currentExtension = currentExtension; } - - public final String getAppData() + + public Extension getFirstExtension() { - return appData; + return firstExtension; } - public final void setAppData(final String appData) + public void setFirstExtension(Extension firstExtension) { - this.appData = appData; + this.firstExtension = firstExtension; } /** @@ -311,11 +278,6 @@ public class Channel implements Serializ sb.append("callerId='" + getCallerId() + "'; "); sb.append("state='" + getState() + "'; "); sb.append("account='" + getAccount() + "'; "); - sb.append("context='" + getContext() + "'; "); - sb.append("extension='" + getExtension() + "'; "); - sb.append("priority='" + getPriority() + "'; "); - sb.append("application='" + getApplication() + "'; "); - sb.append("appData='" + getAppData() + "'; "); sb.append("dateOfCreation=" + getDateOfCreation() + "; "); if (linkedChannel == null) { Index: MultiAsterisksManager.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/MultiAsterisksManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- MultiAsterisksManager.java 27 Jul 2005 23:38:14 -0000 1.6 +++ MultiAsterisksManager.java 8 Aug 2005 05:22:07 -0000 1.7 @@ -219,9 +219,7 @@ public class MultiAsterisksManager imple channel.setCallerId(event.getCallerId()); channel.setAccount(event.getAccount()); channel.setState(ChannelStateEnum.getEnum(event.getState())); - channel.setContext(event.getContext()); - channel.setExtension(event.getExtension()); - channel.setPriority(event.getPriority()); + // TODO handle extension if (event.getLink() != null) { Channel linkedChannel = getChannelByName(event.getLink()); @@ -348,11 +346,7 @@ public class MultiAsterisksManager imple synchronized (channel) { - channel.setContext(event.getContext()); - channel.setExtension(event.getExtension()); - channel.setPriority(event.getPriority()); - channel.setApplication(event.getApplication()); - channel.setAppData(event.getAppData()); + // TODO handle new extension } } |
From: Stefan R. <sr...@us...> - 2005-08-08 04:23:52
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24105/src/java/net/sf/asterisk/manager/event Modified Files: RegistryEvent.java Log Message: Fixed typo Index: RegistryEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/RegistryEvent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- RegistryEvent.java 8 Aug 2005 04:17:50 -0000 1.4 +++ RegistryEvent.java 8 Aug 2005 04:23:43 -0000 1.5 @@ -17,7 +17,7 @@ package net.sf.asterisk.manager.event; /** - * A RegistryEvent is triggered when this asterisk server attempts to registrer + * A RegistryEvent is triggered when this asterisk server attempts to register * as a client at another SIP or IAX server.<br> * This event is implemented in <code>channels/chan_iax2.c</code> and * <code>channels/chan_sip.c</code> |
From: Stefan R. <sr...@us...> - 2005-08-08 04:17:58
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23356/src/java/net/sf/asterisk/manager/event Modified Files: RegistryEvent.java Log Message: Updated javadoc for setUser() as patch for Asterisk bug 4916 has been commited to CVS-HEAD. Index: RegistryEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/RegistryEvent.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- RegistryEvent.java 7 Aug 2005 18:31:30 -0000 1.3 +++ RegistryEvent.java 8 Aug 2005 04:17:50 -0000 1.4 @@ -17,8 +17,8 @@ package net.sf.asterisk.manager.event; /** - * A RegistryEvent is triggered when this asterisk server attempts to registrer as a client at - * another SIP or IAX server.<br> + * A RegistryEvent is triggered when this asterisk server attempts to registrer + * as a client at another SIP or IAX server.<br> * This event is implemented in <code>channels/chan_iax2.c</code> and * <code>channels/chan_sip.c</code> * @@ -45,8 +45,8 @@ public class RegistryEvent extends Manag } /** - * Returns the type of channel that is registered, i.e. "IAX2" for an IAX2 channel or "SIP" for - * a SIP channel. + * Returns the type of channel that is registered, i.e. "IAX2" for an IAX2 + * channel or "SIP" for a SIP channel. */ public String getChannel() { @@ -63,8 +63,8 @@ public class RegistryEvent extends Manag /** * Returns the domain or host name of the SIP or IAX2 server.<br> - * This is the host part used in the <code>register</code> lines in <code>iax.conf</code> - * and <code>sip.conf</code>. + * This is the host part used in the <code>register</code> lines in + * <code>iax.conf</code> and <code>sip.conf</code>. */ public String getDomain() { @@ -81,8 +81,8 @@ public class RegistryEvent extends Manag /** * Returns the username used for registration.<br> - * For SIP channels this is not used at all, IAX2 sends the username in case of a registration - * failure. + * SIP send the username in case of a registration timeout, IAX2 in case of + * a registration failure. Otherwise the username is <code>null</code>. */ public String getUsername() { @@ -96,12 +96,12 @@ public class RegistryEvent extends Manag { this.username = username; } - /** - * Sets the username used for registration.<br> - * Please do not use this method it is a temporary workaround until - * Asterisk bug 4916 is acted upon. + * Sets the username used for registration. + * + * @deprecated Please do not use this method it is a workaround for Asterisk + * 1.0.x servers. See Asterisk bug 4916. */ public void setUser(String username) { @@ -110,8 +110,8 @@ public class RegistryEvent extends Manag /** * Returns the registration state.<br> - * 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) + * 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) * <ul> * <li>Unregistered</li> * <li>Request Sent</li> @@ -121,11 +121,11 @@ public class RegistryEvent extends Manag * <li>Timeout</li> * <li>No Authentication</li> * </ul> - * iax2 only uses + * IAX2 only uses * <ul> * <li>Rejected</li> * </ul> - * Successful iax2 registrations do not use the this property at all. + * Successful IAX2 registrations do not use the this property at all. */ public String getStatus() { |
From: Stefan R. <sr...@us...> - 2005-08-07 19:07:04
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv831/src/java/net/sf/asterisk/fastagi Modified Files: BaseAGIScript.java Log Message: Added check for invalid thread access to sendCommand() Index: BaseAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/BaseAGIScript.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- BaseAGIScript.java 6 Aug 2005 18:43:24 -0000 1.1 +++ BaseAGIScript.java 7 Aug 2005 19:06:46 -0000 1.2 @@ -76,8 +76,7 @@ public abstract class BaseAGIScript impl * hung up.<br> * 0 disables the autohangup feature. */ - protected void setAutoHangup(int time) - throws AGIException + protected void setAutoHangup(int time) throws AGIException { sendCommand(new SetAutoHangupCommand(time)); } @@ -87,8 +86,7 @@ public abstract class BaseAGIScript impl * * @param callerId the raw caller id to set, for example "John Doe<1234>". */ - protected void setCallerId(String callerId) - throws AGIException + protected void setCallerId(String callerId) throws AGIException { sendCommand(new SetCallerIdCommand(callerId)); } @@ -107,8 +105,7 @@ public abstract class BaseAGIScript impl * @param musicOnHoldClass the music on hold class to play music from as * configures in Asterisk's <code><musiconhold.conf/code>. */ - protected void playMusicOnHold(String musicOnHoldClass) - throws AGIException + protected void playMusicOnHold(String musicOnHoldClass) throws AGIException { sendCommand(new SetMusicOnCommand(musicOnHoldClass)); } @@ -153,8 +150,7 @@ public abstract class BaseAGIScript impl * @param file the name of the file to play * @return a String containing the DTMF the user entered */ - protected String getData(String file) - throws AGIException + protected String getData(String file) throws AGIException { AGIReply reply; @@ -173,8 +169,7 @@ public abstract class BaseAGIScript impl * (essentially never times out). * @return a String containing the DTMF the user entered */ - protected String getData(String file, int timeout) - throws AGIException + protected String getData(String file, int timeout) throws AGIException { AGIReply reply; @@ -196,8 +191,8 @@ public abstract class BaseAGIScript impl * enter * @return a String containing the DTMF the user entered */ - protected String getData(String file, int timeout, - int maxDigits) throws AGIException + protected String getData(String file, int timeout, int maxDigits) + throws AGIException { AGIReply reply; @@ -218,8 +213,8 @@ public abstract class BaseAGIScript impl * press. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char getOption(String file, - String escapeDigits) throws AGIException + protected char getOption(String file, String escapeDigits) + throws AGIException { AGIReply reply; @@ -240,13 +235,12 @@ public abstract class BaseAGIScript impl * esacpe digits was presses while streaming. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char getOption(String file, - String escapeDigits, int timeout) throws AGIException + protected char getOption(String file, String escapeDigits, int timeout) + throws AGIException { AGIReply reply; - reply = sendCommand(new GetOptionCommand(file, escapeDigits, - timeout)); + reply = sendCommand(new GetOptionCommand(file, escapeDigits, timeout)); return reply.getResultCodeAsChar(); } @@ -258,8 +252,7 @@ public abstract class BaseAGIScript impl * @return the return code of the application of -2 if the application was * not found. */ - protected int exec(String application) - throws AGIException + protected int exec(String application) throws AGIException { AGIReply reply; @@ -277,8 +270,7 @@ public abstract class BaseAGIScript impl * @return the return code of the application of -2 if the application was * not found. */ - protected int exec(String application, String options) - throws AGIException + protected int exec(String application, String options) throws AGIException { AGIReply reply; @@ -291,8 +283,7 @@ public abstract class BaseAGIScript impl * * @param context the context for continuation upon exiting the application. */ - protected void setContext(String context) - throws AGIException + protected void setContext(String context) throws AGIException { sendCommand(new SetContextCommand(context)); } @@ -303,8 +294,7 @@ public abstract class BaseAGIScript impl * @param extension the extension for continuation upon exiting the * application. */ - protected void setExtension(String extension) - throws AGIException + protected void setExtension(String extension) throws AGIException { sendCommand(new SetExtensionCommand(extension)); } @@ -315,8 +305,7 @@ public abstract class BaseAGIScript impl * @param priority the priority for continuation upon exiting the * application. */ - protected void setPriority(int priority) - throws AGIException + protected void setPriority(int priority) throws AGIException { sendCommand(new SetPriorityCommand(priority)); } @@ -326,8 +315,7 @@ public abstract class BaseAGIScript impl * * @param file name of the file to play. */ - protected void streamFile(String file) - throws AGIException + protected void streamFile(String file) throws AGIException { sendCommand(new StreamFileCommand(file)); } @@ -341,8 +329,8 @@ public abstract class BaseAGIScript impl * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char streamFile(String file, - String escapeDigits) throws AGIException + protected char streamFile(String file, String escapeDigits) + throws AGIException { AGIReply reply; @@ -355,8 +343,7 @@ public abstract class BaseAGIScript impl * * @param digits the digit string to say. */ - protected void sayDigits(String digits) - throws AGIException + protected void sayDigits(String digits) throws AGIException { sendCommand(new SayDigitsCommand(digits)); } @@ -370,8 +357,8 @@ public abstract class BaseAGIScript impl * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char sayDigits(String digits, - String escapeDigits) throws AGIException + protected char sayDigits(String digits, String escapeDigits) + throws AGIException { AGIReply reply; @@ -384,8 +371,7 @@ public abstract class BaseAGIScript impl * * @param number the number to say. */ - protected void sayNumber(String number) - throws AGIException + protected void sayNumber(String number) throws AGIException { sendCommand(new SayNumberCommand(number)); } @@ -399,8 +385,8 @@ public abstract class BaseAGIScript impl * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char sayNumber(String number, - String escapeDigits) throws AGIException + protected char sayNumber(String number, String escapeDigits) + throws AGIException { AGIReply reply; @@ -413,8 +399,7 @@ public abstract class BaseAGIScript impl * * @param text the text to say. */ - protected void sayPhonetic(String text) - throws AGIException + protected void sayPhonetic(String text) throws AGIException { sendCommand(new SayPhoneticCommand(text)); } @@ -428,8 +413,8 @@ public abstract class BaseAGIScript impl * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char sayPhonetic(String text, - String escapeDigits) throws AGIException + protected char sayPhonetic(String text, String escapeDigits) + throws AGIException { AGIReply reply; @@ -442,8 +427,7 @@ public abstract class BaseAGIScript impl * * @param text the text to say. */ - protected void sayAlpha(String text) - throws AGIException + protected void sayAlpha(String text) throws AGIException { sendCommand(new SayAlphaCommand(text)); } @@ -485,8 +469,7 @@ public abstract class BaseAGIScript impl * user to escape. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char sayTime(long time, String escapeDigits) - throws AGIException + protected char sayTime(long time, String escapeDigits) throws AGIException { AGIReply reply; @@ -501,8 +484,7 @@ public abstract class BaseAGIScript impl * @return the value of the given variable or <code>null</code> if not * set. */ - protected String getVariable(String name) - throws AGIException + protected String getVariable(String name) throws AGIException { AGIReply reply; @@ -520,8 +502,7 @@ public abstract class BaseAGIScript impl * @param name the name of the variable to retrieve. * @param value the new value to set. */ - protected void setVariable(String name, String value) - throws AGIException + protected void setVariable(String name, String value) throws AGIException { sendCommand(new SetVariableCommand(name, value)); } @@ -533,8 +514,7 @@ public abstract class BaseAGIScript impl * receive a DTMF digit, -1 will wait forever. * @return the DTMF digit pressed or 0x0 if none was pressed. */ - protected char waitForDigit(int timeout) - throws AGIException + protected char waitForDigit(int timeout) throws AGIException { AGIReply reply; @@ -554,6 +534,12 @@ public abstract class BaseAGIScript impl AGIChannel channel; channel = AGIConnectionHandler.getChannel(); + if (channel == null) + { + throw new RuntimeException( + "Trying to send command from an invalid thread"); + } + return channel.sendCommand(command); } } |
From: Stefan R. <sr...@us...> - 2005-08-07 19:00:09
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31953 Modified Files: ChangeLog Log Message: Added not about new convenience constructors for manager actions to ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/ChangeLog,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -p -r1.6 -r1.7 --- ChangeLog 6 Aug 2005 20:37:49 -0000 1.6 +++ ChangeLog 7 Aug 2005 18:59:55 -0000 1.7 @@ -12,6 +12,7 @@ Asterisk-Java 0.2 * 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 |
From: Stefan R. <sr...@us...> - 2005-08-07 18:31:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26578/src/java/net/sf/asterisk/manager/event Modified Files: RegistryEvent.java Log Message: Temporary workaround for Asterisk bug 4916 Index: RegistryEvent.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/event/RegistryEvent.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- RegistryEvent.java 23 Feb 2005 22:50:58 -0000 1.2 +++ RegistryEvent.java 7 Aug 2005 18:31:30 -0000 1.3 @@ -96,6 +96,17 @@ public class RegistryEvent extends Manag { this.username = username; } + + + /** + * Sets the username used for registration.<br> + * Please do not use this method it is a temporary workaround until + * Asterisk bug 4916 is acted upon. + */ + public void setUser(String username) + { + this.username = username; + } /** * Returns the registration state.<br> |
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12413/src/java/net/sf/asterisk/manager/action Modified Files: ZapDNDOffAction.java ZapDNDOnAction.java ZapDialOffhookAction.java ZapShowChannelsAction.java ZapHangupAction.java Log Message: Added convenience constructors to some more manager actions Index: ZapDNDOffAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ZapDNDOffAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ZapDNDOffAction.java 16 Jul 2005 13:19:33 -0000 1.3 +++ ZapDNDOffAction.java 7 Aug 2005 17:10:29 -0000 1.4 @@ -17,7 +17,7 @@ package net.sf.asterisk.manager.action; /** - * The ZapDNDOnAction toggles a zap channel "Do Not Disturb" status off. + * The ZapDNDOnAction switches a zap channel "Do Not Disturb" status off. * * @author srt * @version $Id$ @@ -31,6 +31,26 @@ public class ZapDNDOffAction extends Abs 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". */ public String getAction() Index: ZapDNDOnAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ZapDNDOnAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ZapDNDOnAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ ZapDNDOnAction.java 7 Aug 2005 17:10:29 -0000 1.4 @@ -17,7 +17,7 @@ package net.sf.asterisk.manager.action; /** - * The ZapDNDOnAction toggles a zap channel "Do Not Disturb" status on. + * The ZapDNDOnAction switches a zap channel "Do Not Disturb" status on. * * @author srt * @version $Id$ @@ -31,6 +31,26 @@ public class ZapDNDOnAction extends Abst 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". */ public String getAction() Index: ZapDialOffhookAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ZapDialOffhookAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ZapDialOffhookAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ ZapDialOffhookAction.java 7 Aug 2005 17:10:29 -0000 1.4 @@ -32,6 +32,28 @@ public class ZapDialOffhookAction extend 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". */ public String getAction() Index: ZapShowChannelsAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ZapShowChannelsAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ZapShowChannelsAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ ZapShowChannelsAction.java 7 Aug 2005 17:10:29 -0000 1.4 @@ -16,18 +16,21 @@ */ package net.sf.asterisk.manager.action; +import net.sf.asterisk.manager.event.ZapShowChannelsCompleteEvent; + /** * The ZapShowChannelsAction requests the state of all zap channels.<br> - * For each zap channel a ZapShowChannelsEvent is generated. After all zap channels have been listed - * a ZapShowChannelsCompleteEvent is generated. + * For each zap channel a ZapShowChannelsEvent is generated. After all zap + * channels have been listed a ZapShowChannelsCompleteEvent is generated. * * @see net.sf.asterisk.manager.event.ZapShowChannelsEvent * @see net.sf.asterisk.manager.event.ZapShowChannelsCompleteEvent - * * @author srt * @version $Id$ */ public class ZapShowChannelsAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serializable version identifier @@ -35,10 +38,23 @@ public class ZapShowChannelsAction exten private static final long serialVersionUID = 8697000330085766825L; /** + * Creates a new ZapShowChannelsAction. + */ + public ZapShowChannelsAction() + { + + } + + /** * Returns the name of this action, i.e. "ZapShowChannels". */ public String getAction() { return "ZapShowChannels"; } + + public Class getActionCompleteEventClass() + { + return ZapShowChannelsCompleteEvent.class; + } } Index: ZapHangupAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ZapHangupAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ZapHangupAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ ZapHangupAction.java 7 Aug 2005 17:10:29 -0000 1.4 @@ -31,6 +31,25 @@ public class ZapHangupAction extends Abs 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". */ public String getAction() |
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10109/src/java/net/sf/asterisk/manager/action Modified Files: SIPPeersAction.java SetVarAction.java StopMonitorAction.java StatusAction.java SIPShowPeerAction.java Log Message: Added convenience constructors to some more manager actions Index: SIPPeersAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/SIPPeersAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- SIPPeersAction.java 18 Jul 2005 14:53:24 -0000 1.1 +++ SIPPeersAction.java 7 Aug 2005 16:55:18 -0000 1.2 @@ -18,11 +18,11 @@ package net.sf.asterisk.manager.action; import net.sf.asterisk.manager.event.PeerlistCompleteEvent; - /** * Retrieves a list of all defined SIP peers.<br> - * 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.<br> + * 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.<br> * Available since Asterisk 1.2 * * @see net.sf.asterisk.manager.event.PeerEntryEvent @@ -31,13 +31,23 @@ import net.sf.asterisk.manager.event.Pee * @version $Id$ * @since 0.2 */ -public class SIPPeersAction extends AbstractManagerAction implements EventGeneratingAction +public class SIPPeersAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serial version identifier */ private static final long serialVersionUID = 921037572305993779L; + /** + * Creates a new SIPPeersAction. + */ + public SIPPeersAction() + { + + } + public String getAction() { return "SIPPeers"; Index: SetVarAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/SetVarAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- SetVarAction.java 16 Jul 2005 13:19:34 -0000 1.2 +++ SetVarAction.java 7 Aug 2005 16:55:18 -0000 1.3 @@ -17,7 +17,7 @@ package net.sf.asterisk.manager.action; /** - * The SetVar action will set the value of a variable for a given channel. + * The SetVar action sets the value of a channel variable for a given channel. * * @author Asteria Solutions Group, Inc. <http://www.asteriasgi.com> * @version $Id$ @@ -45,6 +45,30 @@ public class SetVarAction extends Abstra public String value; /** + * Creates a new empty SetVarAction. + */ + public SetVarAction() + { + + } + + /** + * 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 Index: StopMonitorAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/StopMonitorAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- StopMonitorAction.java 16 Jul 2005 13:19:33 -0000 1.4 +++ StopMonitorAction.java 7 Aug 2005 16:55:18 -0000 1.5 @@ -36,6 +36,26 @@ public class StopMonitorAction extends A 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) + { + + } + + /** * Returns the name of this action, i.e. "StopMonitor". * * @return the name of this action. Index: StatusAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/StatusAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- StatusAction.java 16 Jul 2005 14:25:48 -0000 1.4 +++ StatusAction.java 7 Aug 2005 16:55:18 -0000 1.5 @@ -20,16 +20,17 @@ import net.sf.asterisk.manager.event.Sta /** * The StatusAction requests the state of all active channels.<br> - * For each active channel a StatusEvent is generated. After the state of all channels has been - * reported a StatusCompleteEvent is generated. + * For each active channel a StatusEvent is generated. After the state of all + * channels has been reported a StatusCompleteEvent is generated. * * @see net.sf.asterisk.manager.event.StatusEvent * @see net.sf.asterisk.manager.event.StatusCompleteEvent - * * @author srt * @version $Id$ */ -public class StatusAction extends AbstractManagerAction implements EventGeneratingAction +public class StatusAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serializable version identifier @@ -37,6 +38,14 @@ public class StatusAction extends Abstra static final long serialVersionUID = -320228893513973367L; /** + * Creates a new StatusAction. + */ + public StatusAction() + { + + } + + /** * Returns the name of this action, i.e. "Status". */ public String getAction() Index: SIPShowPeerAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/SIPShowPeerAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- SIPShowPeerAction.java 18 Jul 2005 14:53:25 -0000 1.1 +++ SIPShowPeerAction.java 7 Aug 2005 16:55:18 -0000 1.2 @@ -20,8 +20,8 @@ import net.sf.asterisk.manager.event.Pee /** * Retrieves a the details about a given SIP peer.<br> - * For a PeerEntryEvent is sent by Asterisk containing the details of the peer followed by a - * PeerlistCompleteEvent.<br> + * For a PeerEntryEvent is sent by Asterisk containing the details of the peer + * followed by a PeerlistCompleteEvent.<br> * Available since Asterisk 1.2 * * @see net.sf.asterisk.manager.event.PeerEntryEvent @@ -30,7 +30,9 @@ import net.sf.asterisk.manager.event.Pee * @version $Id$ * @since 0.2 */ -public class SIPShowPeerAction extends AbstractManagerAction implements EventGeneratingAction +public class SIPShowPeerAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serial version identifier @@ -38,6 +40,26 @@ public class SIPShowPeerAction extends A private static final long serialVersionUID = 921037572305993779L; private String peer; + /** + * Creates a new empty SIPShowPeerAction. + */ + public SIPShowPeerAction() + { + + } + + /** + * Creates a new SIPShowPeerAction that requests the details about the given + * SIP peer. + * + * @param peer the name of the SIP peer to retrieve details for. + * @since 0.2 + */ + public SIPShowPeerAction(String peer) + { + this.peer = peer; + } + public String getAction() { return "SIPPeer"; |
From: Stefan R. <sr...@us...> - 2005-08-07 16:43:38
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6755/src/java/net/sf/asterisk/manager/action Modified Files: PingAction.java ChangeMonitorAction.java RedirectAction.java SetCDRUserFieldAction.java QueueRemoveAction.java MonitorAction.java QueueAddAction.java ParkedCallsAction.java QueueStatusAction.java Log Message: Added convenience constructors to some more manager actions Index: PingAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/PingAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- PingAction.java 16 Jul 2005 13:19:33 -0000 1.3 +++ PingAction.java 7 Aug 2005 16:43:29 -0000 1.4 @@ -17,8 +17,8 @@ package net.sf.asterisk.manager.action; /** - * The PingAction will ellicit a 'Pong' response, it is used to keep the manager connection open and - * performs no operation. + * The PingAction will ellicit a 'Pong' response, it is used to keep the manager + * connection open and performs no operation. * * @author srt * @version $Id$ @@ -31,6 +31,14 @@ public class PingAction extends Abstract private static final long serialVersionUID = -2930397629192323391L; /** + * Creates a new PingAction. + */ + public PingAction() + { + + } + + /** * Returns the name of this action, i.e. "Ping". */ public String getAction() Index: ChangeMonitorAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ChangeMonitorAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- ChangeMonitorAction.java 7 Aug 2005 00:09:42 -0000 1.4 +++ ChangeMonitorAction.java 7 Aug 2005 16:43:29 -0000 1.5 @@ -42,10 +42,10 @@ public class ChangeMonitorAction extends } /** - * Creates a new ChangeMonitorAction that causes the given channel to be - * monitored and voice data to be written to the given files. + * 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 to monitor + * @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 @@ -65,7 +65,7 @@ public class ChangeMonitorAction extends } /** - * Returns the name of the channel to start monitoring. + * Returns the name of the monitored channel. */ public String getChannel() { @@ -73,7 +73,7 @@ public class ChangeMonitorAction extends } /** - * Sets the name of the channel to start monitoring.<br> + * Sets the name of the monitored channel.<br> * This property is mandatory. */ public void setChannel(String channel) Index: RedirectAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/RedirectAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- RedirectAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ RedirectAction.java 7 Aug 2005 16:43:29 -0000 1.4 @@ -17,6 +17,9 @@ package net.sf.asterisk.manager.action; /** + * Redirects a given channel (and an optional additional channel) to a new + * extension. + * * @author srt * @version $Id$ */ @@ -34,6 +37,54 @@ public class RedirectAction extends Abst private Integer priority; /** + * 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. + * + * @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; + } + + /** * Returns the name of this action, i.e. "Redirect". */ public String getAction() @@ -42,7 +93,9 @@ public class RedirectAction extends Abst } /** - * @return Returns the channel. + * Returns name of the channel to redirect. + * + * @return the name of the channel to redirect */ public String getChannel() { @@ -50,7 +103,9 @@ public class RedirectAction extends Abst } /** - * @param channel The channel to set. + * Sets the name of the channel to redirect. + * + * @param channel the name of the channel to redirect */ public void setChannel(String channel) { @@ -58,55 +113,69 @@ public class RedirectAction extends Abst } /** - * @return Returns the context. + * Returns the name of the additional channel to redirect. + * + * @return the name of the additional channel to redirect */ - public String getContext() + public String getExtraChannel() { - return context; + return extraChannel; } /** - * @param context The context to set. + * Sets the name of the additional channel to redirect. + * + * @param extraChannel the name of the additional channel to redirect */ - public void setContext(String context) + public void setExtraChannel(String extraChannel) { - this.context = context; + this.extraChannel = extraChannel; } /** - * @return Returns the exten. + * Returns the destination context. + * + * @return the destination context */ - public String getExten() + public String getContext() { - return exten; + return context; } /** - * @param exten The exten to set. + * Sets the destination context. + * + * @param context the destination context */ - public void setExten(String exten) + public void setContext(String context) { - this.exten = exten; + this.context = context; } /** - * @return Returns the extraChannel. + * Returns the destination extension. + * + * @return the destination extension */ - public String getExtraChannel() + public String getExten() { - return extraChannel; + return exten; } /** - * @param extraChannel The extraChannel to set. + * Sets the destination extension. + * + * @param exten the destination extension */ - public void setExtraChannel(String extraChannel) + public void setExten(String exten) { - this.extraChannel = extraChannel; + this.exten = exten; } /** - * @return Returns the priority. + * Returns the destination priority. + * + * @return the destination priority */ public Integer getPriority() { @@ -114,7 +183,9 @@ public class RedirectAction extends Abst } /** - * @param priority The priority to set. + * Sets the destination priority. + * + * @param priority the destination priority */ public void setPriority(Integer priority) { Index: SetCDRUserFieldAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/SetCDRUserFieldAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- SetCDRUserFieldAction.java 16 Jul 2005 13:19:33 -0000 1.3 +++ SetCDRUserFieldAction.java 7 Aug 2005 16:43:29 -0000 1.4 @@ -17,10 +17,12 @@ package net.sf.asterisk.manager.action; /** - * The SetCDRUserFieldAction causes the user field of the call detail record for the given channel - * to be changed.<br> - * Depending on the value of the append property the value is appended or overwritten.<br> - * The SetCDRUserFieldAction is implemented in <code>apps/app_setcdruserfield.c</code> + * The SetCDRUserFieldAction causes the user field of the call detail record for + * the given channel to be changed.<br> + * Depending on the value of the append property the value is appended or + * overwritten.<br> + * The SetCDRUserFieldAction is implemented in + * <code>apps/app_setcdruserfield.c</code> * * @author srt * @version $Id$ @@ -36,6 +38,46 @@ public class SetCDRUserFieldAction exten 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". */ public String getAction() @@ -86,7 +128,8 @@ public class SetCDRUserFieldAction exten } /** - * Set to true to append the value to the cdr user field or false to overwrite. + * Set to true to append the value to the cdr user field or false to + * overwrite. */ public void setAppend(Boolean append) { Index: QueueRemoveAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/QueueRemoveAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- QueueRemoveAction.java 16 Jul 2005 13:19:33 -0000 1.4 +++ QueueRemoveAction.java 7 Aug 2005 16:43:29 -0000 1.5 @@ -37,6 +37,28 @@ public class QueueRemoveAction extends A 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. Index: MonitorAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/MonitorAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- MonitorAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ MonitorAction.java 7 Aug 2005 16:43:29 -0000 1.4 @@ -35,6 +35,66 @@ public class MonitorAction extends Abstr private Boolean mix; /** + * Creates a new empty MonitorAction. + */ + public MonitorAction() + { + + } + + /** + * 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 + * @since 0.2 + */ + public MonitorAction(String channel, String file) + { + this.channel = channel; + this.file = file; + } + + /** + * 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 + * @since 0.2 + */ + public MonitorAction(String channel, String file, String format) + { + 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) + { + this.channel = channel; + this.file = file; + this.format = format; + this.mix = mix; + } + + /** * Returns the name of this action, i.e. "Monitor". */ public String getAction() @@ -43,7 +103,7 @@ public class MonitorAction extends Abstr } /** - * Returns the name of the channel to start monitoring. + * Returns the name of the channel to monitor. */ public String getChannel() { @@ -51,7 +111,7 @@ public class MonitorAction extends Abstr } /** - * Sets the name of the channel to start monitoring.<br> + * Sets the name of the channel to monitor.<br> * This property is mandatory. */ public void setChannel(String channel) @@ -69,8 +129,8 @@ public class MonitorAction extends Abstr /** * Sets the (base) name of the file(s) to which the voice data is written.<br> - * If this property is not set it defaults to to the channel name as per CLI with the '/' - * replaced by '-'. + * 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) { @@ -95,7 +155,8 @@ public class MonitorAction extends Abstr } /** - * Returns true if the two voice files should be joined at the end of the call. + * Returns true if the two voice files should be joined at the end of the + * call. */ public Boolean getMix() { @@ -103,7 +164,8 @@ public class MonitorAction extends Abstr } /** - * Set to true if the two voice files should be joined at the end of the call. + * Set to true if the two voice files should be joined at the end of the + * call. */ public void setMix(Boolean mix) { Index: QueueAddAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/QueueAddAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- QueueAddAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ QueueAddAction.java 7 Aug 2005 16:43:29 -0000 1.4 @@ -34,6 +34,48 @@ public class QueueAddAction extends Abst private Integer penality; /** + * 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 penality. + * + * @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 penality the penality for this member. The penality must be a + * positive integer or 0 for no penality. When calls are + * distributed members with higher penalties are considered last. + * @since 0.2 + */ + public QueueAddAction(String queue, String iface, Integer penality) + { + this.queue = queue; + this.iface = iface; + this.penality = penality; + } + + /** * Returns the name of this action, i.e. "QueueAdd". */ public String getAction() @@ -86,8 +128,10 @@ public class QueueAddAction extends Abst /** * Sets the penality for this member.<br> - * The penality must be a positive integer or 0 for no penality. If it is not set 0 is assumed.<br> - * When calls are distributed members with higher penalties are considered last. + * The penality must be a positive integer or 0 for no penality. If it is + * not set 0 is assumed.<br> + * When calls are distributed members with higher penalties are considered + * last. */ public void setPenality(Integer penality) { Index: ParkedCallsAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ParkedCallsAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- ParkedCallsAction.java 16 Jul 2005 14:25:48 -0000 1.4 +++ ParkedCallsAction.java 7 Aug 2005 16:43:29 -0000 1.5 @@ -20,16 +20,17 @@ import net.sf.asterisk.manager.event.Par /** * The ParkedCallsAction requests a list of all currently parked calls.<br> - * For each active channel a ParkedCallEvent is generated. After all parked calls have been reported - * a ParkedCallsCompleteEvent is generated. + * For each active channel a ParkedCallEvent is generated. After all parked + * calls have been reported a ParkedCallsCompleteEvent is generated. * * @see net.sf.asterisk.manager.event.ParkedCallEvent * @see net.sf.asterisk.manager.event.ParkedCallsCompleteEvent - * * @author srt * @version $Id$ */ -public class ParkedCallsAction extends AbstractManagerAction implements EventGeneratingAction +public class ParkedCallsAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serializable version identifier @@ -37,6 +38,14 @@ public class ParkedCallsAction extends A private static final long serialVersionUID = 1859575016378824743L; /** + * Creates a new ParkedCallsAction. + */ + public ParkedCallsAction() + { + + } + + /** * Returns the name of this action, i.e. "ParkedCalls". */ public String getAction() Index: QueueStatusAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/QueueStatusAction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- QueueStatusAction.java 16 Jul 2005 14:25:48 -0000 1.5 +++ QueueStatusAction.java 7 Aug 2005 16:43:29 -0000 1.6 @@ -19,25 +19,25 @@ package net.sf.asterisk.manager.action; import net.sf.asterisk.manager.event.QueueStatusCompleteEvent; /** - * The QueueStatusAction requests the state of all defined queues their members (agents) and entries - * (callers).<br> - * - * 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.<br> - * - * Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of the generated dump.<br> - * + * The QueueStatusAction requests the state of all defined queues their members + * (agents) and entries (callers).<br> + * 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.<br> + * Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of + * the generated dump.<br> * This action is implemented in <code>apps/app_queue.c</code> * * @see net.sf.asterisk.manager.event.QueueParamsEvent * @see net.sf.asterisk.manager.event.QueueMemberEvent * @see net.sf.asterisk.manager.event.QueueEntryEvent * @see net.sf.asterisk.manager.event.QueueStatusCompleteEvent - * * @author srt * @version $Id$ */ -public class QueueStatusAction extends AbstractManagerAction implements EventGeneratingAction +public class QueueStatusAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serializable version identifier @@ -45,6 +45,14 @@ public class QueueStatusAction extends A private static final long serialVersionUID = -8599401015517232869L; /** + * Creates a new QueueStatusAction. + */ + public QueueStatusAction() + { + + } + + /** * Returns the name of this action, i.e. "QueueStatus". */ public String getAction() |
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24230/src/java/net/sf/asterisk/manager/action Modified Files: AgentCallbackLoginAction.java MailboxStatusAction.java CommandAction.java MailboxCountAction.java ChallengeAction.java EventsAction.java ChangeMonitorAction.java DBPutAction.java DBGetAction.java LogoffAction.java AbsoluteTimeoutAction.java AgentsAction.java AgentLogoffAction.java LoginAction.java Log Message: Added convenience constructors to some manager actions Index: AgentCallbackLoginAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/AgentCallbackLoginAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- AgentCallbackLoginAction.java 21 Jul 2005 16:49:35 -0000 1.2 +++ AgentCallbackLoginAction.java 7 Aug 2005 00:09:42 -0000 1.3 @@ -18,9 +18,11 @@ package net.sf.asterisk.manager.action; /** * The AgentCallbackLoginAction aets an agent as logged in with callback.<br> - * You can pass an extentsion (and optionally a context) to specify the destination of the callback.<br> - * 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.<br> + * You can pass an extentsion (and optionally a context) to specify the + * destination of the callback.<br> + * 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.<br> * Available since Asterisk 1.2 * * @author srt @@ -40,6 +42,28 @@ public class AgentCallbackLoginAction ex 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; + } + + /** * Returns the name of this action, i.e. "AgentCallbackLogin". * * @return the name of this action @@ -114,8 +138,8 @@ public class AgentCallbackLoginAction ex /** * Returns if an acknowledgement is needed when agent is called back. * - * @return Boolean.TRUE to 'true' to require an acknowledgement by '#' when agent is called - * back, Boolean.FALSE otherwise. + * @return Boolean.TRUE to 'true' to require an acknowledgement by '#' when + * agent is called back, Boolean.FALSE otherwise. */ public Boolean getAckCall() { @@ -124,11 +148,11 @@ public class AgentCallbackLoginAction ex /** * Sets if an acknowledgement is needed when agent is called back.<br> - * This property is optional, it allows you to override the defaults defined in Asterisk's - * configuration. + * This property is optional, it allows you to override the defaults defined + * in Asterisk's configuration. * - * @param ackCall Boolean.TRUE to 'true' to require an acknowledgement by '#' when agent is - * called back, Boolean.FALSE otherwise. + * @param ackCall Boolean.TRUE to 'true' to require an acknowledgement by + * '#' when agent is called back, Boolean.FALSE otherwise. */ public void setAckCall(Boolean ackCall) { @@ -136,11 +160,11 @@ public class AgentCallbackLoginAction ex } /** - * Returns the minimum amount of time after disconnecting before the caller can receive a new - * call. + * 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 milliseconds. + * @return the minimum amount of time after disconnecting before the caller + * can receive a new call in milliseconds. */ public Long getWrapupTime() { @@ -148,12 +172,13 @@ public class AgentCallbackLoginAction ex } /** - * Sets the minimum amount of time after disconnecting before the caller can receive a new call.<br> - * This property is optional, it allows you to override the defaults defined in Asterisk's - * configuration. + * Sets the minimum amount of time after disconnecting before the caller can + * receive a new call.<br> + * This property is optional, it allows you to override the defaults defined + * in Asterisk's configuration. * - * @param wrapupTime the minimum amount of time after disconnecting before the caller can - * receive a new call in milliseconds. + * @param wrapupTime the minimum amount of time after disconnecting before + * the caller can receive a new call in milliseconds. */ public void setWrapupTime(Long wrapupTime) { Index: MailboxStatusAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/MailboxStatusAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- MailboxStatusAction.java 16 Jul 2005 13:19:33 -0000 1.4 +++ MailboxStatusAction.java 7 Aug 2005 00:09:42 -0000 1.5 @@ -21,7 +21,6 @@ package net.sf.asterisk.manager.action; * The MailboxStatusAction returns a MailboxStatusResponse. * * @see net.sf.asterisk.manager.response.MailboxStatusResponse - * * @author srt * @version $Id$ */ @@ -35,6 +34,29 @@ public class MailboxStatusAction extends 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.<br> + * 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". */ public String getAction() @@ -54,8 +76,9 @@ public class MailboxStatusAction extends * Sets the name of the mailbox to query.<br> * 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.<br> - * Multiple mailboxes may be given, separated by ','. In this case the action checks whether at - * least one of the given mailboxes has waiting messages.<br> + * Multiple mailboxes may be given, separated by ','. In this case the + * action checks whether at least one of the given mailboxes has waiting + * messages.<br> * This property is mandatory.<br> * Example: "1234,1235@mycontext" */ Index: CommandAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/CommandAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- CommandAction.java 27 Jul 2005 20:54:01 -0000 1.4 +++ CommandAction.java 7 Aug 2005 00:09:42 -0000 1.5 @@ -46,6 +46,7 @@ public class CommandAction extends Abstr * Creates a new CommandAction with the given command. * * @param command the CLI command to execute. + * @since 0.2 */ public CommandAction(String command) { Index: MailboxCountAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/MailboxCountAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- MailboxCountAction.java 16 Jul 2005 13:19:33 -0000 1.3 +++ MailboxCountAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -6,11 +6,11 @@ package net.sf.asterisk.manager.action; /** - * The MailboxCountAction queries the number of unread and read messages in a mailbox.<br> + * The MailboxCountAction queries the number of unread and read messages in a + * mailbox.<br> * The MailboxCountAction returns a MailboxStatusResponse. * * @see net.sf.asterisk.manager.response.MailboxCountResponse - * * @author srt * @version $Id$ */ @@ -24,6 +24,29 @@ public class MailboxCountAction extends 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.<br> + * 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". */ public String getAction() Index: ChallengeAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ChallengeAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ChallengeAction.java 16 Jul 2005 13:19:33 -0000 1.3 +++ ChallengeAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -17,13 +17,12 @@ package net.sf.asterisk.manager.action; /** - * 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. + * 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. * * @see net.sf.asterisk.manager.action.LoginAction * @see net.sf.asterisk.manager.response.ChallengeResponse - * * @author srt * @version $Id$ */ @@ -36,6 +35,26 @@ public class ChallengeAction extends Abs 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". */ public String getAction() Index: EventsAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/EventsAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- EventsAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ EventsAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -17,8 +17,8 @@ package net.sf.asterisk.manager.action; /** - * With the EventsAction you can specify what kind of events should be sent to this manager - * connection. + * With the EventsAction you can specify what kind of events should be sent to + * this manager connection. * * @author srt * @version $Id$ @@ -33,6 +33,29 @@ public class EventsAction extends Abstra 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". */ public String getAction() @@ -50,9 +73,9 @@ public class EventsAction extends Abstra /** * Sets the event mask.<br> - * 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. + * 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) { Index: ChangeMonitorAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/ChangeMonitorAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- ChangeMonitorAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ ChangeMonitorAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -17,8 +17,8 @@ package net.sf.asterisk.manager.action; /** - * The ChangeMonitorAction changes the monitoring filename of a channel. It has no effect if the - * channel is not monitored.<br> + * The ChangeMonitorAction changes the monitoring filename of a channel. It has + * no effect if the channel is not monitored.<br> * It is implemented in <code>res/res_monitor.c</code> * * @author srt @@ -34,6 +34,29 @@ public class ChangeMonitorAction extends private String file; /** + * Creates a new empty ChangeMonitorAction. + */ + public ChangeMonitorAction() + { + + } + + /** + * Creates a new ChangeMonitorAction that causes the given channel to be + * monitored and voice data to be written to the given files. + * + * @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 + * @since 0.2 + */ + public ChangeMonitorAction(String channel, String file) + { + this.channel = channel; + this.file = file; + } + + /** * Returns the name of this action, i.e. "ChangeMonitor". */ public String getAction() Index: DBPutAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/DBPutAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- DBPutAction.java 16 Jul 2005 13:44:36 -0000 1.2 +++ DBPutAction.java 7 Aug 2005 00:09:42 -0000 1.3 @@ -35,11 +35,35 @@ public class DBPutAction extends Abstrac 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; + } + public String getAction() { return "DBPut"; } - + /** * Returns the family of the key to set. * Index: DBGetAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/DBGetAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- DBGetAction.java 18 Jul 2005 14:53:08 -0000 1.3 +++ DBGetAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -20,8 +20,8 @@ import net.sf.asterisk.manager.event.DBG /** * Retrieves an entry in the Asterisk database for a given family and key.<br> - * If an entry is found a DBGetResponseEvent is sent by Asterisk containing - * the value, otherwise a ManagerError indicates that no entry matches.<br> + * If an entry is found a DBGetResponseEvent is sent by Asterisk containing the + * value, otherwise a ManagerError indicates that no entry matches.<br> * Available since Asterisk 1.2 * * @see net.sf.asterisk.manager.event.DBGetResponseEvent @@ -29,7 +29,9 @@ import net.sf.asterisk.manager.event.DBG * @version $Id$ * @since 0.2 */ -public class DBGetAction extends AbstractManagerAction implements EventGeneratingAction +public class DBGetAction extends AbstractManagerAction + implements + EventGeneratingAction { /** * Serial version identifier @@ -38,15 +40,37 @@ public class DBGetAction extends Abstrac 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; + } + public String getAction() { return "DBGet"; } - + /** - * Returns the family of the key to retrieve. + * Returns the family of the key. * - * @return the family of the key to retrieve. + * @return the family of the key. */ public String getFamily() { @@ -54,9 +78,9 @@ public class DBGetAction extends Abstrac } /** - * Sets the family of the key to retrieve. + * Sets the family of the key. * - * @param family the family of the key to retrieve. + * @param family the family of the key. */ public void setFamily(String family) { @@ -64,9 +88,9 @@ public class DBGetAction extends Abstrac } /** - * Returns the the key to retrieve. + * Returns the the key of the entry to retrieve. * - * @return the key to retrieve. + * @return the key of the entry to retrieve. */ public String getKey() { @@ -74,9 +98,9 @@ public class DBGetAction extends Abstrac } /** - * Sets the key to retrieve. + * Sets the key of the entry to retrieve. * - * @param key the key to retrieve. + * @param key the key of the entry to retrieve. */ public void setKey(String key) { Index: LogoffAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/LogoffAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- LogoffAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ LogoffAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -30,6 +30,14 @@ public class LogoffAction extends Abstra static final long serialVersionUID = -7576797478570238525L; /** + * Creates a new LogoffAction. + */ + public LogoffAction() + { + + } + + /** * Returns the name of this action, i.e. "Logoff". */ public String getAction() Index: AbsoluteTimeoutAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/AbsoluteTimeoutAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- AbsoluteTimeoutAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ AbsoluteTimeoutAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -17,13 +17,14 @@ package net.sf.asterisk.manager.action; /** - * The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted for a call on a - * given channel.<br> - * Note that the timeout is set from the current time forward, not counting the number of seconds - * the call has already been up.<br> + * The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted + * for a call on a given channel.<br> + * Note that the timeout is set from the current time forward, not counting the + * number of seconds the call has already been up.<br> * When setting a new timeout all previous absolute timeouts are cancelled.<br> - * 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).<br> + * 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).<br> * This action corresponds the the AbsoluteTimeout command used in the dialplan. * * @author srt @@ -40,6 +41,27 @@ public class AbsoluteTimeoutAction exten 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 timeout 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". */ public String getAction() Index: AgentsAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/AgentsAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -p -r1.4 -r1.5 --- AgentsAction.java 16 Jul 2005 14:25:48 -0000 1.4 +++ AgentsAction.java 7 Aug 2005 00:09:42 -0000 1.5 @@ -39,6 +39,14 @@ public class AgentsAction extends Abstra static final long serialVersionUID = -320228893513973367L; /** + * Creates a new AgentsAction. + */ + public AgentsAction() + { + + } + + /** * Returns the name of this action, i.e. "Agents". */ public String getAction() Index: AgentLogoffAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/AgentLogoffAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -p -r1.1 -r1.2 --- AgentLogoffAction.java 21 Jul 2005 13:18:29 -0000 1.1 +++ AgentLogoffAction.java 7 Aug 2005 00:09:42 -0000 1.2 @@ -33,6 +33,25 @@ public class AgentLogoffAction extends A private String agent; /** + * 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. + * @since 0.2 + */ + public AgentLogoffAction(String agent) + { + this.agent = agent; + } + + /** * Returns the name of this action, i.e. "AgentLogoff". * * @return the name of this action Index: LoginAction.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/action/LoginAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -p -r1.3 -r1.4 --- LoginAction.java 16 Jul 2005 13:19:34 -0000 1.3 +++ LoginAction.java 7 Aug 2005 00:09:42 -0000 1.4 @@ -18,14 +18,14 @@ package net.sf.asterisk.manager.action; /** * The LoginAction authenticates the connection.<br> - * A successful login is the precondition for sending any other action except for the - * ChallengeAction.<br> - * 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. + * A successful login is the precondition for sending any other action except + * for the ChallengeAction.<br> + * 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 net.sf.asterisk.manager.action.ChallengeAction * @see net.sf.asterisk.manager.response.ManagerError - * * @author srt * @version $Id$ */ @@ -43,6 +43,71 @@ public class LoginAction extends Abstrac private String events; /** + * Creates a new empty LoginAction. + */ + public LoginAction() + { + + } + + /** + * Creates a new LoginAction that performs a cleartext login.<br> + * You should not use cleartext login if you are concerned about security, + * using {@see ChallengeAction} and login with a password hash instead. + * + * @param username the username as configured in Asterisk's + * <code>manager.conf</code> + * @param secret the user's password as configured in Asterisk's + * <code>manager.conf</code> + * @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 + * <code>manager.conf</code> + * @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 + * <code>manager.conf</code> + * @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". */ public String getAction() @@ -75,8 +140,9 @@ public class LoginAction extends Abstrac } /** - * Sets the secret to use when using clear text login.<br> - * The secret contains the user's password as configured in asterisk's <code>manager.conf</code>.<br> + * Sets the secret to use when using cleartext login.<br> + * The secret contains the user's password as configured in Asterisk's + * <code>manager.conf</code>.<br> * The secret and key properties are mutually exclusive. */ public void setSecret(String secret) @@ -94,9 +160,9 @@ public class LoginAction extends Abstrac /** * Sets the digest alogrithm when using challenge/response.<br> - * The digest algorithm is used to create the key based on the challenge and the user's - * password.<br> - * Currently asterisk supports only "MD5". + * The digest algorithm is used to create the key based on the challenge and + * the user's password.<br> + * Currently Asterisk supports only "MD5". */ public void setAuthType(String authType) { @@ -120,7 +186,9 @@ public class LoginAction extends Abstrac } /** - * @return Returns the events. + * Returns the event mask. + * + * @return the event mask. */ public String getEvents() { @@ -128,7 +196,12 @@ public class LoginAction extends Abstrac } /** - * @param events The events to set. + * 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) { |
From: Stefan R. <sr...@us...> - 2005-08-07 00:09:51
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24230/src/java/net/sf/asterisk/manager Modified Files: DefaultManagerConnection.java Log Message: Added convenience constructors to some manager actions Index: DefaultManagerConnection.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/manager/DefaultManagerConnection.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -p -r1.24 -r1.25 --- DefaultManagerConnection.java 2 Aug 2005 10:14:21 -0000 1.24 +++ DefaultManagerConnection.java 7 Aug 2005 00:09:42 -0000 1.25 @@ -384,6 +384,7 @@ public class DefaultManagerConnection im ChallengeAction challengeAction; ChallengeResponse challengeResponse; String challenge; + String key; LoginAction loginAction; ManagerResponse loginResponse; @@ -412,16 +413,11 @@ public class DefaultManagerConnection im } } - challengeAction = new ChallengeAction(); - challengeAction.setAuthType("MD5"); - + challengeAction = new ChallengeAction("MD5"); challengeResponse = (ChallengeResponse) sendAction(challengeAction); challenge = challengeResponse.getChallenge(); - loginAction = new LoginAction(); - loginAction.setAuthType("MD5"); - loginAction.setUsername(username); try { MessageDigest md; @@ -435,7 +431,7 @@ public class DefaultManagerConnection im { md.update(password.getBytes()); } - loginAction.setKey(Util.toHexString(md.digest())); + key = Util.toHexString(md.digest()); } catch (NoSuchAlgorithmException ex) { @@ -444,6 +440,7 @@ public class DefaultManagerConnection im "Unable to create login key using MD5 Message Digest", ex); } + loginAction = new LoginAction(username, "MD5", key); loginResponse = sendAction(loginAction); if (loginResponse instanceof ManagerError) { |
From: Stefan R. <sr...@us...> - 2005-08-06 20:37:57
|
Update of /cvsroot/asterisk-java/asterisk-java/xdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26520/xdocs Modified Files: tutorial.xml Log Message: Updated to include BaseAGIScript Index: tutorial.xml =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/xdocs/tutorial.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -p -r1.13 -r1.14 --- tutorial.xml 2 Jul 2005 09:42:44 -0000 1.13 +++ tutorial.xml 6 Aug 2005 20:37:49 -0000 1.14 @@ -73,6 +73,12 @@ public class HelloAGIScript extends Abst } } ]]></source> + <p>If you are using Asterisk-Java 0.2 (or a snapshot thereof) + you should extend + <a href="http://asterisk-java.sourceforge.net/apidocs/net/sf/asterisk/fastagi/BaseAGIScript.html">BaseAGIScript</a> + instead of AbstractAGIScript. That way you don't have to + pass the channel to all the methods as this is done + automatically.</p> <p>Put this Java source file into a directory of your choice, add the <code>asterisk-java.jar</code> and compile it:</p> <source><![CDATA[ |
From: Stefan R. <sr...@us...> - 2005-08-06 20:37:57
|
Update of /cvsroot/asterisk-java/asterisk-java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26520 Modified Files: ChangeLog Log Message: Updated to include BaseAGIScript Index: ChangeLog =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- ChangeLog 24 Jul 2005 07:53:52 -0000 1.5 +++ ChangeLog 6 Aug 2005 20:37:49 -0000 1.6 @@ -9,6 +9,9 @@ Asterisk-Java 0.2 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. Asterisk-Java 0.1 * Added accessors for raw attributes in ManagerResponse |
From: Stefan R. <sr...@us...> - 2005-08-06 18:43:40
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7780/src/java/net/sf/asterisk/fastagi Modified Files: AGIConnectionHandler.java AbstractAGIScript.java Added Files: BaseAGIScript.java Log Message: Desprecated AbstractAGIScript in favor of BaseAGIScript When using BaseAGIScript you don't have to pass the AGIChannel around to all methods for sending actions as it will always use the AGIChannel attached to the current thread. --- NEW FILE: BaseAGIScript.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi; import net.sf.asterisk.fastagi.command.AGICommand; import net.sf.asterisk.fastagi.command.AnswerCommand; import net.sf.asterisk.fastagi.command.ChannelStatusCommand; import net.sf.asterisk.fastagi.command.ExecCommand; import net.sf.asterisk.fastagi.command.GetDataCommand; import net.sf.asterisk.fastagi.command.GetOptionCommand; import net.sf.asterisk.fastagi.command.GetVariableCommand; import net.sf.asterisk.fastagi.command.HangupCommand; import net.sf.asterisk.fastagi.command.SayAlphaCommand; import net.sf.asterisk.fastagi.command.SayDigitsCommand; import net.sf.asterisk.fastagi.command.SayNumberCommand; import net.sf.asterisk.fastagi.command.SayPhoneticCommand; import net.sf.asterisk.fastagi.command.SayTimeCommand; import net.sf.asterisk.fastagi.command.SetAutoHangupCommand; import net.sf.asterisk.fastagi.command.SetCallerIdCommand; import net.sf.asterisk.fastagi.command.SetContextCommand; import net.sf.asterisk.fastagi.command.SetExtensionCommand; import net.sf.asterisk.fastagi.command.SetMusicOffCommand; import net.sf.asterisk.fastagi.command.SetMusicOnCommand; import net.sf.asterisk.fastagi.command.SetPriorityCommand; import net.sf.asterisk.fastagi.command.SetVariableCommand; import net.sf.asterisk.fastagi.command.StreamFileCommand; import net.sf.asterisk.fastagi.command.WaitForDigitCommand; import net.sf.asterisk.fastagi.reply.AGIReply; /** * The BaseAGIScript provides some convinience methods to make it easier to * write custom AGIScripts.<br> * Just extend it by your own AGIScripts. * * @since 0.2 * @author srt * @version $Id: BaseAGIScript.java,v 1.1 2005/08/06 18:43:24 srt Exp $ */ public abstract class BaseAGIScript implements AGIScript { /** * Answers the channel. */ protected void answer() throws AGIException { sendCommand(new AnswerCommand()); } /** * Hangs the channel up. */ protected void hangup() throws AGIException { sendCommand(new HangupCommand()); } /** * 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.<br> * 0 disables the autohangup feature. */ protected void setAutoHangup(int time) throws AGIException { sendCommand(new SetAutoHangupCommand(time)); } /** * Sets the caller id on the current channel. * * @param callerId the raw caller id to set, for example "John Doe<1234>". */ protected void setCallerId(String callerId) throws AGIException { sendCommand(new SetCallerIdCommand(callerId)); } /** * Plays music on hold from the default music on hold class. */ protected void playMusicOnHold() throws AGIException { sendCommand(new SetMusicOnCommand()); } /** * 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 <code><musiconhold.conf/code>. */ protected void playMusicOnHold(String musicOnHoldClass) throws AGIException { sendCommand(new SetMusicOnCommand(musicOnHoldClass)); } /** * Stops playing music on hold. */ protected void stopMusicOnHold() throws AGIException { sendCommand(new SetMusicOffCommand()); } /** * Returns the status of the channel.<br> * Return values: * <ul> * <li>0 Channel is down and available * <li>1 Channel is down, but reserved * <li>2 Channel is off hook * <li>3 Digits (or equivalent) have been dialed * <li>4 Line is ringing * <li>5 Remote end is ringing * <li>6 Line is up * <li>7 Line is busy * </ul> * * @return the status of the channel. */ protected int getChannelStatus() throws AGIException { AGIReply reply; reply = sendCommand(new ChannelStatusCommand()); return reply.getResultCode(); } /** * 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 */ protected String getData(String file) throws AGIException { AGIReply reply; reply = sendCommand(new GetDataCommand(file)); return reply.getResult(); } /** * 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 to wait for user input.<br> * 0 means standard timeout value, -1 means "ludicrous time" * (essentially never times out). * @return a String containing the DTMF the user entered */ protected String getData(String file, int timeout) throws AGIException { AGIReply reply; reply = sendCommand(new GetDataCommand(file, timeout)); return reply.getResult(); } /** * 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 to wait for user input.<br> * 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 */ protected String getData(String file, int timeout, int maxDigits) throws AGIException { AGIReply reply; reply = sendCommand(new GetDataCommand(file, timeout, maxDigits)); return reply.getResult(); } // TODO add getOption() methods /** * 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 * 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. */ protected char getOption(String file, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new GetOptionCommand(file, escapeDigits)); return reply.getResultCodeAsChar(); } /** * 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 * 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 seconds to wait if none of the defined * esacpe digits was presses while streaming. * @return the DTMF digit pressed or 0x0 if none was pressed. */ protected char getOption(String file, String escapeDigits, int timeout) throws AGIException { AGIReply reply; reply = sendCommand(new GetOptionCommand(file, escapeDigits, timeout)); return reply.getResultCodeAsChar(); } /** * 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. */ protected int exec(String application) throws AGIException { AGIReply reply; reply = sendCommand(new ExecCommand(application)); return reply.getResultCode(); } /** * 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. */ protected int exec(String application, String options) throws AGIException { AGIReply reply; reply = sendCommand(new ExecCommand(application, options)); return reply.getResultCode(); } /** * Sets the context for continuation upon exiting the application. * * @param context the context for continuation upon exiting the application. */ protected void setContext(String context) throws AGIException { sendCommand(new SetContextCommand(context)); } /** * Sets the extension for continuation upon exiting the application. * * @param extension the extension for continuation upon exiting the * application. */ protected void setExtension(String extension) throws AGIException { sendCommand(new SetExtensionCommand(extension)); } /** * Sets the priority for continuation upon exiting the application. * * @param priority the priority for continuation upon exiting the * application. */ protected void setPriority(int priority) throws AGIException { sendCommand(new SetPriorityCommand(priority)); } /** * Plays the given file. * * @param file name of the file to play. */ protected void streamFile(String file) throws AGIException { sendCommand(new StreamFileCommand(file)); } /** * 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. */ protected char streamFile(String file, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new StreamFileCommand(file, escapeDigits)); return reply.getResultCodeAsChar(); } /** * Says the given digit string. * * @param digits the digit string to say. */ protected void sayDigits(String digits) throws AGIException { sendCommand(new SayDigitsCommand(digits)); } /** * 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. */ protected char sayDigits(String digits, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new SayDigitsCommand(digits, escapeDigits)); return reply.getResultCodeAsChar(); } /** * Says the given number. * * @param number the number to say. */ protected void sayNumber(String number) throws AGIException { sendCommand(new SayNumberCommand(number)); } /** * 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. */ protected char sayNumber(String number, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new SayNumberCommand(number, escapeDigits)); return reply.getResultCodeAsChar(); } /** * Says the given character string with phonetics. * * @param text the text to say. */ protected void sayPhonetic(String text) throws AGIException { sendCommand(new SayPhoneticCommand(text)); } /** * 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. */ protected char sayPhonetic(String text, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new SayPhoneticCommand(text, escapeDigits)); return reply.getResultCodeAsChar(); } /** * Says the given character string. * * @param text the text to say. */ protected void sayAlpha(String text) throws AGIException { sendCommand(new SayAlphaCommand(text)); } /** * 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. */ protected char sayAlpha(String text, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new SayAlphaCommand(text, escapeDigits)); return reply.getResultCodeAsChar(); } /** * Says the given time. * * @param time the time to say in seconds since 00:00:00 on January 1, 1970. */ protected void sayTime(long time) throws AGIException { sendCommand(new SayTimeCommand(time)); } /** * 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. */ protected char sayTime(long time, String escapeDigits) throws AGIException { AGIReply reply; reply = sendCommand(new SayTimeCommand(time, escapeDigits)); return reply.getResultCodeAsChar(); } /** * Returns the value of the given channel variable. * * @param name the name of the variable to retrieve. * @return the value of the given variable or <code>null</code> if not * set. */ protected String getVariable(String name) throws AGIException { AGIReply reply; reply = sendCommand(new GetVariableCommand(name)); if (reply.getResultCode() != 1) { return null; } return reply.getExtra(); } /** * Sets the value of the given channel variable to a new value. * * @param name the name of the variable to retrieve. * @param value the new value to set. */ protected void setVariable(String name, String value) throws AGIException { sendCommand(new SetVariableCommand(name, value)); } /** * 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. */ protected char waitForDigit(int timeout) throws AGIException { AGIReply reply; reply = sendCommand(new WaitForDigitCommand(timeout)); return reply.getResultCodeAsChar(); } /** * Sends the given command to the channel attached to the current thread. * * @param command the command to send to Asterisk * @return the reply received from Asterisk * @throws AGIException if the command could not be processed properly */ private AGIReply sendCommand(AGICommand command) throws AGIException { AGIChannel channel; channel = AGIConnectionHandler.getChannel(); return channel.sendCommand(command); } } Index: AGIConnectionHandler.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AGIConnectionHandler.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -p -r1.11 -r1.12 --- AGIConnectionHandler.java 14 Jul 2005 12:54:41 -0000 1.11 +++ AGIConnectionHandler.java 6 Aug 2005 18:43:25 -0000 1.12 @@ -39,6 +39,7 @@ import net.sf.asterisk.util.LogFactory; public class AGIConnectionHandler implements Runnable { private final Log logger = LogFactory.getLog(getClass()); + private static final ThreadLocal channel = new ThreadLocal(); /** * The socket connection. @@ -83,6 +84,7 @@ public class AGIConnectionHandler implem AGIRequest request; AGIChannel channel; AGIScript script; + Thread thread; String threadName; reader = createReader(); @@ -93,7 +95,9 @@ public class AGIConnectionHandler implem script = mappingStrategy.determineScript(request); - threadName = Thread.currentThread().getName(); + thread = Thread.currentThread(); + threadName = thread.getName(); + AGIConnectionHandler.channel.set(channel); if (script != null) { @@ -122,6 +126,7 @@ public class AGIConnectionHandler implem } finally { + AGIConnectionHandler.channel.set(null); try { socket.close(); @@ -132,4 +137,15 @@ public class AGIConnectionHandler implem } } } + + /** + * Returns the AGIChannel associated with the current thread.<br> + * + * @return the AGIChannel associated with the current thread or + * <code>null</code> if none is associated. + */ + static AGIChannel getChannel() + { + return (AGIChannel) AGIConnectionHandler.channel.get(); + } } Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -p -r1.15 -r1.16 --- AbstractAGIScript.java 1 Aug 2005 18:38:43 -0000 1.15 +++ AbstractAGIScript.java 6 Aug 2005 18:43:25 -0000 1.16 @@ -43,8 +43,9 @@ import net.sf.asterisk.fastagi.reply.AGI /** * The AbstractAGIScript provides some convinience methods to make it easier to * write custom AGIScripts.<br> - * Just extend it by your own AGIScripts. + * Just extend it by your own AGIScripts.<br> * + * @deprecated use {@see net.sf.asterisk.fastagi.BaseAGIScript} instead * @author srt * @version $Id$ */ |