diff --git a/src/net/java/sip/communicator/impl/gui/i18n/messages.properties b/src/net/java/sip/communicator/impl/gui/i18n/messages.properties
index 87b9cd764..21be10ece 100644
--- a/src/net/java/sip/communicator/impl/gui/i18n/messages.properties
+++ b/src/net/java/sip/communicator/impl/gui/i18n/messages.properties
@@ -95,6 +95,7 @@ identifier=Identifier
ignore=Ignore
insertSmiley=Insert smiley
invalidCall=Invalid call
+join=&Join
joinChatRoom=&Join chat room
last=Last
launchBrowserError=Error attempting to launch web browser.
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
new file mode 100644
index 000000000..c31eb1639
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContact.java
@@ -0,0 +1,213 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.gui.main.chat;
+
+import java.awt.*;
+import java.util.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.impl.gui.*;
+import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * The ChatContact is a wrapping class for the Contact and
+ * ChatRoomMember interface.
+ *
+ * @author Yana Stamcheva
+ */
+public class ChatContact
+{
+ private Logger logger = Logger.getLogger(ChatContact.class);
+
+ private String name;
+
+ private String address;
+
+ private ImageIcon image;
+
+ private ProtocolProviderService protocolProvider;
+
+ private PresenceStatus presenceStatus;
+
+ private boolean isMultiChatContact;
+
+ private Object sourceContact;
+
+ /**
+ * 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
+ */
+ 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
+ * is created
+ */
+ public ChatContact(MetaContact metaContact, Contact contact)
+ {
+ this.sourceContact = contact;
+ this.address = contact.getAddress();
+ this.isMultiChatContact = false;
+ this.protocolProvider = contact.getProtocolProvider();
+
+ if(metaContact != null)
+ name = metaContact.getDisplayName();
+ else
+ name = contact.getDisplayName();
+
+ }
+
+ /**
+ * 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.
+ */
+ public ChatContact(ChatRoomMember chatRoomMember)
+ {
+ this.sourceContact = chatRoomMember;
+ this.name = chatRoomMember.getName();
+ this.address = chatRoomMember.getContactAddress();
+ this.isMultiChatContact = true;
+ this.protocolProvider = chatRoomMember.getProtocolProvider();
+ }
+
+ /**
+ * Returns the contact identifier.
+ *
+ * @return the contact identifier
+ */
+ public String getAddress()
+ {
+ return address;
+ }
+
+ /**
+ * 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
+ */
+ public PresenceStatus getPresenceStatus()
+ {
+ if(!isMultiChatContact)
+ return ((Contact)sourceContact).getPresenceStatus();
+
+ return null;
+ }
+
+ /**
+ * 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
+ */
+ public ImageIcon getImage()
+ {
+ byte[] contactImage = null;
+
+ if(!(sourceContact instanceof Contact))
+ return null;
+
+ Contact contact = (Contact)sourceContact;
+
+ MetaContact metaContact = GuiActivator.getMetaContactListService()
+ .findMetaContactByContact(contact);
+
+ if(metaContact != null)
+ {
+ Iterator i = metaContact.getContacts();
+
+ while(i.hasNext())
+ {
+ Contact protoContact = (Contact) i.next();
+
+ try
+ {
+ contactImage = protoContact.getImage();
+ }
+ catch (Exception ex)
+ {
+ logger.error("Failed to load contact photo.", ex);
+ }
+
+ if(contactImage != null && contactImage.length > 0)
+ break;
+ }
+ }
+ else if(contact != null)
+ {
+ try
+ {
+ contactImage = contact.getImage();
+ }
+ catch (Exception ex)
+ {
+ logger.error("Failed to load contact photo.", ex);
+ }
+ }
+
+ if(contactImage != null)
+ {
+ Image image = ImageLoader.getBytesInImage(contactImage);
+
+ return new ImageIcon(image.getScaledInstance(
+ 40, 45, Image.SCALE_SMOOTH));
+ }
+ else
+ return null;
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactListPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactListPanel.java
index 22a7a7d5f..1a50e1f7a 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactListPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactListPanel.java
@@ -14,8 +14,6 @@
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.protocol.*;
/**
* The ChatContactListPanel is the panel added on the right of the
@@ -44,7 +42,7 @@ public class ChatContactListPanel
private JPanel contactsPanel = new JPanel();
- private Hashtable contacts = new Hashtable();
+ private Hashtable chatContacts = new Hashtable();
private ChatPanel chatPanel;
@@ -62,46 +60,6 @@ public ChatContactListPanel(ChatPanel chatPanel)
this.setMinimumSize(new Dimension(150, 100));
- this.init();
- }
-
- /**
- * Adds a simple Contact to the list of contacts contained in the
- * chat.
- *
- * @param contact the Contact to be added
- */
- public void addContact(Contact contact)
- {
- ChatContactPanel chatContactPanel = new ChatContactPanel(
- chatPanel, contact);
-
- this.contactsPanel.add(chatContactPanel);
-
- this.contacts.put(contact, chatContactPanel);
- }
-
- /**
- * Adds a MetaContact to the list of contacts contained in the chat.
- *
- * @param metaContact the MetaContact to be added
- * @param contact the subcontact which is initially selected
- */
- public void addContact(MetaContact metaContact, Contact contact)
- {
- ChatContactPanel chatContactPanel = new ChatContactPanel(
- chatPanel, metaContact, contact);
-
- this.contactsPanel.add(chatContactPanel);
-
- this.contacts.put(metaContact, chatContactPanel);
- }
-
- /**
- * Constructs the ChatContactListPanel.
- */
- private void init()
- {
this.contactsPanel.setLayout(new BoxLayout(this.contactsPanel,
BoxLayout.Y_AXIS));
@@ -116,90 +74,60 @@ private void init()
// Disable all unused buttons.
this.addToChatButton.setEnabled(false);
}
-
+
/**
- * Updates the status icon of the contact in this
- * ChatContactListPanel.
- * @param contact the Contact, which should be updated
+ * Adds a ChatContact to the list of contacts contained in the
+ * chat.
+ *
+ * @param chatContact the ChatContact to add
*/
- public void updateContactStatus(Contact contact)
- {
- ChatContactPanel chatContactPanel = null;
- if(contacts.containsKey(contact))
- {
- chatContactPanel = (ChatContactPanel)contacts.get(contact);
-
- chatContactPanel.setStatusIcon(contact.getPresenceStatus());
- }
- }
+ public void addContact(ChatContact chatContact)
+ {
+ ChatContactPanel chatContactPanel = new ChatContactPanel(
+ chatPanel, chatContact);
- /**
- * Updates the status icon of the contact in this
- * ChatContactListPanel.
- * @param metaContact the MetaContact, which should be updated
- */
- public void updateContactStatus(MetaContact metaContact)
- {
- ChatContactPanel chatContactPanel = null;
- if(contacts.containsKey(metaContact))
- {
- chatContactPanel = (ChatContactPanel)contacts.get(metaContact);
+ this.contactsPanel.add(chatContactPanel);
- chatContactPanel.setStatusIcon(
- metaContact.getDefaultContact().getPresenceStatus());
- }
+ this.chatContacts.put(chatContact, chatContactPanel);
}
/**
- * Updates the given protocol contact chat panel in the list. Disables or
- * enable buttons, according to the functionalities supported by this
- * contact.
+ * In the corresponding ChatContactPanel changes the name of the
+ * given Contact.
*
- * @param contact the Contact, which chat contact panel to update
+ * @param chatContact the ChatContact to be renamed
*/
- public void updateProtocolContact(Contact contact)
- {
+ public void renameContact(ChatContact chatContact)
+ {
ChatContactPanel chatContactPanel = null;
- if(contacts.containsKey(contact))
+ if(chatContacts.containsKey(chatContact))
{
- chatContactPanel = (ChatContactPanel)contacts.get(contact);
+ chatContactPanel = (ChatContactPanel)chatContacts.get(chatContact);
- chatContactPanel.updateProtocolContact(contact);
- }
+ chatContactPanel.renameContact(chatContact.getName());
+ }
}
/**
- * In the corresponding ChatContactPanel changes the name of the
- * given Contact.
- *
- * @param contact the Contact, which has been renamed
+ * Returns the list of ChatContacts contained in this container.
+ * @return the list of ChatContacts contained in this container
*/
- public void renameContact(Contact contact)
+ public Enumeration getChatContacts()
{
- ChatContactPanel chatContactPanel = null;
- if(contacts.containsKey(contact))
- {
- chatContactPanel = (ChatContactPanel)contacts.get(contact);
-
- chatContactPanel.renameContact(contact.getDisplayName());
- }
+ return chatContacts.keys();
}
-
+
/**
- * In the corresponding ChatContactPanel changes the name of the
- * given MetaContact.
- *
- * @param contact the MetaContact, which has been renamed
+ * Returns the ChatContactPanel corresponding to the given
+ * ChatContact.
+ *
+ * @param chatContact the ChatContact to search for.
+ * @return the ChatContactPanel corresponding to the given
+ * ChatContact
*/
- public void renameContact(MetaContact contact)
+ public ChatContactPanel getChatContactPanel(ChatContact chatContact)
{
- ChatContactPanel chatContactPanel = null;
- if(contacts.containsKey(contact))
- {
- chatContactPanel = (ChatContactPanel)contacts.get(contact);
-
- chatContactPanel.renameContact(contact.getDisplayName());
- }
+ return (ChatContactPanel) chatContacts.get(chatContact);
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactPanel.java
index 9b81e7afb..75c7d3add 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactPanel.java
@@ -9,7 +9,6 @@
import java.awt.*;
import java.awt.event.*;
-import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
@@ -18,9 +17,7 @@
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*;
-import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
-import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@@ -42,7 +39,7 @@
*/
public class ChatContactPanel
extends JPanel
- implements ActionListener
+ implements ActionListener
{
private Logger logger = Logger.getLogger(ChatContactPanel.class);
@@ -67,58 +64,40 @@ public class ChatContactPanel
private JPanel mainPanel = new JPanel(new BorderLayout());
- private Contact protocolContact;
+ private ImageIcon contactPhotoIcon;
+
+ private ChatContact chatContact;
private PresenceStatus status;
private ChatPanel chatPanel;
- /**
- * Creates an instance of the ChatContactPanel.
- *
- * @param chatPanel
- * @param protocolContact
- */
- public ChatContactPanel(ChatPanel chatPanel, Contact protocolContact)
- {
- this(chatPanel, null, protocolContact);
- }
-
+
/**
* Creates an instance of the ChatContactPanel.
*
* @param chatPanel the ChatPanel, to which this
* ChatContactPanel belongs to.
- * @param metaContact
- * @param protocolContact
+ * @param chatContact the chat contact
*/
- public ChatContactPanel(ChatPanel chatPanel,
- MetaContact metaContact, Contact protocolContact)
+ public ChatContactPanel(ChatPanel chatPanel, ChatContact contact)
{
super(new BorderLayout(10, 5));
- this.protocolContact = protocolContact;
+ this.chatContact = contact;
this.setPreferredSize(new Dimension(100, 60));
-
+
this.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
- this.status = protocolContact.getPresenceStatus();
+ this.status = chatContact.getPresenceStatus();
this.chatPanel = chatPanel;
this.setOpaque(false);
this.mainPanel.setOpaque(false);
- //this.contactNamePanel.setOpaque(false);
this.buttonsPanel.setOpaque(false);
-
- String chatContactName;
-
- if(metaContact != null)
- chatContactName = metaContact.getDisplayName();
- else
- chatContactName = protocolContact.getDisplayName();
-
- this.personNameLabel.setText(chatContactName);
+
+ this.personNameLabel.setText(chatContact.getName());
this.personNameLabel.setFont(this.getFont().deriveFont(Font.BOLD));
this.personNameLabel.setIcon(new ImageIcon(Constants
.getStatusIcon(status)));
@@ -150,9 +129,40 @@ public ChatContactPanel(ChatPanel chatPanel,
this.callButton.setEnabled(false);
this.sendFileButton.setEnabled(false);
- new LoadContactPhoto(metaContact, protocolContact).start();
+ //Load the contact photo.
+ new Thread()
+ {
+ public void run()
+ {
+ contactPhotoIcon = chatContact.getImage();
+
+ SwingUtilities.invokeLater(new Runnable(){
+ public void run()
+ {
+ if(contactPhotoIcon != null)
+ {
+ personPhotoLabel.setBorder(
+ new SIPCommBorders.BoldRoundBorder());
+ personPhotoLabel.setIcon(contactPhotoIcon);
+ }
+ }
+ });
+
+ }
+ }.start();
+
+ ProtocolProviderService pps
+ = chatContact.getProtocolProvider();
+
+ Object contactInfoOpSet
+ = pps.getOperationSet(OperationSetWebContactInfo.class);
- this.updateProtocolContact(protocolContact);
+ if(contactInfoOpSet == null)
+ infoButton.setEnabled(false);
+ else
+ infoButton.setEnabled(true);
+
+ this.setStatusIcon(chatContact.getPresenceStatus());
}
/**
@@ -199,31 +209,7 @@ public void setStatusIcon(PresenceStatus newStatus) {
this.personNameLabel.setIcon(new ImageIcon(Constants
.getStatusIcon(newStatus)));
}
-
- /**
- * Disables or enables the contact info button depending on the selected
- * protocol contact.
- *
- * @param protocolContact the selected protocol contact
- */
- public void updateProtocolContact(Contact protocolContact)
- {
- MainFrame mainFrame = chatPanel.getChatWindow().getMainFrame();
-
- ProtocolProviderService pps
- = protocolContact.getProtocolProvider();
-
- OperationSetWebContactInfo wContactInfo
- = mainFrame.getWebContactInfoOpSet(pps);
-
- if(wContactInfo == null)
- infoButton.setEnabled(false);
- else
- infoButton.setEnabled(true);
- this.setStatusIcon(protocolContact.getPresenceStatus());
- }
-
/**
*
*/
@@ -231,22 +217,22 @@ public void actionPerformed(ActionEvent e)
{
JButton button = (JButton) e.getSource();
- MainFrame mainFrame = chatPanel.getChatWindow().getMainFrame();
-
- if(button.getName().equals("call")) {
-
+ if(button.getName().equals("call"))
+ {
+ //TODO: Implement the call functionality
}
else if(button.getName().equals("info"))
{
ProtocolProviderService pps
- = protocolContact.getProtocolProvider();
+ = chatContact.getProtocolProvider();
- OperationSetWebContactInfo wContactInfo
- = mainFrame.getWebContactInfoOpSet(pps);
+ Object contactInfoOpSet
+ = pps.getOperationSet(OperationSetWebContactInfo.class);
- if(wContactInfo != null) {
+ if(contactInfoOpSet != null) {
GuiActivator.getBrowserLauncher().openURL(
- wContactInfo.getWebContactInfo(protocolContact)
+ ((OperationSetWebContactInfo)contactInfoOpSet)
+ .getWebContactInfo(chatContact.getAddress())
.toString());
}
}
@@ -262,83 +248,17 @@ public void renameContact(String newName)
}
/**
- * Loads contact photo in a separate thread
+ * Sets the given ImageIcon to be the photo shown on the left of
+ * the contact name.
+ *
+ * @param contactPhoto the image to show as a contact photo
*/
- private class LoadContactPhoto extends Thread
- {
- private MetaContact metaContact;
- private Contact contact;
- private ImageIcon contactPhoto;
-
- public LoadContactPhoto(MetaContact metaContact, Contact contact)
- {
- this.metaContact = metaContact;
- this.contact = contact;
- }
-
- public LoadContactPhoto(MetaContact metaContact)
- {
- this.metaContact = metaContact;
- }
-
- public void run()
- {
- byte[] image = null;
-
- if(metaContact != null)
- {
- Iterator i = metaContact.getContacts();
+ public void setContactPhoto(ImageIcon contactPhoto)
+ {
+ contactPhotoIcon = contactPhoto;
- while(i.hasNext())
- {
- Contact protoContact = (Contact) i.next();
-
- try
- {
- image = protoContact.getImage();
- }
- catch (Exception ex)
- {
- logger.error("Failed to load contact photo.", ex);
- }
-
- if(image != null && image.length > 0)
- break;
- }
- }
- else if(contact != null)
- {
- try
- {
- image = contact.getImage();
- }
- catch (Exception ex)
- {
- logger.error("Failed to load contact photo.", ex);
- }
- }
-
- if(image != null && image.length > 0)
- {
- Image contactImage
- = ImageLoader.getBytesInImage(image);
-
- contactPhoto = new ImageIcon(
- contactImage.getScaledInstance(
- 40, 45, Image.SCALE_SMOOTH));
- }
-
- if(contactPhoto == null)
- return;
-
- SwingUtilities.invokeLater(new Runnable(){
- public void run()
- {
- personPhotoLabel.setBorder(
- new SIPCommBorders.BoldRoundBorder());
- personPhotoLabel.setIcon(contactPhoto);
- }
- });
- }
+ personPhotoLabel.setBorder(
+ new SIPCommBorders.BoldRoundBorder());
+ personPhotoLabel.setIcon(contactPhotoIcon);
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java
index 7857fcc88..9607d0f92 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatPanel.java
@@ -16,7 +16,6 @@
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.i18n.*;
-import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.contactlist.event.*;
@@ -35,7 +34,8 @@
public class MetaContactChatPanel
extends ChatPanel
implements ContactPresenceStatusListener,
- MetaContactListListener
+ MetaContactListListener,
+ SubscriptionListener
{
private static final Logger logger = Logger
@@ -72,8 +72,10 @@ public MetaContactChatPanel( ChatWindow chatWindow,
this.metaContact = metaContact;
- //Add the contact to the list of contacts contained in this panel
- getChatContactListPanel().addContact(metaContact, protocolContact);
+ ChatContact chatContact = new ChatContact(metaContact, protocolContact);
+
+ //Add the contact to the list of contacts contained in this panel
+ getChatContactListPanel().addContact(chatContact);
//Load the history period, to initialize the firstMessageTimestamp and
//the lastMessageTimeStamp variables. Used to disable/enable history
@@ -93,9 +95,17 @@ public void run(){
{
Contact subContact = (Contact) protocolContacts.next();
- chatWindow.getMainFrame()
- .getProtocolPresenceOpSet(subContact.getProtocolProvider())
- .addContactPresenceStatusListener(this);
+ Object opSet = subContact.getProtocolProvider()
+ .getOperationSet(OperationSetPersistentPresence.class);
+
+ if(opSet != null)
+ {
+ ((OperationSetPersistentPresence)opSet)
+ .addContactPresenceStatusListener(this);
+
+ ((OperationSetPersistentPresence)opSet)
+ .addSubsciptionListener(this);
+ }
}
//Obtains the MetaContactListService and adds itself to it as a
@@ -274,23 +284,39 @@ public void contactPresenceStatusChanged(
ContactPresenceStatusChangeEvent evt)
{
Contact sourceContact = evt.getSourceContact();
-
- MainFrame mainFrame = getChatWindow().getMainFrame();
- MetaContact sourceMetaContact = mainFrame
- .getContactList().findMetaContactByContact(sourceContact);
+ MetaContact sourceMetaContact = GuiActivator.getMetaContactListService()
+ .findMetaContactByContact(sourceContact);
if (sourceMetaContact != null && metaContact.equals(sourceMetaContact))
{
+ // Update the status of the given contact in the "send via" selector
+ // box.
contactSelectorBox.updateContactStatus(sourceContact);
+ // Update the status of the source meta contact in the contact details
+ // panel on the right.
+
+ if(sourceMetaContact != null
+ && sourceMetaContact.getDefaultContact().equals(sourceContact))
+ {
+ ChatContact chatContact
+ = findChatContactByMetaContact(sourceMetaContact);
+
+ ChatContactPanel chatContactPanel
+ = getChatContactListPanel()
+ .getChatContactPanel(chatContact);
+
+ chatContactPanel.setStatusIcon(
+ chatContact.getPresenceStatus());
+ }
+
PresenceStatus status = contactSelectorBox
.getSelectedProtocolContact().getPresenceStatus();
- getChatContactListPanel().updateContactStatus(metaContact);
-
+ // Show a status message to the user.
String message = getChatConversationPanel().processMessage(
- this.metaContact.getDisplayName(),
+ sourceContact.getAddress(),
new Date(System.currentTimeMillis()),
Constants.SYSTEM_MESSAGE,
Messages.getI18NString("statusChangedChatMessage",
@@ -393,7 +419,10 @@ public void metaContactRenamed(MetaContactRenamedEvent evt)
if(evt.getSourceMetaContact().equals(metaContact))
{
- getChatContactListPanel().renameContact(evt.getSourceMetaContact());
+ ChatContact chatContact
+ = findChatContactByMetaContact(evt.getSourceMetaContact());
+
+ getChatContactListPanel().renameContact(chatContact);
getChatWindow().setTabTitle(this, newName);
@@ -645,8 +674,111 @@ public void run()
}
}
+ /**
+ * Returns the MetaContact corresponding to the chat.
+ *
+ * @return the MetaContact corresponding to the chat.
+ */
public MetaContact getMetaContact()
{
return metaContact;
}
+
+ public void subscriptionCreated(SubscriptionEvent evt)
+ {}
+
+ public void subscriptionFailed(SubscriptionEvent evt)
+ {}
+
+ public void subscriptionRemoved(SubscriptionEvent evt)
+ {}
+
+ public void subscriptionMoved(SubscriptionMovedEvent evt)
+ {}
+
+ public void subscriptionResolved(SubscriptionEvent evt)
+ {}
+
+ /**
+ * Change the contact avatar image when contact details were updated.
+ */
+ public void contactModified(ContactPropertyChangeEvent evt)
+ {
+ Contact sourceContact = evt.getSourceContact();
+
+ ChatContact chatContact = findChatContactByContact(sourceContact);
+
+ if(chatContact != null)
+ {
+ ChatContactPanel chatContactPanel
+ = getChatContactListPanel().getChatContactPanel(chatContact);
+
+ chatContactPanel.setContactPhoto(chatContact.getImage());
+ }
+ }
+
+ /**
+ * Returns the ChatContact corresponding to the given
+ * MetaContact.
+ *
+ * @param metaContact the MetaContact to search for
+ * @return the ChatContact corresponding to the given
+ * MetaContact.
+ */
+ private ChatContact findChatContactByMetaContact(MetaContact metaContact)
+ {
+ Enumeration chatContacts
+ = getChatContactListPanel().getChatContacts();
+
+ while(chatContacts.hasMoreElements())
+ {
+ ChatContact chatContact
+ = (ChatContact) chatContacts.nextElement();
+
+ Object chatSourceContact = chatContact.getSourceContact();
+
+ if(chatSourceContact instanceof Contact)
+ {
+ MetaContact parentMetaContact
+ = GuiActivator.getMetaContactListService()
+ .findMetaContactByContact((Contact)chatSourceContact);
+
+ if(parentMetaContact != null
+ && parentMetaContact.equals(metaContact))
+ return chatContact;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the ChatContact corresponding to the given
+ * Contact.
+ *
+ * @param metaContact the MetaContact to search for
+ * @return the ChatContact corresponding to the given
+ * Contact.
+ */
+ private ChatContact findChatContactByContact(Contact contact)
+ {
+ Enumeration chatContacts
+ = getChatContactListPanel().getChatContacts();
+
+ while(chatContacts.hasMoreElements())
+ {
+ ChatContact chatContact
+ = (ChatContact) chatContacts.nextElement();
+
+ Object chatSourceContact = chatContact.getSourceContact();
+
+ if(chatSourceContact instanceof Contact
+ && chatSourceContact.equals(contact))
+ {
+ return chatContact;
+ }
+ }
+
+ return null;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java
index 297c165c1..0c840a283 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatPanel.java
@@ -54,7 +54,11 @@ public ConferenceChatPanel(ChatWindow chatWindow, ChatRoom chatRoom)
for (int i = 0; i < membersList.size(); i ++)
{
- getChatContactListPanel().addContact((Contact)membersList.get(i));
+ ChatContact chatContact
+ = new ChatContact((ChatRoomMember)membersList.get(i));
+
+ getChatContactListPanel()
+ .addContact(chatContact);
}
this.chatRoom.addMessageListener(this);