Ongoing works on the MetaContactList and its SLICK

cusax-fix
Emil Ivov 21 years ago
parent fdd89fde0d
commit 66d2d0b0eb

@ -26,7 +26,7 @@ handlers= java.util.logging.ConsoleHandler
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level= FINE
.level= INFO
############################################################
# Handler specific properties.
@ -52,9 +52,8 @@ java.util.logging.ConsoleHandler.formatter = net.java.sip.communicator.util.ScLo
# We don't want trace logs from joscar and joustsim
net.kano.level = INFO
# But we want everything coming from the sip-comm
net.java.sip.communicator.service.protocol.level = FINEST
net.java.sip.communicatserverStoredGroupListenersor.impl.protocol.level = FINEST
net.java.sip.communicator.slick.protocol.level = FINEST
net.java.sip.communicator.impl.level = FINEST
net.java.sip.communicator.slick.level = FINEST
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:

@ -61,8 +61,8 @@ 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/meta-cl-slick.jar \
file:sc-bundles/protocol-icq-slick.jar
file:sc-bundles/protocol-icq-slick.jar \
file:sc-bundles/meta-cl-slick.jar
oscar.auto.start.100= \
file:sc-bundles/slick-runner.jar

@ -42,8 +42,9 @@ public void start(BundleContext context) throws Exception
mclServiceImpl,
hashtable);
logger.debug("Service Impl: " + getClass().getName() + " [REGISTERED]");
mclServiceImpl.start(context);
logger.debug("Service Impl: " + getClass().getName() + " [REGISTERED]");
}
/**

@ -183,6 +183,29 @@ public void addProtoGroup(ProtocolProviderService owner,
this.protoGroups.put(owner, group);
}
/**
* Returns a String representation of this group and the contacts it
* contains (may turn out to be a relatively long string).
* @return a String representing this group and its child contacts.
*/
public String toString()
{
StringBuffer buff = new StringBuffer("MetaContactGroup.");
buff.append(getGroupName());
buff.append(", childContacts="+countChildContacts()+":[");
Iterator contacts = getChildContacts();
while (contacts.hasNext())
{
MetaContactImpl contact = (MetaContactImpl) contacts.next();
buff.append(contact.toString());
if(contacts.hasNext())
buff.append(", ");
}
return buff.append("]").toString();
}
/**
* Verifies whether a protocol specific ContactGroup with the specified
* name and originating from the specified provider is encapsulated by this

@ -110,6 +110,21 @@ public String getMetaContactID()
return uid;
}
/**
* Returns a string representation of this contact, containing most of its
* representative details.
*
* @return a string representation of this contact.
*/
public String toString()
{
StringBuffer buff = new StringBuffer("MetaContact[ DisplayName=")
.append(getDisplayName()).append("]");
return buff.toString();
}
/**
* Returns a characteristic display name that can be used when including
* this <tt>MetaContact</tt> in user interface.

@ -66,7 +66,7 @@ public MetaContactListServiceImpl()
}
/**
*Starts this implementation of the MetaContactListService. The
* Starts this implementation of the MetaContactListService. The
* implementation would first restore a default contact list from what has
* been stored in a file. It would then connect to OSGI and retrieve
* any existing protocol providers and if <br>
@ -89,6 +89,7 @@ public MetaContactListServiceImpl()
*/
public void start(BundleContext bc)
{
logger.debug("Starting the meta contact list implementation.");
this.bundleContext = bc;
//start listening for newly register or removed protocol providers
@ -111,14 +112,19 @@ public void start(BundleContext bc)
return;
}
//retrieve the root groups for all protocol providers and create the
//meta contact list
for (int i = 0; i < protocolProviderRefs.length; i++)
//in case we found any, retrieve the root groups for all protocol
//providers and create the meta contact list
if (protocolProviderRefs != null)
{
ProtocolProviderService provider = (ProtocolProviderService)bc
.getService(protocolProviderRefs[i]);
logger.debug("Found " + protocolProviderRefs.length
+ " already installed providers.");
for (int i = 0; i < protocolProviderRefs.length; i++)
{
ProtocolProviderService provider = (ProtocolProviderService) bc
.getService(protocolProviderRefs[i]);
this.handleProviderAdded(provider);
this.handleProviderAdded(provider);
}
}
}
@ -203,9 +209,7 @@ public void createMetaContactGroup(String groupName) throws
*/
public MetaContactGroup getRoot()
{
/**@todo implement getRoot() */
System.out.println("@todo implement getRoot()");
return null;
return rootMetaGroup;
}
/**
@ -345,16 +349,17 @@ private void synchronizeOpSetWithServerContactList(
= presenceOpSet.getServerStoredContactListRoot();
logger.trace("subgroups: " + rootProtoGroup.countSubGroups());
logger.trace("child contacts: " + rootProtoGroup.countContacts());
//first register the root group
rootMetaGroup.registerProtocolSpecificRoot(
rootMetaGroup.addProtoGroup(
provider,
presenceOpSet.getServerStoredContactListRoot());
//register subgroups and contacts
//this implementation only supports one level of groups apart from
//the root group - so let's keep this simple and do it in a nested loop
Iterator subgroupsIter = rootMetaGroup.getSubgroups();
Iterator subgroupsIter = rootProtoGroup.subGroups();
while(subgroupsIter.hasNext())
{
@ -375,7 +380,29 @@ private void synchronizeOpSetWithServerContactList(
MetaContactImpl newMetaContact = new MetaContactImpl();
newMetaContact.addProtoContact(contact);
/** @todo this shouldn't be that simple */
newMetaContact.setDisplayName(contact.getAlias());
newMetaGroup.addMetaContact(newMetaContact);
}
rootMetaGroup.addSubgroup(newMetaGroup);
}
//now add all contacts, located in the root group
Iterator contactsIter = rootProtoGroup.contacts();
while (contactsIter.hasNext())
{
Contact contact = (Contact) contactsIter.next();
MetaContactImpl newMetaContact = new MetaContactImpl();
newMetaContact.addProtoContact(contact);
/** @todo this shouldn't be that simple */
newMetaContact.setDisplayName(contact.getAlias());
rootMetaGroup.addMetaContact(newMetaContact);
}
}
@ -403,6 +430,8 @@ private void handleProviderAdded(ProtocolProviderService provider)
if( opSetPersPresence != null ){
synchronizeOpSetWithServerContactList(provider, opSetPersPresence);
}
else
logger.debug("Service did not have a pers. pres. op. set.");
/** @todo implement handling non persistent presence operation sets */
this.currentlyInstalledProviders.add(provider);
@ -438,17 +467,21 @@ public void serviceChanged(ServiceEvent event)
if( !(sService instanceof ProtocolProviderService) )
return;
logger.debug("Service is a protocol provider.");
if(event.getType() == ServiceEvent.REGISTERED)
{
logger.debug("Handling registration of a new Protocol Provider.");
//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)){
String servRefMask = (String)event.getServiceReference()
.getProperty(MetaContactListService.PROVIDER_MASK_PROPERTY);
if (servRefMask == null
|| !servRefMask.equals(providerMask)){
return;
}
}

@ -4,6 +4,7 @@
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
/**
* An implementation of the meta contact group that would only be used for the
@ -13,16 +14,17 @@
public class RootMetaContactGroupImpl
implements MetaContactGroup
{
private static final Logger logger =
Logger.getLogger(RootMetaContactGroupImpl.class);
/**
* All the subgroups that this group contains.
*/
private Vector subgroups = new Vector();
/**
* An empty list that we'll use to return an iterator over the
* (non-exising) contats in this group.
* A list containing all child contacts.
*/
private List dummyContacts = new LinkedList();
private List childContacts = new LinkedList();
/**
* The name of the group (fixed for root groups since it won't show).
@ -57,12 +59,11 @@ public boolean canContainSubgroups()
/**
* Returns the number of <tt>MetaContact</tt>s that this group contains.
* <p>
* @return always 0 since this is the root contact group and in our impl it
* can only contain groups.
* @return the number of <tt>MetaContact</tt>s that this group contains.
*/
public int countChildContacts()
{
return 0;
return childContacts.size();
}
/**
@ -84,7 +85,7 @@ public int countSubgroups()
*/
public Iterator getChildContacts()
{
return dummyContacts.iterator();
return childContacts.iterator();
}
/**
@ -92,24 +93,55 @@ public Iterator getChildContacts()
*
* @param metaContactID a String identifier obtained through the
* <tt>MetaContact.getMetaContactID()</tt> method. <p>
* @return always null since this is the root contact group and in our impl
* it can only contain groups.
* @return the <tt>MetaContact</tt> with the specified idnetifier.
*/
public MetaContact getMetaContact(String metaContactID)
{
Iterator contactsIter = getChildContacts();
while(contactsIter.hasNext())
{
MetaContact contact = (MetaContact)contactsIter.next();
if (contact.getMetaContactID().equals(metaContactID))
return contact;
}
return null;
}
/**
* Returns the meta contact on the specified index.
*
* @param index the index of the meta contact to return.
* @return always null since this is the root contact group and in our impl
* it can only contain groups. <p>
* @return the MetaContact with the specified index, <p>
* @throws IndexOutOfBoundsException in case <tt>index</tt> is not a
* valid index for this group.
*/
public MetaContact getMetaContact(int index)
public MetaContact getMetaContact(int index) throws
IndexOutOfBoundsException
{
return null;
return (MetaContact)childContacts.get(index);
}
/**
* Adds the specified <tt>metaContact</tt> to ths local list of child
* contacts.
* @param metaContact the <tt>MetaContact</tt> to add in the local vector.
*/
void addMetaContact(MetaContact metaContact)
{
this.childContacts.add(metaContact);
}
/**
* Removes the specified <tt>metaContact</tt> from the local list of
* contacts.
* @param metaContact the <tt>MetaContact</tt>
*/
void removeMetaContact(MetaContact metaContact)
{
this.childContacts.remove( metaContact );
}
/**
@ -168,6 +200,39 @@ public String getGroupName()
return groupName;
}
/**
* Returns a String representation of this group and the contacts it
* contains (may turn out to be a relatively long string).
* @return a String representing this group and its child contacts.
*/
public String toString()
{
StringBuffer buff = new StringBuffer(getGroupName());
buff.append(".subGroups=" + countSubgroups() + ":\n");
Iterator subGroups = getSubgroups();
while (subGroups.hasNext())
{
MetaContactGroupImpl group = (MetaContactGroupImpl)subGroups.next();
buff.append(group.toString());
if (subGroups.hasNext())
buff.append("\n");
}
buff.append("\nRootChildContacts="+countChildContacts()+":[");
Iterator contacts = getChildContacts();
while (contacts.hasNext())
{
MetaContactImpl contact = (MetaContactImpl) contacts.next();
buff.append(contact.toString());
if(contacts.hasNext())
buff.append(", ");
}
return buff.append("]").toString();
}
/**
* Addes the specified group to the list of protocol specific roots
* that we're encapsulating in this meta contact list.
@ -175,12 +240,14 @@ public String getGroupName()
* group.
* @param ownerProtocol the protocol that the specified group came from.
*/
void registerProtocolSpecificRoot(
ProtocolProviderService ownerProtocol, ContactGroup protoRoot)
void addProtoGroup( ProtocolProviderService ownerProtocol,
ContactGroup protoRoot)
{
protoGroups.put(ownerProtocol, protoRoot);
}
/**
* Adds the specified meta group to the subgroups of this one.
* @param subgroup the MetaContactGroup to register as a subgroup to this
@ -188,6 +255,8 @@ void registerProtocolSpecificRoot(
*/
void addSubgroup(MetaContactGroup subgroup)
{
logger.trace("Adding subgroup " + subgroup.getGroupName()
+ " to" + getGroupName());
this.subgroups.add(subgroup);
}

@ -0,0 +1,95 @@
package net.java.sip.communicator.slick.contactlist.mockprovider;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.icqconstants.*;
/**
* A simple, straightforward mock implementation of the Contact interface
* that can be manually created and used in testing a
* MetaContactList service
*
* @author Emil Ivov
*/
public class MockContact
implements Contact
{
private String contactID = null;
private MockProvider parentProvider = null;
/**
* Creates an instance of a meta contact with the specified string used
* as a name and identifier.
*
* @param id the identifier of this contact (also used as a name).
* @param parentProvider
*/
public MockContact(String id, MockProvider parentProvider)
{
this.contactID = id;
this.parentProvider = parentProvider;
}
/**
* Returns a String that can be used for identifying the contact.
*
* @return a String id representing and uniquely identifying the contact.
*/
public String getAddress()
{
return contactID;
}
/**
* Returns a String that could be used by any user interacting modules
* for referring to this contact.
*
* @return a String that can be used for referring to this contact when
* interacting with the user.
*/
public String getAlias()
{
return contactID;
}
/**
* Returns a byte array containing an image (most often a photo or an
* avatar) that the contact uses as a representation.
*
* @return byte[] an image representing the contact.
*/
public byte[] getImage()
{
return null;
}
/**
* Returns the status of the contact.
*
* @return always IcqStatusEnum.ONLINE.
*/
public PresenceStatus getPresenceStatus()
{
return IcqStatusEnum.ONLINE;
}
/**
* Returns a reference to the protocol provider that created the contact.
*
* @return a refererence to an instance of the ProtocolProviderService
*/
public ProtocolProviderService getProtocolProvider()
{
return parentProvider;
}
/**
* Determines whether or not this contact represents our own identity.
*
* @return true in case this is a contact that represents ourselves and
* false otherwise.
*/
public boolean isLocal()
{
return false;
}
}

@ -0,0 +1,182 @@
package net.java.sip.communicator.slick.contactlist.mockprovider;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
/**
* A simple, straightforward mock implementation of the ContactGroup interface
* that can be manually created and filled and used in testing a
* MetaContactList service
* @author Emil Ivov
*/
public class MockContactGroup
implements ContactGroup
{
private String groupName = null;
private Vector contacts = new Vector();
private Vector subGroups = new Vector();
private MockProvider parentProvider = null;
/**
* Creates a MockGroup with the specified name.
* @param groupName the name of the group.
* @param parentProvider the protocol provider that created this group.
*/
public MockContactGroup(String groupName, MockProvider parentProvider)
{
this.groupName = groupName;
this.parentProvider = parentProvider;
}
/**
* Determines whether the group may contain subgroups or not.
*
* @return always true in this implementation.
*/
public boolean canContainSubgroups()
{
return true;
}
/**
* Returns an Iterator over all contacts, member of this
* <tt>ContactGroup</tt>.
*
* @return a java.util.Iterator over all contacts inside this
* <tt>ContactGroup</tt>
*/
public Iterator contacts()
{
return contacts.iterator();
}
/**
* Adds the specified contact to this group.
* @param contactToAdd the MockContact to add to this group.
*/
public void addContact(MockContact contactToAdd)
{
this.contacts.add(contactToAdd);
}
/**
* Returns the number of <tt>Contact</tt> members of this
* <tt>ContactGroup</tt>
*
* @return an int indicating the number of <tt>Contact</tt>s, members of
* this <tt>ContactGroup</tt>.
*/
public int countContacts()
{
return contacts.size();
}
/**
* Returns the number of subgroups contained by this
* <tt>ContactGroup</tt>.
*
* @return the number of subGroups currently added to this group.
*/
public int countSubGroups()
{
return subGroups.size();
}
/**
* Adds the specified contact group to the contained by this group.
* @param subGroup the MockContactGroup to add as a subgroup to this group.
*/
public void addSubGroup(MockContactGroup subGroup)
{
this.subGroups.add(subGroup);
}
/**
* Returns the <tt>Contact</tt> with the specified index.
*
* @param index the index of the <tt>Contact</tt> to return.
* @return the <tt>Contact</tt> with the specified index.
*/
public Contact getContact(int index)
{
return (MockContact)contacts.get(index);
}
/**
* Returns the <tt>Contact</tt> with the specified address or identifier.
*
* @param id the addres or identifier of the <tt>Contact</tt> we are
* looking for.
* @return the <tt>Contact</tt> with the specified id or address.
*/
public Contact getContact(String id)
{
Iterator contactsIter = contacts();
while (contactsIter.hasNext())
{
MockContact contact = (MockContact) contactsIter.next();
if (contact.getAddress().equals(id))
return contact;
}
return null;
}
/**
* Returns the subgroup with the specified index.
*
* @param index the index of the <tt>ContactGroup</tt> to retrieve.
* @return the <tt>ContactGroup</tt> with the specified index.
*/
public ContactGroup getGroup(int index)
{
return (ContactGroup)subGroups.get(index);
}
/**
* Returns the subgroup with the specified name.
*
* @param groupName the name of the <tt>ContactGroup</tt> to retrieve.
* @return the <tt>ContactGroup</tt> with the specified index.
*/
public ContactGroup getGroup(String groupName)
{
Iterator groupsIter = contacts();
while (groupsIter.hasNext())
{
MockContactGroup contactGroup
= (MockContactGroup) groupsIter.next();
if (contactGroup.getGroupName().equals(groupName))
return contactGroup;
}
return null;
}
/**
* Returns the name of this group.
*
* @return a String containing the name of this group.
*/
public String getGroupName()
{
return this.groupName;
}
/**
* Returns an iterator over the sub groups that this
* <tt>ContactGroup</tt> contains.
*
* @return a java.util.Iterator over the <tt>ContactGroup</tt> children
* of this group (i.e. subgroups).
*/
public Iterator subGroups()
{
return subGroups.iterator();
}
}

@ -0,0 +1,372 @@
package net.java.sip.communicator.slick.contactlist.mockprovider;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.icqconstants.*;
/**
* A mock implementation of a persistent presence operation set containing a
* constant contact list and used for testing the meta contact list.
* @author Emil Ivov
*/
public class MockPersistentPresenceOperationSet
implements OperationSetPersistentPresence
{
/**
* The root of the mock contact list.
*/
private MockContactGroup contactListRoot = null;
public MockPersistentPresenceOperationSet(MockProvider provider)
{
contactListRoot = new MockContactGroup("RootMockGroup", provider);
}
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param listener a dummy param.
*/
public void addContactPresenceStatusListener(ContactPresenceStatusListener
listener)
{
}
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param listener a dummy param.
*/
public void addProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
}
/**
* Registers a listener that would receive events upon changes in server
* stored groups.
*
* @param listener a ServerStoredGroupChangeListener impl that would
* receive events upong group changes.
*/
public void addServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
}
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param listener the SubscriptionListener to register
*/
public void addSubsciptionListener(SubscriptionListener listener)
{
}
/**
* Creates a group with the specified name and parent in the server
* stored contact list.
*
* @param parent the group where the new group should be created
* @param groupName the name of the new group to create.
*/
public void createServerStoredContactGroup(ContactGroup parent,
String groupName)
{
/** @todo implement createServerStoredContactGroup() */
}
/**
* A Mock Provider method to use for fast filling of a contact list.
*/
public void addMockGroup(MockContactGroup contactGroup)
{
contactListRoot.addSubGroup(contactGroup);
}
/**
* Returns a reference to the contact with the specified ID in case we
* have a subscription for it and null otherwise/
*
* @param contactID a String identifier of the contact which we're
* seeking a reference of.
* @return a reference to the Contact with the specified
* <tt>contactID</tt> or null if we don't have a subscription for the
* that identifier.
*/
public Contact findContactByID(String contactID)
{
/** @todo implement findContactByID() */
return null;
}
/**
* Returns the status message that was last set through
* setCurrentStatusMessage.
*
* @return the last status message that we have requested and the aim
* server has confirmed.
*/
public String getCurrentStatusMessage()
{
/** @todo implement getCurrentStatusMessage() */
return "";
}
/**
* Returns the protocol specific contact instance representing the local
* user.
*
* @return the Contact (address, phone number, or uin) that the Provider
* implementation is communicating on behalf of.
*/
public Contact getLocalContact()
{
return null;
}
/**
* Returns a PresenceStatus instance representing the state this provider
* is currently in.
*
* @return the PresenceStatus last published by this provider.
*/
public PresenceStatus getPresenceStatus()
{
return IcqStatusEnum.ONLINE;
}
/**
* Returns the root group of the server stored contact list.
*
* @return the root ContactGroup for the ContactList stored by this
* service.
*/
public ContactGroup getServerStoredContactListRoot()
{
return contactListRoot;
}
/**
* Returns the set of PresenceStatus objects that a user of this service
* may request the provider to enter.
*
* @return Iterator a PresenceStatus array containing "enterable" status
* instances.
*/
public Iterator getSupportedStatusSet()
{
return IcqStatusEnum.icqStatusSet.iterator();
}
/**
* Removes the specified contact from its current parent and places it
* under <tt>newParent</tt>.
*
* @param contactToMove the <tt>Contact</tt> to move
* @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt>
* would be placed.
*/
public void moveContactToGroup(Contact contactToMove,
ContactGroup newParent)
{
/** @todo implement moveContactToGroup() */
}
/**
* Requests the provider to enter into a status corresponding to the
* specified paramters.
*
* @param status the PresenceStatus as returned by
* getRequestableStatusSet
* @param statusMessage the message that should be set as the reason to
* enter that status
* @throws IllegalArgumentException if the status requested is not a
* valid PresenceStatus supported by this provider.
* @throws IllegalStateException if the provider is not currently
* registered.
* @throws OperationFailedException with code NETWORK_FAILURE if
* publishing the status fails due to a network error.
*/
public void publishPresenceStatus(PresenceStatus status,
String statusMessage) throws
IllegalArgumentException, IllegalStateException,
OperationFailedException
{
/** @todo implement publishPresenceStatus() */
}
/**
* Get the PresenceStatus for a particular contact.
*
* @param contactIdentifier the identifier of the contact whose status
* we're interested in.
* @return PresenceStatus the <tt>PresenceStatus</tt> of the specified
* <tt>contact</tt>
* @throws IllegalArgumentException if <tt>contact</tt> is not a contact
* known to the underlying protocol provider
* @throws IllegalStateException if the underlying protocol provider is
* not registered/signed on a public service.
* @throws OperationFailedException with code NETWORK_FAILURE if
* retrieving the status fails due to errors experienced during
* network communication
*/
public PresenceStatus queryContactStatus(String contactIdentifier) throws
IllegalArgumentException, IllegalStateException,
OperationFailedException
{
return IcqStatusEnum.ONLINE;
}
/**
* Removes the specified listener so that it won't receive any further
* updates on contact presence status changes
*
* @param listener the listener to remove.
*/
public void removeContactPresenceStatusListener(
ContactPresenceStatusListener listener)
{
/** @todo implement removeContactPresenceStatusListener() */
}
/**
* Unregisters the specified listener so that it does not receive further
* events upon changes in local presence status.
*
* @param listener ProviderPresenceStatusListener
*/
public void removeProviderPresenceStatusListener(
ProviderPresenceStatusListener listener)
{
/** @todo implement removeProviderPresenceStatusListener() */
}
/**
* Removes the specified group from the server stored contact list.
*
* @param group the group to remove.
*/
public void removeServerStoredContactGroup(ContactGroup group)
{
/** @todo implement removeServerStoredContactGroup() */
}
/**
* Removes the specified group change listener so that it won't receive
* any further events.
*
* @param listener the ServerStoredGroupChangeListener to remove
*/
public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
listener)
{
/** @todo implement removeServerStoredGroupChangeListener() */
}
/**
* Removes the specified subscription listener.
*
* @param listener the listener to remove.
*/
public void removeSubsciptionListener(SubscriptionListener listener)
{
/** @todo implement removeSubsciptionListener() */
}
/**
* Renames the specified group from the server stored contact list.
*
* @param group the group to rename.
* @param newName the new name of the group.
*/
public void renameServerStoredContactGroup(ContactGroup group,
String newName)
{
/** @todo implement renameServerStoredContactGroup() */
}
/**
* Handler for incoming authorization requests.
*
* @param handler an instance of an AuthorizationHandler for
* authorization requests coming from other users requesting
* permission add us to their contact list.
*/
public void setAuthorizationHandler(AuthorizationHandler handler)
{
/** @todo implement setAuthorizationHandler() */
}
/**
* Persistently adds a subscription for the presence status of the
* contact corresponding to the specified contactIdentifier and indicates
* that it should be added to the specified group of the server stored
* contact list.
*
* @param parent the parent group of the server stored contact list
* where the contact should be added. <p>
* @param contactIdentifier the contact whose status updates we are
* subscribing for.
* @throws IllegalArgumentException if <tt>contact</tt> or
* <tt>parent</tt> are not a contact known to the underlying protocol
* provider.
* @throws IllegalStateException if the underlying protocol provider is
* not registered/signed on a public service.
* @throws OperationFailedException with code NETWORK_FAILURE if
* subscribing fails due to errors experienced during network
* communication
*/
public void subscribe(ContactGroup parent, String contactIdentifier) throws
IllegalArgumentException, IllegalStateException,
OperationFailedException
{
/** @todo implement subscribe() */
}
/**
* Adds a subscription for the presence status of the contact
* corresponding to the specified contactIdentifier.
*
* @param contactIdentifier the identifier of the contact whose status
* updates we are subscribing for. <p>
* @throws IllegalArgumentException if <tt>contact</tt> is not a contact
* known to the underlying protocol provider
* @throws IllegalStateException if the underlying protocol provider is
* not registered/signed on a public service.
* @throws OperationFailedException with code NETWORK_FAILURE if
* subscribing fails due to errors experienced during network
* communication
*/
public void subscribe(String contactIdentifier) throws
IllegalArgumentException, IllegalStateException,
OperationFailedException
{
/** @todo implement subscribe() */
}
/**
* Removes a subscription for the presence status of the specified
* contact.
*
* @param contact the contact whose status updates we are unsubscribing
* from.
* @throws IllegalArgumentException if <tt>contact</tt> is not a contact
* known to the underlying protocol provider
* @throws IllegalStateException if the underlying protocol provider is
* not registered/signed on a public service.
* @throws OperationFailedException with code NETWORK_FAILURE if
* unsubscribing fails due to errors experienced during network
* communication
*/
public void unsubscribe(Contact contact) throws IllegalArgumentException,
IllegalStateException, OperationFailedException
{
/** @todo implement unsubscribe() */
}
}

@ -2,11 +2,25 @@
import org.osgi.framework.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.slick.contactlist.mockprovider.*;
/**
* Fields, commonly used by the MetaContactListSlick.
*
* @author Emil Ivov
*/
public class MclSlickFixture
extends junit.framework.TestCase
{
/**
* The bundle context that we received when the slick was activated.
*/
public static BundleContext bundleContext = null;
/**
* A reference to the meta contact list service currently available on the
* OSGI bus.
*/
public MetaContactListService metaClService = null;
public MclSlickFixture(Object obj)
@ -19,6 +33,7 @@ public MclSlickFixture(Object obj)
*/
public void setUp()
{
//find a reference to the meta contaact list service.
ServiceReference ref = bundleContext.getServiceReference(
MetaContactListService.class.getName());
metaClService
@ -26,6 +41,9 @@ public void setUp()
}
/**
*
*/
public void tearDown()
{
}

@ -10,9 +10,16 @@
import org.osgi.framework.*;
import net.java.sip.communicator.util.*;
import java.util.*;
import net.java.sip.communicator.slick.contactlist.mockprovider.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.contactlist.*;
/**
* Performs testing of the MetaContactListService.
* Performs testing of the MetaContactListService. This SLICK would register
* a mock protocol provider, manually fill in its protocol specific contact
* list and then verify that it is proparly retrieved and manipulated by the
* tested implementation of the MetaContactListService implementation.
*
* @author Emil Ivov
*/
public class MetaContactListServiceLick
@ -23,29 +30,105 @@ public class MetaContactListServiceLick
Logger.getLogger(MetaContactListServiceLick.class);
/**
* Register.
* A reference to the registration of the mock provider.
*/
private ServiceRegistration mockProviderRegistration = null;
/**
* Start, init and register the SLICK. Create the mock protocol provider
* and register it as a service.
*
* @param context a currently valid bundle context.
*/
public void start(BundleContext context) throws Exception
public void start(BundleContext context)
{
MclSlickFixture.bundleContext = context;
setName("MetaContactListServiceLick");
Hashtable properties = new Hashtable();
properties.put("service.pid", getName());
Hashtable slickServiceProperties = new Hashtable();
slickServiceProperties.put("service.pid", getName());
logger.debug("Service " + getClass().getName() + " [ STARTED ]");
//initialize and register a mock protocol provider that woul fill the
//meta contact list with dummy data.
initMockProvider(context);
//add the meta contact list tests.
addTestSuite(TestMetaContactList.class);
context.registerService(getClass().getName(), this, properties);
//register the slick itself
context.registerService(getClass().getName(), this, slickServiceProperties);
logger.debug("Service " + getClass().getName() + " [REGISTERED]");
}
/**
* Unregisters the mock provider that we registered in <tt>start()</tt>.
*
* @param context a currently valid bundle context
*/
public void stop(BundleContext context)
{
mockProviderRegistration.unregister();
}
/**
* Initializes the mock provider.
*
* @param context a currently valid bundle context.
*/
public void stop(BundleContext context) throws Exception
private void initMockProvider(BundleContext context)
{
//create and init an instance of a MockProvider
MockProvider provider = new MockProvider();
//fill the provider with dummy contacts and contact groups
fillMockContactList(provider);
//in order to make sure that only our mock provider will be taken into
//account by the meta contact list implementation, we need to set the
//provider mask both as a system property and as one of the service
//properties of the newly registered provider.
System.setProperty(MetaContactListService.PROVIDER_MASK_PROPERTY, "1");
Hashtable mockProvProperties = new Hashtable();
mockProvProperties.put(MetaContactListService.PROVIDER_MASK_PROPERTY,
"1");
mockProviderRegistration = context.registerService(
ProtocolProviderService.class.getName(),
provider,
mockProvProperties);
logger.debug("Registerd a mock protocol provider!");
}
/**
* Creates a number of dummy contacts and fills the specified provider with
* them.
* @param provider the <tt>MockProvider</tt> to fill in.
*/
private void fillMockContactList(MockProvider provider)
{
MockPersistentPresenceOperationSet mockOpSet
= (MockPersistentPresenceOperationSet)provider.
getSupportedOperationSets().get( OperationSetPersistentPresence.
class.getName());
MockContactGroup root =
(MockContactGroup)mockOpSet.getServerStoredContactListRoot();
root.addContact( new MockContact("Ivan Ivanov", provider) );
root.addContact( new MockContact("Martin Dupont", provider) );
root.addContact( new MockContact("Joe Bloggs", provider) );
MockContactGroup group1 = new MockContactGroup("SomePeople", provider);
group1.addContact( new MockContact("Spencer", provider) );
group1.addContact( new MockContact("Pencho", provider) );
group1.addContact( new MockContact("Toto", provider) );
root.addSubGroup(group1);
}
}

@ -1,6 +1,7 @@
package net.java.sip.communicator.slick.contactlist;
import junit.framework.*;
import net.java.sip.communicator.service.contactlist.*;
/**
* Test basic meta contact list functionality such as filling in the contact
@ -15,11 +16,19 @@ public class TestMetaContactList
*/
MclSlickFixture fixture = new MclSlickFixture(getClass().getName());
/**
* Creates a unit test with the specified name.
* @param name the name of one of the test methods in this class.
*/
public TestMetaContactList(String name)
{
super(name);
}
/**
* Initialize the environment.
* @throws Exception if anything goes wrong.
*/
protected void setUp() throws Exception
{
super.setUp();
@ -27,14 +36,24 @@ protected void setUp() throws Exception
}
/**
* Finalization
* @throws Exception in case sth goes wrong.
*/
protected void tearDown() throws Exception
{
fixture.tearDown();
super.tearDown();
}
/**
* Verifies that the contacts retrieved by the meta contact list service,
* match those that were in the mock provider.
*/
public void testContactListRetrieving()
{
MetaContactGroup listRoot = fixture.metaClService.getRoot();
System.out.println("!!! Meta Contact List Root = " + listRoot);
}
}

@ -10,4 +10,5 @@ Import-Package: net.java.sip.communicator.service.contactlist,
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.icqconstants,
net.java.sip.communicator.service.protocol.event

@ -20,8 +20,31 @@
public class MockProvider
implements ProtocolProviderService
{
/**
* The SIP Communicator Mock Protocol name.
*/
private static final String PROTO_NAME = "TheSipCommMockProtocol";
/**
* The operation sets that our mock provider supports.
*/
private Hashtable supportedOperationSets = new Hashtable();
/**
* The presence operation set supported by the mock provider.
*/
private MockPersistentPresenceOperationSet mockPresOpSet = null;
/**
* Creates an instance of this mockprovider with a ttsupportedOperationSet-s
* map set to contain a single persistent presence operation set.
*/
public MockProvider()
{
mockPresOpSet = new MockPersistentPresenceOperationSet(this);
this.supportedOperationSets.put(
OperationSetPersistentPresence.class.getName(),
mockPresOpSet);
}
/**
@ -37,21 +60,21 @@ public void addRegistrationStateChangeListener(
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @return an empty.
* @return a String describing this mock protocol.
*/
public String getProtocolName()
{
return "";
return PROTO_NAME;
}
/**
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @return a null ProviderRegistrationState
* @return a Registered RegistrationState.
*/
public RegistrationState getRegistrationState()
{
return null;
return RegistrationState.REGISTERED;
}
/**
@ -64,7 +87,7 @@ public RegistrationState getRegistrationState()
*/
public Map getSupportedOperationSets()
{
return null;
return this.supportedOperationSets;
}
/**
@ -78,52 +101,35 @@ public boolean isRegistered()
}
/**
* Starts the registration process.
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param authority the security authority that will be used for
* resolving any security challenges that may be returned during the
* registration or at any moment while wer're registered.
* @todo Implement this
* net.java.sip.communicator.service.protocol.ProtocolProviderService
* method
* @param authority a dummy param
*/
public void register(SecurityAuthority authority)
{
}
/**
* Removes the specified listener.
* Mock implementation of the corresponding ProtocolProviderService method.
*
* @param listener the listener to remove.
* @todo Implement this
* net.java.sip.communicator.service.protocol.ProtocolProviderService
* method
* @param listener a dummy param.
*/
public void removeRegistrationStateChangeListener(
RegistrationStateChangeListener listener)
{
}
/**
* Makes the service implementation close all open sockets and release
* any resources that it might have taken and prepare for
* shutdown/garbage collection.
*
* @todo Implement this
* net.java.sip.communicator.service.protocol.ProtocolProviderService
* method
* Mock implementation of the corresponding ProtocolProviderService method.
*/
public void shutdown()
{
}
/**
* Ends the registration of this protocol provider with the current
* registration service.
*
* @todo Implement this
* net.java.sip.communicator.service.protocol.ProtocolProviderService
* method
* Mock implementation of the corresponding ProtocolProviderService method.
*/
public void unregister()
{

@ -112,17 +112,6 @@ public void start(BundleContext bundleContext) throws Exception
public void stop(BundleContext bundleContext) throws Exception
{
IcqSlickFixture.testerAgent.unregister();
uninstallTestIcqAccount();
}
/**
* Uninstalls the test icq account used IcqProtocolProvider tests
*/
private void uninstallTestIcqAccount()
{
//sign the corresponding protocol provider off icq
//uninstall the account
}
/**

@ -728,7 +728,7 @@ public void gotBuddyStatus(BuddyService service, Screenname buddy,
}
}
else
System.out.println("no extra info.");
logger.trace("no extra info.");
}
public void buddyOffline(BuddyService service, Screenname buddy)

Loading…
Cancel
Save