aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2010-12-16 09:46:32 +0000
committerSebastien Vincent <seb@jitsi.org>2010-12-16 09:46:32 +0000
commit7f8963b371cf2bf9fe8acbadfe6d40c104b7379a (patch)
tree5c0bb56ea9ad4a7023207f2a82a26e023358d247 /src/net/java/sip
parent29b8bca9c837c3f7ff5c003f0d05435e9a6d7922 (diff)
downloadjitsi-7f8963b371cf2bf9fe8acbadfe6d40c104b7379a.zip
jitsi-7f8963b371cf2bf9fe8acbadfe6d40c104b7379a.tar.gz
jitsi-7f8963b371cf2bf9fe8acbadfe6d40c104b7379a.tar.bz2
Reflect contact capabilities, such as call, video or desktop sharing support, in contact list (right click menu) and chat window (issue 891).
Diffstat (limited to 'src/net/java/sip')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java43
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java81
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java52
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java15
4 files changed, 161 insertions, 30 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java b/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java
index baa0eab..cd1c0d6 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/ChooseCallAccountPopupMenu.java
@@ -18,6 +18,7 @@ import net.java.sip.communicator.impl.gui.main.chat.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.skin.*;
/**
@@ -33,6 +34,11 @@ public class ChooseCallAccountPopupMenu
implements Skinnable
{
/**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
* The invoker component.
*/
private final JComponent invoker;
@@ -99,9 +105,9 @@ public class ChooseCallAccountPopupMenu
* @param opSetClass the operation class, which indicates what action would
* be performed if an item is selected from the list
*/
- public ChooseCallAccountPopupMenu( JComponent invoker,
- List<?> telephonyObjects,
- Class<? extends OperationSet> opSetClass)
+ public ChooseCallAccountPopupMenu(JComponent invoker,
+ List<?> telephonyObjects,
+ Class<? extends OperationSet> opSetClass)
{
this.invoker = invoker;
this.init();
@@ -111,7 +117,8 @@ public class ChooseCallAccountPopupMenu
if (o instanceof UIContactDetail)
this.addTelephonyContactItem((UIContactDetail) o, opSetClass);
else if (o instanceof ChatTransport)
- this.addTelephonyChatTransportItem((ChatTransport) o, opSetClass);
+ this.addTelephonyChatTransportItem((ChatTransport) o,
+ opSetClass);
}
}
@@ -302,6 +309,11 @@ public class ChooseCallAccountPopupMenu
extends JMenuItem
implements Skinnable
{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
private final ProtocolProviderService protocolProvider;
public ProviderMenuItem(ProtocolProviderService protocolProvider)
@@ -338,6 +350,11 @@ public class ChooseCallAccountPopupMenu
extends JMenuItem
implements Skinnable
{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
private final UIContactDetail contact;
public ContactMenuItem(UIContactDetail contact)
@@ -381,6 +398,11 @@ public class ChooseCallAccountPopupMenu
extends JMenuItem
implements Skinnable
{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
private final ChatTransport chatTransport;
public ChatTransportMenuItem(ChatTransport chatTransport)
@@ -396,11 +418,16 @@ public class ChooseCallAccountPopupMenu
*/
public void loadSkin()
{
- BufferedImage contactIcon
- = Constants.getStatusIcon(chatTransport.getStatus());
+ PresenceStatus status = chatTransport.getStatus();
+ Image statusIcon = null;
- if (contactIcon != null)
- this.setIcon(new ImageIcon(contactIcon));
+ statusIcon = ImageLoader.badgeImageWithProtocolIndex(
+ ImageUtils.getBytesInImage(
+ status.getStatusIcon()),
+ chatTransport.getProtocolProvider());
+
+ if (statusIcon != null)
+ this.setIcon(new ImageIcon(statusIcon));
}
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java
index c190c1e..95ab150 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java
@@ -271,17 +271,66 @@ public class MainToolBar
chatPanel.findInviteChatTransport() != null);
sendFileButton.setEnabled(
chatPanel.findFileTransferChatTransport() != null);
- callButton.setEnabled(
- !chatPanel.chatSession.getTransportsForOperationSet(
+ callButton.setEnabled(!getOperationSetForCapabilities(
+ chatPanel.chatSession.getTransportsForOperationSet(
+ OperationSetBasicTelephony.class),
OperationSetBasicTelephony.class).isEmpty());
- desktopSharingButton.setEnabled(
- !chatPanel.chatSession.getTransportsForOperationSet(
+ desktopSharingButton.setEnabled(!getOperationSetForCapabilities(
+ chatPanel.chatSession.getTransportsForOperationSet(
+ OperationSetDesktopSharingServer.class),
OperationSetDesktopSharingServer.class).isEmpty());
changeHistoryButtonsState(chatPanel);
}
}
+
+ /**
+ * Returns list of <tt>ChatTransport</tt> (i.e. contact) that supports the
+ * specified <tt>OperationSet</tt>.
+ *
+ * @param transports list of <tt>ChatTransport</tt>
+ * @param opSetClass <tt>OperationSet</tt> to find
+ * @return list of <tt>ChatTransport</tt> (i.e. contact) that supports the
+ * specified <tt>OperationSet</tt>.
+ */
+ private List<ChatTransport> getOperationSetForCapabilities(
+ List<ChatTransport> transports,
+ Class<? extends OperationSet> opSetClass)
+ {
+ List<ChatTransport> list = new ArrayList<ChatTransport>();
+
+ for(ChatTransport transport : transports)
+ {
+ OperationSetContactCapabilities capOpSet =
+ transport.getProtocolProvider().
+ getOperationSet(OperationSetContactCapabilities.class);
+
+ OperationSetPersistentPresence presOpSet =
+ transport.getProtocolProvider().
+ getOperationSet(OperationSetPersistentPresence.class);
+
+ if (capOpSet == null)
+ {
+ list.add(transport);
+ }
+ else if (presOpSet != null)
+ {
+ Contact contact = presOpSet.findContactByID(
+ transport.getName());
+
+ if(capOpSet.getOperationSet(contact, opSetClass) != null)
+ {
+ // It supports OpSet for at least one of its
+ // ChatTransports
+ list.add(transport);
+ }
+ }
+ }
+
+ return list;
+ }
+
/**
* Implements
* ChatSessionChangeListener#currentChatTransportChanged(ChatSession).
@@ -392,21 +441,25 @@ public class MainToolBar
.getTransportsForOperationSet(
OperationSetBasicTelephony.class);
+ List<ChatTransport> contactOpSetSupported =
+ getOperationSetForCapabilities(telTransports,
+ OperationSetBasicTelephony.class);
+
if (telTransports != null)
{
- if (telTransports.size() == 1)
+ if (contactOpSetSupported.size() == 1)
{
- ChatTransport transport = telTransports.get(0);
+ ChatTransport transport = contactOpSetSupported.get(0);
CallManager.createCall(
transport.getProtocolProvider(),
transport.getName());
}
- else if (telTransports.size() > 1)
+ else if (contactOpSetSupported.size() > 1)
{
ChooseCallAccountPopupMenu chooseAccountDialog
= new ChooseCallAccountPopupMenu(
callButton,
- telTransports);
+ contactOpSetSupported);
Point location = new Point(callButton.getX(),
callButton.getY() + callButton.getHeight());
@@ -429,21 +482,25 @@ public class MainToolBar
.getTransportsForOperationSet(
OperationSetDesktopSharingServer.class);
+ List<ChatTransport> contactOpSetSupported =
+ getOperationSetForCapabilities(desktopTransports,
+ OperationSetDesktopSharingServer.class);
+
if (desktopTransports != null)
{
- if (desktopTransports.size() == 1)
+ if (contactOpSetSupported.size() == 1)
{
- ChatTransport transport = desktopTransports.get(0);
+ ChatTransport transport = contactOpSetSupported.get(0);
CallManager.createDesktopSharing(
transport.getProtocolProvider(),
transport.getName());
}
- else if (desktopTransports.size() > 1)
+ else if (contactOpSetSupported.size() > 1)
{
ChooseCallAccountPopupMenu chooseAccountDialog
= new ChooseCallAccountPopupMenu(
desktopSharingButton,
- desktopTransports,
+ contactOpSetSupported,
OperationSetDesktopSharingServer.class);
Point location = new Point(callButton.getX(),
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java
index 9654481..b0cf7c4 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/MetaContactRightButtonMenu.java
@@ -101,7 +101,7 @@ public class MetaContactRightButtonMenu
* The menu responsible for adding a contact.
*/
private final JMenuItem addContactItem = new JMenuItem();
-
+
/**
* The menu item responsible for calling a contact.
*/
@@ -339,7 +339,9 @@ public class MetaContactRightButtonMenu
if (metaContact.getContactCount() > 1)
{
if (protocolProvider.getOperationSet(
- OperationSetBasicTelephony.class) != null)
+ OperationSetBasicTelephony.class) != null &&
+ hasContactCapabilities(contact,
+ OperationSetBasicTelephony.class))
{
callContactMenu.add(
createMenuItem( contactDisplayName,
@@ -349,7 +351,9 @@ public class MetaContactRightButtonMenu
}
if (protocolProvider.getOperationSet(
- OperationSetVideoTelephony.class) != null)
+ OperationSetVideoTelephony.class) != null &&
+ hasContactCapabilities(contact,
+ OperationSetVideoTelephony.class))
{
videoCallMenu.add(
createMenuItem( contactDisplayName,
@@ -359,7 +363,9 @@ public class MetaContactRightButtonMenu
}
if (protocolProvider.getOperationSet(
- OperationSetDesktopSharingServer.class) != null)
+ OperationSetDesktopSharingServer.class) != null &&
+ hasContactCapabilities(contact,
+ OperationSetDesktopSharingServer.class))
{
desktopSharingMenu.add(
createMenuItem( contactDisplayName,
@@ -655,7 +661,7 @@ public class MetaContactRightButtonMenu
else if (itemName.equals("sendFile"))
{
SipCommFileChooser scfc = GenericFileDialog.create(
- null, "Send file...",
+ null, "Send file...",
SipCommFileChooser.LOAD_FILE_OPERATION,
ConfigurationManager.getSendFileLastDir());
File selectedFile = scfc.getFileFromDialog();
@@ -825,7 +831,7 @@ public class MetaContactRightButtonMenu
/**
* Indicates that a group has been selected during a move operation. Moves
* the selected contact to the selected group.
- * @param evt the <tt>ContactListEvent</tt> has
+ * @param evt the <tt>ContactListEvent</tt> has
*/
public void groupClicked(ContactListEvent evt)
{
@@ -919,7 +925,7 @@ public class MetaContactRightButtonMenu
/**
* Adds the according plug-in component to this container.
- * @param event
+ * @param event received event
*/
public void pluginComponentAdded(PluginComponentEvent event)
{
@@ -1020,4 +1026,36 @@ public class MetaContactRightButtonMenu
callContactMenu.setIcon(new ImageIcon(
ImageLoader.getImage(ImageLoader.CALL_16x16_ICON)));
}
+
+ /**
+ * Returns <tt>true</tt> if <tt>Contact</tt> supports the specified
+ * <tt>OperationSet</tt>, <tt>false</tt> otherwise.
+ *
+ * @param contact contact to check
+ * @param opSet <tt>OperationSet</tt> to search for
+ * @return Returns <tt>true</tt> if <tt>Contact</tt> supports the specified
+ * <tt>OperationSet</tt>, <tt>false</tt> otherwise.
+ */
+ private boolean hasContactCapabilities(
+ Contact contact, Class<? extends OperationSet> opSet)
+ {
+ OperationSetContactCapabilities capOpSet =
+ contact.getProtocolProvider().
+ getOperationSet(OperationSetContactCapabilities.class);
+
+ if (capOpSet == null)
+ {
+ // assume contact has OpSet capabilities
+ return true;
+ }
+ else
+ {
+ if(capOpSet.getOperationSet(contact, opSet) != null)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java
index 051a017..ff0434c 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetContactCapabilitiesJabberImpl.java
@@ -50,7 +50,7 @@ public class OperationSetContactCapabilitiesJabberImpl
* The <tt>Map</tt> which associates specific <tt>OperationSet</tt> classes
* with the features to be supported by a <tt>Contact</tt> in order to
* consider the <tt>Contact</tt> to possess the respective
- * <tt>OperationSet</tt> capability.
+ * <tt>OperationSet</tt> capability.
*/
private static final Map<Class<? extends OperationSet>, String[]>
OPERATION_SETS_TO_FEATURES
@@ -77,6 +77,15 @@ public class OperationSetContactCapabilitiesJabberImpl
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_VIDEO
});
+
+ OPERATION_SETS_TO_FEATURES.put(
+ OperationSetDesktopSharingServer.class,
+ new String[]
+ {
+ ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE,
+ ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP,
+ ProtocolProviderServiceJabberImpl.URN_XMPP_JINGLE_RTP_VIDEO
+ });
}
/**
@@ -116,7 +125,7 @@ public class OperationSetContactCapabilitiesJabberImpl
*
* @param <U> the type extending <tt>OperationSet</tt> for which the
* specified <tt>contact</tt> is to be checked whether it possesses it as a
- * capability
+ * capability
* @param contact the <tt>Contact</tt> for which the <tt>opsetClass</tt>
* capability is to be queried
* @param opsetClass the <tt>OperationSet</tt> <tt>Class</tt> for which the
@@ -255,7 +264,7 @@ public class OperationSetContactCapabilitiesJabberImpl
*
* @param <U> the type extending <tt>OperationSet</tt> for which the
* specified <tt>contact</tt> is to be checked whether it possesses it as a
- * capability
+ * capability
* @param jid the Jabber id for which we're checking supported operation
* sets
* @param opsetClass the <tt>OperationSet</tt> <tt>Class</tt> for which the