svn commit: r7023 - trunk: resources/images resources/images/impl/gui/buttons src/net/java/sip/communicator/impl/gui/main/call src/net/java/sip/com...

yanas at dev.java.net yanas at dev.java.net
Wed Apr 21 17:28:14 CEST 2010


Author: yanas
Date: 2010-04-21 15:28:12+0000
New Revision: 7023

Added:
   trunk/resources/images/impl/gui/buttons/chatCall.png   (contents, props changed)
Modified:
   trunk/resources/images/images.properties
   trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java
   trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java
   trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java

Log:
- Adds a call button in the chat window, which is enabled for all contacts supporting calls.
- Makes the ChatSession interface an abstract class and moves there some of the common method used by its implementations (avoids code duplication).

Modified: trunk/resources/images/images.properties
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/resources/images/images.properties?view=diff&rev=7023&p1=trunk/resources/images/images.properties&p2=trunk/resources/images/images.properties&r1=7022&r2=7023
==============================================================================
--- trunk/resources/images/images.properties	(original)
+++ trunk/resources/images/images.properties	2010-04-21 15:28:12+0000
@@ -172,6 +172,7 @@
 service.gui.buttons.HIDE_ACTIONS_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/hideMoreActionsRollover.png
 service.gui.buttons.CALL_PEER_TOOLS=resources/images/impl/gui/buttons/tools.png
 service.gui.buttons.CHAT_ROOM_CONFIG=resources/images/impl/gui/buttons/chatRoomConfig.png
+service.gui.buttons.CHAT_CALL=resources/images/impl/gui/buttons/chatCall.png
 
 # Sound level icons
 service.gui.soundlevel.SOUND_LEVEL_ACTIVE=resources/images/impl/gui/common/soundlevel/soundActive.png

Added: trunk/resources/images/impl/gui/buttons/chatCall.png
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/resources/images/impl/gui/buttons/chatCall.png?view=auto&rev=7023
==============================================================================
Binary file. No diff available.

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java	2010-04-21 15:28:12+0000
@@ -14,6 +14,7 @@
 import javax.swing.*;
 
 import net.java.sip.communicator.impl.gui.*;
+import net.java.sip.communicator.impl.gui.main.chat.*;
 import net.java.sip.communicator.impl.gui.utils.*;
 import net.java.sip.communicator.service.protocol.*;
 
@@ -53,17 +54,20 @@
      * Creates this dialog by specifying a list of telephony contacts to choose
      * from.
      * @param invoker the invoker of this pop up
-     * @param telephonyContacts the list of telephony contacts to select through
+     * @param telephonyObjects the list of telephony contacts to select through
      */
     public ChooseCallAccountPopupMenu(  JComponent invoker,
-                                        List<Contact> telephonyContacts)
+                                        List<?> telephonyObjects)
     {
         this.invoker = invoker;
         this.init();
 
-        for (Contact contact : telephonyContacts)
+        for (Object o : telephonyObjects)
         {
-            this.addTelephonyContactItem(contact);
+            if (o instanceof Contact)
+                this.addTelephonyContactItem((Contact) o);
+            else if (o instanceof ChatTransport)
+                this.addTelephonyChatTransportItem((ChatTransport) o);
         }
     }
 
@@ -129,6 +133,29 @@
     }
 
     /**
+     * Adds the given <tt>ChatTransport</tt> to the list of available
+     * telephony chat transports.
+     * @param telTransport the telephony chat transport to add
+     */
+    private void addTelephonyChatTransportItem(final ChatTransport telTransport)
+    {
+        final ChatTransportMenuItem transportItem
+            = new ChatTransportMenuItem(telTransport);
+
+        transportItem.addActionListener(new ActionListener()
+        {
+            public void actionPerformed(ActionEvent e)
+            {
+                CallManager.createCall( telTransport.getProtocolProvider(),
+                                        telTransport.getName());
+                ChooseCallAccountPopupMenu.this.setVisible(false);
+            }
+        });
+
+        this.add(transportItem);
+    }
+
+    /**
      * Shows the dialog at the given location.
      * @param x the x coordinate
      * @param y the y coordinate
@@ -219,4 +246,29 @@
             return contact;
         }
     }
+
+    /**
+     * A custom menu item corresponding to a specific <tt>ChatTransport</tt>.
+     */
+    private class ChatTransportMenuItem extends JMenuItem
+    {
+        private final ChatTransport chatTransport;
+
+        public ChatTransportMenuItem(ChatTransport chatTransport)
+        {
+            this.chatTransport = chatTransport;
+            this.setText(chatTransport.getDisplayName());
+
+            BufferedImage contactIcon
+                = Constants.getStatusIcon(chatTransport.getStatus());
+
+            if (contactIcon != null)
+                this.setIcon(new ImageIcon(contactIcon));
+        }
+
+        public ChatTransport getChatTransport()
+        {
+            return chatTransport;
+        }
+    }
 }

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatSession.java	2010-04-21 15:28:12+0000
@@ -12,22 +12,39 @@
 
 import net.java.sip.communicator.service.filehistory.*;
 import net.java.sip.communicator.service.msghistory.*;
+import net.java.sip.communicator.service.protocol.*;
 
 /**
  * @author Yana Stamcheva
  * @author Lubomir Marinov
  */
-public interface ChatSession
+public abstract class ChatSession
 {
-    final String[] chatHistoryFilter
+    /**
+     * The chat history filter.
+     */
+    protected final String[] chatHistoryFilter
         = new String[]{ MessageHistoryService.class.getName(),
                         FileHistoryService.class.getName()};
+
+    /**
+     * The list of <tt>ChatContact</tt>s contained in this chat session.
+     */
+    protected final List<ChatContact> chatParticipants
+        = new ArrayList<ChatContact>();
+
+    /**
+     * The list of <tt>ChatTransport</tt>s available in this session.
+     */
+    protected final List<ChatTransport> chatTransports
+        = new ArrayList<ChatTransport>();
+
     /**
      * Returns the descriptor of this chat session.
      * 
      * @return the descriptor of this chat session.
      */
-    public Object getDescriptor();
+    public abstract Object getDescriptor();
 
     /**
      * Returns <code>true</code> if this chat session descriptor is persistent,
@@ -38,141 +55,178 @@
     public abstract boolean isDescriptorPersistent();
 
     /**
-     * Returns an iterator to the list of all participants contained in this 
+     * Returns an iterator to the list of all participants contained in this
      * chat session.
-     * 
-     * @return an iterator to the list of all participants contained in this 
+     *
+     * @return an iterator to the list of all participants contained in this
      * chat session.
      */
-    public Iterator<ChatContact> getParticipants();
+    public Iterator<ChatContact> getParticipants()
+    {
+        return chatParticipants.iterator();
+    }
 
     /**
      * Returns all available chat transports for this chat session. Each chat
      * transport is corresponding to a protocol provider.
-     * 
+     *
      * @return all available chat transports for this chat session.
      */
-    public Iterator<ChatTransport> getChatTransports();
+    public Iterator<ChatTransport> getChatTransports()
+    {
+        return chatTransports.iterator();
+    }
 
     /**
      * Returns the currently used transport for all operation within this chat
      * session.
-     * 
+     *
      * @return the currently used transport for all operation within this chat
      * session.
      */
-    public ChatTransport getCurrentChatTransport();
+    public abstract ChatTransport getCurrentChatTransport();
+
+    /**
+     * Returns a list of all <tt>ChatTransport</tt>s contained in this session
+     * supporting the given <tt>opSetClass</tt>.
+     * @param opSetClass the <tt>OperationSet</tt> class we're looking for
+     * @return a list of all <tt>ChatTransport</tt>s contained in this session
+     * supporting the given <tt>opSetClass</tt>
+     */
+    public List<ChatTransport> getTransportsForOperationSet(
+                                    Class<? extends OperationSet> opSetClass)
+    {
+        LinkedList<ChatTransport> opSetTransports
+            = new LinkedList<ChatTransport>();
+
+        for (ChatTransport transport : chatTransports)
+        {
+            if(transport.getProtocolProvider()
+                    .getOperationSet(opSetClass) != null)
+                opSetTransports.add(transport);
+        }
+        return opSetTransports;
+    }
 
     /**
      * Returns the <tt>ChatSessionRenderer</tt> that provides the connection
      * between this chat session and its UI.
-     * 
+     *
      * @return The <tt>ChatSessionRenderer</tt>.
      */
-    public ChatSessionRenderer getChatSessionRenderer();
+    public abstract ChatSessionRenderer getChatSessionRenderer();
 
     /**
      * Sets the transport that will be used for all operations within this chat
      * session.
-     * 
+     *
      * @param chatTransport The transport to set as a default transport for this
      * session.
      */
-    public void setCurrentChatTransport(ChatTransport chatTransport);
+    public abstract void setCurrentChatTransport(ChatTransport chatTransport);
 
     /**
      * Returns the name of the chat. If this chat panel corresponds to a single
      * chat it will return the name of the <tt>MetaContact</tt>, otherwise it
      * will return the name of the chat room.
-     * 
+     *
      * @return the name of the chat
      */
-    public String getChatName();
+    public abstract String getChatName();
 
     /**
      * Returns a collection of the last N number of history messages given by
      * count.
-     * 
+     *
      * @param count The number of messages from history to return.
      * @return a collection of the last N number of messages given by count.
      */
-    public Collection<Object> getHistory(int count);
+    public abstract Collection<Object> getHistory(int count);
 
     /**
      * Returns a collection of the last N number of history messages given by
      * count.
-     * 
+     *
      * @param date The date up to which we're looking for messages.
      * @param count The number of messages from history to return.
      * @return a collection of the last N number of messages given by count.
      */
-    public Collection<Object> getHistoryBeforeDate(Date date, int count);
+    public abstract Collection<Object> getHistoryBeforeDate(Date date, int count);
 
     /**
      * Returns a collection of the last N number of history messages given by
      * count.
-     * 
+     *
      * @param date The date from which we're looking for messages.
      * @param count The number of messages from history to return.
      * @return a collection of the last N number of messages given by count.
      */
-    public Collection<Object> getHistoryAfterDate(Date date, int count);
+    public abstract Collection<Object> getHistoryAfterDate(Date date, int count);
 
     /**
      * Returns the start date of the history of this chat session.
-     * 
+     *
      * @return the start date of the history of this chat session.
      */
-    public long getHistoryStartDate();
+    public abstract long getHistoryStartDate();
 
     /**
      * Returns the end date of the history of this chat session.
-     * 
+     *
      * @return the end date of the history of this chat session.
      */
-    public long getHistoryEndDate();
+    public abstract long getHistoryEndDate();
 
     /**
      * Returns the default mobile number used to send sms-es in this session.
-     * 
+     *
      * @return the default mobile number used to send sms-es in this session.
      */
-    public String getDefaultSmsNumber();
+    public abstract String getDefaultSmsNumber();
 
     /**
      * Sets the default mobile number used to send sms-es in this session.
-     * 
+     *
      * @param smsPhoneNumber The default mobile number used to send sms-es in
      * this session.
      */
-    public void setDefaultSmsNumber(String smsPhoneNumber);
+    public abstract void setDefaultSmsNumber(String smsPhoneNumber);
 
     /**
      * Disposes this chat session.
      */
-    public void dispose();
+    public abstract void dispose();
 
     /**
      * Returns the ChatTransport corresponding to the given descriptor.
-     * 
+     *
      * @param descriptor The descriptor of the chat transport we're looking for.
      * @return The ChatTransport corresponding to the given descriptor.
      */
-    public ChatTransport findChatTransportForDescriptor(Object descriptor);
+    public ChatTransport findChatTransportForDescriptor(
+        Object descriptor)
+    {
+        for (ChatTransport chatTransport : chatTransports)
+        {
+            if (chatTransport.getDescriptor().equals(descriptor))
+                return chatTransport;
+        }
+        return null;
+    }
 
     /**
      * Returns the status icon of this chat session.
      *
      * @return the status icon of this chat session.
      */
-    public ImageIcon getChatStatusIcon();
+    public abstract ImageIcon getChatStatusIcon();
 
     /**
      * Returns the avatar icon of this chat session.
      *
      * @return the avatar icon of this chat session.
      */
-    public byte[] getChatAvatar();
+    public abstract byte[] getChatAvatar();
 
     /**
      * Gets the indicator which determines whether a contact list of (multiple)
@@ -184,21 +238,23 @@
      * @return <tt>true</tt> if this <code>ChatSession</code> supports a contact
      *         list of (multiple) participants; otherwise, <tt>false</tt>
      */
-    public boolean isContactListSupported();
-    
+    public abstract boolean isContactListSupported();
+
     /**
      * Adds the given {@link ChatSessionChangeListener} to this 
      * <tt>ChatSession</tt>.
-     * 
+     *
      * @param l the <tt>ChatSessionChangeListener</tt> to add
      */
-    public void addChatTransportChangeListener(ChatSessionChangeListener l);
-    
+    public abstract void addChatTransportChangeListener(
+        ChatSessionChangeListener l);
+
     /**
      * Removes the given {@link ChatSessionChangeListener} to this 
      * <tt>ChatSession</tt>.
-     * 
+     *
      * @param l the <tt>ChatSessionChangeListener</tt> to add
      */
-    public void removeChatTransportChangeListener(ChatSessionChangeListener l);
+    public abstract void removeChatTransportChangeListener(
+        ChatSessionChangeListener l);
 }

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransport.java	2010-04-21 15:28:12+0000
@@ -14,7 +14,7 @@
 
 /**
  * The <tt>ChatTransport</tt> is an abstraction of the transport method used
- * when sending messages or sms-es.
+ * when sending messages, making calls, etc. through the chat window.
  * 
  * @author Yana Stamcheva
  */
@@ -23,7 +23,7 @@
     /**
      * Returns the descriptor object of this ChatTransport.
      * 
-     * @return the descriptor object of this ChatTransport.
+     * @return the descriptor object of this ChatTransport
      */
     public Object getDescriptor();
 
@@ -32,7 +32,7 @@
      * messaging, otherwise returns <code>false</code>.
      * 
      * @return <code>true</code> if this chat transport supports instant
-     * messaging, otherwise returns <code>false</code>.
+     * messaging, otherwise returns <code>false</code>
      */
     public boolean allowsInstantMessage();
 
@@ -41,7 +41,7 @@
      * messaging, otherwise returns <code>false</code>.
      * 
      * @return <code>true</code> if this chat transport supports sms
-     * messaging, otherwise returns <code>false</code>.
+     * messaging, otherwise returns <code>false</code>
      */
     public boolean allowsSmsMessage();
 
@@ -50,14 +50,14 @@
      * notifications, otherwise returns <code>false</code>.
      * 
      * @return <code>true</code> if this chat transport supports typing
-     * notifications, otherwise returns <code>false</code>.
+     * notifications, otherwise returns <code>false</code>
      */
     public boolean allowsTypingNotifications();
 
     /**
      * Returns the name of this chat transport. This is for example the name of
      * the contact in a single chat mode and the name of the chat room in the
-     * multi chat mode.
+     * multi-chat mode.
      * 
      * @return The name of this chat transport.
      */
@@ -66,7 +66,7 @@
     /**
      * Returns the display name of this chat transport. This is for example the
      * name of the contact in a single chat mode and the name of the chat room
-     * in the multi chat mode.
+     * in the multi-chat mode.
      * 
      * @return The display name of this chat transport.
      */
@@ -91,19 +91,22 @@
     /**
      * Sends the given instant message trough this chat transport, by specifying
      * the mime type (html or plain text).
-     * 
+     *
      * @param message The message to send.
      * @param mimeType The mime type of the message to send: text/html or
      * text/plain.
+     * @throws Exception if the send doesn't succeed
      */
     public void sendInstantMessage( String message,
                                     String mimeType)
         throws Exception;
 
     /**
-     * Sends the given sms message trough this chat transport.
-     * 
+     * Sends the given SMS message trough this chat transport.
+     *
+     * @param phoneNumber the phone number to which to send the message
      * @param message The message to send.
+     * @throws Exception if the send doesn't succeed
      */
     public void sendSmsMessage(String phoneNumber, String message)
         throws Exception;
@@ -122,6 +125,9 @@
      * Sends the given file trough this chat transport.
      * 
      * @param file the file to send
+     * @return the <tt>FileTransfer</tt> charged to transfer the given
+     * <tt>file</tt>.
+     * @throws Exception if the send doesn't succeed
      */
     public FileTransfer sendFile(File file)
         throws Exception;

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/ChatWindow.java	2010-04-21 15:28:12+0000
@@ -423,13 +423,6 @@
         this.setTitle(chatSession.getChatName());
         this.setChatContactPhoto(chatSession);
 
-        mainToolBar
-            .enableInviteButton(chatPanel.findInviteChatTransport() != null);
-        mainToolBar
-            .enableSendFileButton(
-                chatPanel.findFileTransferChatTransport() != null);
-        mainToolBar.changeHistoryButtonsState(chatPanel);
-
         chatPanel.requestFocusInWriteArea();
 
         for (ChatChangeListener l : this.chatChangeListeners)

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatSession.java	2010-04-21 15:28:12+0000
@@ -25,19 +25,14 @@
  *
  * @author Yana Stamcheva
  * @author Lubomir Marinov
+ * 
  */
 public class MetaContactChatSession
-    implements  ChatSession,
-                MetaContactListListener
+    extends  ChatSession
+    implements MetaContactListListener
 {
     private final MetaContact metaContact;
 
-    private final List<ChatContact> chatParticipants
-        = new ArrayList<ChatContact>();
-
-    private final List<ChatTransport> chatTransports
-        = new ArrayList<ChatTransport>();
-
     private final MetaContactListService metaContactListService;
 
     private ChatTransport currentChatTransport;
@@ -82,29 +77,6 @@
     }
 
     /**
-     * Returns an iterator to the list of all participants contained in this
-     * chat session.
-     *
-     * @return an iterator to the list of all participants contained in this
-     * chat session.
-     */
-    public Iterator<ChatContact> getParticipants()
-    {
-        return chatParticipants.iterator();
-    }
-
-    /**
-     * Returns all available chat transports for this chat session. Each chat
-     * transport is corresponding to a protocol provider.
-     *
-     * @return all available chat transports for this chat session.
-     */
-    public Iterator<ChatTransport> getChatTransports()
-    {
-        return chatTransports.iterator();
-    }
-
-    /**
      * Returns the name of this chat.
      *
      * @return the name of this chat
@@ -588,29 +560,6 @@
     }
 
     /**
-     * Returns the ChatTransport corresponding to the given descriptor.
-     *
-     * @param descriptor The descriptor of the chat transport we're looking for.
-     * @return The ChatTransport corresponding to the given descriptor.
-     */
-    public ChatTransport findChatTransportForDescriptor(Object descriptor)
-    {
-        return findChatTransportForDescriptor(chatTransports, descriptor);
-    }
-
-    public static ChatTransport findChatTransportForDescriptor(
-            Iterable<ChatTransport> chatTransports,
-            Object descriptor)
-    {
-        for (ChatTransport chatTransport : chatTransports)
-        {
-            if (chatTransport.getDescriptor().equals(descriptor))
-                return chatTransport;
-        }
-        return null;
-    }
-
-    /**
      * Implements the <tt>ChatPanel.getChatStatusIcon</tt> method.
      *
      * @return the status icon corresponding to this chat room
@@ -636,7 +585,9 @@
     public void protoContactModified(ProtoContactEvent evt)
     {}
 
-    /* Implements ChatSession#isContactListSupported(). */
+    /**
+     *  Implements ChatSession#isContactListSupported().
+     */
     public boolean isContactListSupported()
     {
         return false;

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/MetaContactChatTransport.java	2010-04-21 15:28:12+0000
@@ -25,19 +25,45 @@
     implements  ChatTransport,
                 ContactPresenceStatusListener
 {
+    /**
+     * The logger.
+     */
     private static final Logger logger
         = Logger.getLogger(MetaContactChatTransport.class);
 
+    /**
+     * The parent <tt>ChatSession</tt>, where this transport is available.
+     */
     private final ChatSession parentChatSession;
 
+    /**
+     * The associated protocol <tt>Contact</tt>.
+     */
     private final Contact contact;
 
+    /**
+     * The protocol presence operation set associated with this transport.
+     */
     private final OperationSetPresence presenceOpSet;
 
+    /**
+     * The thumbnail default width.
+     */
     private static final int THUMBNAIL_WIDTH = 64;
 
+    /**
+     * The thumbnail default height.
+     */
     private static final int THUMBNAIL_HEIGHT = 64;
 
+    /**
+     * Creates an instance of <tt>MetaContactChatTransport</tt> by specifying
+     * the parent <tt>chatSession</tt> and the <tt>contact</tt> associated with
+     * the transport.
+     *
+     * @param chatSession the parent <tt>ChatSession</tt>
+     * @param contact the <tt>Contact</tt> associated with this transport
+     */
     public MetaContactChatTransport(ChatSession chatSession,
                                     Contact contact)
     {
@@ -53,6 +79,10 @@
             presenceOpSet.addContactPresenceStatusListener(this);
     }
 
+    /**
+     * Returns the contact associated with this transport.
+     * @return the contact associated with this transport
+     */
     public Contact getContact()
     {
         return contact;
@@ -175,10 +205,11 @@
     /**
      * Sends the given instant message trough this chat transport, by specifying
      * the mime type (html or plain text).
-     * 
+     *
      * @param message The message to send.
      * @param mimeType The mime type of the message to send: text/html or
      * text/plain.
+     * @throws Exception if the send operation is interrupted
      */
     public void sendInstantMessage( String message,
                                     String mimeType)
@@ -212,9 +243,10 @@
 
     /**
      * Sends the given sms message trough this chat transport.
-     * 
+     *
      * @param phoneNumber phone number of the destination
      * @param messageText The message to send.
+     * @throws Exception if the send operation is interrupted
      */
     public void sendSmsMessage(String phoneNumber, String messageText)
         throws Exception
@@ -236,9 +268,8 @@
 
     /**
      * Sends a typing notification state.
-     * 
+     *
      * @param typingState the typing notification state to send
-     * 
      * @return the result of this operation. One of the TYPING_NOTIFICATION_XXX
      * constants defined in this class
      */
@@ -279,6 +310,7 @@
      * Sends the given file through this chat transport file transfer operation
      * set.
      * @param file the file to send
+     * @return the <tt>FileTransfer</tt> object charged to transfer the file
      * @throws Exception if anything goes wrong
      */
     public FileTransfer sendFile(File file)
@@ -315,7 +347,6 @@
                 }
             }
         }
-
         return ftOpSet.sendFile(contact, file);
     }
 
@@ -333,9 +364,7 @@
         return ftOpSet.getMaximumFileLength();
     }
 
-    public void inviteChatContact(String contactAddress, String reason)
-    {
-    }
+    public void inviteChatContact(String contactAddress, String reason) {}
 
     /**
      * Returns the parent session of this chat transport. A <tt>ChatSession</tt>
@@ -347,10 +376,9 @@
     {
         return parentChatSession;
     }
-    
+
     /**
-     * Adds an sms message listener to this chat transport.
-     * 
+     * Adds an SMS message listener to this chat transport.
      * @param l The message listener to add.
      */
     public void addSmsMessageListener(MessageListener l)
@@ -370,7 +398,6 @@
 
     /**
      * Adds an instant message listener to this chat transport.
-     * 
      * @param l The message listener to add.
      */
     public void addInstantMessageListener(MessageListener l)
@@ -390,7 +417,6 @@
 
     /**
      * Removes the given sms message listener from this chat transport.
-     * 
      * @param l The message listener to remove.
      */
     public void removeSmsMessageListener(MessageListener l)
@@ -410,7 +436,6 @@
 
     /**
      * Removes the instant message listener from this chat transport.
-     * 
      * @param l The message listener to remove.
      */
     public void removeInstantMessageListener(MessageListener l)
@@ -430,7 +455,6 @@
 
     /**
      * Indicates that a contact has changed its status.
-     *
      * @param evt The presence event containing information about the
      * contact status change.
      */
@@ -448,7 +472,6 @@
 
     /**
      * Updates the status of this contact with the new given status.
-     * 
      * @param newStatus The new status.
      */
     private void updateContactStatus(PresenceStatus newStatus)
@@ -472,7 +495,6 @@
 
     /**
      * Returns the descriptor of this chat transport.
-     * 
      * @return the descriptor of this chat transport
      */
     public Object getDescriptor()
@@ -482,8 +504,9 @@
 
     /**
      * Sets the icon for the given file.
-     * 
+     *
      * @param file the file to set an icon for
+     * @return the byte array containing the thumbnail
      */
     private byte[] getFileThumbnail(File file)
     {
@@ -513,7 +536,6 @@
                 logger.debug("Could not locate image.", e);
             }
         }
-
         return bytes;
     }
 }

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/AdHocConferenceChatSession.java	2010-04-21 15:28:12+0000
@@ -23,15 +23,9 @@
  * @author Valentin Martinet
  */
 public class AdHocConferenceChatSession
-    implements  ChatSession,
-                AdHocChatRoomParticipantPresenceListener
+    extends ChatSession
+    implements AdHocChatRoomParticipantPresenceListener
 {
-    private final List<ChatContact> chatParticipants
-        = new ArrayList<ChatContact>();
-
-    private final List<ChatTransport> chatTransports
-        = new ArrayList<ChatTransport>();
-
     private ChatTransport currentChatTransport;
 
     private final AdHocChatRoomWrapper chatRoomWrapper;
@@ -108,28 +102,6 @@
     }
 
     /**
-     * Returns an iterator to the list of all participants contained in this 
-     * chat session.
-     * 
-     * @return an iterator to the list of all participants contained in this 
-     * chat session.
-     */
-    public Iterator<ChatContact> getParticipants()
-    {
-        return chatParticipants.iterator();
-    }
-
-    /**
-     * Returns all available chat transports for this chat session.
-     * 
-     * @return all available chat transports for this chat session.
-     */
-    public Iterator<ChatTransport> getChatTransports()
-    {
-        return chatTransports.iterator();
-    }
-
-    /**
      * Returns the currently used transport for all operation within this chat
      * session.
      * 
@@ -365,13 +337,6 @@
         return false;
     }
 
-    public ChatTransport findChatTransportForDescriptor(Object descriptor)
-    {
-        return MetaContactChatSession.findChatTransportForDescriptor(
-            chatTransports,
-            descriptor);
-    }
-
     /**
      * Loads the given chat room in the this chat conference panel. Loads all
      * members and adds all corresponding listeners.

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatSession.java	2010-04-21 15:28:12+0000
@@ -25,23 +25,11 @@
  * @author Valentin Martinet
  */
 public class ConferenceChatSession
-    implements  ChatSession,
-                ChatRoomMemberPresenceListener,
+    extends ChatSession
+    implements  ChatRoomMemberPresenceListener,
                 ChatRoomPropertyChangeListener
 {
     /**
-     * The list of all chat participants.
-     */
-    private final List<ChatContact> chatParticipants
-        = new ArrayList<ChatContact>();
-
-    /**
-     * The list of available chat transports.
-     */
-    private final List<ChatTransport> chatTransports
-        = new ArrayList<ChatTransport>();
-
-    /**
      * The current chat transport used for messaging.
      */
     private ChatTransport currentChatTransport;
@@ -147,28 +135,6 @@
     }
 
     /**
-     * Returns an iterator to the list of all participants contained in this 
-     * chat session.
-     * 
-     * @return an iterator to the list of all participants contained in this 
-     * chat session.
-     */
-    public Iterator<ChatContact> getParticipants()
-    {
-        return chatParticipants.iterator();
-    }
-
-    /**
-     * Returns all available chat transports for this chat session.
-     * 
-     * @return all available chat transports for this chat session.
-     */
-    public Iterator<ChatTransport> getChatTransports()
-    {
-        return chatTransports.iterator();
-    }
-
-    /**
      * Returns the currently used transport for all operation within this chat
      * session.
      * 
@@ -518,20 +484,6 @@
     }
 
     /**
-     * Finds the <tt>ChatTransport</tt> corresponding to the given
-     * <tt>descriptor</tt>.
-     * @param descriptor the descriptor of the chat transport we're looking for
-     * @return the <tt>ChatTransport</tt> corresponding to the given
-     * <tt>descriptor</tt>
-     */
-    public ChatTransport findChatTransportForDescriptor(Object descriptor)
-    {
-        return MetaContactChatSession.findChatTransportForDescriptor(
-            chatTransports,
-            descriptor);
-    }
-
-    /**
      * Loads the given chat room in the this chat conference panel. Loads all
      * members and adds all corresponding listeners.
      * 

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java	2010-04-21 15:28:12+0000
@@ -10,14 +10,17 @@
 import java.awt.event.*;
 import java.io.*;
 import java.util.*;
+import java.util.List;
 
 import javax.swing.*;
 
 import net.java.sip.communicator.impl.gui.*;
 import net.java.sip.communicator.impl.gui.customcontrols.*;
+import net.java.sip.communicator.impl.gui.main.call.*;
 import net.java.sip.communicator.impl.gui.main.chat.*;
 import net.java.sip.communicator.impl.gui.main.chat.conference.*;
 import net.java.sip.communicator.impl.gui.main.chat.history.*;
+import net.java.sip.communicator.impl.gui.main.contactlist.*;
 import net.java.sip.communicator.impl.gui.utils.*;
 import net.java.sip.communicator.service.contactlist.*;
 import net.java.sip.communicator.service.gui.*;
@@ -64,13 +67,26 @@
                 ImageLoader.getImage(ImageLoader.NEXT_ICON));
 
     /**
+     * The call button.
+     */
+    private final ChatToolbarButton callButton
+        = new ChatToolbarButton(
+                ImageLoader.getImage(ImageLoader.CHAT_CALL));
+
+    /**
      * The current <tt>ChatSession</tt> made known to this instance by the last
      * call to its {@link #chatChanged(ChatPanel)}. 
      */
     private ChatSession chatSession;
 
+    /**
+     * The chat window, where this tool bar is contained.
+     */
     protected final ChatWindow messageWindow;
 
+    /**
+     * The plug-in container contained in this tool bar.
+     */
     private final PluginContainer pluginContainer;
 
     /**
@@ -90,6 +106,9 @@
         this.messageWindow.addChatChangeListener(this);
     }
 
+    /**
+     * Initializes this component.
+     */
     protected void init()
     {
         ChatToolbarButton optionsButton
@@ -100,6 +119,7 @@
         this.setOpaque(false);
 
         this.add(inviteButton);
+        this.add(callButton);
         this.add(historyButton);
         this.add(optionsButton);
         this.add(sendFileButton);
@@ -111,6 +131,11 @@
         this.inviteButton.setToolTipText(
             GuiActivator.getResources().getI18NString("service.gui.INVITE"));
 
+        this.callButton.setName("call");
+        this.callButton.setToolTipText(
+            GuiActivator.getResources().getI18NString(
+                "service.gui.CALL_CONTACT"));
+
         this.historyButton.setName("history");
         this.historyButton.setToolTipText(
             GuiActivator.getResources().getI18NString("service.gui.HISTORY")
@@ -133,6 +158,7 @@
             GuiActivator.getResources().getI18NString("service.gui.NEXT"));
 
         this.inviteButton.addActionListener(this);
+        this.callButton.addActionListener(this);
         this.historyButton.addActionListener(this);
         optionsButton.addActionListener(this);
         this.sendFileButton.addActionListener(this);
@@ -150,30 +176,42 @@
         pluginContainer.dispose();
     }
 
-    /*
+    /**
      * Implements ChatChangeListener#chatChanged(ChatPanel).
+     * @param chatPanel the <tt>ChatPanel</tt>, which changed
      */
-    public void chatChanged(ChatPanel panel)
+    public void chatChanged(ChatPanel chatPanel)
     {
-        if (panel == null)
+        if (chatPanel == null)
         {
             setChatSession(null);
         }
         else
         {
             MetaContact contact
-                = GuiActivator.getUIService().getChatContact(panel);
+                = GuiActivator.getUIService().getChatContact(chatPanel);
 
             for (PluginComponent c : pluginContainer.getPluginComponents())
                 c.setCurrentContact(contact);
 
-            setChatSession(panel.chatSession);
+            setChatSession(chatPanel.chatSession);
+
+            inviteButton.setEnabled(
+                chatPanel.findInviteChatTransport() != null);
+            sendFileButton.setEnabled(
+                chatPanel.findFileTransferChatTransport() != null);
+            callButton.setEnabled(
+                !chatPanel.chatSession.getTransportsForOperationSet(
+                    OperationSetBasicTelephony.class).isEmpty());
+
+            changeHistoryButtonsState(chatPanel);
         }
     }
 
-    /*
+    /**
      * Implements
      * ChatSessionChangeListener#currentChatTransportChanged(ChatSession).
+     * @param chatSession the <tt>ChatSession</tt>, which transport has changed
      */
     public void currentChatTransportChanged(ChatSession chatSession)
     {
@@ -193,8 +231,9 @@
     }
 
     /**
-     * Handles the <tt>ActionEvent</tt>, when one of the toolbar buttons is
+     * Handles the <tt>ActionEvent</tt>, when one of the tool bar buttons is
      * clicked.
+     * @param e the <tt>ActionEvent</tt> that notified us
      */
     public void actionPerformed(ActionEvent e)
     {
@@ -262,6 +301,43 @@
 
             inviteDialog.setVisible(true);
         }
+        else if (buttonText.equals("call"))
+        {
+            ChatSession chatSession = chatPanel.getChatSession();
+
+            List<ChatTransport> telTransports = null;
+            if (chatSession != null)
+                telTransports = chatSession
+                    .getTransportsForOperationSet(
+                        OperationSetBasicTelephony.class);
+
+            if (telTransports != null)
+            {
+                if (telTransports.size() == 1)
+                {
+                    ChatTransport transport = telTransports.get(0);
+                    CallManager.createCall(
+                        transport.getProtocolProvider(),
+                        transport.getName());
+                }
+                else if (telTransports.size() > 1)
+                {
+                    ChooseCallAccountPopupMenu chooseAccountDialog
+                        = new ChooseCallAccountPopupMenu(
+                            callButton,
+                            telTransports);
+
+                    Point location = new Point(callButton.getX(),
+                        callButton.getY() + callButton.getHeight());
+
+                    SwingUtilities.convertPointToScreen(
+                        location, this);
+
+                    chooseAccountDialog
+                        .showPopupMenu(location.x, location.y);
+                }
+            }
+        }
         else if (buttonText.equals("options"))
         {
             GuiActivator.getUIService().setConfigurationWindowVisible(true);
@@ -281,6 +357,7 @@
     /**
      * Disables/Enables history arrow buttons depending on whether the
      * current page is the first, the last page or a middle page.
+     * @param chatPanel the <tt>ChatPanel</tt> which has provoked the change.
      */
     public void changeHistoryButtonsState(ChatPanel chatPanel)
     {
@@ -307,28 +384,6 @@
     }
 
     /**
-     * Enables or disables the conference button in this tool bar.
-     *
-     * @param isEnabled <code>true</code> if the conference button should be
-     * enabled; <code>false</code>, otherwise.
-     */
-    public void enableInviteButton(boolean isEnabled)
-    {
-        inviteButton.setEnabled(isEnabled);
-    }
-
-    /**
-     * Enables or disables the send file button in this tool bar.
-     *
-     * @param isEnabled <code>true</code> if the send file button should be
-     * enabled; <code>false</code>, otherwise.
-     */
-    public void enableSendFileButton(boolean isEnabled)
-    {
-        sendFileButton.setEnabled(isEnabled);
-    }
-
-    /**
      * Sets the current <tt>ChatSession</tt> made known to this instance by the
      * last call to its {@link #chatChanged(ChatPanel)}.
      * 

Modified: trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java?view=diff&rev=7023&p1=trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java&p2=trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java&r1=7022&r2=7023
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java	2010-04-21 15:28:12+0000
@@ -272,6 +272,12 @@
         = new ImageID("service.gui.buttons.CHAT_BUTTON_SMALL");
 
     /**
+     * The chat call button image.
+     */
+    public static final ImageID CHAT_CALL
+        = new ImageID("service.gui.buttons.CHAT_CALL");
+
+    /**
      * The chat button small pressed image.
      */
     public static final ImageID CHAT_BUTTON_SMALL_PRESSED

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





More information about the commits mailing list