📄 tapiconnection.java
字号:
/*
* JTAPI library copyright 1998 by Web4Groups consortium (http://Web4Groups.at)
*/
import java.telephony.*;
import java.telephony.events.*;
import java.telephony.capabilities.*;
class TAPIConnection implements Connection {
int state = IDLE;
Call call;
Address address;
int line;
ArrayVector tConnections;
TAPIConnection(Call call, Address address, int line) {
this.call = call;
this.address = address;
this.line = line;
tConnections = new ArrayVector();
}
private native void TAPIDisconnect(int line);
/* implementation specific */
void addTerminalConnection(TAPIMediaTerminalConnection tConnection) {
if (tConnection != null)
tConnections.addElement(tConnection);
}
public int getState() {
return state;
}
public Call getCall() {
return call;
}
public Address getAddress() {
return address;
}
public TerminalConnection[] getTerminalConnections() throws InvalidStateException, PlatformException {
Provider provider = call.getProvider();
int s = provider.getState();
if (s != Provider.IN_SERVICE)
throw new InvalidStateException(provider, InvalidStateException.PROVIDER_OBJECT, s);
TerminalConnection ret[] = null;
Object obj[] = tConnections.getArray();
if (obj != null){
ret = new TerminalConnection[obj.length];
System.arraycopy(obj, 0, ret, 0, obj.length);
}
return ret;
}
public void disconnect() throws InvalidStateException, PlatformException {
Provider provider = call.getProvider();
int s = provider.getState();
if (s != Provider.IN_SERVICE)
throw new InvalidStateException(provider, InvalidStateException.PROVIDER_OBJECT, s);
if ( !((state == CONNECTED) || (state == ALERTING) || (state == FAILED) || (state == INPROGRESS)))
throw new InvalidStateException(this, InvalidStateException.CONNECTION_OBJECT, state);
TAPIDisconnect(line);
state = DISCONNECTED;
TerminalConnection tc[] = getTerminalConnections();
TAPITerminalConnection ttc = null;
TAPITerminal terminal = null;
CallEv[] evList = new TAPICallEv[1 + tc.length];
evList[0] = new TAPIConnDisconnectedEv(terminal, call, this);
for (int i = 0; i < tc.length; i++) {
ttc = (TAPITerminalConnection)tc[i];
terminal = (TAPITerminal)ttc.getTerminal();
terminal.removeTerminalConnection(ttc);
ttc.state = TerminalConnection.DROPPED;
evList[1+i] = new TAPITermConnDroppedEv(terminal, call, ttc);
}
tConnections = null;
TAPICall tCall = (TAPICall)getCall();
Connection conn[] = tCall.getConnections();
for (int i = 0; i < conn.length; i++) {
tCall.removeConnection(conn[i]);
}
TAPIAddress address = (TAPIAddress)getAddress();
address.removeConnection(this);
CallObserver[] obs = terminal.getCallObservers();
RunCallObservers ro = new RunCallObservers(obs, evList);
ro.start();
//prepare this object for garbage collection (destroy?)
}
public ConnectionCapabilities getConnectionCapabilities(Terminal terminal, Address address) {
TerminalConnection tc[] = null;
try {
tc = terminal.getTerminalConnections();
}
catch (Exception e) {
System.out.println("Exception in Connection.getConnectionCapabilities: " + e.toString());
}
TAPITerminalConnection ttc = (TAPITerminalConnection)tc[0];
return new TAPIMediaTerminalConnectionCapabilities(ttc.line);
}
static {
System.loadLibrary("KapschProvider");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -