use of gov.nist.javax.sip.address.AddressImpl in project XobotOS by xamarin.
the class SIPDialog method addRoute.
/**
* Add a route list extracted from a record route list. If this is a server dialog then we
* assume that the record are added to the route list IN order. If this is a client dialog
* then we assume that the record route headers give us the route list to add in reverse
* order.
*
* @param recordRouteList -- the record route list from the incoming message.
*/
private void addRoute(RecordRouteList recordRouteList) {
try {
if (this.isClientDialog()) {
// This is a client dialog so we extract the record
// route from the response and reverse its order to
// careate a route list.
this.routeList = new RouteList();
// start at the end of the list and walk backwards
ListIterator li = recordRouteList.listIterator(recordRouteList.size());
boolean addRoute = true;
while (li.hasPrevious()) {
RecordRoute rr = (RecordRoute) li.previous();
if (addRoute) {
Route route = new Route();
AddressImpl address = ((AddressImpl) ((AddressImpl) rr.getAddress()).clone());
route.setAddress(address);
route.setParameters((NameValueList) rr.getParameters().clone());
this.routeList.add(route);
}
}
} else {
// This is a server dialog. The top most record route
// header is the one that is closest to us. We extract the
// route list in the same order as the addresses in the
// incoming request.
this.routeList = new RouteList();
ListIterator li = recordRouteList.listIterator();
boolean addRoute = true;
while (li.hasNext()) {
RecordRoute rr = (RecordRoute) li.next();
if (addRoute) {
Route route = new Route();
AddressImpl address = ((AddressImpl) ((AddressImpl) rr.getAddress()).clone());
route.setAddress(address);
route.setParameters((NameValueList) rr.getParameters().clone());
routeList.add(route);
}
}
}
} finally {
if (sipStack.getStackLogger().isLoggingEnabled()) {
Iterator it = routeList.iterator();
while (it.hasNext()) {
SipURI sipUri = (SipURI) (((Route) it.next()).getAddress().getURI());
if (!sipUri.hasLrParam()) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logWarning("NON LR route in Route set detected for dialog : " + this);
sipStack.getStackLogger().logStackTrace();
}
}
}
}
}
}
use of gov.nist.javax.sip.address.AddressImpl in project XobotOS by xamarin.
the class ListeningPointImpl method createContactHeader.
public ContactHeader createContactHeader() {
try {
String ipAddress = this.getIPAddress();
int port = this.getPort();
SipURI sipURI = new SipUri();
sipURI.setHost(ipAddress);
sipURI.setPort(port);
sipURI.setTransportParam(this.transport);
Contact contact = new Contact();
AddressImpl address = new AddressImpl();
address.setURI(sipURI);
contact.setAddress(address);
return contact;
} catch (Exception ex) {
InternalErrorHandler.handleException("Unexpected exception", sipStack.getStackLogger());
return null;
}
}
use of gov.nist.javax.sip.address.AddressImpl in project XobotOS by xamarin.
the class Contact method setWildCardFlag.
/**
* Set the wildCardFlag member
* @param w boolean to set
*/
public void setWildCardFlag(boolean w) {
this.wildCardFlag = true;
this.address = new AddressImpl();
this.address.setWildCardFlag();
}
use of gov.nist.javax.sip.address.AddressImpl in project XobotOS by xamarin.
the class SIPClientTransaction method createAck.
/*
* (non-Javadoc)
*
* @see javax.sip.ClientTransaction#createAck()
*/
public Request createAck() throws SipException {
SIPRequest originalRequest = this.getOriginalRequest();
if (originalRequest == null)
throw new SipException("bad state " + getState());
if (getMethod().equalsIgnoreCase(Request.ACK)) {
throw new SipException("Cannot ACK an ACK!");
} else if (lastResponse == null) {
throw new SipException("bad Transaction state");
} else if (lastResponse.getStatusCode() < 200) {
if (sipStack.isLoggingEnabled()) {
sipStack.getStackLogger().logDebug("lastResponse = " + lastResponse);
}
throw new SipException("Cannot ACK a provisional response!");
}
SIPRequest ackRequest = originalRequest.createAckRequest((To) lastResponse.getTo());
// Pull the record route headers from the last reesponse.
RecordRouteList recordRouteList = lastResponse.getRecordRouteHeaders();
if (recordRouteList == null) {
// request URI.
if (lastResponse.getContactHeaders() != null && lastResponse.getStatusCode() / 100 != 3) {
Contact contact = (Contact) lastResponse.getContactHeaders().getFirst();
javax.sip.address.URI uri = (javax.sip.address.URI) contact.getAddress().getURI().clone();
ackRequest.setRequestURI(uri);
}
return ackRequest;
}
ackRequest.removeHeader(RouteHeader.NAME);
RouteList routeList = new RouteList();
// start at the end of the list and walk backwards
ListIterator<RecordRoute> li = recordRouteList.listIterator(recordRouteList.size());
while (li.hasPrevious()) {
RecordRoute rr = (RecordRoute) li.previous();
Route route = new Route();
route.setAddress((AddressImpl) ((AddressImpl) rr.getAddress()).clone());
route.setParameters((NameValueList) rr.getParameters().clone());
routeList.add(route);
}
Contact contact = null;
if (lastResponse.getContactHeaders() != null) {
contact = (Contact) lastResponse.getContactHeaders().getFirst();
}
if (!((SipURI) ((Route) routeList.getFirst()).getAddress().getURI()).hasLrParam()) {
// Contact may not yet be there (bug reported by Andreas B).
Route route = null;
if (contact != null) {
route = new Route();
route.setAddress((AddressImpl) ((AddressImpl) (contact.getAddress())).clone());
}
Route firstRoute = (Route) routeList.getFirst();
routeList.removeFirst();
javax.sip.address.URI uri = firstRoute.getAddress().getURI();
ackRequest.setRequestURI(uri);
if (route != null)
routeList.add(route);
ackRequest.addHeader(routeList);
} else {
if (contact != null) {
javax.sip.address.URI uri = (javax.sip.address.URI) contact.getAddress().getURI().clone();
ackRequest.setRequestURI(uri);
ackRequest.addHeader(routeList);
}
}
return ackRequest;
}
use of gov.nist.javax.sip.address.AddressImpl in project XobotOS by xamarin.
the class AddressHeaderParser method parse.
protected void parse(AddressHeaderIms addressHeader) throws ParseException {
dbg_enter("AddressHeaderParser.parse");
try {
AddressParser addressParser = new AddressParser(this.getLexer());
AddressImpl addr = addressParser.address(true);
addressHeader.setAddress(addr);
} catch (ParseException ex) {
throw ex;
} finally {
dbg_leave("AddressParametersParser.parse");
}
}
Aggregations