Adds a protocol aware contact source interface and moves demultiplexing contact source functionality to a separate plug-in. Conference and transfer invite dialogs now show a separate contact for each contact detail (i.e. each telephone number, email address) and search results are taking into account the selected account.

cusax-fix
Yana Stamcheva 13 years ago
parent a87481ac4b
commit a3ef89863f

@ -948,7 +948,8 @@
bundle-provisioning,bundle-addrbook,bundle-plugin-ldap,
bundle-plugin-contactsourceconfig,bundle-plugin-certconfig,
bundle-globalshortcut,bundle-plugin-msofficecomm,bundle-libjitsi,
bundle-customcontactactions, bundle-phonenumbercontactsource"/>
bundle-customcontactactions, bundle-phonenumbercontactsource,
bundle-demuxcontactsource"/>
<!--BUNDLE-SC-LAUNCHER-->
<target name="bundle-sc-launcher">
@ -2766,4 +2767,14 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/plugin/phonenumbercontactsource"/>
</jar>
</target>
<!-- BUNDLE-PHONE-NUMBER-CONTACT-SOURCE -->
<target name="bundle-demuxcontactsource">
<!-- Creates a bundle containing the contact source interfaces.-->
<jar compress="false" destfile="${bundles.dest}/demuxcontactsource.jar"
manifest="${src}/net/java/sip/communicator/plugin/demuxcontactsource/demuxcontactsource.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/demuxcontactsource"
prefix="net/java/sip/communicator/plugin/demuxcontactsource"/>
</jar>
</target>
</project>

@ -174,7 +174,8 @@ felix.auto.start.67= \
reference:file:sc-bundles/plugin-ldap.jar \
reference:file:sc-bundles/plugin-contactsourceconfig.jar \
reference:file:sc-bundles/plugin-certconfig.jar \
reference:file:sc-bundles/phonenumbercontactsource.jar
reference:file:sc-bundles/phonenumbercontactsource.jar \
reference:file:sc-bundles/demuxcontactsource.jar
# Level 68 is for profiler4j. Either don't use it or change the build.xml file
# accordingly.

@ -95,6 +95,8 @@ public class GuiActivator implements BundleActivator
private static SecurityAuthority securityAuthority;
private static DemuxContactSourceService demuxContactSourceService;
private static final Map<Object, ProtocolProviderFactory>
providerFactoriesMap = new Hashtable<Object, ProtocolProviderFactory>();
@ -685,6 +687,25 @@ public static MediaService getMediaService()
return mediaService;
}
/**
* Returns the <tt>DemuxContactSourceService</tt> obtained from the bundle
* context.
*
* @return the <tt>DemuxContactSourceService</tt> obtained from the bundle
* context
*/
public static DemuxContactSourceService getDemuxContactSourceService()
{
if (demuxContactSourceService == null)
{
demuxContactSourceService
= ServiceUtils.getService(
bundleContext,
DemuxContactSourceService.class);
}
return demuxContactSourceService;
}
/**
* Returns a list of all registered contact sources.
* @return a list of all registered contact sources

@ -77,14 +77,18 @@ public void actionPerformed(ActionEvent e)
}
/**
* Initializes the left contact list with the contacts that could be added
* to the current chat session.
*
* @param protocolProvider the protocol provider from which to initialize
* the contact list data
* Initializes contact list sources.
*/
private void initContactListData(ProtocolProviderService protocolProvider)
private void initContactSources()
{
DemuxContactSourceService demuxCSService
= GuiActivator.getDemuxContactSourceService();
// If the DemuxContactSourceService isn't registered we use the default
// contact source set.
if (demuxCSService == null)
return;
Iterator<UIContactSource> sourcesIter
= new ArrayList<UIContactSource>(
contactList.getContactSources()).iterator();
@ -97,8 +101,20 @@ private void initContactListData(ProtocolProviderService protocolProvider)
= sourcesIter.next().getContactSourceService();
contactList.addContactSource(
new DemuxContactSource(contactSource));
demuxCSService.createDemuxContactSource(contactSource));
}
}
/**
* Initializes the left contact list with the contacts that could be added
* to the current chat session.
*
* @param protocolProvider the protocol provider from which to initialize
* the contact list data
*/
private void initContactListData(ProtocolProviderService protocolProvider)
{
initContactSources();
contactList.addContactSource(
new ProtocolContactSourceServiceImpl(

@ -98,7 +98,7 @@ public ConferenceInviteDialog(CallConference conference)
{
public void run()
{
initContactListSources();
initContactSources();
// Initialize the list of contacts to select from.
initContactListData(
@ -252,10 +252,18 @@ else if (accountSelectorBox.getItemCount() > 0)
}
/**
* Initializes contact sources for the source contact list.
* Initializes contact list sources.
*/
private void initContactListSources()
private void initContactSources()
{
DemuxContactSourceService demuxCSService
= GuiActivator.getDemuxContactSourceService();
// If the DemuxContactSourceService isn't registered we use the default
// contact source set.
if (demuxCSService == null)
return;
Iterator<UIContactSource> sourcesIter
= new ArrayList<UIContactSource>(
srcContactList.getContactSources()).iterator();
@ -268,7 +276,7 @@ private void initContactListSources()
= sourcesIter.next().getContactSourceService();
srcContactList.addContactSource(
new DemuxContactSource(contactSource));
demuxCSService.createDemuxContactSource(contactSource));
}
}
@ -282,6 +290,23 @@ private void initContactListData(ProtocolProviderService protocolProvider)
{
this.setCurrentProvider(protocolProvider);
Iterator<UIContactSource> sourcesIter
= new ArrayList<UIContactSource>(
srcContactList.getContactSources()).iterator();
while (sourcesIter.hasNext())
{
ContactSourceService contactSource
= sourcesIter.next().getContactSourceService();
if (contactSource instanceof ProtocolAwareContactSourceService)
{
((ProtocolAwareContactSourceService) contactSource)
.setPreferredProtocolProvider(
OperationSetBasicTelephony.class, protocolProvider);
}
}
srcContactList.removeContactSource(currentProviderContactSource);
srcContactList.removeContactSource(currentStringContactSource);

@ -4,12 +4,13 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.contactlist.contactsource;
package net.java.sip.communicator.plugin.demuxcontactsource;
import java.util.*;
import java.util.regex.*;
import net.java.sip.communicator.service.contactsource.*;
import net.java.sip.communicator.service.protocol.*;
/**
* The <tt>DemuxContactSource</tt> is a contact source that takes as parameter
@ -20,13 +21,19 @@
* @author Yana Stamcheva
*/
public class DemuxContactSource
implements ContactSourceService
implements ProtocolAwareContactSourceService
{
/**
* The underlying contact source service.
*/
private final ContactSourceService contactSource;
/**
* The preferred protocol provider for this contact source.
*/
private Map<Class<? extends OperationSet>, ProtocolProviderService>
preferredProtocolProviders;
/**
* Create an instance of <tt>DemuxContactSource</tt> by specifying the
* underlying <tt>ContactSourceService</tt> to be demuxed.
@ -39,6 +46,23 @@ public DemuxContactSource(ContactSourceService contactSource)
this.contactSource = contactSource;
}
/**
* Sets the preferred protocol provider for this contact source.
*
* @param protocolProvider the <tt>ProtocolProviderService</tt> to set
*/
public void setPreferredProtocolProvider(
Class<? extends OperationSet> opSetClass,
ProtocolProviderService protocolProvider)
{
if (preferredProtocolProviders == null)
preferredProtocolProviders
= new HashMap< Class<? extends OperationSet>,
ProtocolProviderService>();
preferredProtocolProviders.put(opSetClass, protocolProvider);
}
/**
* Returns the type of the underlying contact source.
*
@ -182,11 +206,16 @@ public List<SourceContact> getQueryResults()
while (detailsIter.hasNext())
{
ContactDetail detail = detailsIter.next();
if (preferredProtocolProviders == null
|| isPreferredContactDetail(detail))
{
newSourceContacts.add(
createSourceContact(sourceContact,
detail));
}
}
}
return newSourceContacts;
}
@ -224,10 +253,14 @@ public void contactReceived(ContactReceivedEvent event)
{
ContactDetail detail = detailsIter.next();
if (preferredProtocolProviders == null
|| isPreferredContactDetail(detail))
{
fireContactReceived(
createSourceContact(sourceContact, detail));
}
}
}
/**
* Creates a single contact from the given <tt>sourceContact</tt> and
@ -269,4 +302,38 @@ public void contactRemoved(ContactRemovedEvent event) {}
public void contactChanged(ContactChangedEvent event) {}
}
/**
* Indicates if the given contact detail has a pair of OperationSet and
* ProtocolProviderService that matches the preferred pairs indicated for
* this contact source.
*
* @param c the <tt>ContactDetail</tt> to check
* @return <tt>true</tt> if the given <tt>ContactDetail</tt> contains one
* of the preferred pairs or has no preferred pairs,
* <tt>false</tt> - otherwise.
*/
private boolean isPreferredContactDetail(ContactDetail c)
{
Iterator<Class<? extends OperationSet>> preferredProviderOpSets
= preferredProtocolProviders.keySet().iterator();
while (preferredProviderOpSets.hasNext())
{
Class<? extends OperationSet> opSetClass
= preferredProviderOpSets.next();
ProtocolProviderService preferredProvider
= c.getPreferredProtocolProvider(opSetClass);
if (preferredProvider == null
|| preferredProvider.equals(
preferredProtocolProviders.get(opSetClass)))
{
return true;
}
}
return false;
}
}

@ -0,0 +1,58 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.demuxcontactsource;
import net.java.sip.communicator.service.contactsource.*;
import org.osgi.framework.*;
/**
* Implements <tt>BundleActivator</tt> for the demux contact source plug-in.
*
* @author Yana Stamcheva
*/
public class DemuxContactSourceActivator
implements BundleActivator
{
private ServiceRegistration demuxServiceRegistration;
/**
* Starts the demux contact source plug-in.
*
* @param bundleContext the <tt>BundleContext</tt> in which the demux
* contact source plug-in is to be started
* @throws Exception if anything goes wrong while starting the demux
* contact source plug-in
* @see BundleActivator#start(BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception
{
// Registers the service implementation provided by this plugin.
demuxServiceRegistration = bundleContext.registerService(
DemuxContactSourceService.class.getName(),
new DemuxContactSourceServiceImpl(),
null);
}
/**
* Stops the addrbook plug-in.
*
* @param bundleContext the <tt>BundleContext</tt> in which the addrbook
* plug-in is to be stopped
* @throws Exception if anything goes wrong while stopping the addrbook
* plug-in
* @see BundleActivator#stop(BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception
{
if (demuxServiceRegistration != null)
{
demuxServiceRegistration.unregister();
demuxServiceRegistration = null;
}
}
}

@ -0,0 +1,36 @@
/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.demuxcontactsource;
import net.java.sip.communicator.service.contactsource.*;
/**
* Provides an implementation of the <tt>DemuxContactSourceService</tt> abstract
* class. This implementation provides a de-multiplexed protocol aware copy of
* the given <tt>ContactSourceService</tt>.
*
* @author Yana Stamcheva
*/
public class DemuxContactSourceServiceImpl
extends DemuxContactSourceService
{
/**
* Creates a demultiplexed copy of the given <tt>ContactSourceService</tt>,
* where each contact detail like telephone number or protocol contact
* address is represented as a single entry in the query result set.
*
* @param contactSourceService the original <tt>ContactSourceService</tt> to
* be demultiplexed
* @return a demultiplexed copy of the given <tt>ContactSourceService</tt>
*/
@Override
public ContactSourceService createDemuxContactSource(
ContactSourceService contactSourceService)
{
return new DemuxContactSource(contactSourceService);
}
}

@ -0,0 +1,9 @@
Bundle-Activator: net.java.sip.communicator.plugin.demuxcontactsource.DemuxContactSourceActivator
Bundle-Description: Demultiplexing contact source
Bundle-Name: Demux Contact Source
Bundle-Vendor: jitsi.org
Bundle-Version: 0.0.1
Import-Package: net.java.sip.communicator.service.contactsource,
net.java.sip.communicator.service.protocol,
org.osgi.framework
System-Bundle: yes

@ -0,0 +1,30 @@
/*
* Jitsi, 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.contactsource;
/**
* The <tt>DemuxContactSourceService</tt> provides a de-multiplexed copy of
* the given <tt>ContactSourceService</tt>, where each contact detail like
* telephone number or protocol contact address is represented as a single entry
* in the query result set.
*
* @author Yana Stamcheva
*/
public abstract class DemuxContactSourceService
{
/**
* Creates a demultiplexed copy of the given <tt>ContactSourceService</tt>,
* where each contact detail like telephone number or protocol contact
* address is represented as a single entry in the query result set.
*
* @param contactSourceService the original <tt>ContactSourceService</tt> to
* be demultiplexed
* @return a demultiplexed copy of the given <tt>ContactSourceService</tt>
*/
public abstract ContactSourceService createDemuxContactSource(
ContactSourceService contactSourceService);
}

@ -0,0 +1,38 @@
/*
* Jitsi, 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.contactsource;
import net.java.sip.communicator.service.protocol.*;
/**
* The <tt>ProtocolAwareContactSourceService</tt> extends the basic
* <tt>ContactSourceService</tt> interface to provide a protocol aware contact
* source. In other words a preferred <tt>ProtocolProviderService</tt> can be
* set for a given <tt>OperationSet</tt> class that would affect the query
* result by excluding source contacts that has a preferred provider different
* from the one specified as a preferred provider.
*
* @author Yana Stamcheva
*/
public interface ProtocolAwareContactSourceService
extends ContactSourceService
{
/**
* Sets the preferred protocol provider for this contact source. The
* preferred <tt>ProtocolProviderService</tt> set for a given
* <tt>OperationSet</tt> class would affect the query result by excluding
* source contacts that has a preferred provider different from the one
* specified here.
*
* @param opSetClass the <tt>OperationSet</tt> class, for which the
* preferred provider is set
* @param protocolProvider the <tt>ProtocolProviderService</tt> to set
*/
public void setPreferredProtocolProvider(
Class<? extends OperationSet> opSetClass,
ProtocolProviderService protocolProvider);
}
Loading…
Cancel
Save