svn commit: r3316 - trunk: . lib src/net/java/sip/communicator/impl/gui src/net/java/sip/communicator/impl/gui/main src/net/java/sip/communicator/i...

yanas at dev.java.net yanas at dev.java.net
Wed Dec 12 19:07:32 CET 2007


Author: yanas
Date: 2007-12-12 18:07:31+0000
New Revision: 3316

Added:
   trunk/src/net/java/sip/communicator/service/contacteventhandler/
   trunk/src/net/java/sip/communicator/service/contacteventhandler/ContactEventHandler.java
   trunk/src/net/java/sip/communicator/service/contacteventhandler/contact.event.handler.manifest.mf
Modified:
   trunk/build.xml
   trunk/lib/felix.client.run.properties
   trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java
   trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
   trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
   trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java
   trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java
   trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java
   trunk/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf

Log:
ContactEventHandler service was added. It is meant to be used from other bundles in order to change the default behavior of events generated when clicking a contact. The GUI implementation takes now in consideration all registered ContactEventHandler-s when managing contact list events.

Modified: trunk/build.xml
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/build.xml?view=diff&rev=3316&p1=trunk/build.xml&p2=trunk/build.xml&r1=3315&r2=3316
==============================================================================
--- trunk/build.xml	(original)
+++ trunk/build.xml	2007-12-12 18:07:31+0000
@@ -877,7 +877,7 @@
         bundle-irc,bundle-plugin-ircaccregwizz,
         bundle-pluginmanager,bundle-notification,
         bundle-ssh,bundle-plugin-sshaccregwizz,
-    	bundle-plugin-exampleplugin"/>
+    	bundle-plugin-exampleplugin,bundle-contacteventhandler"/>
 
     <!--BUNDLE-HISTORY-->
     <target name="bundle-history">
@@ -1745,7 +1745,6 @@
         </jar>
     </target>
 
-
     <!-- BUNDLE-PLUGIN-WHITEBOARD -->
     <target name="bundle-plugin-whiteboard">
     <!-- Creates a bundle for the Whiteboard plugin.-->
@@ -1755,4 +1754,14 @@
                prefix="net/java/sip/communicator/plugin/whiteboard"/>
        </jar>
    </target>
+
+    <!-- BUNDLE-CONTACT-EVENT-HANDLER -->
+    <target name="bundle-contacteventhandler">
+    <!-- Creates a bundle for the ContactEventHandler service.-->
+        <jar compress="false" destfile="${bundles.dest}/contacteventhandler.jar"
+           manifest="src/net/java/sip/communicator/service/contacteventhandler/contact.event.handler.manifest.mf">
+           <zipfileset dir="${dest}/net/java/sip/communicator/service/contacteventhandler"
+               prefix="net/java/sip/communicator/service/contacteventhandler"/>
+        </jar>
+    </target>
 </project>

Modified: trunk/lib/felix.client.run.properties
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/lib/felix.client.run.properties?view=diff&rev=3316&p1=trunk/lib/felix.client.run.properties&p2=trunk/lib/felix.client.run.properties&r1=3315&r2=3316
==============================================================================
--- trunk/lib/felix.client.run.properties	(original)
+++ trunk/lib/felix.client.run.properties	2007-12-12 18:07:31+0000
@@ -104,6 +104,7 @@
  reference:file:sc-bundles/rssaccregwizz.jar \
  reference:file:sc-bundles/zeroconfaccregwizz.jar \
  reference:file:sc-bundles/ircaccregwizz.jar \
+ reference:file:sc-bundles/contacteventhandler.jar \
  reference:file:sc-bundles/shutdown.jar
 
 # Uncomment the following lines if you want to run the architect viewer

Modified: trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java&p2=trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java&r1=3315&r2=3316
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/GuiActivator.java	2007-12-12 18:07:31+0000
@@ -75,9 +75,9 @@
 
             logger.info("UI Service...[  STARTED ]");
 
-            bundleContext.registerService(UIService.class.getName(),
-                    this.uiService, null);
-            
+            bundleContext.registerService(  UIService.class.getName(),
+                                            this.uiService, null);
+
             logger.info("UI Service ...[REGISTERED]");
 
             this.uiService.loadApplicationGui();

Modified: trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java&p2=trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java&r1=3315&r2=3316
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java	2007-12-12 18:07:31+0000
@@ -18,7 +18,6 @@
 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.configforms.*;
-import net.java.sip.communicator.impl.gui.main.contactlist.*;
 import net.java.sip.communicator.impl.gui.main.contactlist.addcontact.*;
 import net.java.sip.communicator.impl.gui.main.login.*;
 import net.java.sip.communicator.impl.gui.utils.*;
@@ -43,11 +42,14 @@
 
     private AccountRegWizardContainerImpl wizardContainer;
 
-    private Map registeredPlugins = new Hashtable();
+    private Map<ContainerID, Vector<Object>> registeredPlugins
+        = new Hashtable<ContainerID, Vector<Object>>();
 
-    private Vector pluginComponentListeners = new Vector();
+    private Vector<PluginComponentListener>
+        pluginComponentListeners = new Vector<PluginComponentListener>();
 
-    private static final List supportedContainers = new ArrayList();
+    private static final List<ContainerID> supportedContainers
+        = new ArrayList<ContainerID>();
     static
     {
         supportedContainers.add(UIService.CONTAINER_MAIN_TOOL_BAR);
@@ -61,14 +63,13 @@
         supportedContainers.add(UIService.CONTAINER_CHAT_HELP_MENU);
     }
 
-    private static final Hashtable exportedWindows = new Hashtable();
+    private static final Hashtable<WindowID, ExportedWindow> exportedWindows
+        = new Hashtable<WindowID, ExportedWindow>();
 
     private MainFrame mainFrame;
 
     private LoginManager loginManager;
 
-    private ContactListPanel contactListPanel;
-
     private ConfigurationFrame configurationFrame;
 
     private boolean exitOnClose = true;
@@ -91,8 +92,6 @@
 
         this.loginManager = new LoginManager(mainFrame);
 
-        this.contactListPanel = mainFrame.getContactListPanel();
-
         this.popupDialog = new PopupDialogImpl();
 
         this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame);
@@ -728,6 +727,10 @@
         return this.configurationFrame;
     }
 
+    /**
+     * Returns an instance of <tt>AuthenticationWindow</tt> for the given
+     * protocol provider, realm and user credentials.
+     */
     public ExportedWindow getAuthenticationWindow(
         ProtocolProviderService protocolProvider,
         String realm, UserCredentials userCredentials)

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java&r1=3315&r2=3316
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/MainFrame.java	2007-12-12 18:07:31+0000
@@ -28,9 +28,10 @@
 import net.java.sip.communicator.impl.gui.main.menus.*;
 import net.java.sip.communicator.impl.gui.main.presence.*;
 import net.java.sip.communicator.impl.gui.utils.*;
-import net.java.sip.communicator.impl.gui.utils.Constants;
 import net.java.sip.communicator.service.configuration.*;
+import net.java.sip.communicator.service.contacteventhandler.*;
 import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.gui.*;
 import net.java.sip.communicator.service.protocol.*;
 import net.java.sip.communicator.service.protocol.event.*;
 import net.java.sip.communicator.util.*;
@@ -77,7 +78,11 @@
 
     private HistoryWindowManager historyWindowManager
         = new HistoryWindowManager();
-    
+
+    private Hashtable<ProtocolProviderService, ContactEventHandler>
+        providerContactHandlers
+            = new Hashtable<ProtocolProviderService, ContactEventHandler>();
+
     /**
      * Creates an instance of <tt>MainFrame</tt>.
      */
@@ -317,13 +322,21 @@
     {
         logger.trace("Add the following protocol provider to the gui: "
             + protocolProvider.getAccountID().getAccountAddress());
-        
+
         this.protocolProviders.put(protocolProvider,
                 new Integer(initiateProviderIndex(protocolProvider)));
 
         this.addProtocolSupportedOperationSets(protocolProvider);
 
         this.addAccount(protocolProvider);
+
+        ContactEventHandler contactHandler
+            = this.getContactHandlerForProvider(protocolProvider);
+
+        if (contactHandler == null)
+            contactHandler = new DefaultContactEventHandler(this);
+
+        this.addProviderContactHandler(protocolProvider, contactHandler);
     }
 
     /**
@@ -1108,4 +1121,61 @@
                 tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
         }
     };
+
+    /**
+     * 
+     * @param protocolProvider
+     * @param contactHandler
+     */
+    public void addProviderContactHandler(
+        ProtocolProviderService protocolProvider,
+        ContactEventHandler contactHandler)
+    {
+        providerContactHandlers.put(protocolProvider, contactHandler);
+    }
+
+    /**
+     * Returns the <tt>ContactEventHandler</tt> registered for this protocol
+     * provider.
+     * 
+     * @param protocolProvider the <tt>ProtocolProviderService</tt> for which
+     * we are searching a <tt>ContactEventHandler</tt>.
+     * @return the <tt>ContactEventHandler</tt> registered for this protocol
+     * provider
+     */
+    public ContactEventHandler getContactHandler(
+        ProtocolProviderService protocolProvider)
+    {
+        return providerContactHandlers.get(protocolProvider);
+    }
+
+    /**
+     * 
+     * @param protocolProvider
+     * @return
+     */
+    private ContactEventHandler getContactHandlerForProvider(
+        ProtocolProviderService protocolProvider)
+    {
+        ServiceReference[] serRefs = null;
+
+        String osgiFilter = "("
+            + ProtocolProviderFactory.PROTOCOL
+            + "=" + protocolProvider.getProtocolName()+")";
+
+        try
+        {
+            serRefs = GuiActivator.bundleContext.getServiceReferences(
+                ContactEventHandler.class.getName(), osgiFilter);
+        }
+        catch (InvalidSyntaxException ex){
+            logger.error("GuiActivator : " + ex);
+        }
+
+        if(serRefs == null)
+            return null;
+
+        return (ContactEventHandler) GuiActivator.bundleContext
+            .getService(serRefs[0]);
+    }
 }

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java&r1=3315&r2=3316
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactList.java	2007-12-12 18:07:31+0000
@@ -642,7 +642,8 @@
                     contactRightButtonMenu.setVisible(true);
                 }
                 // Left click on the contact label opens Chat window
-                else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
+                else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0
+                    && e.getClickCount() > 1)
                 {
                     fireContactListEvent(contact,
                         ContactListEvent.CONTACT_SELECTED, e.getClickCount());

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java&r1=3315&r2=3316
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPanel.java	2007-12-12 18:07:31+0000
@@ -18,6 +18,7 @@
 import net.java.sip.communicator.impl.gui.main.*;
 import net.java.sip.communicator.impl.gui.main.chat.*;
 import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.service.contacteventhandler.*;
 import net.java.sip.communicator.service.contactlist.*;
 import net.java.sip.communicator.service.protocol.*;
 import net.java.sip.communicator.service.protocol.event.*;
@@ -127,13 +128,53 @@
      */
     public void contactClicked(ContactListEvent evt)
     {
-        if (evt.getClickCount() > 1)
+        MetaContact metaContact = evt.getSourceContact();
+
+        // Searching for the right proto contact to use as default for the
+        // chat conversation.
+        Contact defaultContact = metaContact.getDefaultContact();
+
+        ProtocolProviderService defaultProvider
+            = defaultContact.getProtocolProvider();
+
+        OperationSetBasicInstantMessaging
+            defaultIM = (OperationSetBasicInstantMessaging)
+                defaultProvider.getOperationSet(
+                        OperationSetBasicInstantMessaging.class);
+
+        ProtocolProviderService protoContactProvider;
+        OperationSetBasicInstantMessaging protoContactIM;
+
+        if (defaultContact.getPresenceStatus().getStatus() < 1
+                && (!defaultIM.isOfflineMessagingSupported()
+                        || !defaultProvider.isRegistered()))
         {
-            SwingUtilities
-                .invokeLater(new RunMessageWindow(evt.getSourceContact()));
+            Iterator<Contact> protoContacts = metaContact.getContacts();
+
+            while(protoContacts.hasNext())
+            {
+                Contact contact = protoContacts.next();
+
+                protoContactProvider = contact.getProtocolProvider();
+
+                protoContactIM = (OperationSetBasicInstantMessaging)
+                    protoContactProvider.getOperationSet(
+                        OperationSetBasicInstantMessaging.class);
+
+                if(protoContactIM.isOfflineMessagingSupported()
+                        && protoContactProvider.isRegistered())
+                {
+                    defaultContact = contact;
+                }
+            }
         }
+
+        ContactEventHandler contactHandler = mainFrame
+            .getContactHandler(defaultContact.getProtocolProvider());
+
+        contactHandler.contactClicked(defaultContact, evt.getClickCount());
     }
-    
+
     /**
      * Implements the ContactListListener.groupSelected method.
      */
@@ -145,8 +186,12 @@
      */
     public void protocolContactClicked(ContactListEvent evt)
     {
-        SwingUtilities.invokeLater(new RunMessageWindow(evt.getSourceContact(),
-                evt.getSourceProtoContact()));
+        Contact protoContact = evt.getSourceProtoContact();
+
+        ContactEventHandler contactHandler = mainFrame
+            .getContactHandler(protoContact.getProtocolProvider());
+
+        contactHandler.contactClicked(protoContact, evt.getClickCount());
     }
 
     /**
@@ -296,29 +341,29 @@
     public void messageDelivered(MessageDeliveredEvent evt)
     {
         Contact contact = evt.getDestinationContact();
-        
+
         MetaContact metaContact = mainFrame.getContactList()
             .findMetaContactByContact(contact);
                 
         logger.trace("MESSAGE DELIVERED to contact: "
             + evt.getDestinationContact().getAddress());
-        
-        Message msg = evt.getSourceMessage();        
-        
+
+        Message msg = evt.getSourceMessage();
+
         ChatWindowManager chatWindowManager = mainFrame.getChatWindowManager();
         MetaContactChatPanel chatPanel = null;
-        
+
         if(chatWindowManager.isChatOpenedForContact(metaContact))
             chatPanel = chatWindowManager.getContactChat(metaContact);
-            
+
         if (chatPanel != null)
-        {   
+        {
             ProtocolProviderService protocolProvider = evt
                     .getDestinationContact().getProtocolProvider();
 
             logger.trace("MESSAGE DELIVERED: process message to chat for contact: "
                     + evt.getDestinationContact().getAddress());
-            
+
             chatPanel.processMessage(this.mainFrame
                     .getAccount(protocolProvider), evt.getTimestamp(),
                     Constants.OUTGOING_MESSAGE, msg.getContent(),

Modified: trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java&p2=trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java&r1=3315&r2=3316
==============================================================================
--- trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java	(original)
+++ trunk/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java	2007-12-12 18:07:31+0000
@@ -81,8 +81,9 @@
     public ProtocolProviderService installAccount(
         ProtocolProviderFactory providerFactory, String user, String passwd)
     {
+        Hashtable<String, String> accountProperties
+            = new Hashtable<String, String>();
 
-        Hashtable accountProperties = new Hashtable();
         accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
 
         AccountID accountID = providerFactory.installAccount(user,

Modified: trunk/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf?view=diff&rev=3316&p1=trunk/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf&p2=trunk/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf&r1=3315&r2=3316
==============================================================================
Binary files. No diff available.

Added: trunk/src/net/java/sip/communicator/service/contacteventhandler/ContactEventHandler.java
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/service/contacteventhandler/ContactEventHandler.java?view=auto&rev=3316
==============================================================================
--- (empty file)
+++ trunk/src/net/java/sip/communicator/service/contacteventhandler/ContactEventHandler.java	2007-12-12 18:07:31+0000
@@ -0,0 +1,28 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.service.contacteventhandler;
+
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * The <tt>ContactEventHandler</tt> is meant to be used from other bundles in
+ * order to change the default behavior of events generated when clicking
+ * a contact. The GUI implementation should take in consideration all registered
+ * <tt>ContactEventHandler</tt>s when managing contact list events.
+ * 
+ * @author Yana Stamcheva
+ */
+public interface ContactEventHandler
+{
+    /**
+     * Indicates that a contact in the contact list was clicked.
+     * 
+     * @param contact the selected <tt>Contact</tt>
+     * @param clickCount the count of clicks
+     */
+    public void contactClicked(Contact contact, int clickCount);
+}

Added: trunk/src/net/java/sip/communicator/service/contacteventhandler/contact.event.handler.manifest.mf
Url: https://sip-communicator.dev.java.net/source/browse/sip-communicator/trunk/src/net/java/sip/communicator/service/contacteventhandler/contact.event.handler.manifest.mf?view=auto&rev=3316
==============================================================================
--- (empty file)
+++ trunk/src/net/java/sip/communicator/service/contacteventhandler/contact.event.handler.manifest.mf	2007-12-12 18:07:31+0000
@@ -0,0 +1,7 @@
+Bundle-Name: Contact Event Handler service
+Bundle-Description: Contact Event Handler service
+Bundle-Vendor: sip-communicator.org
+Bundle-Version: 0.0.1
+Import-Package: org.osgi.framework,
+ net.java.sip.communicator.service.protocol
+Export-Package: net.java.sip.communicator.service.contacteventhandler

---------------------------------------------------------------------
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