/* * Jitsi, the OpenSource Java VoIP and Instant Messaging client. * * Distributable under LGPL license. * See terms of license at gnu.org. */ package net.java.sip.communicator.impl.protocol.gibberish; import java.util.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.util.*; /** * A basic implementation of the OperationSetTelephonyConferencing for * the Gibberish protocol (used for test purposes). * * @author Yana Stamcheva */ public class OperationSetTelephonyConferencingGibberishImpl implements OperationSetTelephonyConferencing, CallChangeListener { private static final Logger logger = Logger.getLogger(OperationSetTelephonyConferencingGibberishImpl.class); /** * A reference to the ProtocolProviderServiceGibberishImpl instance * that created us. */ private final ProtocolProviderServiceGibberishImpl protocolProvider; /** * A reference to the OperationSetBasicTelephonyGibberishImpl used * to manage calls. */ private final OperationSetBasicTelephonyGibberishImpl telephonyOpSet; /** * A table mapping call id-s against call instances. */ private Hashtable activeCalls = new Hashtable(); /** * Creates an OperationSetTelephonyConferencingGibberishImpl by * specifying the protocol provider and the according * telephonyOpSet. * @param provider the protocol provider * @param telephonyOpSet the according telephony operation set */ public OperationSetTelephonyConferencingGibberishImpl( ProtocolProviderServiceGibberishImpl provider, OperationSetBasicTelephonyGibberishImpl telephonyOpSet) { this.protocolProvider = provider; this.telephonyOpSet = telephonyOpSet; } /** * Creates a conference call with the given list of callees * @param callees the list of callees to invite in the call * @return the created call * @throws OperationNotSupportedException indicates that the operation is * not supported for the given callees. */ public Call createConfCall(String[] callees) throws OperationNotSupportedException { return createConfCall(callees, null); } /** * Creates a conference call with the given list of callees * * @param callees the list of callees to invite in the call * @param conference the CallConference which represents the state * of the telephony conference into which the specified callees are to be * invited * @return the created call * @throws OperationNotSupportedException indicates that the operation is * not supported for the given callees. */ public Call createConfCall(String[] callees, CallConference conference) throws OperationNotSupportedException { CallGibberishImpl newCall = new CallGibberishImpl(protocolProvider); newCall.addCallChangeListener(this); activeCalls.put(newCall.getCallID(), newCall); for (String callee : callees) { CallPeerGibberishImpl callPeer = new CallPeerGibberishImpl(callee, newCall); newCall.addCallPeer(callPeer); } telephonyOpSet.fireCallEvent(CallEvent.CALL_INITIATED, newCall); return newCall; } /** * Invites the given callee to the given existingCall. * @param callee the address of the callee to invite * @param existingCall the call, to which she will be invited * @return the CallPeer corresponding to the invited * callee * @throws OperationNotSupportedException if the operation is not supported */ public CallPeer inviteCalleeToCall(String callee, Call existingCall) throws OperationNotSupportedException { CallGibberishImpl gibberishCall = (CallGibberishImpl) existingCall; CallPeerGibberishImpl callPeer = new CallPeerGibberishImpl(callee, gibberishCall); gibberishCall.addCallPeer(callPeer); return callPeer; } public void callPeerAdded(CallPeerEvent evt) {} public void callPeerRemoved(CallPeerEvent evt) {} public void callStateChanged(CallChangeEvent evt) { if(evt.getEventType().equals(CallChangeEvent.CALL_STATE_CHANGE) && ((CallState)evt.getNewValue()).equals(CallState.CALL_ENDED)) { CallGibberishImpl sourceCall = (CallGibberishImpl) this.activeCalls .remove(evt.getSourceCall().getCallID()); if (logger.isTraceEnabled()) logger.trace( "Removing call " + sourceCall + " from the list of " + "active calls because it entered an ENDED state"); telephonyOpSet.fireCallEvent(CallEvent.CALL_ENDED, sourceCall); } } }