Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-02-14 02:20:56 -0500
committerslewis2014-02-14 02:20:56 -0500
commit4286c8c53e78bf08010b6c5cec30467b5530927f (patch)
tree9ed2956d7e67e3ca66aac11d6434afe2a5ba4b35
parent2e2b9cb53eb81bf7d1334e54cb234c5bd6672201 (diff)
downloadorg.eclipse.ecf-4286c8c53e78bf08010b6c5cec30467b5530927f.tar.gz
org.eclipse.ecf-4286c8c53e78bf08010b6c5cec30467b5530927f.tar.xz
org.eclipse.ecf-4286c8c53e78bf08010b6c5cec30467b5530927f.zip
Fix for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=392664
-rw-r--r--framework/bundles/org.eclipse.ecf.presence/META-INF/MANIFEST.MF2
-rw-r--r--framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IMultiResourceRosterEntry.java14
-rw-r--r--framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IRosterEntry.java3
-rw-r--r--framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterEntry.java58
-rw-r--r--framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterResource.java55
5 files changed, 128 insertions, 4 deletions
diff --git a/framework/bundles/org.eclipse.ecf.presence/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.presence/META-INF/MANIFEST.MF
index fcaa97cc6..4367d3307 100644
--- a/framework/bundles/org.eclipse.ecf.presence/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf.presence/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-Name: %plugin.name
Bundle-SymbolicName: org.eclipse.ecf.presence;singleton:=true
-Bundle-Version: 2.0.0.qualifier
+Bundle-Version: 2.1.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.presence.PresencePlugin
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IMultiResourceRosterEntry.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IMultiResourceRosterEntry.java
new file mode 100644
index 000000000..9277f37a5
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IMultiResourceRosterEntry.java
@@ -0,0 +1,14 @@
+package org.eclipse.ecf.presence.roster;
+
+/**
+ * @since 2.1
+ */
+public interface IMultiResourceRosterEntry {
+
+ /**
+ * Get all the resources for this multi resource roster entry
+ * @return IRosterResource[] of resources. Will not return <code>null</code>.
+ */
+ public IRosterResource[] getResources();
+
+}
diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IRosterEntry.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IRosterEntry.java
index 75c3ec601..5f77bfd1a 100644
--- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IRosterEntry.java
+++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/IRosterEntry.java
@@ -12,7 +12,6 @@
package org.eclipse.ecf.presence.roster;
import java.util.Collection;
-
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.presence.IPresence;
@@ -35,7 +34,7 @@ public interface IRosterEntry extends IRosterItem {
* Get groups associated with this roster entry. Instance in list are of
* type {@link IRosterGroup}
*
- * @return Iterator of groups that this roster entry belongs to. Will not
+ * @return Collection of IRosterGroup instances entry belongs to. Will not
* return <code>null</code>.
*/
public Collection getGroups();
diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterEntry.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterEntry.java
index fa33a6d12..691790808 100644
--- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterEntry.java
+++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterEntry.java
@@ -21,7 +21,7 @@ import org.eclipse.ecf.presence.IPresence;
* created as appropriate.
*
*/
-public class RosterEntry extends RosterItem implements IRosterEntry {
+public class RosterEntry extends RosterItem implements IRosterEntry, IMultiResourceRosterEntry {
protected IUser user;
@@ -29,6 +29,11 @@ public class RosterEntry extends RosterItem implements IRosterEntry {
protected List groups;
+ /**
+ * @since 2.1
+ */
+ protected List resources;
+
public RosterEntry(IRosterItem parent, IUser user, IPresence presenceState) {
Assert.isNotNull(parent);
Assert.isNotNull(user);
@@ -40,6 +45,7 @@ public class RosterEntry extends RosterItem implements IRosterEntry {
groups.add(parent);
((RosterGroup) parent).add(this);
}
+ this.resources = new ArrayList();
}
public void setPresence(IPresence newPresence) {
@@ -129,6 +135,7 @@ public class RosterEntry extends RosterItem implements IRosterEntry {
public String toString() {
StringBuffer sb = new StringBuffer("RosterEntry["); //$NON-NLS-1$
synchronized (sb) {
+ sb.append("userid=" + getUser().getID().getName()).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
sb.append("name=").append(getName()).append(';'); //$NON-NLS-1$
sb.append("presence=").append(presence).append(';'); //$NON-NLS-1$
sb.append("groups="); //$NON-NLS-1$
@@ -144,4 +151,53 @@ public class RosterEntry extends RosterItem implements IRosterEntry {
return sb.toString();
}
+ /**
+ * @since 2.1
+ */
+ public boolean updateResource(String resourceName, IPresence p) {
+ if (resourceName == null)
+ return false;
+ synchronized (resources) {
+ for (Iterator i = resources.iterator(); i.hasNext();) {
+ RosterResource r = (RosterResource) i.next();
+ if (r.getName().equals(resourceName)) {
+ r.setPresence(p);
+ return true;
+ }
+ }
+ resources.add(new RosterResource(this, resourceName, p));
+ return false;
+ }
+ }
+
+ /**
+ * @since 2.1
+ */
+ public RosterResource removeResource(String resourceName) {
+ if (resourceName == null)
+ return null;
+ RosterResource result = null;
+ synchronized (resources) {
+ for (Iterator i = resources.iterator(); i.hasNext();) {
+ RosterResource r = (RosterResource) i.next();
+ if (r.getName().equals(resourceName)) {
+ i.remove();
+ result = r;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * @since 2.1
+ */
+ public IRosterResource[] getResources() {
+ List result = null;
+ synchronized (resources) {
+ result = new ArrayList(resources);
+ }
+ return (IRosterResource[]) result.toArray(new IRosterResource[result.size()]);
+ }
+
}
diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterResource.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterResource.java
new file mode 100644
index 000000000..42c88e0f8
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/roster/RosterResource.java
@@ -0,0 +1,55 @@
+package org.eclipse.ecf.presence.roster;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.ecf.internal.presence.PresencePlugin;
+import org.eclipse.ecf.presence.IPresence;
+
+/**
+ * @since 2.1
+ */
+public class RosterResource implements IRosterResource {
+
+ private String name;
+ private IRosterEntry parent;
+ private IPresence presence;
+
+ public RosterResource(IRosterEntry parent, String name, IPresence presence) {
+ Assert.isNotNull(parent);
+ this.parent = parent;
+ Assert.isNotNull(name);
+ this.name = name;
+ this.presence = presence;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public IRosterItem getParent() {
+ return parent;
+ }
+
+ public IRoster getRoster() {
+ return parent.getRoster();
+ }
+
+ public Object getAdapter(Class adapter) {
+ if (adapter.isInstance(this)) {
+ return this;
+ }
+ IAdapterManager adapterManager = PresencePlugin.getDefault().getAdapterManager();
+ if (adapterManager == null)
+ return null;
+ return adapterManager.loadAdapter(this, adapter.getName());
+ }
+
+ public IPresence getPresence() {
+ return presence;
+ }
+
+ public void setPresence(IPresence presence) {
+ this.presence = presence;
+ }
+
+}

Back to the top