- 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).
cusax-fix
Yana Stamcheva 16 years ago
parent f5924f19e6
commit fd6b9abba9

@ -172,6 +172,7 @@ service.gui.buttons.HIDE_ACTIONS_BUTTON=resources/images/impl/gui/buttons/hideMo
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

@ -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 @@ public ChooseCallAccountPopupMenu(
* 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);
}
}
@ -128,6 +132,29 @@ public void actionPerformed(ActionEvent e)
this.add(contactItem);
}
/**
* 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
@ -219,4 +246,29 @@ public Contact getContact()
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;
}
}
}

@ -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 interface ChatSession
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 @@ public interface ChatSession
* @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);
}

@ -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 @@ public interface ChatTransport
/**
* 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 @@ public interface ChatTransport
* 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 @@ public interface ChatTransport
* 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 @@ public interface ChatTransport
* 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 @@ public interface ChatTransport
/**
* 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 @@ public interface ChatTransport
/**
* 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 @@ public void sendSmsMessage(String phoneNumber, String message)
* 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;

@ -423,13 +423,6 @@ public void setCurrentChatPanel(ChatPanel chatPanel)
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)

@ -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;
@ -81,29 +76,6 @@ public MetaContactChatSession( ChatSessionRenderer sessionRenderer,
metaContactListService.addMetaContactListListener(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
* 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.
*
@ -587,29 +559,6 @@ public boolean isDescriptorPersistent()
}
}
/**
* 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.
*
@ -636,7 +585,9 @@ public byte[] getChatAvatar()
public void protoContactModified(ProtoContactEvent evt)
{}
/* Implements ChatSession#isContactListSupported(). */
/**
* Implements ChatSession#isContactListSupported().
*/
public boolean isContactListSupported()
{
return false;

@ -25,19 +25,45 @@ public class MetaContactChatTransport
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 @@ public MetaContactChatTransport(ChatSession chatSession,
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 @@ public boolean allowsFileTransfer()
/**
* 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 @@ public void sendInstantMessage( String message,
/**
* 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 @@ public void sendSmsMessage(String phoneNumber, String messageText)
/**
* 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 @@ public int sendTypingNotification(int typingState)
* 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 @@ public FileTransfer sendFile(File file)
}
}
}
return ftOpSet.sendFile(contact, file);
}
@ -333,9 +364,7 @@ public long getMaximumFileLength()
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 @@ public ChatSession getParentChatSession()
{
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 @@ public void addSmsMessageListener(MessageListener l)
/**
* 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 @@ public void addInstantMessageListener(MessageListener l)
/**
* 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 @@ public void removeSmsMessageListener(MessageListener l)
/**
* 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 @@ public void removeInstantMessageListener(MessageListener l)
/**
* Indicates that a contact has changed its status.
*
* @param evt The presence event containing information about the
* contact status change.
*/
@ -448,7 +472,6 @@ public void contactPresenceStatusChanged(
/**
* 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 @@ public void dispose()
/**
* Returns the descriptor of this chat transport.
*
* @return the descriptor of this chat transport
*/
public Object getDescriptor()
@ -482,8 +504,9 @@ public Object getDescriptor()
/**
* 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 @@ private byte[] getFileThumbnail(File file)
logger.debug("Could not locate image.", e);
}
}
return bytes;
}
}

@ -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;
@ -107,28 +101,6 @@ public ChatRoomConfigurationForm getChatConfigurationForm()
return null;
}
/**
* 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 @@ public boolean isDescriptorPersistent()
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.

@ -25,22 +25,10 @@
* @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.
*/
@ -146,28 +134,6 @@ public ChatRoomConfigurationForm getChatConfigurationForm()
return chatRoomWrapper.getChatRoom().getConfigurationForm();
}
/**
* 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.
@ -517,20 +483,6 @@ public boolean isDescriptorPersistent()
return true;
}
/**
* 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.

@ -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.*;
@ -63,14 +66,27 @@ public class MainToolBar
= new ChatToolbarButton(
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 @@ public MainToolBar(ChatWindow messageWindow)
this.messageWindow.addChatChangeListener(this);
}
/**
* Initializes this component.
*/
protected void init()
{
ChatToolbarButton optionsButton
@ -100,6 +119,7 @@ protected void init()
this.setOpaque(false);
this.add(inviteButton);
this.add(callButton);
this.add(historyButton);
this.add(optionsButton);
this.add(sendFileButton);
@ -111,6 +131,11 @@ protected void init()
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 @@ protected void init()
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 @@ public void dispose()
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 @@ public void currentChatTransportChanged(ChatSession chatSession)
}
/**
* 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 @@ else if (buttonText.equals("invite"))
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 @@ public ChatToolbarButton getHistoryButton()
/**
* 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)
{
@ -306,28 +383,6 @@ public void changeHistoryButtonsState(ChatPanel chatPanel)
&& (lastMsgInHistory > lastMsgInPage.getTime()));
}
/**
* 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)}.

@ -271,6 +271,12 @@ public class ImageLoader
public static final ImageID CHAT_BUTTON_SMALL
= 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.
*/

Loading…
Cancel
Save