From 73f52e7913888fa92dbdda51d63410e082add56d Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 12 Jun 2007 10:11:59 +0000 Subject: [PATCH] Fix problem when receiving a call from asterisk - problem with contact headers. --- .../sip/ProtocolProviderServiceSipImpl.java | 36 +++++++++---------- .../protocol/sip/SipRegistrarConnection.java | 4 +-- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index 60523809f..02d8d8a78 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -1320,22 +1320,18 @@ public ContactHeader getContactHeader() { if(this.genericContactHeader == null) { - genericContactHeader = headerFactory.createContactHeader( - ourSipAddress); - try - { - genericContactHeader.getAddress() - .setDisplayName(getOurDisplayName()); - } - catch (ParseException ex) - { - logger.error( - "Failed to set a display name on a Contact header." - , ex); - } - logger.debug("generated contactHeader:" - + genericContactHeader); - + try + { + genericContactHeader = getContactHeader( + sipRegistrarConnection.getRegistrarAddress(), + sipRegistrarConnection.getRegistrarListeningPoint()); + } + catch(OperationFailedException ex) + { + logger.error("Failed to create Contact header.", ex); + } + logger.debug("generated contactHeader:" + + genericContactHeader); } return genericContactHeader; } @@ -1344,7 +1340,7 @@ public ContactHeader getContactHeader() * Retrns a Contact header containing a sip URI base on a localhost address * and thereforeusable in REGISTER requests only. * - * @param registrarAddress the address of the registrar that this contact + * @param targetAddress the address of the registrar that this contact * header is meant for. * @param srcListeningPoint the listening point that will be used when * accessing the registrar. @@ -1353,8 +1349,8 @@ public ContactHeader getContactHeader() * @throws OperationFailedException if we fail constructing the contact * header. */ - ContactHeader getRegistrationContactHeader(InetAddress registrarAddress, - ListeningPoint srcListeningPoint) + ContactHeader getContactHeader(InetAddress targetAddress, + ListeningPoint srcListeningPoint) throws OperationFailedException { ContactHeader registrationContactHeader = null; @@ -1362,7 +1358,7 @@ ContactHeader getRegistrationContactHeader(InetAddress registrarAddress, { InetSocketAddress localAddress = SipActivator .getNetworkAddressManagerService() - .getPublicAddressFor(registrarAddress + .getPublicAddressFor(targetAddress , srcListeningPoint.getPort()); SipURI contactURI = addressFactory.createSipURI( diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java index 760e90abf..2448fb5dd 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java @@ -301,7 +301,7 @@ void register() //Contact Header (should contain IP) ContactHeader contactHeader - = sipProvider.getRegistrationContactHeader( + = sipProvider.getContactHeader( registrarAddress, getRegistrarListeningPoint()); //add expires in the contact header as well in case server likes it @@ -737,7 +737,7 @@ public InetAddress getRegistrarAddress() * @return the listening point that should be used for communiction with our * current registrar. */ - private ListeningPoint getRegistrarListeningPoint() + ListeningPoint getRegistrarListeningPoint() { return sipProvider.getListeningPoint(registrarURI.getTransportParam()); }