diff --git a/build.xml b/build.xml index 3e83a338d..4643a291f 100644 --- a/build.xml +++ b/build.xml @@ -397,7 +397,8 @@ bundle-history-slick,bundle-configuration-slick,bundle-netaddr, bundle-netaddr-slick,bundle-slickless,bundle-slick-runner,bundle-sip, bundle-fileaccess,bundle-fileaccess-slick,bundle-media, - bundle-media-slick,bundle-icq,bundle-icq-slick,bundle-swing-ui"/> + bundle-media-slick,bundle-icq,bundle-icq-slick,bundle-swing-ui, + meta-contactlist,meta-contactlist-slick"/> @@ -617,6 +618,7 @@ javax.swing.event, javax.swing.border"/> + + + + + + + + + + + + + + + + + + diff --git a/lib/oscar.unit.test.properties b/lib/oscar.unit.test.properties index 2e54ee883..1522259ed 100644 --- a/lib/oscar.unit.test.properties +++ b/lib/oscar.unit.test.properties @@ -51,7 +51,8 @@ oscar.auto.start.4= \ file:sc-bundles/fileaccess.jar \ file:sc-bundles/history.jar \ file:sc-bundles/protocol-icq.jar \ - file:sc-bundles/media.jar + file:sc-bundles/media.jar \ + file:sc-bundles/meta-cl.jar oscar.auto.start.5= \ file:sc-bundles/slickless.jar \ @@ -60,7 +61,9 @@ oscar.auto.start.5= \ file:sc-bundles/netaddr-slick.jar \ file:sc-bundles/fileaccess-slick.jar \ file:sc-bundles/history-slick.jar \ - file:sc-bundles/protocol-icq-slick.jar + file:sc-bundles/meta-cl-slick.jar \ + file:sc-bundles/protocol-icq-slick.jar \ + oscar.auto.start.100= \ file:sc-bundles/slick-runner.jar diff --git a/lib/testing.properties b/lib/testing.properties index 43f75b634..abfc8be8e 100644 --- a/lib/testing.properties +++ b/lib/testing.properties @@ -9,4 +9,5 @@ test.list=ConfigurationServiceLick \ FileAccessServiceLick \ HistoryServiceLick \ SlicklessTests \ - IcqProtocolProviderSlick + IcqProtocolProviderSlick \ + MetaContactListServiceLick diff --git a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java index c2171166d..9d100ef3e 100644 --- a/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java +++ b/src/net/java/sip/communicator/impl/configuration/ConfigurationServiceImpl.java @@ -18,8 +18,6 @@ import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.xml.*; - - /** * A straight forward implementation of the ConfigurationService using an xml * file for storing properties. Currently only String properties are diff --git a/src/net/java/sip/communicator/impl/contactlist/Activator.java b/src/net/java/sip/communicator/impl/contactlist/Activator.java new file mode 100644 index 000000000..fd83935b7 --- /dev/null +++ b/src/net/java/sip/communicator/impl/contactlist/Activator.java @@ -0,0 +1,62 @@ +/* + * 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.impl.contactlist; + +import org.osgi.framework.*; +import java.util.*; +import net.java.sip.communicator.service.contactlist.*; +import net.java.sip.communicator.util.*; + +/** + * + * @author Emil Ivov + */ +public class Activator + implements BundleActivator +{ + private static final Logger logger = + Logger.getLogger(Activator.class); + + ServiceRegistration mclServiceRegistration = null; + /** + * Called when this bundle is started. + * + * @param context The execution context of the bundle being started. + * @throws Exception If + */ + public void start(BundleContext context) throws Exception + { + logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]"); + Hashtable hashtable = new Hashtable(); + + MetaContactListServiceImpl mclServiceImpl = + new MetaContactListServiceImpl(); + + //reg the icq account man. + mclServiceRegistration = context.registerService( + MetaContactListService.class.getName(), + mclServiceImpl, + hashtable); + + logger.debug("Service Impl: " + getClass().getName() + " [REGISTERED]"); + + } + + /** + * Called when this bundle is stopped so the Framework can perform the + * bundle-specific activities necessary to stop the bundle. + * + * @param context The execution context of the bundle being stopped. + * @throws Exception If this method throws an exception, the bundle is + * still marked as stopped, and the Framework will remove the bundle's + * listeners, unregister all services registered by the bundle, and + * release all services used by the bundle. + */ + public void stop(BundleContext context) throws Exception + { + } +} diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java index acb490a44..f87752560 100644 --- a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java +++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java @@ -367,6 +367,15 @@ private void synchronizeOpSetWithServerContactList( = new MetaContactGroupImpl(group.getGroupName()); newMetaGroup.addProtoGroup(provider, group); + + Iterator contactsIter = group.contacts(); + while(contactsIter.hasNext()) + { + Contact contact = (Contact)contactsIter.next(); + MetaContactImpl newMetaContact = new MetaContactImpl(); + + newMetaContact.addProtoContact(contact); + } } } @@ -431,12 +440,24 @@ public void serviceChanged(ServiceEvent event) if(event.getType() == ServiceEvent.REGISTERED) { - this.handleProviderAdded((ProtocolProviderService)sService); + //if we have the PROVIDER_MASK property set, make sure that this + //provider has it and if not ignore it. + String providerMask = System.getProperty( + MetaContactListService.PROVIDER_MASK_PROPERTY); + if(providerMask != null && providerMask.trim().length() > 0) + { + if (event.getServiceReference().getProperty( + MetaContactListService.PROVIDER_MASK_PROPERTY) + .equals(providerMask)){ + return; + } + } + + this.handleProviderAdded( (ProtocolProviderService)sService); } else if(event.getType() == ServiceEvent.UNREGISTERING) { this.handleProviderRemoved((ProtocolProviderService)sService); } } - } diff --git a/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf b/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf new file mode 100644 index 000000000..4679bd11c --- /dev/null +++ b/src/net/java/sip/communicator/impl/contactlist/meta.cl.manifest.mf @@ -0,0 +1,12 @@ +Bundle-Activator: net.java.sip.communicator.impl.contactlist.Activator +Bundle-Name: MetaContactList +Bundle-Description: An implementation of the MetaContactList service. +Bundle-Vendor: sip-communicator.org +Bundle-Version: 0.0.1 +Export-Package: net.jata.sip.communicator.service.contactlist +Import-Package: org.osgi.framework, + net.java.sip.communicator.util, + net.java.sip.communicator.service.configuration, + net.java.sip.communicator.service.configuration.event, + net.java.sip.communicator.service.protocol, + net.java.sip.communicator.service.protocol.event diff --git a/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java b/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java index 5e4ff030b..fe7741498 100644 --- a/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java +++ b/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java @@ -33,18 +33,38 @@ * specific contacts. These protocol specific contacts may also be removed * away from a MetaContact. Whenever a MetaContact remains empty (i.e. all of * its protocol specific contacts are removed) it is automatically deleted. - * + *

* Note that for most of the methods defined by this interface, it is likely * that implementations require one or more network operations to complete * before returning. It is therefore strongly advised not to call these methods * in event dispatching threads (watch out UI implementors ;) ) as this may lead * to unpleasant user experience. - * + *

+ * The MetaContactListService also defines a property named:
+ * net.java.sip.communicator.service.contactlist.PROVIDER_MASK
+ * When this property is set, implementations of the MetaContactListService + * would only interact with protocol providers that same property set to the + * same value. This feature is mostly used during unit testing so that testing + * bundles could make sure that a tested meta contact list implementation would + * only load their mocking protocol provider implementations during the test + * run. + *

* @todo expections * @author Emil Ivov */ public interface MetaContactListService { + /** + * This property is used to tell implementations of the + * MetaContactListService that they are to only interact with providers + * that have the same property set to the same value as the system one. + * This feature is mostly used during unit testing so that testing bundles + * could make sure that a tested meta contact list implementation would only + * load their mocking protocol provider implementations during the test run. + */ + public static String PROVIDER_MASK_PROPERTY = + "net.java.sip.communicator.service.contactlist.PROVIDER_MASK"; + /** * Returns the root MetaContactGroup in this contact list. * All meta contacts and subgroups are children of the root meta contact diff --git a/test/net/java/sip/communicator/slick/contactlist/MetaContactListServiceLick.java b/test/net/java/sip/communicator/slick/contactlist/MetaContactListServiceLick.java new file mode 100644 index 000000000..1028f511e --- /dev/null +++ b/test/net/java/sip/communicator/slick/contactlist/MetaContactListServiceLick.java @@ -0,0 +1,53 @@ +/* + * 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.slick.contactlist; + +import junit.framework.*; +import org.osgi.framework.*; +import net.java.sip.communicator.util.*; +import java.util.*; + +/** + * + * @author Emil Ivov + */ +public class MetaContactListServiceLick + extends TestSuite + implements BundleActivator +{ + private static final Logger logger = + Logger.getLogger(MetaContactListServiceLick.class); + /** + * The bundle context that we get upon activation. + */ + protected static BundleContext bundleContext = null; + + /** + */ + public void start(BundleContext context) throws Exception + { + this.bundleContext = context; + + setName("MetaContactListServiceLick"); + Hashtable properties = new Hashtable(); + properties.put("service.pid", getName()); + + addTestSuite(TestMetaContactList.class); + + + bundleContext.registerService(getClass().getName(), this, properties); + logger.debug("Service " + getClass().getName() + " [REGISTERED]"); + } + + /** + */ + public void stop(BundleContext context) throws Exception + { + + } + +} diff --git a/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java b/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java new file mode 100644 index 000000000..aa35f16c2 --- /dev/null +++ b/test/net/java/sip/communicator/slick/contactlist/TestMetaContactList.java @@ -0,0 +1,33 @@ +package net.java.sip.communicator.slick.contactlist; + +import junit.framework.*; + +/** + * Test basic meta contact list functionality such as filling in the contact + * list from existing protocol provider implementations and others. + * @author Emil Ivov + */ +public class TestMetaContactList + extends TestCase +{ + public TestMetaContactList(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + super.setUp(); + + } + + protected void tearDown() throws Exception + { + super.tearDown(); + } + + public void testContactListRetrieving() + { + System.out.println("-= DUPE =-"); + } +} diff --git a/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf b/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf new file mode 100644 index 000000000..0d60ac420 --- /dev/null +++ b/test/net/java/sip/communicator/slick/contactlist/meta.cl.slick.manifest.mf @@ -0,0 +1,13 @@ +Bundle-Activator: net.java.sip.communicator.slick.contactlist.MetaContactListServiceLick +Bundle-Name: MetaContactListServiceLick +Bundle-Description: An SLI compatibility kit for the MetaContactList service. +Bundle-Vendor: sip-communicator.org +Bundle-Version: 0.0.1 +Import-Package: net.jata.sip.communicator.service.contactlist, + org.osgi.framework, + junit.framework, + net.java.sip.communicator.util, + net.java.sip.communicator.service.configuration, + net.java.sip.communicator.service.configuration.event, + net.java.sip.communicator.service.protocol, + net.java.sip.communicator.service.protocol.event