aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator
diff options
context:
space:
mode:
authorYana Stamcheva <yana@jitsi.org>2012-10-16 12:49:57 +0000
committerYana Stamcheva <yana@jitsi.org>2012-10-16 12:49:57 +0000
commita3ef89863f3330407992b563a8ddb707e0c4c801 (patch)
treeeddc394ef93fb7fca3c4939605e68cc387494c75 /src/net/java/sip/communicator
parenta87481ac4b82b247d5aef5baa2217ddd670f45d6 (diff)
downloadjitsi-a3ef89863f3330407992b563a8ddb707e0c4c801.zip
jitsi-a3ef89863f3330407992b563a8ddb707e0c4c801.tar.gz
jitsi-a3ef89863f3330407992b563a8ddb707e0c4c801.tar.bz2
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.
Diffstat (limited to 'src/net/java/sip/communicator')
-rw-r--r--src/net/java/sip/communicator/impl/gui/GuiActivator.java21
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java30
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java33
-rw-r--r--src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSource.java (renamed from src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/DemuxContactSource.java)81
-rw-r--r--src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceActivator.java58
-rw-r--r--src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceServiceImpl.java36
-rw-r--r--src/net/java/sip/communicator/plugin/demuxcontactsource/demuxcontactsource.manifest.mf9
-rw-r--r--src/net/java/sip/communicator/service/contactsource/DemuxContactSourceService.java30
-rw-r--r--src/net/java/sip/communicator/service/contactsource/ProtocolAwareContactSourceService.java38
9 files changed, 318 insertions, 18 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java
index 089d172..c569f60 100644
--- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java
+++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java
@@ -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>();
@@ -686,6 +688,25 @@ public class GuiActivator implements BundleActivator
}
/**
+ * 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
*/
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java
index af176d6..1947ea5 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java
@@ -77,14 +77,18 @@ public class TransferCallDialog
}
/**
- * 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 @@ public class TransferCallDialog
= 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(
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java
index 465c72a..edf6dde 100644
--- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java
@@ -98,7 +98,7 @@ public class ConferenceInviteDialog
{
public void run()
{
- initContactListSources();
+ initContactSources();
// Initialize the list of contacts to select from.
initContactListData(
@@ -252,10 +252,18 @@ public class ConferenceInviteDialog
}
/**
- * 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 @@ public class ConferenceInviteDialog
= sourcesIter.next().getContactSourceService();
srcContactList.addContactSource(
- new DemuxContactSource(contactSource));
+ demuxCSService.createDemuxContactSource(contactSource));
}
}
@@ -282,6 +290,23 @@ public class ConferenceInviteDialog
{
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);
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/DemuxContactSource.java b/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSource.java
index 8c1d3e9..60731c0 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/DemuxContactSource.java
+++ b/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSource.java
@@ -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,7 +21,7 @@ import net.java.sip.communicator.service.contactsource.*;
* @author Yana Stamcheva
*/
public class DemuxContactSource
- implements ContactSourceService
+ implements ProtocolAwareContactSourceService
{
/**
* The underlying contact source service.
@@ -28,6 +29,12 @@ public class DemuxContactSource
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.
*
@@ -40,6 +47,23 @@ public class DemuxContactSource
}
/**
+ * 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.
*
* @return the type of this contact source
@@ -182,9 +206,14 @@ public class DemuxContactSource
while (detailsIter.hasNext())
{
ContactDetail detail = detailsIter.next();
- newSourceContacts.add(
- createSourceContact(sourceContact,
- detail));
+
+ if (preferredProtocolProviders == null
+ || isPreferredContactDetail(detail))
+ {
+ newSourceContacts.add(
+ createSourceContact(sourceContact,
+ detail));
+ }
}
}
@@ -224,8 +253,12 @@ public class DemuxContactSource
{
ContactDetail detail = detailsIter.next();
- fireContactReceived(
- createSourceContact(sourceContact, detail));
+ if (preferredProtocolProviders == null
+ || isPreferredContactDetail(detail))
+ {
+ fireContactReceived(
+ createSourceContact(sourceContact, detail));
+ }
}
}
@@ -269,4 +302,38 @@ public class DemuxContactSource
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;
+ }
} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceActivator.java b/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceActivator.java
new file mode 100644
index 0000000..cb0035c
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceActivator.java
@@ -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;
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceServiceImpl.java b/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceServiceImpl.java
new file mode 100644
index 0000000..3bcc4db
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/demuxcontactsource/DemuxContactSourceServiceImpl.java
@@ -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);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/demuxcontactsource/demuxcontactsource.manifest.mf b/src/net/java/sip/communicator/plugin/demuxcontactsource/demuxcontactsource.manifest.mf
new file mode 100644
index 0000000..f93560f
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/demuxcontactsource/demuxcontactsource.manifest.mf
@@ -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
diff --git a/src/net/java/sip/communicator/service/contactsource/DemuxContactSourceService.java b/src/net/java/sip/communicator/service/contactsource/DemuxContactSourceService.java
new file mode 100644
index 0000000..d77b6a8
--- /dev/null
+++ b/src/net/java/sip/communicator/service/contactsource/DemuxContactSourceService.java
@@ -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);
+}
diff --git a/src/net/java/sip/communicator/service/contactsource/ProtocolAwareContactSourceService.java b/src/net/java/sip/communicator/service/contactsource/ProtocolAwareContactSourceService.java
new file mode 100644
index 0000000..cb40170
--- /dev/null
+++ b/src/net/java/sip/communicator/service/contactsource/ProtocolAwareContactSourceService.java
@@ -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);
+}