[sip-comm-dev] Re: svn commit: r6023 - trunk/src/net/java/sip/communicator/impl/gui/main: chat chat/conference contactlist


#1

I see in ChatWindowManager that ChatWindow is registered as
ExportedWindow only if isMultiChatWindowEnabled and then
ChatAlerterActivator uses it to alert it when a message is received.
In other words, if the user chooses to have each chat in a separate
chat window, then there will be no alerts upon receiving messages.
Which isn't ideal I guess. Anyway, it makes me question the usefulness
of ExportedWindow for ChatWindow if it's not going to always work for
the plugins.

···

On Fri, Sep 25, 2009 at 10:54 PM, <lubomir_m@dev.java.net> wrote:

Author: lubomir_m
Date: 2009-09-25 19:54:19+0000
New Revision: 6023

Modified:
trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java
trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java

Log:
Removes some duplication in ChatWindowManager in order to limit the use of its #syncChat which is one of the causes for IRC to deadlock with the UI.

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java?view=diff&rev=6023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java&r1=6022&r2=6023

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindowManager.java 2009-09-25 19:54:19+0000
@@ -27,14 +27,13 @@
*/
public class ChatWindowManager
{
- private final java.util.List<ChatPanel> chatPanels =
- new ArrayList<ChatPanel>();
+ private final java.util.List<ChatPanel> chatPanels
+ = new ArrayList<ChatPanel>();

private final Object syncChat = new Object\(\);

/\*\*

- * Opens the specified chatPanel and brings it to the front if so
- * specified.
+ * Opens the specified chatPanel and brings it to the front if so specified.
*
* @param chatPanel the chat panel that we will be opening
* @param setSelected specifies whether we should bring the chat to front
@@ -106,73 +105,75 @@
}

/\*\*

- * Returns TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>MetaContact</tt>.
+ * Returns <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>MetaContact</tt>.
+ *
* @param metaContact the <tt>MetaContact</tt>, for which the chat is about
- * @return TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>MetaContact</tt>
+ * @return <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>MetaContact</tt>
*/
- public boolean isChatOpenedForContact(MetaContact metaContact)
+ public boolean isChatOpenedFor(MetaContact metaContact)
{
- synchronized (syncChat)
- {
- ChatSession chatSession = findChatSessionForDescriptor(metaContact);
-
- return (chatSession != null
- && getChat(chatSession).isShown());
- }
+ return isChatOpenedForDescriptor(metaContact);
}

/\*\*

- * Returns TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>AdHocChatRoom</tt>.
+ * Returns <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>AdHocChatRoom</tt>.
*
- * @param adHocChatRoomWrapper the <tt>AdHocChatRoomWrapper</tt>, for which the
- * ad-hoc chat is about
- * @return TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>AdHocChatRoom</tt>
+ * @param adHocChatRoomWrapper the <tt>AdHocChatRoomWrapper</tt> for which
+ * the ad-hoc chat is about
+ * @return <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>AdHocChatRoom</tt>
*/
- public boolean isChatOpenedForAdHocChatRoom(
- AdHocChatRoomWrapper adHocChatRoomWrapper)
+ public boolean isChatOpenedFor(AdHocChatRoomWrapper adHocChatRoomWrapper)
{
- synchronized (syncChat)
- {
- ChatSession chatSession
- = findChatSessionForDescriptor(adHocChatRoomWrapper);
-
- return (chatSession != null
- && getChat(chatSession).isShown());
- }
+ return isChatOpenedForDescriptor(adHocChatRoomWrapper);
}

/\*\*

- * Returns TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>ChatRoom</tt>.
+ * Returns <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>ChatRoom</tt>.
+ *
* @param chatRoomWrapper the <tt>ChatRoomWrapper</tt>, for which the chat
* is about
- * @return TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>ChatRoom</tt>
+ * @return <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>ChatRoom</tt>
*/
- public boolean isChatOpenedForChatRoom(ChatRoomWrapper chatRoomWrapper)
+ public boolean isChatOpenedFor(ChatRoomWrapper chatRoomWrapper)
+ {
+ return isChatOpenedForDescriptor(chatRoomWrapper);
+ }
+
+ /**
+ * Determines whether there is an opened <tt>ChatPanel</tt> for a specific
+ * chat descriptor.
+ *
+ * @param descriptor the chat descriptor which is to be checked whether
+ * there is an opened <tt>ChatPanel</tt> for
+ * @return <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * specified chat descriptor; <tt>false</tt>, otherwise
+ */
+ private boolean isChatOpenedForDescriptor(Object descriptor)
{
synchronized (syncChat)
{
ChatSession chatSession
- = findChatSessionForDescriptor(chatRoomWrapper);
+ = findChatSessionForDescriptor(descriptor);

- return (chatSession != null
- && getChat(chatSession).isShown());
+ return ((chatSession != null) && getChat(chatSession).isShown());
}
}

/\*\*

- * Returns TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>ChatRoom</tt>.
+ * Returns <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>ChatRoom</tt>.
+ *
* @param chatRoom the <tt>ChatRoom</tt>, for which the chat is about
- * @return TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>ChatRoom</tt>
+ * @return <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>ChatRoom</tt>
*/
- public boolean isChatOpenedForChatRoom(ChatRoom chatRoom)
+ public boolean isChatOpenedFor(ChatRoom chatRoom)
{
synchronized (syncChat)
{
@@ -201,15 +202,15 @@
}

/\*\*

- * Returns TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>AdHocChatRoom</tt>.
+ * Returns <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>AdHocChatRoom</tt>.
*
* @param adHocChatRoom the <tt>AdHocChatRoom</tt>, for which the ad-hoc
* chat is about
- * @return TRUE if there is an opened <tt>ChatPanel</tt> for the given
- * <tt>AdHocChatRoom</tt>
+ * @return <tt>true</tt> if there is an opened <tt>ChatPanel</tt> for the
+ * given <tt>AdHocChatRoom</tt>
*/
- public boolean isChatOpenedForAdHocChatRoom(AdHocChatRoom adHocChatRoom)
+ public boolean isChatOpenedFor(AdHocChatRoom adHocChatRoom)
{
synchronized (syncChat)
{
@@ -333,7 +334,8 @@

/\*\*
 \* Closes the chat window\. Removes all contained chats and invokes

- * setVisible(false) to the window.
+ * <code>setVisible(false)</code> to the window.
+ *
* @param chatWindow the chat window
*/
public void closeWindow(ChatWindow chatWindow)
@@ -469,17 +471,7 @@
public ChatPanel getContactChat(MetaContact metaContact,
Contact protocolContact)
{
- synchronized (syncChat)
- {
- ChatSession chatSession = findChatSessionForDescriptor(metaContact);
-
- if(chatSession != null)
- {
- return getChat(chatSession);
- }
- else
- return createChat(metaContact, protocolContact);
- }
+ return getContactChat(metaContact, protocolContact, null);
}

/\*\*

@@ -500,9 +492,7 @@
ChatSession chatSession = findChatSessionForDescriptor(metaContact);

        if\(chatSession \!= null\)

- {
return getChat(chatSession);
- }
else
return createChat( metaContact,
protocolContact,
@@ -512,6 +502,7 @@

/\*\*
 \* Returns the currently selected &lt;tt&gt;ChatPanel&lt;/tt&gt;\.

+ *
* @return the currently selected <tt>ChatPanel</tt>
*/
public ChatPanel getSelectedChat()
@@ -559,12 +550,10 @@
synchronized (syncChat)
{
ChatSession chatSession
- = findChatSessionForDescriptor(chatRoomWrapper);
+ = findChatSessionForDescriptor(chatRoomWrapper);

        if\(chatSession \!= null\)

- {
return getChat(chatSession);
- }
else
return createChat(chatRoomWrapper);
}
@@ -744,23 +733,17 @@
* supports offline messaging.
*
* @param metaContact the meta contact for the chat
- *
* @return the newly created ChatPanel
*/
private ChatPanel createChat(MetaContact metaContact)
{
Contact defaultContact = metaContact.getDefaultContact();
-
ProtocolProviderService defaultProvider
= defaultContact.getProtocolProvider();
-
- OperationSetBasicInstantMessaging
- defaultIM = (OperationSetBasicInstantMessaging)
- defaultProvider.getOperationSet(
- OperationSetBasicInstantMessaging.class);
-
- ProtocolProviderService protoContactProvider;
- OperationSetBasicInstantMessaging protoContactIM;
+ OperationSetBasicInstantMessaging defaultIM
+ = (OperationSetBasicInstantMessaging)
+ defaultProvider
+ .getOperationSet(OperationSetBasicInstantMessaging.class);

    if \(defaultContact\.getPresenceStatus\(\)\.getStatus\(\) &lt; 1
            &amp;&amp; \(\!defaultIM\.isOfflineMessagingSupported\(\)

@@ -771,12 +754,13 @@
while(protoContacts.hasNext())
{
Contact contact = protoContacts.next();
-
- protoContactProvider = contact.getProtocolProvider();
-
- protoContactIM = (OperationSetBasicInstantMessaging)
- protoContactProvider.getOperationSet(
- OperationSetBasicInstantMessaging.class);
+ ProtocolProviderService protoContactProvider
+ = contact.getProtocolProvider();
+ OperationSetBasicInstantMessaging protoContactIM
+ = (OperationSetBasicInstantMessaging)
+ protoContactProvider
+ .getOperationSet(
+ OperationSetBasicInstantMessaging.class);

            if\(protoContactIM\.isOfflineMessagingSupported\(\)
                    &amp;&amp; protoContactProvider\.isRegistered\(\)\)

@@ -786,27 +770,12 @@
}
}

- return createChat(metaContact, defaultContact);
- }
-
-
- /**
- * Creates a <tt>ChatPanel</tt> for the given contact and saves it in the
- * list ot created <tt>ChatPanel</tt>s.
- *
- * @param contact The MetaContact for this chat.
- * @param protocolContact The protocol contact.
- * @return The <code>ChatPanel</code> newly created.
- */
- private ChatPanel createChat(MetaContact contact,
- Contact protocolContact)
- {
- return createChat(contact, protocolContact, null);
+ return createChat(metaContact, defaultContact, null);
}

/\*\*
 \* Creates a &lt;tt&gt;ChatPanel&lt;/tt&gt; for the given contact and saves it in the

- * list ot created <tt>ChatPanel</tt>s.
+ * list of created <tt>ChatPanel</tt>s.
*
* @param metaContact The MetaContact for this chat.
* @param protocolContact The protocol contact.
@@ -1036,12 +1005,12 @@
}

/\*\*

- * Returns TRUE if this chat window contains the given chatPanel,
- * FALSE otherwise.
+ * Returns <tt>true</tt> if this chat window contains the given chatPanel;
+ * <tt>false</tt>, otherwise.
*
* @param chatPanel the chat panel that we're looking for.
- * @return TRUE if this chat window contains the given chatPanel,
- * FALSE otherwise
+ * @return <tt>true</tt> if this chat window contains the given chatPanel;
+ * <tt>false</tt>, otherwise
*/
private boolean containsChat(ChatPanel chatPanel)
{

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java?view=diff&rev=6023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java&r1=6022&r2=6023

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocChatRoomWrapper.java 2009-09-25 19:54:19+0000
@@ -17,13 +17,13 @@
*/
public class AdHocChatRoomWrapper
{
- private AdHocChatRoomProviderWrapper parentProvider;
+ private final AdHocChatRoomProviderWrapper parentProvider;

private AdHocChatRoom adHocChatRoom;

- private String adHocChatRoomName;
+ private final String adHocChatRoomName;

- private String adHocChatRoomID;
+ private final String adHocChatRoomID;

/\*\*
 \* Creates a &lt;tt&gt;AdHocChatRoomWrapper&lt;/tt&gt; by specifying the protocol

@@ -91,16 +91,6 @@
}

/\*\*

- * Sets the ad-hoc chat room name.
- *
- * @param adHocChatRoomName the name of the ad-hoc chat room
- */
- public void setAdHocChatRoomName(String adHocChatRoomName)
- {
- this.adHocChatRoomName = adHocChatRoomName;
- }
-
- /**
* Returns the identifier of the ad-hoc chat room.
*
* @return the identifier of the ad-hoc chat room
@@ -111,16 +101,6 @@
}

/\*\*

- * Sets the identifier of the ad-hoc chat room.
- *
- * @param adHocChatRoomID the identifier of the ad-hoc chat room
- */
- public void setAdHocChatRoomID(String adHocChatRoomID)
- {
- this.adHocChatRoomID = adHocChatRoomID;
- }
-
- /**
* Returns the parent protocol provider.
*
* @return the parent protocol provider

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java?view=diff&rev=6023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java&r1=6022&r2=6023

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomWrapper.java 2009-09-25 19:54:19+0000
@@ -17,13 +17,13 @@
*/
public class ChatRoomWrapper
{
- private ChatRoomProviderWrapper parentProvider;
+ private final ChatRoomProviderWrapper parentProvider;

private ChatRoom chatRoom;

- private String chatRoomName;
+ private final String chatRoomName;

- private String chatRoomID;
+ private final String chatRoomID;

/\*\*
 \* Creates a &lt;tt&gt;ChatRoomWrapper&lt;/tt&gt; by specifying the protocol provider,

@@ -90,16 +90,6 @@
}

/\*\*

- * Sets the chat room name.
- *
- * @param chatRoomName the name of the chat room
- */
- public void setChatRoomName(String chatRoomName)
- {
- this.chatRoomName = chatRoomName;
- }
-
- /**
* Returns the identifier of the chat room.
*
* @return the identifier of the chat room
@@ -110,16 +100,6 @@
}

/\*\*

- * Sets the identifier of the chat room.
- *
- * @param chatRoomID the identifier of the chat room
- */
- public void setChatRoomID(String chatRoomID)
- {
- this.chatRoomID = chatRoomID;
- }
-
- /**
* Returns the parent protocol provider.
*
* @return the parent protocol provider

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java?view=diff&rev=6023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java&r1=6022&r2=6023

--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java 2009-09-25 19:54:19+0000
@@ -142,7 +142,7 @@
ChatWindowManager chatWindowManager
= GuiActivator.getUIService().getChatWindowManager();

- if(chatWindowManager.isChatOpenedForChatRoom(sourceChatRoom))
+ if(chatWindowManager.isChatOpenedFor(sourceChatRoom))
{
chatPanel = chatWindowManager.getMultiChat(sourceChatRoom);
}
@@ -405,8 +405,7 @@
// Check if we have already opened a chat window for this chat
// wrapper and load the real chat room corresponding to the
// wrapper.
- if(chatWindowManager
- .isChatOpenedForAdHocChatRoom(adHocChatRoomWrapper))
+ if(chatWindowManager.isChatOpenedFor(adHocChatRoomWrapper))
{
((AdHocConferenceChatSession) chatPanel.getChatSession())
.loadChatRoom(sourceAdHocChatRoom);
@@ -490,8 +489,7 @@
// Check if we have already opened a chat window for this chat
// wrapper and load the real chat room corresponding to the
// wrapper.
- if(chatWindowManager
- .isChatOpenedForChatRoom(chatRoomWrapper))
+ if(chatWindowManager.isChatOpenedFor(chatRoomWrapper))
{
((ConferenceChatSession) chatPanel.getChatSession())
.loadChatRoom(sourceChatRoom);
@@ -1272,7 +1270,7 @@
final ChatWindowManager chatWindowManager
= GuiActivator.getUIService().getChatWindowManager();

- if(chatWindowManager.isChatOpenedForChatRoom(chatRoomWrapper))
+ if(chatWindowManager.isChatOpenedFor(chatRoomWrapper))
{
final ChatPanel chatPanel
= chatWindowManager.getMultiChat(chatRoomWrapper);
@@ -1300,7 +1298,7 @@
final ChatWindowManager chatWindowManager
= GuiActivator.getUIService().getChatWindowManager();

- if(chatWindowManager.isChatOpenedForAdHocChatRoom(chatRoomWrapper))
+ if(chatWindowManager.isChatOpenedFor(chatRoomWrapper))
{
final ChatPanel chatPanel
= chatWindowManager.getAdHocMultiChat(chatRoomWrapper);
@@ -1776,7 +1774,7 @@
ChatWindowManager chatWindowManager
= GuiActivator.getUIService().getChatWindowManager();

- if(chatWindowManager.isChatOpenedForAdHocChatRoom(sourceChatRoom))
+ if(chatWindowManager.isChatOpenedFor(sourceChatRoom))
{
chatPanel = chatWindowManager.getAdHocMultiChat(sourceChatRoom);
}

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java?view=diff&rev=6023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java&r1=6022&r2=6023

--- trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java (original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java 2009-09-25 19:54:19+0000
@@ -411,7 +411,7 @@

    ChatPanel chatPanel = null;

- if(chatWindowManager.isChatOpenedForContact(metaContact))
+ if(chatWindowManager.isChatOpenedFor(metaContact))
chatPanel = chatWindowManager.getContactChat(metaContact);

    if \(chatPanel \!= null\)

@@ -536,7 +536,7 @@
typingTimer.start();

        // Proactive typing notification

- if (!chatWindowManager.isChatOpenedForContact(metaContact))
+ if (!chatWindowManager.isChatOpenedFor(metaContact))
{
this.fireProactiveNotification(evt.getSourceContact());
return;
@@ -700,7 +700,7 @@
public void setChatNotificationMsg(MetaContact metaContact,
String notificationMsg)
{
- if(chatWindowManager.isChatOpenedForContact(metaContact))
+ if(chatWindowManager.isChatOpenedFor(metaContact))
chatWindowManager.getContactChat(metaContact)
.setStatusMessage(notificationMsg);
}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net