diff --git a/resources/images/images.properties b/resources/images/images.properties index 37133a52d..8c2cb24f7 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 000000000..2784bda3c Binary files /dev/null and b/resources/images/plugin/contactinfo/callUserInfo.png differ diff --git a/resources/images/plugin/contactinfo/chatWindowUserInfo.png b/resources/images/plugin/contactinfo/chatWindowUserInfo.png new file mode 100644 index 000000000..1f221a3af Binary files /dev/null and b/resources/images/plugin/contactinfo/chatWindowUserInfo.png differ diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java index 0aeb839d1..2412bf27d 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 @@ 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 void start(BundleContext bc) throws Exception cinfoMenuItem, containerFilter); - if (logger.isInfoEnabled()) + if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false)) + { + containerFilter = new Hashtable(); + 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(); + 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 static BrowserLauncherService getBrowserLauncher() 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 MetaContactListService obtained from the bundle + * context. + * @return the MetaContactListService 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 5e3960e91..1d33857a5 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 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 ContactInfoMenuItem. */ public ContactInfoMenuItem() { - super(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); + this(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU); + } + + /** + * Creates a ContactInfoMenuItem. + */ + public ContactInfoMenuItem(Container container) + { + super(container); } /** @@ -45,11 +61,32 @@ public void setCurrentContact(MetaContact metaContact) 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 String getName() 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 b1ec3cab7..9e5a9e249 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,