diff --git a/build.xml b/build.xml
index 9f47beae5..f44e188c4 100644
--- a/build.xml
+++ b/build.xml
@@ -131,10 +131,12 @@
+
-
+
+
@@ -625,5 +627,18 @@ javax.swing.event, javax.swing.border"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java
index 5c032ce2b..b49bd448f 100644
--- a/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java
+++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactGroupImpl.java
@@ -28,9 +28,11 @@ public class MetaContactGroupImpl
private final List dummySubgroupsList = new LinkedList();
/**
- * The protocol specific group that this groups encapsulates.
+ * All protocol specific contact groups encapsulated by this
+ * MetaContactGoup.
*/
- private Vector protoGroups = new Vector();
+ private Hashtable protoGroups = new Hashtable();
+
private String groupName = null;
@@ -168,17 +170,19 @@ public Iterator getSubgroups()
}
/**
- * Returns an Iterator over all protocol specific groups that
- * this group encapsulates.
- * @return Iterator
+ * Adds the specified group to the list of protocol specific
+ * groups merged by this MetaContactGroup.
+ * @param owner the ProtocolProviderService where the specified group came
+ * from.
+ * @param group the ContactGroup to add merge into this
+ * MetaContactGroup.
*/
- Iterator getProtoGroups()
+ public void addProtoGroup(ProtocolProviderService owner,
+ ContactGroup group)
{
- return protoGroups.iterator();
+ this.protoGroups.put(owner, group);
}
-// public void addProtoGroup(ContactGroup group)
-
/**
* Verifies whether a protocol specific ContactGroup with the specified
* name and originating from the specified provider is encapsulated by this
diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
index 842793b1c..acb490a44 100644
--- a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
@@ -26,6 +26,9 @@
* properly if the underlying service providers have already been loaded at the
* time this one gets started.
*
+ * @todo might be a good idea to say that the implementation does not support
+ * subgroups.
+ *
* @author Emil Ivov
*/
public class MetaContactListServiceImpl
@@ -332,17 +335,39 @@ public MetaContact findMetaContactByID(String metaContactID)
* sure they are all present in the local contact list.
* @param presenceOpSet the presence operation set whose contact list we'd
* like to synchronize with the local contact list.
+ * @param provider the provider that the operation set belongs to.
*/
private void synchronizeOpSetWithServerContactList(
+ ProtocolProviderService provider,
OperationSetPersistentPresence presenceOpSet)
{
ContactGroup rootProtoGroup
= presenceOpSet.getServerStoredContactListRoot();
+ logger.trace("subgroups: " + rootProtoGroup.countSubGroups());
+
+ //first register the root group
+ rootMetaGroup.registerProtocolSpecificRoot(
+ provider,
+ presenceOpSet.getServerStoredContactListRoot());
-// rootMetaGroup.addSubgroup();
+ //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();
- logger.trace("subgroups: " + rootProtoGroup.countSubGroups());
+ while(subgroupsIter.hasNext())
+ {
+ ContactGroup group = (ContactGroup)subgroupsIter.next();
+
+ //right now we simply map this group to an existing one
+ //without being cautious and verify whether we already have it
+ //registered
+ MetaContactGroupImpl newMetaGroup
+ = new MetaContactGroupImpl(group.getGroupName());
+
+ newMetaGroup.addProtoGroup(provider, group);
+ }
}
/**
@@ -367,7 +392,7 @@ private void handleProviderAdded(ProtocolProviderService provider)
//If we have a persistent presence op set - then retrieve its contat
//list and merge it with the local one.
if( opSetPersPresence != null ){
- synchronizeOpSetWithServerContactList(opSetPersPresence);
+ synchronizeOpSetWithServerContactList(provider, opSetPersPresence);
}
/** @todo implement handling non persistent presence operation sets */
diff --git a/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java b/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java
index 61d6f5d8c..983e2418a 100644
--- a/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java
+++ b/src/net/java/sip/communicator/impl/contactlist/RootMetaContactGroupImpl.java
@@ -3,6 +3,7 @@
import java.util.*;
import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.protocol.*;
/**
* An implementation of the meta contact group that would only be used for the
@@ -23,8 +24,17 @@ public class RootMetaContactGroupImpl
*/
private List dummyContacts = new LinkedList();
+ /**
+ * The name of the group (fixed for root groups since it won't show).
+ */
private static final String groupName = "RootMetaContactGroup";
+ /**
+ * The root groups for all protocol contact lists that we've detected so
+ * far, mapped against their owner protocol providers.
+ */
+ private Hashtable protoGroups = new Hashtable();
+
/**
* Creates an instance of the root meta contact group.
*/
@@ -158,11 +168,17 @@ public String getGroupName()
return groupName;
}
-
-
- void addProtocolSpecificGroup()
+ /**
+ * Addes the specified group to the list of protocol specific roots
+ * that we're encapsulating in this meta contact list.
+ * @param protoRoot the root to add to the groups merged in this meta contact
+ * group.
+ * @param ownerProtocol the protocol that the specified group came from.
+ */
+ void registerProtocolSpecificRoot(
+ ProtocolProviderService ownerProtocol, ContactGroup protoRoot)
{
-
+ protoGroups.put(ownerProtocol, protoRoot);
}
/**
@@ -177,7 +193,7 @@ void addSubgroup(MetaContactGroup subgroup)
/**
* Removes the meta contact group with the specified index.
- * @param the index index of the group to remove.
+ * @param index the index of the group to remove.
* @return the MetaContactGroup that has just been removed.
*/
MetaContactGroupImpl removeSubgroup(int index)
diff --git a/src/net/java/sip/communicator/service/contactlist/MetaContact.java b/src/net/java/sip/communicator/service/contactlist/MetaContact.java
index dba601112..a87ffc332 100644
--- a/src/net/java/sip/communicator/service/contactlist/MetaContact.java
+++ b/src/net/java/sip/communicator/service/contactlist/MetaContact.java
@@ -73,4 +73,10 @@ public interface MetaContact
* @return a human readable String that represents this meta contact.
*/
public String getDisplayName();
+
+ /**
+ * Returns a String representation of this MetaContact.
+ * @return a String representation of this MetaContact.
+ */
+ public String toString();
}
diff --git a/src/net/java/sip/communicator/service/contactlist/MetaContactGroup.java b/src/net/java/sip/communicator/service/contactlist/MetaContactGroup.java
index 301036785..9b89c8a27 100644
--- a/src/net/java/sip/communicator/service/contactlist/MetaContactGroup.java
+++ b/src/net/java/sip/communicator/service/contactlist/MetaContactGroup.java
@@ -112,4 +112,11 @@ public MetaContact getMetaContact(int index)
public MetaContactGroup getMetaContactSubgroup(int index)
throws IndexOutOfBoundsException;
+ /**
+ * 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();
+
}
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java
index c54d69776..f1ed78771 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderService.java
@@ -99,4 +99,11 @@ public void removeRegistrationStateChangeListener(
* collection.
*/
public void shutdown();
+
+ /**
+ * A hashcode allowing usage of protocol providers as keys in Hashtables.
+ * @return an int that may be used when storing protocol providers as
+ * hashtable keys.
+ */
+ public int hashCode();
}