From 04d5a4c7e3fdc94f039808702c01910ffae42db7 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Wed, 10 Sep 2008 20:38:50 +0000 Subject: [PATCH] Make sure that the contact list really gets the images from the network and not only from the local cache. --- .../impl/contactlist/MetaContactImpl.java | 17 +++++--- .../MetaContactListServiceImpl.java | 2 +- .../impl/gui/main/chat/ChatContact.java | 39 ++++++++++--------- .../impl/protocol/rss/RssActivator.java | 2 +- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java index 4b3cb054b..1309d5899 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactImpl.java @@ -518,8 +518,13 @@ public byte[] getAvatar(boolean isLazy) { Contact protoContact = iter.next(); - String avatarPath = AVATAR_DIR + "/" - + protoContact.getProtocolProvider().getProtocolName() + "/" + String accountUID = escapeSpecialCharacters(protoContact + .getProtocolProvider().getAccountID().getAccountUniqueID()); + + String avatarPath = AVATAR_DIR + + File.separator + + accountUID + + File.separator + escapeSpecialCharacters(protoContact.getAddress()); cachedAvatar = getLocallyStoredAvatar(avatarPath); @@ -939,12 +944,14 @@ public List getDetails(String name) public void storeAvatar( Contact protoContact, byte[] avatarBytes) { - String protocolName - = protoContact.getProtocolProvider().getProtocolName(); + String accountUID = protoContact.getProtocolProvider() + .getAccountID().getAccountUniqueID(); + + accountUID = escapeSpecialCharacters(accountUID); String avatarDirPath = AVATAR_DIR + File.separator - + protocolName; + + accountUID; String escapedProtocolId = escapeSpecialCharacters(protoContact.getAddress()); diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java index 303db10ac..a194df2d4 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java @@ -841,7 +841,7 @@ public void changeMetaContactAvatar(MetaContact metaContact, metaContact + " is not a MetaContactImpl instance."); } - byte[] oldAvatar = metaContact.getAvatar(true); + byte[] oldAvatar = metaContact.getAvatar(); ((MetaContactImpl)metaContact).storeAvatar(protoContact, newAvatar); fireMetaContactPropertyChangeEvent(new MetaContactAvatarUpdate( diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContact.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContact.java index 758ff2cb7..062717da5 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContact.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContact.java @@ -21,7 +21,7 @@ /** * The ChatContact is a wrapping class for the Contact and * ChatRoomMember interface. - * + * * @author Yana Stamcheva */ public class ChatContact @@ -49,7 +49,7 @@ public class ChatContact /** * Creates an instance of ChatContact by passing to it the * Contact for which it is created. - * + * * @param contact the Contact for which this ChatContact * is created */ @@ -57,11 +57,11 @@ public ChatContact(Contact contact) { this(null, contact); } - + /** * Creates an instance of ChatContact by passing to it the * corresponding MetaContact and Contact. - * + * * @param metaContact the MetaContact encapsulating the given * Contact * @param contact the Contact for which this ChatContact @@ -82,11 +82,11 @@ public ChatContact(MetaContact metaContact, Contact contact) if (name == null || name.length() < 1) name = Messages.getI18NString("unknown").getText(); } - + /** * Creates an instance of ChatContact by passing to it the * ChatRoomMember for which it is created. - * + * * @param chatRoomMember the ChatRoomMember for which this * ChatContact is created. */ @@ -104,7 +104,7 @@ public ChatContact(ChatRoomMember chatRoomMember) /** * Returns the contact identifier. - * + * * @return the contact identifier */ public String getAddress() @@ -114,18 +114,18 @@ public String getAddress() /** * Returns the contact name. - * + * * @return the contact name - */ + */ public String getName() { return name; } - + /** * Returns the current presence status for single user chat contacts and * null for multi user chat contacts. - * + * * @return the current presence status for single user chat contacts and * null for multi user chat contacts */ @@ -145,29 +145,29 @@ public ImageIcon getStatusIcon() /** * Returns the ProtocolProviderService of the contact. - * + * * @return the ProtocolProviderService of the contact */ public ProtocolProviderService getProtocolProvider() { return protocolProvider; } - + /** * Returns the source contact. It could be an instance of Contact * or ChatRoomMember interface. - * + * * @return the source contact */ public Object getSourceContact() { return sourceContact; } - + /** * Returns the avatar image corresponding to the source contact. In the case * of multi user chat contact returns null. - * + * * @return the avatar image corresponding to the source contact. In the case * of multi user chat contact returns null */ @@ -202,6 +202,9 @@ else if(contact != null) if(contactImage != null) { Image image = ImageLoader.getBytesInImage(contactImage); + if(image == null) + return null; + return ImageUtils.scaleIconWithinBounds( new ImageIcon(image), AVATAR_ICON_WIDTH, @@ -211,7 +214,7 @@ else if(contact != null) else return null; } - + /** * Returns true if this is the currently selected contact in * the list of contacts for the chat, otherwise returns false. @@ -225,7 +228,7 @@ public boolean isSelected() /** * Sets this isSelected property of this chat contact. - * + * * @param isSelected true to indicate that this contact would * be the selected contact in the list of chat window contacts, otherwise - * false diff --git a/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java b/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java index b812368a0..cae818c50 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/RssActivator.java @@ -277,4 +277,4 @@ public void checkServerTrusted( { } } -} +} \ No newline at end of file