Shows SIP contact display name instead of SIP URI. Patch provided by Chris Maciejewski on dev mailing list (subject: "[jitsi-dev] Re: Display Name instead of SIP URI") and extended to handle the case of typing notifications received before the real message.

cusax-fix
Yana Stamcheva 15 years ago
parent b440c43b21
commit 066e959d70

@ -697,13 +697,24 @@ public boolean processRequest(RequestEvent requestEvent)
Message newMessage = createMessage(content, ctype, cencoding, null);
if (from == null) {
if (from == null)
{
if (logger.isDebugEnabled())
logger.debug("received a message from an unknown contact: "
+ fromHeader.getAddress().getURI().toString());
//create the volatile contact
from = opSetPersPresence.createVolatileContact(
fromHeader.getAddress().getURI().toString());
if (fromHeader.getAddress().getDisplayName() != null)
{
from = opSetPersPresence.createVolatileContact(
fromHeader.getAddress().getURI().toString(),
fromHeader.getAddress().getDisplayName().toString());
}
else
{
from = opSetPersPresence.createVolatileContact(
fromHeader.getAddress().getURI().toString());
}
}
// answer ok

@ -1708,9 +1708,12 @@ public Contact createUnresolvedContact(String contactId,
*
* @param contactAddress the address of the volatile contact we'd like to
* create.
* @param displayName the Display Name of the volatile contact we'd like to
* create.
* @return the newly created volatile contact.
*/
public ContactSipImpl createVolatileContact(String contactAddress)
public ContactSipImpl createVolatileContact(String contactAddress,
String displayName)
{
try
{
@ -1724,8 +1727,16 @@ public ContactSipImpl createVolatileContact(String contactAddress)
volatileGroup = ssContactList
.createGroup(rootGroup, "NotInContactList", false);
}
return ssContactList.createContact(volatileGroup,
contactAddress, false);
if (displayName != null)
return ssContactList.createContact( volatileGroup,
contactAddress,
displayName,
false);
else
return ssContactList.createContact( volatileGroup,
contactAddress,
false);
}
catch (OperationFailedException ex)
{
@ -1733,6 +1744,22 @@ public ContactSipImpl createVolatileContact(String contactAddress)
}
}
/**
* Creates a non persistent contact for the specified address. This would
* also create (if necessary) a group for volatile contacts that would not
* be added to the server stored contact list. This method would have no
* effect on the server stored contact list.
*
* @param contactAddress the address of the volatile contact we'd like to
* create.
*
* @return the newly created volatile contact.
*/
public ContactSipImpl createVolatileContact(String contactAddress)
{
return createVolatileContact(contactAddress, null);
}
/**
* Returns the volatile group or null if this group has not yet been
* created.

@ -202,11 +202,20 @@ public boolean processMessage(RequestEvent requestEvent)
fromHeader.getAddress().getURI().toString());
// create fn not in contact list
if(from == null)
if (from == null)
{
//create the volatile contact
from = opSetPersPresence.createVolatileContact(
if (fromHeader.getAddress().getDisplayName() != null)
{
from = opSetPersPresence.createVolatileContact(
fromHeader.getAddress().getURI().toString(),
fromHeader.getAddress().getDisplayName().toString());
}
else
{
from = opSetPersPresence.createVolatileContact(
fromHeader.getAddress().getURI().toString());
}
}
// parse content

@ -256,7 +256,31 @@ public synchronized ContactSipImpl createUnresolvedContact(
* communication.
*/
synchronized public ContactSipImpl createContact(
ContactGroupSipImpl parentGroup, String contactId,
ContactGroupSipImpl parentGroup, String contactId,
boolean persistent)
throws OperationFailedException
{
return createContact(parentGroup, contactId, null, persistent);
}
/**
* Creates contact for the specified address and inside the
* specified group . If creation is successfull event will be fired.
*
* @param parentGroup the group where the unersolved contact is to be
* created.
* @param contactId the sip id of the contact to create.
* @param displayName the display name of the contact to create
* @param persistent specify whether created contact is persistent ot not.
* @return the newly created <tt>ContactSipImpl</tt>.
* @throws OperationFailedException with code NETWORK_FAILURE if the
* operation if failed during network
* communication.
*/
synchronized public ContactSipImpl createContact(
ContactGroupSipImpl parentGroup,
String contactId,
String displayName,
boolean persistent)
throws OperationFailedException
{
@ -309,8 +333,13 @@ synchronized public ContactSipImpl createContact(
newContact = new ContactSipImpl(contactAddress,
sipProvider);
newContact.setPersistent(persistent);
String name = ((SipURI) contactAddress.getURI()).getUser();
newContact.setDisplayName(name);
// Set the display name.
if (displayName == null || displayName.length() <= 0)
displayName = ((SipURI) contactAddress.getURI()).getUser();
newContact.setDisplayName(displayName);
parentGroup.addContact(newContact);
if (newContact.isPersistent())
{

Loading…
Cancel
Save