aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2013-06-18 17:20:26 +0300
committerDamian Minkov <damencho@jitsi.org>2013-06-18 17:20:26 +0300
commitd9ea78e35d82e6fc11a861f67dfa0eb1c5909feb (patch)
tree37dd2737e623899c673ad6a40cc1d71503163308
parent11997123d47c939b37561fa7ad57be407c31d7ab (diff)
downloadjitsi-d9ea78e35d82e6fc11a861f67dfa0eb1c5909feb.zip
jitsi-d9ea78e35d82e6fc11a861f67dfa0eb1c5909feb.tar.gz
jitsi-d9ea78e35d82e6fc11a861f67dfa0eb1c5909feb.tar.bz2
Updates callinfo plugin to be able to add its button to more locations.
-rw-r--r--resources/images/images.properties2
-rw-r--r--resources/images/plugin/contactinfo/callUserInfo.pngbin0 -> 1831 bytes
-rw-r--r--resources/images/plugin/contactinfo/chatWindowUserInfo.pngbin0 -> 1351 bytes
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java105
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java96
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf1
6 files changed, 195 insertions, 9 deletions
diff --git a/resources/images/images.properties b/resources/images/images.properties
index 37133a5..8c2cb24 100644
--- a/resources/images/images.properties
+++ b/resources/images/images.properties
@@ -484,6 +484,8 @@ plugin.whiteboard.TEXT2_ICON=resources/images/plugin/whiteboard/text2.png
# contactinfo plugin icons
plugin.contactinfo.CONTACT_INFO_ICON=resources/images/plugin/contactinfo/userInfo16x16.png
+plugin.contactinfo.CONTACT_INFO_TOOLBAR=resources/images/plugin/contactinfo/chatWindowUserInfo.png
+plugin.contactinfo.CONTACT_INFO_CALL_WINDOW=resources/images/plugin/contactinfo/callUserInfo.png
# keybinding
plugin.keybinding.PLUGIN_ICON=resources/images/plugin/keybindingchooser/pluginIcon.png
diff --git a/resources/images/plugin/contactinfo/callUserInfo.png b/resources/images/plugin/contactinfo/callUserInfo.png
new file mode 100644
index 0000000..2784bda
--- /dev/null
+++ b/resources/images/plugin/contactinfo/callUserInfo.png
Binary files differ
diff --git a/resources/images/plugin/contactinfo/chatWindowUserInfo.png b/resources/images/plugin/contactinfo/chatWindowUserInfo.png
new file mode 100644
index 0000000..1f221a3
--- /dev/null
+++ b/resources/images/plugin/contactinfo/chatWindowUserInfo.png
Binary files differ
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java
index 0aeb839..2412bf2 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java
@@ -3,9 +3,11 @@ package net.java.sip.communicator.plugin.contactinfo;
import java.util.*;
import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;
+import org.jitsi.service.configuration.*;
import org.osgi.framework.*;
/**
@@ -18,8 +20,32 @@ public class ContactInfoActivator implements BundleActivator
{
private Logger logger = Logger.getLogger(ContactInfoActivator.class);
+ /**
+ * Indicates if the contact info button is enabled in the chat window.
+ */
+ private static final String ENABLED_IN_CHAT_WINDOW_PROP
+ = "net.java.sip.communicator.plugin.contactinfo." +
+ "ENABLED_IN_CHAT_WINDOW_PROP";
+
+ /**
+ * Indicates if the contact info button is enabled in the call window.
+ */
+ private static final String ENABLED_IN_CALL_WINDOW_PROP
+ = "net.java.sip.communicator.plugin.contactinfo." +
+ "ENABLED_IN_CALL_WINDOW_PROP";
+
private static BrowserLauncherService browserLauncherService;
+ /**
+ * The image loader service implementation.
+ */
+ private static ImageLoaderService imageLoaderService = null;
+
+ /**
+ * The contact list service implementation.
+ */
+ private static MetaContactListService metaCListService;
+
static BundleContext bundleContext;
/**
@@ -41,7 +67,33 @@ public class ContactInfoActivator implements BundleActivator
cinfoMenuItem,
containerFilter);
- if (logger.isInfoEnabled())
+ if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false))
+ {
+ containerFilter = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_CHAT_TOOL_BAR.getID());
+
+ bundleContext.registerService(
+ PluginComponent.class.getName(),
+ new ContactInfoMenuItem(Container.CONTAINER_CHAT_TOOL_BAR),
+ containerFilter);
+ }
+
+ if(getConfigService().getBoolean(ENABLED_IN_CALL_WINDOW_PROP, false))
+ {
+ containerFilter = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_CALL_DIALOG.getID());
+
+ bundleContext.registerService(
+ PluginComponent.class.getName(),
+ new ContactInfoMenuItem(Container.CONTAINER_CALL_DIALOG),
+ containerFilter);
+ }
+
+ if (logger.isInfoEnabled())
logger.info("CONTACT INFO... [REGISTERED]");
}
@@ -68,4 +120,53 @@ public class ContactInfoActivator implements BundleActivator
return browserLauncherService;
}
-}
+
+ /**
+ * Returns the imageLoaderService instance, if missing query osgi for it.
+ * @return the imageLoaderService.
+ */
+ public static ImageLoaderService getImageLoaderService()
+ {
+ if(imageLoaderService == null)
+ {
+ imageLoaderService =
+ ServiceUtils.getService(
+ bundleContext,
+ ImageLoaderService.class);
+ }
+
+ return imageLoaderService;
+ }
+
+ /**
+ * Returns the <tt>MetaContactListService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>MetaContactListService</tt> obtained from the bundle
+ * context
+ */
+ public static MetaContactListService getContactListService()
+ {
+ if (metaCListService == null)
+ {
+ metaCListService
+ = ServiceUtils.getService(
+ bundleContext,
+ MetaContactListService.class);
+ }
+ return metaCListService;
+ }
+
+ /**
+ * Returns a reference to a ConfigurationService implementation currently
+ * registered in the bundle context or null if no such implementation was
+ * found.
+ *
+ * @return a currently valid implementation of the ConfigurationService.
+ */
+ public static ConfigurationService getConfigService()
+ {
+ return ServiceUtils.getService(bundleContext,
+ ConfigurationService.class);
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java
index 5e3960e..1d33857 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java
@@ -11,9 +11,12 @@ import java.awt.event.*;
import javax.swing.*;
+import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.Container;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.resources.*;
/**
*
@@ -23,16 +26,29 @@ public class ContactInfoMenuItem
extends AbstractPluginComponent
implements ActionListener
{
- private JMenuItem menuItem = null;
+ private AbstractButton menuItem = null;
private MetaContact metaContact;
/**
+ * The button index, for now placed on last position.
+ */
+ private final static int CONTACT_INFO_BUTTON_IX = 50;
+
+ /**
* Creates a <tt>ContactInfoMenuItem</tt>.
*/
public ContactInfoMenuItem()
{
- super(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);
+ this(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);
+ }
+
+ /**
+ * Creates a <tt>ContactInfoMenuItem</tt>.
+ */
+ public ContactInfoMenuItem(Container container)
+ {
+ super(container);
}
/**
@@ -45,11 +61,32 @@ public class ContactInfoMenuItem
this.metaContact = metaContact;
}
+ /*
+ * Implements PluginComponent#setCurrentContact(Contact).
+ * @param contact the currently selected contact
+ */
+ @Override
+ public void setCurrentContact(Contact contact)
+ {
+ if(metaContact == null)
+ {
+ // search for the metacontact
+ MetaContactListService mcs =
+ ContactInfoActivator.getContactListService();
+
+ metaContact =
+ mcs.findMetaContactByContact(contact);
+ }
+ }
+
/**
* Initializes and shows the contact details dialog.
*/
public void actionPerformed(ActionEvent e)
{
+ if(metaContact == null)
+ return;
+
ContactInfoDialog cinfoDialog = new ContactInfoDialog(metaContact);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
@@ -69,14 +106,59 @@ public class ContactInfoMenuItem
return getMenuItem().getText();
}
- private JMenuItem getMenuItem()
+ private AbstractButton getMenuItem()
{
if(menuItem == null)
{
- menuItem =
- new JMenuItem(Resources.getString("service.gui.CONTACT_INFO"),
- new ImageIcon(Resources.getImage(
- "plugin.contactinfo.CONTACT_INFO_ICON")));
+ if(getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR))
+ {
+ menuItem =
+ new SIPCommButton(null,
+ (Image)ContactInfoActivator.getImageLoaderService()
+ .getImage(new ImageID(
+ "plugin.contactinfo.CONTACT_INFO_TOOLBAR")))
+ {
+ /**
+ * Returns the button index.
+ * @return the button index.
+ */
+ public int getIndex()
+ {
+ return CONTACT_INFO_BUTTON_IX;
+ }
+ };
+
+ menuItem.setPreferredSize(new Dimension(25, 25));
+ menuItem.setToolTipText(
+ Resources.getString("service.gui.CONTACT_INFO"));
+ }
+ else if(getContainer().equals(Container.CONTAINER_CALL_DIALOG))
+ {
+ menuItem =
+ new SIPCommButton(null,
+ (Image)ContactInfoActivator.getImageLoaderService()
+ .getImage(new ImageID(
+ "plugin.contactinfo.CONTACT_INFO_CALL_WINDOW")))
+ {
+ /**
+ * Returns the button index.
+ * @return the button index.
+ */
+ public int getIndex()
+ {
+ return CONTACT_INFO_BUTTON_IX;
+ }
+ };
+ menuItem.setPreferredSize(new Dimension(44, 38));
+ menuItem.setToolTipText(
+ Resources.getString("service.gui.CONTACT_INFO"));
+ }
+ else
+ menuItem =
+ new JMenuItem(
+ Resources.getString("service.gui.CONTACT_INFO"),
+ new ImageIcon(Resources.getImage(
+ "plugin.contactinfo.CONTACT_INFO_ICON")));
menuItem.addActionListener(this);
}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf b/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf
index b1ec3ca..9e5a9e2 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/contactinfo/contactinfo.manifest.mf
@@ -12,6 +12,7 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.gui.event,
net.java.sip.communicator.service.protocol,
org.jitsi.service.resources, net.java.sip.communicator.service.resources,
+ org.jitsi.service.configuration,
net.java.sip.communicator.util,
net.java.sip.communicator.plugin.desktoputil,
javax.swing,