logger.finer("got status " + status);
WonderlandClientSender sender = WonderlandContext.getCommsManager().getSender(
CellChannelConnectionType.CLIENT_TYPE);
VoiceManager vm = AppContext.getManager(VoiceManager.class);
Call externalCall = null;
if (listing.getExternalCallID() != null) {
externalCall = vm.getCall(listing.getExternalCallID());
}
Call softphoneCall = vm.getCall(listing.getSoftphoneCallID());
logger.fine("external call: " + externalCall);
logger.fine("softphone call: " + softphoneCall);
switch(status.getCode()) {
case CallStatus.INVITED:
//The call has been placed, the phone should be ringing
/** HARRISDEBUG: It should be tested whether or not we'll catch
* callStatus changes for calls which we've just set up.
* If not, this code will have to be moved back to the
* "messageReceived->PlaceCall" function.
**/
if (listing.isPrivate()) {
//Start playing the phone ringing sound
try {
softphoneCall.playTreatment("ring_tone.au");
} catch (IOException e) {
logger.warning("Unable to play treatment " + softphoneCall + ": "
+ e.getMessage());
}
}
sender.send(clientID, new CallInvitedResponseMessage(cellID, listing, true));
break;
//Something's picked up, the call has been connected
case CallStatus.ESTABLISHED:
if (listing.isPrivate()) {
//Stop playing the phone ringing sound
try {
softphoneCall.stopTreatment("ring_tone.au");
} catch (IOException e) {
logger.warning("Unable to stop treatment " + softphoneCall + ": "
+ e.getMessage());
}
}
sender.send(clientID, new CallEstablishedResponseMessage(cellID, listing, true));
break;
case CallStatus.ENDED:
if (ended) {
return;
}
ended = true;
vm.removeCallStatusListener(this);
//Stop the ringing
if (softphoneCall != null) {
try {
softphoneCall.stopTreatment("ring_tone.au");
} catch (IOException e) {
logger.warning(
"Unable to stop treatment " + softphoneCall + ": "
+ e.getMessage());
}
}
String softphoneCallID = listing.getSoftphoneCallID();
//This may appear redundant, but it's necessary for the VoiceManager
// to remove its internal data structures.
if (listing.simulateCalls() == false) {
if (externalCall != null) {
try {
vm.endCall(externalCall, true);
} catch (IOException e) {
logger.warning(
"Unable to end call " + externalCall + ": "
+ e.getMessage());
}
}
if (listing.isPrivate()) {
String audioGroupId = softphoneCallID + "_"
+ listing.getPrivateClientName();
AudioGroup audioGroup = vm.getAudioGroup(audioGroupId);
if (audioGroup != null) {
if (softphoneCall.getPlayer() != null) {
softphoneCall.getPlayer().attenuateOtherGroups(audioGroup,
AudioGroup.DEFAULT_SPEAKING_ATTENUATION,
AudioGroup.DEFAULT_LISTEN_ATTENUATION);
}
vm.removeAudioGroup(audioGroup);
}
}
}
sender.send(clientID, new CallEndedResponseMessage(cellID,