diff options
| author | slewis | 2005-02-13 23:12:30 +0000 |
|---|---|---|
| committer | slewis | 2005-02-13 23:12:30 +0000 |
| commit | c1b106761981846dc0fa7707b9a80b685f513acd (patch) | |
| tree | 23df90e864be17889ed7e8af7900c72814a94963 | |
| parent | 6cc7180e99c9d767e91bfddd359504a63c7aaf79 (diff) | |
| download | org.eclipse.ecf-c1b106761981846dc0fa7707b9a80b685f513acd.tar.gz org.eclipse.ecf-c1b106761981846dc0fa7707b9a80b685f513acd.tar.xz org.eclipse.ecf-c1b106761981846dc0fa7707b9a80b685f513acd.zip | |
Added IRosterEntry (to represent a buddy list/roster entry type), and an IRosterGroup (to represent a buddy list group...e.g. 'friends', type).
4 files changed, 222 insertions, 126 deletions
diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IPresence.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IPresence.java new file mode 100644 index 000000000..687ce9009 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IPresence.java @@ -0,0 +1,142 @@ +/* + * Created on Feb 13, 2005 + * + */ +package org.eclipse.ecf.ui.presence; + +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.util.Map; +import org.eclipse.core.runtime.IAdaptable; + +public interface IPresence extends IAdaptable, Serializable { + + public Mode getMode(); + public int getPriority(); + public Map getProperties(); + public String getStatus(); + public Type getType(); + + /** + * A type-safe enum class to represent the presence type information + * + */ + public static class Type implements Serializable { + + private static final String AVAILABLE_NAME = "available"; + private static final String ERROR_NAME = "error"; + private static final String SUBSCRIBE_NAME = "subscribe"; + private static final String UNAVAILABLE_NAME = "unavailable"; + private static final String UNSUBSCRIBE_NAME = "unsubscribe"; + private static final String UNSUBSCRIBED_NAME = "unsubscribed"; + private static final String UNKWOWN_NAME = "unknown"; + + private final transient String name; + // Protected constructor so that only subclasses are allowed to create instances + protected Type(String name) { + this.name = name; + } + public static Type fromString(String presenceType) { + if (presenceType == null) return null; + if (presenceType.equals(AVAILABLE_NAME)) { + return AVAILABLE; + } else if (presenceType.equals(ERROR_NAME)) { + return ERROR; + } else if (presenceType.equals(SUBSCRIBE_NAME)) { + return SUBSCRIBE; + } else if (presenceType.equals(UNAVAILABLE_NAME)) { + return UNAVAILABLE; + } else if (presenceType.equals(UNSUBSCRIBE_NAME)) { + return UNSUBSCRIBE; + } else if (presenceType.equals(UNSUBSCRIBED_NAME)) { + return UNSUBSCRIBED; + } else if (presenceType.equals(UNKWOWN_NAME)) { + return UNKNOWN; + } else return null; + } + + public static final Type AVAILABLE = new Type(AVAILABLE_NAME); + public static final Type ERROR = new Type(ERROR_NAME); + public static final Type SUBSCRIBE = new Type(SUBSCRIBE_NAME); + public static final Type UNAVAILABLE = new Type(UNAVAILABLE_NAME); + public static final Type UNSUBSCRIBE = new Type(UNSUBSCRIBE_NAME); + public static final Type UNSUBSCRIBED = new Type(UNSUBSCRIBED_NAME); + public static final Type UNKNOWN = new Type(UNKWOWN_NAME); + + public String toString() { return name; } + // This is to make sure that subclasses don't screw up these methods + public final boolean equals(Object that) { + return super.equals(that); + } + public final int hashCode() { + return super.hashCode(); + } + // For serialization + private static int nextOrdinal = 0; + private final int ordinal = nextOrdinal++; + private static final Type [] VALUES = { AVAILABLE, ERROR, SUBSCRIBE, UNAVAILABLE, UNSUBSCRIBE, UNSUBSCRIBED, UNKNOWN }; + Object readResolve() throws ObjectStreamException { + return VALUES[ordinal]; + } + } + + /** + * A type-safe enum class to represent the presence mode information + * + */ + public static class Mode implements Serializable { + + private static final String AVAILABLE_NAME = "available"; + private static final String AWAY_NAME = "away"; + private static final String CHAT_NAME = "chat"; + private static final String DND_NAME = "do not disturb"; + private static final String EXTENDED_AWAY_NAME = "extended away"; + private static final String INVISIBLE_NAME = "unsubscribed"; + + private final transient String name; + // Protected constructor so that only subclasses are allowed to create instances + protected Mode(String name) { + this.name = name; + } + public static Mode fromString(String presenceMode) { + if (presenceMode == null) return null; + if (presenceMode.equals(AVAILABLE_NAME)) { + return AVAILABLE; + } else if (presenceMode.equals(AWAY_NAME)) { + return AWAY; + } else if (presenceMode.equals(CHAT_NAME)) { + return CHAT; + } else if (presenceMode.equals(DND_NAME)) { + return DND; + } else if (presenceMode.equals(EXTENDED_AWAY_NAME)) { + return EXTENDED_AWAY; + } else if (presenceMode.equals(INVISIBLE_NAME)) { + return INVISIBLE; + } else return null; + } + + public static final Mode AVAILABLE = new Mode(AVAILABLE_NAME); + public static final Mode AWAY = new Mode(AWAY_NAME); + public static final Mode CHAT = new Mode(CHAT_NAME); + public static final Mode DND = new Mode(DND_NAME); + public static final Mode EXTENDED_AWAY = new Mode(EXTENDED_AWAY_NAME); + public static final Mode INVISIBLE = new Mode(INVISIBLE_NAME); + + public String toString() { return name; } + // This is to make sure that subclasses don't screw up these methods + public final boolean equals(Object that) { + return super.equals(that); + } + public final int hashCode() { + return super.hashCode(); + } + // For serialization + private static int nextOrdinal = 0; + private final int ordinal = nextOrdinal++; + private static final Mode [] VALUES = { AVAILABLE, AWAY, CHAT, DND, EXTENDED_AWAY, INVISIBLE }; + Object readResolve() throws ObjectStreamException { + return VALUES[ordinal]; + } + } + +} diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IRosterEntry.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IRosterEntry.java new file mode 100644 index 000000000..db00b6ff3 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IRosterEntry.java @@ -0,0 +1,62 @@ +/* + * Created on Feb 13, 2005 + * + */ +package org.eclipse.ecf.ui.presence; + +import java.util.Iterator; +import org.eclipse.ecf.core.identity.ID; + +public interface IRosterEntry { + + public Iterator getGroups(); + public String getName(); + public ID getUserID(); + public void setName(String name); + public InterestType getInterestType(); + + public static class InterestType { + + private static final String BOTH_NAME = "both"; + private static final String FROM_NAME = "from"; + private static final String NONE_NAME = "none"; + private static final String REMOVE_NAME = "remove"; + private static final String TO_NAME = "to"; + + private final transient String name; + // Protected constructor so that only subclasses are allowed to create instances + protected InterestType(String name) { + this.name = name; + } + public static InterestType fromString(String itemType) { + if (itemType == null) return null; + if (itemType.equals(BOTH_NAME)) { + return BOTH; + } else if (itemType.equals(FROM_NAME)) { + return FROM; + } else if (itemType.equals(NONE_NAME)) { + return NONE; + } else if (itemType.equals(REMOVE_NAME)) { + return REMOVE; + } else if (itemType.equals(TO_NAME)) { + return TO; + } else return null; + } + + public static final InterestType BOTH = new InterestType(BOTH_NAME); + public static final InterestType FROM = new InterestType(FROM_NAME); + public static final InterestType NONE = new InterestType(NONE_NAME); + public static final InterestType REMOVE = new InterestType(REMOVE_NAME); + public static final InterestType TO = new InterestType(TO_NAME); + + public String toString() { return name; } + // This is to make sure that subclasses don't screw up these methods + public final boolean equals(Object that) { + return super.equals(that); + } + public final int hashCode() { + return super.hashCode(); + } + } + +} diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IRosterGroup.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IRosterGroup.java new file mode 100644 index 000000000..03d6c01c4 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/IRosterGroup.java @@ -0,0 +1,17 @@ +/* + * Created on Feb 13, 2005 + * + */ +package org.eclipse.ecf.ui.presence; + +import java.util.Iterator; +import org.eclipse.ecf.core.identity.ID; + +public interface IRosterGroup { + public IRosterEntry add(ID entryID, IRosterEntry entry); + public IRosterEntry contains(ID entryID); + public Iterator getRosterEntries(); + public int size(); + public String getName(); + public IRosterEntry removeEntry(IRosterEntry entry); +} diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/Presence.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/Presence.java index 0ba082e52..f586949ae 100644 --- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/Presence.java +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/presence/Presence.java @@ -4,13 +4,10 @@ */ package org.eclipse.ecf.ui.presence; -import java.io.ObjectStreamException; -import java.io.Serializable; import java.util.Map; import java.util.Properties; -import org.eclipse.core.runtime.IAdaptable; -public class Presence implements Serializable, IAdaptable { +public class Presence implements IPresence { protected Type type; protected Mode mode; @@ -52,128 +49,6 @@ public class Presence implements Serializable, IAdaptable { public Type getType() { return type; } - /** - * A type-safe enum class to represent the presence type information - * - */ - public static class Type implements Serializable { - - private static final String AVAILABLE_NAME = "available"; - private static final String ERROR_NAME = "error"; - private static final String SUBSCRIBE_NAME = "subscribe"; - private static final String UNAVAILABLE_NAME = "unavailable"; - private static final String UNSUBSCRIBE_NAME = "unsubscribe"; - private static final String UNSUBSCRIBED_NAME = "unsubscribed"; - private static final String UNKWOWN_NAME = "unknown"; - - private final transient String name; - // Protected constructor so that only subclasses are allowed to create instances - protected Type(String name) { - this.name = name; - } - public static Type fromString(String presenceType) { - if (presenceType == null) return null; - if (presenceType.equals(AVAILABLE_NAME)) { - return AVAILABLE; - } else if (presenceType.equals(ERROR_NAME)) { - return ERROR; - } else if (presenceType.equals(SUBSCRIBE_NAME)) { - return SUBSCRIBE; - } else if (presenceType.equals(UNAVAILABLE_NAME)) { - return UNAVAILABLE; - } else if (presenceType.equals(UNSUBSCRIBE_NAME)) { - return UNSUBSCRIBE; - } else if (presenceType.equals(UNSUBSCRIBED_NAME)) { - return UNSUBSCRIBED; - } else if (presenceType.equals(UNKWOWN_NAME)) { - return UNKNOWN; - } else return null; - } - - public static final Type AVAILABLE = new Type(AVAILABLE_NAME); - public static final Type ERROR = new Type(ERROR_NAME); - public static final Type SUBSCRIBE = new Type(SUBSCRIBE_NAME); - public static final Type UNAVAILABLE = new Type(UNAVAILABLE_NAME); - public static final Type UNSUBSCRIBE = new Type(UNSUBSCRIBE_NAME); - public static final Type UNSUBSCRIBED = new Type(UNSUBSCRIBED_NAME); - public static final Type UNKNOWN = new Type(UNKWOWN_NAME); - - public String toString() { return name; } - // This is to make sure that subclasses don't screw up these methods - public final boolean equals(Object that) { - return super.equals(that); - } - public final int hashCode() { - return super.hashCode(); - } - // For serialization - private static int nextOrdinal = 0; - private final int ordinal = nextOrdinal++; - private static final Type [] VALUES = { AVAILABLE, ERROR, SUBSCRIBE, UNAVAILABLE, UNSUBSCRIBE, UNSUBSCRIBED, UNKNOWN }; - Object readResolve() throws ObjectStreamException { - return VALUES[ordinal]; - } - } - - /** - * A type-safe enum class to represent the presence mode information - * - */ - public static class Mode implements Serializable { - - private static final String AVAILABLE_NAME = "available"; - private static final String AWAY_NAME = "away"; - private static final String CHAT_NAME = "chat"; - private static final String DND_NAME = "do not disturb"; - private static final String EXTENDED_AWAY_NAME = "extended away"; - private static final String INVISIBLE_NAME = "unsubscribed"; - - private final transient String name; - // Protected constructor so that only subclasses are allowed to create instances - protected Mode(String name) { - this.name = name; - } - public static Mode fromString(String presenceMode) { - if (presenceMode == null) return null; - if (presenceMode.equals(AVAILABLE_NAME)) { - return AVAILABLE; - } else if (presenceMode.equals(AWAY_NAME)) { - return AWAY; - } else if (presenceMode.equals(CHAT_NAME)) { - return CHAT; - } else if (presenceMode.equals(DND_NAME)) { - return DND; - } else if (presenceMode.equals(EXTENDED_AWAY_NAME)) { - return EXTENDED_AWAY; - } else if (presenceMode.equals(INVISIBLE_NAME)) { - return INVISIBLE; - } else return null; - } - - public static final Mode AVAILABLE = new Mode(AVAILABLE_NAME); - public static final Mode AWAY = new Mode(AWAY_NAME); - public static final Mode CHAT = new Mode(CHAT_NAME); - public static final Mode DND = new Mode(DND_NAME); - public static final Mode EXTENDED_AWAY = new Mode(EXTENDED_AWAY_NAME); - public static final Mode INVISIBLE = new Mode(INVISIBLE_NAME); - - public String toString() { return name; } - // This is to make sure that subclasses don't screw up these methods - public final boolean equals(Object that) { - return super.equals(that); - } - public final int hashCode() { - return super.hashCode(); - } - // For serialization - private static int nextOrdinal = 0; - private final int ordinal = nextOrdinal++; - private static final Mode [] VALUES = { AVAILABLE, AWAY, CHAT, DND, EXTENDED_AWAY, INVISIBLE }; - Object readResolve() throws ObjectStreamException { - return VALUES[ordinal]; - } - } - /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ |
