Beispiel #1
0
  /**
   * Set the user associated URIs
   *
   * @param uris List of URIs
   */
  public void setAssociatedUri(ListIterator<Header> uris) {
    if (uris == null) {
      return;
    }
    String sipUri = null;
    String telUri = null;
    while (uris.hasNext()) {
      ExtensionHeader header = (ExtensionHeader) uris.next();
      String value = header.getValue();
      value = SipUtils.extractUriFromAddress(value);

      if (value.startsWith(PhoneUtils.SIP_URI_HEADER)) {
        sipUri = value;
      } else if (value.startsWith(PhoneUtils.TEL_URI_HEADER)) {
        telUri = value;
      }
    }
    if ((sipUri != null) && (telUri != null)) {
      mPreferred = Uri.parse(telUri);
    } else if (telUri != null) {
      mPreferred = Uri.parse(telUri);
    } else if (sipUri != null) {
      mPreferred = Uri.parse(sipUri);
    }
  }
 /**
  * Return the associated SIP URI fetched from the 200 OK response
  *
  * @param list
  * @return
  * @throws PayloadException
  */
 private SipURI getSipUri(ListIterator<Header> list) throws PayloadException {
   SipURI sipUri = null;
   while (list.hasNext()) {
     ExtensionHeader associatedHeader = (ExtensionHeader) list.next();
     String unparsedAddress = associatedHeader.getValue();
     try {
       Address sipAddr = SipUtils.ADDR_FACTORY.createAddress(unparsedAddress);
       URI uri = sipAddr.getURI();
       if (uri instanceof SipURI) {
         sipUri = (SipURI) sipAddr.getURI();
         break;
       }
     } catch (ParseException e) {
       if (sLogger.isActivated()) {
         sLogger.warn(
             new StringBuilder("Failed to parse extension header '")
                 .append(unparsedAddress)
                 .append("'")
                 .toString());
       }
     }
   }
   if (sipUri == null) {
     throw new PayloadException("No SIP-URI found in the P-Associated-URI header!");
   }
   return sipUri;
 }