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.

cusax-fix
Yana Stamcheva 18 years ago
parent 6b028de265
commit ed37976640

@ -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 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
<!-- BUNDLE-PLUGIN-WHITEBOARD -->
<target name="bundle-plugin-whiteboard">
<!-- Creates a bundle for the Whiteboard plugin.-->
@ -1755,4 +1754,14 @@ javax.swing.event, javax.swing.border"/>
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>

@ -104,6 +104,7 @@ felix.auto.start.60= \
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

@ -75,9 +75,9 @@ public void start(BundleContext bundleContext) throws Exception {
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();

@ -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 @@ public class UIServiceImpl
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 @@ public class UIServiceImpl
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 @@ public void loadApplicationGui()
this.loginManager = new LoginManager(mainFrame);
this.contactListPanel = mainFrame.getContactListPanel();
this.popupDialog = new PopupDialogImpl();
this.wizardContainer = new AccountRegWizardContainerImpl(mainFrame);
@ -728,6 +727,10 @@ public ConfigurationWindow getConfigurationWindow()
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)

@ -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 @@ public class MainFrame
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 @@ public void addProtocolProvider(ProtocolProviderService protocolProvider)
{
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 @@ public void actionPerformed(ActionEvent e)
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]);
}
}

@ -642,7 +642,8 @@ else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0)
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());

@ -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 ContactList getContactList()
*/
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 groupSelected(ContactListEvent evt)
*/
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 @@ else if(eventType == MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED)
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(),

@ -81,8 +81,9 @@ public LoginManager(MainFrame mainFrame)
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,

@ -23,6 +23,7 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.browserlauncher,
net.java.sip.communicator.service.notification,
net.java.sip.communicator.service.systray,
net.java.sip.communicator.service.contacteventhandler,
javax.swing,
javax.swing.event,
javax.swing.table,

@ -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);
}

@ -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
Loading…
Cancel
Save