diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java index 0d0b5e8..d4662dd 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java @@ -172,7 +172,7 @@ public class ContactSipImpl public String getAddress() { SipURI sipURI = (SipURI) sipAddress.getURI(); - return sipURI.getUser() + "@" + sipURI.getHost(); + return sipURI.toString().substring(sipURI.getScheme().length() + 1); } /** @@ -535,9 +535,7 @@ public class ContactSipImpl if(obj instanceof String) { String sobj = (String)obj; - - if(sobj.startsWith("sip:")) - sobj = sobj.substring(4); + sobj = stripScheme(stripAddress(sobj)); if(getAddress().equalsIgnoreCase(sobj)) return true; @@ -556,6 +554,43 @@ public class ContactSipImpl } /** + * Get rid of any parameters, ports etc. within a sip contact + * @param address the address to strip + * @return [sip[s]:]user@host without any params or port numbers. + */ + static String stripAddress(String address) + { + if (address != null && address.length() > 0) + { + int idx = address.indexOf(':', 5); + if (idx > -1) + address = address.substring(0, idx); + idx = address.indexOf(';'); + if (idx > -1) + address = address.substring(0, idx); + } + return address; + } + + /** + * @param from address to strip + * @return the address, stripped from either "sip:" or "sips:" + */ + public static String stripScheme(String from) + { + if (from.startsWith("sip:")) + { + return from.substring(4); + } + else if (from.startsWith("sips:")) + { + return from.substring(5); + } + + return from; + } + + /** * Returns the presence operation set that this contact belongs * to. * |