?? gcprovider.java
字號:
if ((dc != null) && (nails!=null)){
nails.connectionInProgress(dc, dc.getOrigaddr(),Event.CAUSE_NORMAL);
}
}
void accept(int crn){
debug(1,"accept event on "+crn);
DCall dc = (DCall) calls.get(new Integer(crn));
if (dc != null){
if (dc.getLinedev() != null){
String te = getTermName(dc.getLinedev().intValue());
if(nails!=null){
nails.terminalConnectionCreated(dc,dc.getDestaddr(),"remote",Event.CAUSE_NEW_CALL);
nails.terminalConnectionRinging(dc, dc.getOrigaddr(),te,Event.CAUSE_NEW_CALL);
}
}
}
}
void taskFail(int crn){
debug(1,"taskFail event on "+crn);
}
void answered(int crn){
debug(1,"answered event on "+crn);
DCall dc = (DCall) calls.get(new Integer(crn));
if (dc != null){
if (dc.getLinedev() != null){
String te = getTermName(dc.getLinedev().intValue());
if(nails!=null){
nails.terminalConnectionTalking(dc, dc.getOrigaddr(),te,Event.CAUSE_NORMAL);
}
}
}
}
void dropCall(int crn){
debug(1,"dropCall event on "+crn);
DCall dc = (DCall) calls.get(new Integer(crn));
if (dc != null){
if (dc.getLinedev() != null){
String te = getTermName(dc.getLinedev().intValue());
if(nails!=null){
nails.terminalConnectionDropped(dc, dc.getOrigaddr(),te,Event.CAUSE_NORMAL);
}
}
}
gc_ReleaseCallEx(crn,false);
}
void releaseCall(int crn){
debug(1,"releaseCall event on "+crn);
DCall dc = (DCall) calls.get(new Integer(crn));
if ((dc != null) && (nails != null)){
nails.callInvalid(dc,Event.CAUSE_NORMAL);
}
calls.remove(dc.getCrn());
}
void releaseCallFail(int crn){
debug(1,"releaseCallFail event on "+crn);
}
void callStatus(int crn){
debug(1,"callStatus event on "+crn);
}
void connected(int crn){
debug(1,"connected event on "+crn);
DCall dc = (DCall) calls.get(new Integer(crn));
if ((dc != null) && (nails != null)){
if (dc.getLinedev() != null){
String te = getTermName(dc.getLinedev().intValue());
nails.terminalConnectionTalking((CallId)dc, dc.getOrigaddr(),te,Event.CAUSE_NORMAL);
}
}
}
void disconnected(int crn){
debug(1,"disconnected event on "+crn);
DCall dc = (DCall) calls.get(new Integer(crn));
if (dc != null){
if (dc.getLinedev() != null){
String te = getTermName(dc.getLinedev().intValue());
if(nails!=null){
nails.terminalConnectionDropped(dc, dc.getOrigaddr(),te,Event.CAUSE_NORMAL);
}
}
}
this.gc_DropCall(crn,true,false);
}
/**
* Called from native code when an incomming call arrives.
*/
void createDCall(int ldev,int crn,String dest, String orig){
String line = getTermName(ldev);
debug(1,"call on "+line+" from "+orig+" to "+dest+"crn ="+crn);
DCall dc = new DCall();
dc.setCrn(new Integer(crn));
dc.setLinedev(new Integer(ldev));
dc.setDestaddr(dest);
dc.setOrigaddr(orig);
calls.put(dc.getCrn(),dc);
if (nails!=null) {
nails.callActive(dc,Event.CAUSE_NORMAL);
}
}
/**
* look for Properties that start 'Address' or 'Device'
* Then add them to the requisite tables.
*/
void parseProps(Map p){
Set all = p.keySet();
Iterator it = all.iterator();
Vector addrs = new Vector();
Vector devs = new Vector();
while (it.hasNext()){
String key = (String) it.next();
debug(1,"Property: "+key);
if (key.startsWith("Address")){
String addr = (String) p.get(key);
// could use XXX from the AddressXXX as index into the address
addrs.add(addr);
}
if (key.startsWith("Device")){
String devname = (String) p.get(key);
GCTermData gct = new GCTermData(devname,false);
devs.add(gct);
}
}
String deb =(String) p.get("Debug");
if(deb != null){
try {
debug_level = Integer.parseInt(deb);
} catch (NumberFormatException nfx){
;// drop it.
}
}
String sig = (String) p.get("SigMode");
if ((sig != null) && (sig.startsWith("t"))){
this.polling = false;
}
addresses = new String[addrs.size()];
for (int i=0;i<addresses.length;i++){
addresses[i]= (String) addrs.elementAt(i);
debug(1,"Address ="+addresses[i]);
}
terminals = new GCTermData [devs.size()];
for (int i=0;i<terminals.length;i++){
terminals[i]= (GCTermData) devs.elementAt(i);
debug(1,"terminal ="+terminals[i].terminal);
}
}
/**
* open all the terminals we found in props, bail if _any_ of them
* fail to open.
* Causes async events, which then call waitCall etc.
*/
void openAll(){ // implicit throws RuntimeException
for (int i=0;i<terminals.length;i++){
GCTermData term = terminals[i];
String dev = term.terminal;
int ldev = this.gc_OpenEx(dev,false,(long)i);/**@todo: event to deal with */
term.setLinedev(ldev);
}
}
/**
* close all the terminals
*/
void closeAll(){
RuntimeException x = null;
for (int i=0;i<terminals.length;i++){
GCTermData term = terminals[i];
int ldev = term.linedev;
try {
this.resetLine(ldev);
this.gc_Close(ldev);
} catch (RuntimeException rx) {
x= rx; // we keep trying, but note what failed.
}
}
if (x != null ){
throw x;
}
}
/**
* Find the terminal that has this linedev
*/
GCTermData getTerminal(int ldev){
GCTermData ret = null;
for (int i=0;i<terminals.length;i++){
GCTermData term = terminals[i];
int tdev =term.getLinedev();
if (ldev == tdev){
ret = term;
break;
}
}
return ret;
}
/**
* Find the terminal that has this name
*/
GCTermData getTerminal(String name){
GCTermData ret = null;
if (name != null) {
for (int i=0;i<terminals.length;i++){
GCTermData term = terminals[i];
if (name.equals(term.terminal)){
ret = term;
break;
}
}
}
return ret;
}
/**
* get the name of the LineDev
*/
String getTermName(int ldev){
String name = null;
GCTermData td = getTerminal(ldev);
if (td != null){
name = td.terminal;
}
return name;
}
public void run() {
while (!done){
sr_waitevt(1000);
debug(5,"tick");
}
}
// now our native methods
static {
System.loadLibrary("gcprovider");
}
native int gc_OpenEx(String name, boolean sync, long lineMark);
native int gc_stop();
native int sr_waitevt(long delay);
native int srlibinit(boolean poll);
native int gc_AcceptCall(int crn, int rings,boolean sync);
native int gc_AnswerCall(int crn, int rings,boolean sync);
native int gc_DropCall(int crn, boolean normalcause,boolean sync);
native int gc_ReleaseCallEx(int crn, boolean sync);
native int gc_MakeCall(int linedev, String numberstr, int timeout, boolean sync);
native int gc_WaitCall(int linedev, int timeout, boolean sync);
native int gc_Close(int linedev);
native int resetLine(int linedev);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -