Fixes handling of received errors for sent messages to private contacts when original chat room is left (typing opset used to create a contact for the chat room). Ignore retrieving some information for private contacts as it is not available.

fix-message-formatting 5223
Damian Minkov 12 years ago
parent 1049951787
commit 854e8b73c7

@ -63,6 +63,9 @@ public <T extends GenericDetail> Iterator<T> getDetailsAndDescendants(
Contact contact,
Class<T> detailClass)
{
if(isPrivateMessagingContact(contact))
return new LinkedList<T>().iterator();
List<GenericDetail> details
= infoRetreiver.getContactDetails(contact.getAddress());
List<T> result = new LinkedList<T>();
@ -94,6 +97,9 @@ public Iterator<GenericDetail> getDetails(
Contact contact,
Class<? extends GenericDetail> detailClass)
{
if(isPrivateMessagingContact(contact))
return new LinkedList<GenericDetail>().iterator();
List<GenericDetail> details
= infoRetreiver.getContactDetails(contact.getAddress());
List<GenericDetail> result = new LinkedList<GenericDetail>();
@ -117,6 +123,9 @@ public Iterator<GenericDetail> getDetails(
*/
public Iterator<GenericDetail> getAllDetailsForContact(Contact contact)
{
if(isPrivateMessagingContact(contact))
return new LinkedList<GenericDetail>().iterator();
List<GenericDetail> details
= infoRetreiver.getContactDetails(contact.getAddress());
@ -200,4 +209,19 @@ public void run()
// return null as there is no cache and we will try to retrieve
return null;
}
/**
* Checks whether a contact is a private messaging contact for chat rooms.
* @param contact the contact to check.
* @return <tt>true</tt> if contact is private messaging contact
* for chat room.
*/
private boolean isPrivateMessagingContact(Contact contact)
{
if(contact instanceof VolatileContactJabberImpl)
return ((VolatileContactJabberImpl) contact)
.isPrivateMessagingContact();
return false;
}
}

@ -454,9 +454,19 @@ public void stateChanged(Chat chat,
(isPrivateMessagingAddress? message.getFrom() : fromID));
if(sourceContact == null)
{
//create the volatile contact
sourceContact = opSetPersPresence.createVolatileContact(
chat.getParticipant(), isPrivateMessagingAddress);
// in private messaging we can receive some errors
// when we left room (isPrivateMessagingAddress == false)
// and we try to send some message
if(message.getError() != null)
sourceContact = opSetPersPresence.findContactByID(
message.getFrom());
if(sourceContact == null)
{
//create the volatile contact
sourceContact = opSetPersPresence.createVolatileContact(
chat.getParticipant(), isPrivateMessagingAddress);
}
}
int evtCode = STATE_UNKNOWN;

@ -1173,17 +1173,21 @@ void fireContactResolved( ContactGroup parentGroup,
* when there is no image for contact we must retrieve it
* add contacts for image update
*
* @param c ContactJabberImpl
* @param contact ContactJabberImpl
*/
protected void addContactForImageUpdate(ContactJabberImpl c)
protected void addContactForImageUpdate(ContactJabberImpl contact)
{
if(contact instanceof VolatileContactJabberImpl
&& ((VolatileContactJabberImpl)contact).isPrivateMessagingContact())
return;
if(imageRetriever == null)
{
imageRetriever = new ImageRetriever();
imageRetriever.start();
}
imageRetriever.addContact(c);
imageRetriever.addContact(contact);
}
/**

@ -94,8 +94,6 @@ public class VolatileContactJabberImpl
setJid(id);
}
}
}
/**

Loading…
Cancel
Save