aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2011-08-23 10:40:35 +0000
committerYana Stamcheva <yana@jitsi.org>2011-08-23 10:40:35 +0000
commitc4183ff560b6895eed58c4113d7dd8a268302b0d (patch)
treed40f5bdc47469de89ef1f991c7ed3b8ac233e824 /src/net/java
parent9633f69b2a9fe3e4aec5667e474a29c3005e45b0 (diff)
downloadjitsi-c4183ff560b6895eed58c4113d7dd8a268302b0d.zip
jitsi-c4183ff560b6895eed58c4113d7dd8a268302b0d.tar.gz
jitsi-c4183ff560b6895eed58c4113d7dd8a268302b0d.tar.bz2
Replaces the outgoing contact address with the corresponding display name in the chat window. Shows the protocol contact address in a tooltip.
Diffstat (limited to 'src/net/java')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/MainFrame.java22
-rwxr-xr-xsrc/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java44
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/ChatMessage.java66
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java46
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java5
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java5
6 files changed, 160 insertions, 28 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
index d2cb00e..3e1d4fa 100644
--- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
+++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
@@ -866,9 +866,27 @@ public class MainFrame
* account to add
* @return The account user id for the given protocol provider.
*/
- public String getAccount(ProtocolProviderService protocolProvider)
+ public String getAccountAddress(ProtocolProviderService protocolProvider)
{
- return protocolProvider.getAccountID().getUserID();
+ return protocolProvider.getAccountID().getAccountAddress();
+ }
+
+ /**
+ * Returns the account user display name for the given protocol provider.
+ * @param protocolProvider the protocol provider corresponding to the
+ * account to add
+ * @return The account user display name for the given protocol provider.
+ */
+ public String getAccountDisplayName(ProtocolProviderService protocolProvider)
+ {
+ final OperationSetServerStoredAccountInfo accountInfoOpSet
+ = protocolProvider.getOperationSet(
+ OperationSetServerStoredAccountInfo.class);
+
+ if (accountInfoOpSet != null)
+ return AccountInfoUtils.getDisplayName(accountInfoOpSet);
+
+ return protocolProvider.getAccountID().getDisplayName();
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
index 1ecdecc..19a71fa 100755
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatConversationPanel.java
@@ -352,6 +352,11 @@ public class ChatConversationPanel
public String processMessage(ChatMessage chatMessage, String keyword)
{
String contactName = chatMessage.getContactName();
+ String contactDisplayName = chatMessage.getContactDisplayName();
+ if (contactDisplayName == null
+ || contactDisplayName.trim().length() <= 0)
+ contactDisplayName = contactName;
+
String contentType = chatMessage.getContentType();
long date = chatMessage.getDate();
String messageType = chatMessage.getMessageType();
@@ -389,15 +394,20 @@ public class ChatConversationPanel
{
this.lastIncomingMsgTimestamp = System.currentTimeMillis();
- chatString = "<h2 identifier=\""
+ chatString = "<h2><a style=\"color:#ef7b1e;"
+ + "font-weight:bold;"
+ + "text-decoration:none;\" "
+ + "href=\"" + contactName + "\" "
+ + "identifier=\""
+ msgHeaderID
+ "\" date=\""
+ date + "\">";
- endHeaderTag = "</h2>";
+ endHeaderTag = "</a></h2>";
chatString
- += dateString + contactName + " at " + GuiUtils.formatTime(date)
+ += dateString + contactDisplayName + " at "
+ + GuiUtils.formatTime(date)
+ endHeaderTag + startDivTag + startPlainTextTag
+ formatMessage(message, contentType, keyword)
+ endPlainTextTag + endDivTag;
@@ -420,15 +430,19 @@ public class ChatConversationPanel
}
else if (messageType.equals(Chat.OUTGOING_MESSAGE))
{
- chatString = "<h3 identifier=\""
+ chatString = "<h3><a style=\"color:#2e538b;"
+ + "font-weight:bold;"
+ + "text-decoration:none;\" "
+ + "href=\"" + contactName + "\" "
+ + "identifier=\""
+ msgHeaderID
+ "\" date=\""
+ date + "\">";
- endHeaderTag = "</h3>";
+ endHeaderTag = "</a></h3>";
chatString
- += dateString + contactName + " at "
+ += dateString + contactDisplayName + " at "
+ GuiUtils.formatTime(date) + endHeaderTag
+ startDivTag + startPlainTextTag
+ formatMessage(message, contentType, keyword)
@@ -481,22 +495,30 @@ public class ChatConversationPanel
}
else if (messageType.equals(Chat.HISTORY_INCOMING_MESSAGE))
{
- chatString = "<h2 identifier='"
+ chatString = "<h2><a style=\"color:#ef7b1e;"
+ + "font-weight:bold;"
+ + "text-decoration:none;\" "
+ + "href=\"" + contactName + "\" "
+ msgHeaderID
+ "' date=\""
+ date + "\">";
- endHeaderTag = "</h2>";
+ endHeaderTag = "</a></h2>";
chatString
- += dateString + contactName + " at " + GuiUtils.formatTime(date)
+ += dateString + contactDisplayName
+ + " at " + GuiUtils.formatTime(date)
+ endHeaderTag + startHistoryDivTag + startPlainTextTag
+ formatMessage(message, contentType, keyword)
+ endPlainTextTag + endDivTag;
}
else if (messageType.equals(Chat.HISTORY_OUTGOING_MESSAGE))
{
- chatString = "<h3 identifier=\""
+ chatString = "<h3><a style=\"color:#2e538b;"
+ + "font-weight:bold;"
+ + "text-decoration:none;\" "
+ + "href=\"" + contactName + "\" "
+ + "identifier=\""
+ msgHeaderID
+ "\" date=\""
+ date + "\">";
@@ -505,7 +527,7 @@ public class ChatConversationPanel
chatString
+= dateString
- + contactName
+ + contactDisplayName
+ " at " + GuiUtils.formatTime(date) + endHeaderTag
+ startHistoryDivTag + startPlainTextTag
+ formatMessage(message, contentType, keyword)
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatMessage.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatMessage.java
index eb0b473..e5301b9 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatMessage.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatMessage.java
@@ -20,6 +20,11 @@ public class ChatMessage
private final String contactName;
/**
+ * The display name of the contact sending the message.
+ */
+ private String contactDisplayName;
+
+ /**
* The date and time of the message.
*/
private final long date;
@@ -60,23 +65,63 @@ public class ChatMessage
String message,
String contentType)
{
- this.contactName = contactName;
- this.date = date;
- this.messageType = messageType;
- this.message = message;
- this.contentType = contentType;
+ this(contactName, null, date, messageType, null, message, contentType);
+ }
+
+ /**
+ * Creates a <tt>ChatMessage</tt> by specifying all parameters of the
+ * message.
+ * @param contactName the name of the contact
+ * @param contactDisplayName the contact display name
+ * @param date the date and time
+ * @param messageType the type (INCOMING or OUTGOING)
+ * @param message the content
+ * @param contentType the content type (e.g. "text", "text/html", etc.)
+ */
+ public ChatMessage( String contactName,
+ long date,
+ String messageType,
+ String messageTitle,
+ String message,
+ String contentType)
+ {
+ this(contactName, null, date, messageType,
+ messageTitle, message, contentType);
+ }
+
+ /**
+ * Creates a <tt>ChatMessage</tt> by specifying all parameters of the
+ * message.
+ * @param contactName the name of the contact
+ * @param contactDisplayName the contact display name
+ * @param date the date and time
+ * @param messageType the type (INCOMING or OUTGOING)
+ * @param message the content
+ * @param contentType the content type (e.g. "text", "text/html", etc.)
+ */
+ public ChatMessage( String contactName,
+ String contactDisplayName,
+ long date,
+ String messageType,
+ String message,
+ String contentType)
+ {
+ this(contactName, contactDisplayName, date, messageType,
+ null, message, contentType);
}
/**
* Creates a <tt>ChatMessage</tt> by specifying all parameters of the
* message.
* @param contactName the name of the contact
+ * @param contactDisplayName the contact display name
* @param date the date and time
* @param messageType the type (INCOMING or OUTGOING)
* @param message the content
* @param contentType the content type (e.g. "text", "text/html", etc.)
*/
public ChatMessage( String contactName,
+ String contactDisplayName,
long date,
String messageType,
String messageTitle,
@@ -84,6 +129,7 @@ public class ChatMessage
String contentType)
{
this.contactName = contactName;
+ this.contactDisplayName = contactDisplayName;
this.date = date;
this.messageType = messageType;
this.messageTitle = messageTitle;
@@ -102,6 +148,16 @@ public class ChatMessage
}
/**
+ * Returns the display name of the contact sending the message.
+ *
+ * @return the display name of the contact sending the message
+ */
+ public String getContactDisplayName()
+ {
+ return contactDisplayName;
+ }
+
+ /**
* Returns the date and time of the message.
*
* @return the date and time of the message.
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
index fbaa375..1da0323 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java
@@ -574,7 +574,9 @@ public class ChatPanel
historyString = processHistoryMessage(
GuiActivator.getUIService().getMainFrame()
- .getAccount(protocolProvider),
+ .getAccountAddress(protocolProvider),
+ GuiActivator.getUIService().getMainFrame()
+ .getAccountDisplayName(protocolProvider),
evt.getTimestamp(),
messageType,
evt.getSourceMessage().getContent(),
@@ -596,6 +598,7 @@ public class ChatPanel
messageType = Chat.HISTORY_INCOMING_MESSAGE;
historyString = processHistoryMessage(
+ evt.getSourceContact().getAddress(),
evt.getSourceContact().getDisplayName(),
evt.getTimestamp(),
messageType,
@@ -613,7 +616,9 @@ public class ChatPanel
historyString = processHistoryMessage(
GuiActivator.getUIService().getMainFrame()
- .getAccount(protocolProvider),
+ .getAccountAddress(protocolProvider),
+ GuiActivator.getUIService().getMainFrame()
+ .getAccountDisplayName(protocolProvider),
evt.getTimestamp(),
Chat.HISTORY_OUTGOING_MESSAGE,
evt.getMessage().getContent(),
@@ -628,6 +633,7 @@ public class ChatPanel
.equals(escapedMessageID))
{
historyString = processHistoryMessage(
+ evt.getSourceChatRoomMember().getContactAddress(),
evt.getSourceChatRoomMember().getName(),
evt.getTimestamp(),
Chat.HISTORY_INCOMING_MESSAGE,
@@ -667,8 +673,28 @@ public class ChatPanel
public void addMessage(String contactName, long date,
String messageType, String message, String contentType)
{
- ChatMessage chatMessage = new ChatMessage(contactName, date,
- messageType, message, contentType);
+ addMessage(contactName, null, date, messageType, message, contentType);
+ }
+
+ /**
+ * Passes the message to the contained <code>ChatConversationPanel</code>
+ * for processing and appends it at the end of the conversationPanel
+ * document.
+ *
+ * @param contactName the name of the contact sending the message
+ * @param displayName the display name of the contact
+ * @param date the time at which the message is sent or received
+ * @param messageType the type of the message. One of OUTGOING_MESSAGE
+ * or INCOMING_MESSAGE
+ * @param message the message text
+ * @param contentType the content type
+ */
+ public void addMessage(String contactName, String displayName, long date,
+ String messageType, String message, String contentType)
+ {
+ ChatMessage chatMessage
+ = new ChatMessage(contactName, displayName, date,
+ messageType, message, contentType);
this.addChatMessage(chatMessage);
@@ -810,13 +836,15 @@ public class ChatPanel
* @return a string containing the processed message.
*/
private String processHistoryMessage(String contactName,
+ String contactDisplayName,
long date,
String messageType,
String message,
String contentType)
{
- ChatMessage chatMessage = new ChatMessage(contactName, date,
- messageType, message, contentType);
+ ChatMessage chatMessage = new ChatMessage(
+ contactName, contactDisplayName, date,
+ messageType, null, message, contentType);
String processedMessage =
this.conversationPanel.processMessage(chatMessage);
@@ -874,7 +902,8 @@ public class ChatPanel
/**
* Cuts the write area selected content to the clipboard.
*/
- public void cut(){
+ public void cut()
+ {
this.writeMessagePanel.getEditorPane().cut();
}
@@ -882,7 +911,8 @@ public class ChatPanel
* Copies either the selected write area content or the selected
* conversation panel content to the clipboard.
*/
- public void copy(){
+ public void copy()
+ {
JTextComponent textPane = this.conversationPanel.getChatTextPane();
if (textPane.getSelectedText() == null)
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java b/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java
index 37b9c98..40a5db3 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/history/HistoryWindow.java
@@ -273,7 +273,9 @@ public class HistoryWindow
chatMessage = new ChatMessage(
GuiActivator.getUIService().getMainFrame()
- .getAccount(protocolProvider),
+ .getAccountAddress(protocolProvider),
+ GuiActivator.getUIService().getMainFrame()
+ .getAccountDisplayName(protocolProvider),
evt.getTimestamp(),
Chat.OUTGOING_MESSAGE,
evt.getSourceMessage().getContent(),
@@ -284,6 +286,7 @@ public class HistoryWindow
MessageReceivedEvent evt = (MessageReceivedEvent) o;
chatMessage = new ChatMessage(
+ evt.getSourceContact().getAddress(),
evt.getSourceContact().getDisplayName(),
evt.getTimestamp(),
Chat.INCOMING_MESSAGE,
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
index f802189..8c6b340 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
@@ -272,6 +272,7 @@ public class ContactListPane
}
chatPanel.addMessage(
+ protocolContact.getAddress(),
protocolContact.getDisplayName(),
evt.getTimestamp(),
messageType,
@@ -342,7 +343,8 @@ public class ContactListPane
+ " MESSAGE: " + msg.getContent());
chatPanel.addMessage(
- this.mainFrame.getAccount(protocolProvider),
+ this.mainFrame.getAccountAddress(protocolProvider),
+ this.mainFrame.getAccountDisplayName(protocolProvider),
evt.getTimestamp(),
Chat.OUTGOING_MESSAGE,
msg.getContent(),
@@ -408,6 +410,7 @@ public class ContactListPane
= chatWindowManager.getContactChat(metaContact, sourceContact);
chatPanel.addMessage(
+ sourceContact.getAddress(),
metaContact.getDisplayName(),
System.currentTimeMillis(),
Chat.OUTGOING_MESSAGE,