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

📄 inverterprovider.java

📁 jtapi for telephone
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	}
}
/**
 * Create a Call Object and map it to a CallId.
 */
public CallId reserveCallId(String address) {
	InverterListener il = this.getListener();
	try {
		Call call = this.getJtapiProv().createCall();
			// ensure we monitor this call
		call.addCallListener(il);
		call.addObserver(il);
			// return its id
		return this.getCallMap().getId(call);
	} catch (Exception e) {
			// ResourceUnavailableException, InvalidStateException,
			// PrivilegeViolationException, MethodNotSupportedException
		return null;
	}
}
/**
 * Resolve the target information into a JTAPI object.
 * Creation date: (2000-08-09 12:04:32)
 * @author: Richard Deadman
 * @return The appropriate JTAPI object based on the parameters, or null if it could not be resolved.
 * @param call If null, used for Providers, Addresses and Terminals; otherwise Calls and Connections
 * @param addr If null, used for Providers, Calls and Terminals; otherwise Addresses, Connections and TerminalConnections
 * @param term If null, used for Providers, Calls, Addresses and Connections; otherwise Terminals and TerminalConnections, 
 */
private Object resolveTarget(CallId call, String addr, String term) {
	Provider prov = this.getJtapiProv();

	Call c = null;
	Address a = null;
	Terminal t = null;

		// first check if a provider is requested
	if ((call == null) && (addr == null) && (term == null)) {
		return prov;
	}
	
		// first check Calls, Connections and TerminalConnections
	if (call != null) {
		IdMapper map = this.getCallMap();
		c = map.jtapiCall(call);
		if (c == null) {
			// bad mapping
			return c;
		}
	}

	// Now look up Address, Connection and TerminalConnection info
	if (addr != null) {
		try {
			a = prov.getAddress(addr);
		} catch (InvalidArgumentException iae) {
			// bad mapping
			return null;
		}
	}

	// Now look up Terminal and TerminalConnection info
	if (term != null) {
		try {
			t = prov.getTerminal(term);
		} catch (InvalidArgumentException iae) {
			// bad mapping
			return null;
		}
	}

	// check if we want a Call, Connection or TerminalConnection
	if (call != null) {
		if (addr != null) {
			Connection[] conns = c.getConnections();
			int csize = conns.length;
			for (int i = 0; i < csize; i++) {
				if (conns[i].getAddress().equals(a)) {
					Connection conn = conns[i];
					if (term != null) { // want the TerminalConnection
						TerminalConnection[] tcs = conn.getTerminalConnections();
						int tcSize = tcs.length;
						for (int j = 0; j < tcSize; j++) {
							if (tcs[j].getTerminal().equals(t))
								return tcs[j];
						}
					} else { // just want the connection
						return conn;
					}
				}
			}
		} else {	// just want the call
			return c;
		}
	} else {	// want the Address or Terminal
		if (addr != null) {
			return a;
		} else if (term != null) {
			return t;
		}
	}

	// return null to indicate that the object could not be resolved.
	return null;
}
/**
 * Forward the sendPrivateData off to the appropriate object, or return null if the object does not support PrivateData.
 */
public Object sendPrivateData(CallId call, String address, String terminal, Object data) {
	Object target = this.resolveTarget(call, address, terminal);

	if ((target != null) && (target instanceof PrivateData)) {
		return ((PrivateData)target).sendPrivateData(data);
	} else
		return null;
}
/**
 * Try to find the terminal connection for the call and set it as the conference controller.
 * Creation date: (2000-10-04 13:10:40)
 * @param call javax.telephony.callcontrol.CallControlCall
 * @param address The TerminalConnection's Connection address name.
 * @param terminal The TerminalConnection's terminal name.
 */
private void setConferenceController(CallControlCall call, String address, String terminal) {
	if ((address == null) || (terminal == null))
		return;

	Connection[] conns = call.getConnections();
	int connSize = conns.length;
	for (int i = 0; i < connSize; i++) {
		if (conns[i].getAddress().getName().equals(address)) {
			TerminalConnection[] tcs = conns[i].getTerminalConnections();
			int tcSize = tcs.length;
			for (int j = 0; j < tcSize; j++) {
				if (tcs[i].getTerminal().getName().equals(terminal)) {
					try {
						call.setConferenceController(tcs[i]);
					} catch (Exception e) {
						// we tried...
					}
					return;
				}
			}
		}
	}
}
/**
 * Internal setter for the managed Jtapi provider I am an Adapter for.
 * Creation date: (2000-06-01 14:40:49)
 * @author: Richard Deadman
 * @param newJtapiProv A plugged-in JTAPI adapter
 */
private void setJtapiProv(Provider newJtapiProv) {
	this.jtapiProv = newJtapiProv;
}
/**
 * Insert the method's description here.
 * Creation date: (2000-06-06 13:04:17)
 * @author: Richard Deadman
 * @param newListener net.sourceforge.gjtapi.raw.invert.InverterListener
 */
private void setListener(InverterListener newListener) {
	listener = newListener;
}
/**
 * Forward the setPrivateData off to the appropriate object, or eat the command if the object does not support PrivateData.
 */
public void setPrivateData(CallId call, String address, String terminal, Object data) {
	Object target = this.resolveTarget(call, address, terminal);

	if ((target != null) && (target instanceof PrivateData)) {
		((PrivateData)target).setPrivateData(data);
	}
}
/**
 * Internal setter
 * Creation date: (2000-02-22 14:20:52)
 * @author: Richard Deadman
 * @param newProvProps A new set of properties
 */
private void setProvProps(Map newProvProps) {
	provProps = newProvProps;
}
/**
 * Tell the wrapped JTAPI provider to shut down.
 */
public void shutdown() {
	this.getJtapiProv().shutdown();
}
/**
 * reportCall method comment.
 */
public boolean stopReportingCall(CallId id) {
	Call call = this.getCallMap().jtapiCall(id);
	if (call == null)
		return false;

	InverterListener list = this.getListener();

	call.removeCallListener(list);
	call.removeObserver(list);

	return true;
}
/**
 * Convert a Jtapi Call object to a CallData snapshot.
 * Creation date: (2000-06-24 0:13:14)
 * @author: Richard Deadman
 * @return A snapshot of the call's state.
 * @param c A Jtapi Call.
 */
private CallData toCallData(Call c) {
	Connection[] conns = c.getConnections();
	ConnectionData[] cd = null;
	if (conns != null) {
		int connSize = conns.length;
		cd = new ConnectionData[connSize];
		for (int i = 0; i < connSize; i++) {
			Connection con = conns[i];
			TerminalConnection[] tcs = con.getTerminalConnections();
			TCData[] tcd = null;
			if (tcs != null) {
				int tcSize = tcs.length;
				tcd = new TCData[tcSize];
				for (int j = 0; j < tcSize; j++) {
					TerminalConnection tc = tcs[i];
					Terminal term = tc.getTerminal();
						// find the CallControlTerminalConnection state
					int cctcs = CallControlTerminalConnection.UNKNOWN;
					if (tc instanceof CallControlTerminalConnection) {
						cctcs = ((CallControlTerminalConnection)tc).getCallControlState();
					} else {
						switch (tc.getState()) {
							case TerminalConnection.ACTIVE: {
								cctcs = CallControlTerminalConnection.TALKING;
								break;
							}
							case TerminalConnection.DROPPED: {
								cctcs = CallControlTerminalConnection.DROPPED;
								break;
							}
							case TerminalConnection.IDLE: {
								cctcs = CallControlTerminalConnection.IDLE;
								break;
							}
							case TerminalConnection.PASSIVE: {
								cctcs = CallControlTerminalConnection.BRIDGED;
								break;
							}
							case TerminalConnection.RINGING: {
								cctcs = CallControlTerminalConnection.RINGING;
								break;
							}
						}
					}
					tcd[j] = new TCData(cctcs, new TermData(term.getName(),
											term instanceof MediaTerminal));
				}
			}
			String addrName = con.getAddress().getName();
			boolean local = true;
			// test if the Address is not local
			try {
				this.getJtapiProv().getAddress(addrName);
			} catch (InvalidArgumentException iae) {
				local = false;
			}
			cd[i] = new ConnectionData(con.getState(),
							addrName,
							local,
							tcd);
		}
	}
	return new CallData(this.getCallMap().getId(c), c.getState(), cd);
}
/**
 * Describe myself
 * @return a string representation of the receiver
 */
public String toString() {
	return "A Generic JTAPI TelephonyProvider adapter for a JTAPI provider named: " + this.getJtapiProv().toString();
}
/**
 * unHold method comment.
 */
public void unHold(CallId call, String address, String terminal) throws MethodNotSupportedException, RawStateException, PrivilegeViolationException, ResourceUnavailableException {
	TerminalConnection tc = this.getTc(call, address, terminal);
	if (tc != null) {	// we found the connection
		if (tc instanceof CallControlTerminalConnection) {
			try {
				((CallControlTerminalConnection)tc).unhold();
			} catch (InvalidStateException ise) {
				throw new RawStateException(call, address, terminal,
					ise.getObjectType(),
					ise.getState(),
					ise.getMessage());
			}
		} else {
			throw new MethodNotSupportedException("Not a CallControl Terminal Connection.  Can't hold");
		}
	} else {
		throw new ResourceUnavailableException(ResourceUnavailableException.UNKNOWN, "Could not find terminal connection");
	}
}
	/**
	 * Should we release the NewMedia MediaService on freeing the media
	 * terminal?
	 * @return boolean
	 */
	public boolean mediaFreeRelease() {
		return mediaFreeRelease;
	}

	/**
	 * Sets the mediaFreeRelease state used by the NewMediaProvider.
	 * @param mediaFreeRelease The mediaFreeRelease to set
	 */
	private void setMediaFreeRelease(boolean mediaFreeRelease) {
		this.mediaFreeRelease = mediaFreeRelease;
	}

}

⌨️ 快捷键说明

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