⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 providerfactory.java

📁 jtapi for telephone
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package net.sourceforge.gjtapi.raw;

/*
	Copyright (c) 2002 8x8 Inc. (www.8x8.com) 

	All rights reserved. 

	Permission is hereby granted, free of charge, to any person obtaining a 
	copy of this software and associated documentation files (the 
	"Software"), to deal in the Software without restriction, including 
	without limitation the rights to use, copy, modify, merge, publish, 
	distribute, and/or sell copies of the Software, and to permit persons 
	to whom the Software is furnished to do so, provided that the above 
	copyright notice(s) and this permission notice appear in all copies of 
	the Software and that both the above copyright notice(s) and this 
	permission notice appear in supporting documentation. 

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
	OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 
	OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
	HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 
	INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 
	FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 
	NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 
	WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 

	Except as contained in this notice, the name of a copyright holder 
	shall not be used in advertising or otherwise to promote the sale, use 
	or other dealings in this Software without prior written authorization 
	of the copyright holder.
*/
import net.sourceforge.gjtapi.*;
import net.sourceforge.gjtapi.capabilities.Capabilities;
import java.util.Properties;
import javax.telephony.*;
/**
 * This is a factory for creating a TelephonyProvider wrapper around a coreTpi implementation.
 * <P>The big problem is that the TPI architecture relies on capabilities being dyanically
 * assigned and plugged in.  Unfortunatly, both media and PrivateData rely on interface
 * implementation to determine if a capability is supported.  Since it is too hard to create
 * generic objects at runtime that selectively implement all these interfaces as more
 * capabilites are added, we choose to provide default No-op behaviour when MethodNotSupported
 * cannot be thrown.
 * Creation date: (2000-10-04 14:19:45)
 * @author: Richard Deadman
 */
public class ProviderFactory implements TelephonyProvider {
	private CoreTpi core;
	private BasicJtapiTpi basicJtapi;
	private CCTpi callControl;
	private MediaTpi media;
	private PrivateDataTpi privateData;
	private ThrottleTpi throttle;
	private JccTpi jcc;
/**
 * ProviderFactory constructor comment.
 */
private ProviderFactory(CoreTpi tpi) {
	super();

	this.core = tpi;

	if (tpi instanceof BasicJtapiTpi) {
		this.basicJtapi = (BasicJtapiTpi)tpi;
	}
	if (tpi instanceof CCTpi) {
		this.callControl = (CCTpi)tpi;
	}
	if (tpi instanceof MediaTpi) {
		this.media = (MediaTpi)tpi;
	}
	if (tpi instanceof ThrottleTpi) {
		this.throttle = (ThrottleTpi)tpi;
	}
	if (tpi instanceof PrivateDataTpi) {
		this.privateData = (PrivateDataTpi)tpi;
	}
	if (tpi instanceof JccTpi) {
		this.jcc = (JccTpi)tpi;
	}
}
/**
 * addListener method comment.
 */
public void addListener(TelephonyListener ro) {
	this.core.addListener(ro);
}
/**
 * allocateMedia method comment.
 */
public boolean allocateMedia(String terminal, int type, java.util.Dictionary resourceArgs) {
	if (this.media != null)
		return this.media.allocateMedia(terminal, type, resourceArgs);
	else
		return false;
}
/**
 * answerCall method comment.
 */
public void answerCall(CallId call, String address, String terminal) throws PrivilegeViolationException, MethodNotSupportedException, ResourceUnavailableException, RawStateException {
	this.core.answerCall(call, address, terminal);
}
/**
 * attachMedia method comment.
 */
public boolean attachMedia(net.sourceforge.gjtapi.CallId call, java.lang.String address, boolean onFlag) {
	if (this.jcc != null)
		return this.jcc.attachMedia(call, address, onFlag);
	else
		return true;	// silent ignore
}
/**
 * beep method comment.
 */
public void beep(net.sourceforge.gjtapi.CallId call) {
	if (this.jcc != null)
		this.jcc.beep(call);
}
/**
 * createCall method comment.
 */
public CallId createCall(CallId id, String address, String term, String dest) throws MethodNotSupportedException, RawStateException, ResourceUnavailableException, InvalidPartyException, InvalidArgumentException, PrivilegeViolationException {
	return this.core.createCall(id, address, term, dest);
}
/**
 * Create a wrapper TelephonyProvider if necessary.
 * Creation date: (2000-10-04 14:30:23)
 * @return net.sourceforge.gjtapi.TelephonyProvider
 * @param tpi net.sourceforge.gjtapi.raw.CoreTpi
 */
public static TelephonyProvider createProvider(CoreTpi tpi) {
	if (tpi instanceof TelephonyProvider)
		return (TelephonyProvider)tpi;
	else
		return new ProviderFactory(tpi);
}
/**
 * freeMedia method comment.
 */
public boolean freeMedia(String terminal, int type) {
	if (this.media != null)
		return this.media.freeMedia(terminal, type);
	else
		return false;
}
/**
 * getAddresses method comment.
 */
public java.lang.String[] getAddresses() throws ResourceUnavailableException {
	if (this.basicJtapi != null)
		return this.basicJtapi.getAddresses();
	else
		throw new ResourceUnavailableException(ResourceUnavailableException.OBSERVER_LIMIT_EXCEEDED,
				"Address querying not supported");

}
/**
 * getAddresses method comment.
 */
public java.lang.String[] getAddresses(String terminal) throws InvalidArgumentException {
	if (this.basicJtapi != null)
		return this.basicJtapi.getAddresses(terminal);
	else
		return null;
}
/**
 * getAddressType method comment.
 */
public int getAddressType(java.lang.String name) {
	if (this.jcc != null)
		return this.jcc.getAddressType(name);
	else
		return javax.csapi.cc.jcc.JccAddress.UNDEFINED;	// Can't return type
}
/**
 * getCall method comment.
 */
public CallData getCall(CallId id) {
	if (this.throttle != null)
		return this.throttle.getCall(id);
	else
		return null;
}
/**
 * getCallsOnAddress method comment.
 */
public net.sourceforge.gjtapi.CallData[] getCallsOnAddress(String number) {
	if (this.throttle != null)
		return this.throttle.getCallsOnAddress(number);
	else
		return null;
}
/**
 * getCallsOnTerminal method comment.
 */
public net.sourceforge.gjtapi.CallData[] getCallsOnTerminal(String name) {
	if (this.throttle != null)
		return this.throttle.getCallsOnTerminal(name);
	else
		return null;
}
/**
 * getCapabilities method comment.
 */
public java.util.Properties getCapabilities() {
	Properties props = this.core.getCapabilities();
	if (props == null)
		props = new Properties();
	if (this.callControl == null) {
		props.put(Capabilities.HOLD, "f");
		props.put(Capabilities.JOIN, "f");
		props.put(Capabilities.RELEASE, "f");
	}

	if (this.media == null) {
		props.put(Capabilities.MEDIA, "f");
		props.put(Capabilities.ALL_MEDIA_TERMINALS, "f");
		props.put(Capabilities.ALLOCATE_MEDIA, "f");
	}

	if (this.throttle == null) {
		props.put(Capabilities.THROTTLE, "f");
		props.put(Capabilities.DYNAMIC_ADDRESSES, "f");
	}

	if (this.privateData == null) {
		props.put(Capabilities.PROV + Capabilities.GET, "f");
		props.put(Capabilities.PROV + Capabilities.SEND, "f");
		props.put(Capabilities.PROV + Capabilities.SET, "f");
	
		props.put(Capabilities.CALL + Capabilities.GET, "f");
		props.put(Capabilities.CALL + Capabilities.SEND, "f");
		props.put(Capabilities.CALL + Capabilities.SET, "f");
	
		props.put(Capabilities.ADDR + Capabilities.GET, "f");
		props.put(Capabilities.ADDR + Capabilities.SEND, "f");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -