diff options
| author | slewis | 2005-04-12 01:58:56 +0000 |
|---|---|---|
| committer | slewis | 2005-04-12 01:58:56 +0000 |
| commit | 1c1c8218073cb72d49ffc71739e26892a311a379 (patch) | |
| tree | 06f024365732b59ac0cf19dca0caa9f890ef27bd | |
| parent | 096bbbafced644b54a19b0e20231ff7c35ef7907 (diff) | |
| download | org.eclipse.ecf-1c1c8218073cb72d49ffc71739e26892a311a379.tar.gz org.eclipse.ecf-1c1c8218073cb72d49ffc71739e26892a311a379.tar.xz org.eclipse.ecf-1c1c8218073cb72d49ffc71739e26892a311a379.zip | |
Fixed UI bug for ECF Buddy List view. Added new functionality: 1) new images for active/inactive user in org.eclipse.ecf.ui. 2) Changed behavior of rosterview to better handle groups, and to display number available and total in group. 3) Added new API for handling subscribe/unsubscribe requests (ISubscribeListener); 4) Added code in collab example client to demonstrate use of ISubscribeListener API; 5) Added support in provider org.eclipse.ecf.provider.xmpp. 6) Replaced version of Smack jars with one based upon 1.5.1 of Smack libraries...after removing copyrighted images and replacing StringUtils.encodeHex
24 files changed, 931 insertions, 185 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch index cf9186ed5..2b7268345 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch +++ b/examples/bundles/org.eclipse.ecf.example.collab/launchconfigs/ECF Example Collab Client 1.launch @@ -1,50 +1,44 @@ <?xml version="1.0" encoding="UTF-8"?> <launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench"> <stringAttribute key="product" value="org.eclipse.platform.ide"/> -<booleanAttribute key="clearws" value="false"/> <booleanAttribute key="usefeatures" value="false"/> <stringAttribute key="bootstrap" value=""/> <booleanAttribute key="useProduct" value="false"/> -<booleanAttribute key="tracing" value="false"/> -<stringAttribute key="location1" value="C:\eclipse3.1m4\eclipse\runtime-workspace"/> +<booleanAttribute key="tracing" value="true"/> <stringAttribute key="location2" value="C:\eclipse3.1m4\eclipse\second-runtime-workspace"/> -<stringAttribute key="templateConfig" value=""/> -<booleanAttribute key="default" value="true"/> -<stringAttribute key="vmargs" value=""/> -<booleanAttribute key="clearConfig" value="true"/> <mapAttribute key="tracingOptions"> <mapEntry key="org.eclipse.ecf.example.collab/debug/urlsharedobject" value="false"/> -<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/xmppsharedobject" value="true"/> <mapEntry key="org.eclipse.team.cvs.core/syncchangeevents" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/xmppsharedobject" value="true"/> <mapEntry key="org.eclipse.ecf.provider.xmpp/debug/smackconnection" value="true"/> <mapEntry key="org.eclipse.help.webapp/debug/workingsets" value="false"/> -<mapEntry key="org.eclipse.ecf.example.collab/debug" value="true"/> <mapEntry key="org.eclipse.core.runtime/strings" value="false"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug" value="true"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/filter/loader" value="*"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/actions" value="false"/> <mapEntry key="org.eclipse.core.runtime/timing/shutdown" value="false"/> -<mapEntry key="org.eclipse.jface.text/debug/ContentAssistSubjectAdapters" value="false"/> <mapEntry key="org.eclipse.core.runtime/url/debug/connect" value="false"/> +<mapEntry key="org.eclipse.jface.text/debug/ContentAssistSubjectAdapters" value="false"/> <mapEntry key="org.eclipse.core.resources/restore/markers" value="false"/> <mapEntry key="org.eclipse.core.resources/build/needbuild" value="false"/> <mapEntry key="org.eclipse.ui/trace/graphics" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/resolution" value="false"/> -<mapEntry key="org.eclipse.update.configurator/debug" value="false"/> <mapEntry key="org.eclipse.team.cvs.ssh/ssh_protocol" value="false"/> +<mapEntry key="org.eclipse.update.configurator/debug" value="false"/> <mapEntry key="org.eclipse.ecf.provider/debug/filter" value="*"/> <mapEntry key="org.eclipse.osgi/monitor/activation" value="false"/> <mapEntry key="org.eclipse.core.runtime/registry/debug" value="false"/> <mapEntry key="org.eclipse.osgi/debug/packages" value="false"/> -<mapEntry key="org.eclipse.core.runtime/loader/debug" value="false"/> <mapEntry key="org.eclipse.ui/debug/showSystemJobs" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug" value="false"/> <mapEntry key="org.eclipse.core.resources/monitor/listeners" value="false"/> <mapEntry key="org.eclipse.ant.core/debug" value="true"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes" value="false"/> <mapEntry key="org.eclipse.core.runtime/url/debug" value="false"/> <mapEntry key="org.eclipse.osgi/monitor/classes" value="false"/> <mapEntry key="org.eclipse.update.core/debug" value="true"/> -<mapEntry key="org.eclipse.core.runtime/debug/context" value="false"/> <mapEntry key="org.eclipse.osgi/eclipseadaptor/converter/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/debug/context" value="false"/> <mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin" value="false"/> <mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser" value="false"/> <mapEntry key="org.eclipse.ui/debug/swtdebug" value="false"/> @@ -55,14 +49,14 @@ <mapEntry key="org.eclipse.ecf/debug" value="true"/> <mapEntry key="org.eclipse.ui/trace/keyBindings" value="false"/> <mapEntry key="org.eclipse.ui.intro/trace/printHTML" value="false"/> -<mapEntry key="org.eclipse.jdt.ui/debug/TypeConstraints" value="false"/> <mapEntry key="org.eclipse.core.runtime/registry/debug/dump" value=""/> +<mapEntry key="org.eclipse.jdt.ui/debug/TypeConstraints" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/javadelta/verbose" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug" value="true"/> <mapEntry key="org.eclipse.core.expressions/tracePropertyResolving" value="false"/> <mapEntry key="org.eclipse.core.resources/restore" value="false"/> -<mapEntry key="org.eclipse.ecf.ui/debug/flag" value="true"/> <mapEntry key="org.eclipse.ecf/debug/filter" value="*"/> +<mapEntry key="org.eclipse.ecf.ui/debug/flag" value="true"/> <mapEntry key="org.eclipse.osgi/trace/filename" value="runtime.traces"/> <mapEntry key="org.eclipse.update.core/debug/web" value="false"/> <mapEntry key="org.eclipse.ecf.example.collab/debug/progsharedobject" value="false"/> @@ -70,8 +64,8 @@ <mapEntry key="org.eclipse.ecf.provider.xmpp/debug/flag" value="true"/> <mapEntry key="org.eclipse.core.runtime/registry/debug/resolve" value="false"/> <mapEntry key="org.eclipse.osgi/debug" value="false"/> -<mapEntry key="org.eclipse.osgi/trace/activation" value="false"/> <mapEntry key="org.eclipse.core.resources/build/delta" value="false"/> +<mapEntry key="org.eclipse.osgi/trace/activation" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/search" value="false"/> <mapEntry key="org.eclipse.ecf/debug/idfactory" value="false"/> <mapEntry key="org.eclipse.ecf/debug/connectionfactory" value="false"/> @@ -86,15 +80,15 @@ <mapEntry key="org.eclipse.update.core/debug/configuration" value="false"/> <mapEntry key="org.eclipse.ecf/debug/factoryinit" value="true"/> <mapEntry key="org.eclipse.ui/trace/part.activate" value="false"/> -<mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> -<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver" value="false"/> <mapEntry key="org.eclipse.osgi/trace/filters" value="trace.properties"/> +<mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/platformadmin/resolver" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug/infopop" value="false"/> <mapEntry key="org.eclipse.core.runtime/registry/debug/events/extension" value="false"/> -<mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> <mapEntry key="org.eclipse.help.webapp/debug" value="true"/> +<mapEntry key="org.eclipse.jdt.core/debug/hierarchy" value="false"/> <mapEntry key="org.eclipse.ecf.example.collab/debug/transactionsharedobject" value="true"/> -<mapEntry key="org.eclipse.team.cvs.core/debug" value="false"/> <mapEntry key="org.eclipse.core.resources/refresh" value="false"/> +<mapEntry key="org.eclipse.team.cvs.core/debug" value="false"/> <mapEntry key="org.eclipse.team.core/backgroundevents" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/cpresolution" value="false"/> <mapEntry key="org.eclipse.team.cvs.core/threading" value="false"/> @@ -102,12 +96,12 @@ <mapEntry key="org.eclipse.ecf.example.collab/debug/flag" value="true"/> <mapEntry key="org.eclipse.update.core/debug/warning" value="false"/> <mapEntry key="org.eclipse.core.resources/save" value="false"/> -<mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> <mapEntry key="org.eclipse.update.core/debug/install" value="false"/> -<mapEntry key="org.eclipse.core.runtime/jobs/errorondeadlock" value="false"/> +<mapEntry key="org.eclipse.ui/debug/internalerror/openDialog" value="false"/> <mapEntry key="org.eclipse.ecf.provider/debug/flag" value="true"/> -<mapEntry key="org.eclipse.core.resources/debug" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs/errorondeadlock" value="false"/> <mapEntry key="org.eclipse.help.ui/debug/embeddedBrowser/inprocess" value="false"/> +<mapEntry key="org.eclipse.core.resources/debug" value="false"/> <mapEntry key="org.eclipse.ecf.provider.xmpp/debug" value="true"/> <mapEntry key="org.eclipse.update.core/debug/parsing" value="false"/> <mapEntry key="org.eclipse.core.resources/restore/syncinfo" value="false"/> @@ -127,31 +121,31 @@ <mapEntry key="org.eclipse.ecf.ui/debug/filter" value="*"/> <mapEntry key="org.eclipse.ecf.provider/debug/basesharedobject" value="false"/> <mapEntry key="org.eclipse.osgi/debug/services" value="false"/> -<mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/activateplugin" value="false"/> +<mapEntry key="org.eclipse.team.cvs.ssh/debug" value="false"/> <mapEntry key="org.eclipse.core.resources/monitor/builders" value="false"/> <mapEntry key="org.eclipse.ui/trace/handlers.verbose" value="false"/> <mapEntry key="org.eclipse.core.resources/save/markers" value="false"/> -<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/filter" value="*"/> -<mapEntry key="org.eclipse.osgi/debug/startlevel" value="false"/> <mapEntry key="org.eclipse.update.core/debug/installhandler" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/startlevel" value="false"/> +<mapEntry key="org.eclipse.ecf.provider.xmpp/debug/filter" value="*"/> <mapEntry key="org.eclipse.ecf.provider/debug/gmm" value="false"/> <mapEntry key="org.eclipse.osgi/monitor/resources" value="false"/> -<mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/javadelta" value="false"/> -<mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> -<mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> +<mapEntry key="org.eclipse.jdt.core/debug/selection" value="false"/> <mapEntry key="org.eclipse.core.resources/preferences" value="false"/> +<mapEntry key="org.eclipse.core.resources/restore/tree" value="false"/> +<mapEntry key="org.eclipse.ui/trace/workbench.restore" value="false"/> <mapEntry key="org.eclipse.ui/trace/part.create" value="false"/> <mapEntry key="org.eclipse.help/debug/protocols" value="false"/> <mapEntry key="org.eclipse.core.resources/restore/snapshots" value="false"/> -<mapEntry key="org.eclipse.help.base/debug/search" value="false"/> <mapEntry key="org.eclipse.core.resources/natures" value="false"/> +<mapEntry key="org.eclipse.help.base/debug/search" value="false"/> <mapEntry key="org.eclipse.team.cvs.core/dirtycaching" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/filter/native" value="*"/> <mapEntry key="org.eclipse.jdt.core/debug/zipaccess" value="false"/> -<mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/properties" value="false"/> +<mapEntry key="org.eclipse.core.runtime/url/debug/cachecopy" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/create" value="false"/> <mapEntry key="org.eclipse.ui/trace/include.timings" value="true"/> <mapEntry key="org.eclipse.ui/trace/keyBindings.verbose" value="false"/> @@ -162,15 +156,15 @@ <mapEntry key="org.eclipse.osgi/debug/events" value="false"/> <mapEntry key="org.eclipse.core.runtime/compatibility/debug" value="false"/> <mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectcontext" value="false"/> -<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="false"/> <mapEntry key="org.eclipse.osgi/debug/monitorbundles" value="false"/> +<mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/success" value="false"/> <mapEntry key="org.eclipse.pde.build/debug" value="false"/> <mapEntry key="org.eclipse.osgi/eclipseadaptor/debug/location" value="false"/> -<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectwrapper" value="false"/> <mapEntry key="org.eclipse.ui/trace/contexts.verbose" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/sharedobjectwrapper" value="false"/> <mapEntry key="org.eclipse.help.base/debug" value="true"/> -<mapEntry key="org.eclipse.core.runtime/jobs" value="false"/> <mapEntry key="org.eclipse.core.runtime/debug/pluginstopper" value="false"/> +<mapEntry key="org.eclipse.core.runtime/jobs" value="false"/> <mapEntry key="org.eclipse.ecf.provider.xmpp/debug/smackdebug" value="true"/> <mapEntry key="org.eclipse.ui/trace/workbench.start" value="false"/> <mapEntry key="org.eclipse.core.runtime/contenttypes/debug" value="false"/> @@ -179,8 +173,8 @@ <mapEntry key="org.eclipse.ecf.provider/debug/connectionping" value="false"/> <mapEntry key="org.eclipse.ui/trace/contexts" value="false"/> <mapEntry key="org.eclipse.core.resources/build/invoking" value="false"/> -<mapEntry key="org.eclipse.ui/debug/uijob.longwarning" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/failure" value="false"/> +<mapEntry key="org.eclipse.ui/debug/uijob.longwarning" value="false"/> <mapEntry key="org.eclipse.update.core/debug/type" value="false"/> <mapEntry key="org.eclipse.ui/trace/page.listeners" value="false"/> <mapEntry key="org.eclipse.ui/debug/job.stale" value="false"/> @@ -190,51 +184,62 @@ <mapEntry key="org.eclipse.ui.intro/debug" value="true"/> <mapEntry key="org.eclipse.jdt.core/debug/completion" value="false"/> <mapEntry key="org.eclipse.jdt.debug.ui/debug" value="true"/> -<mapEntry key="org.eclipse.debug.core/debug" value="true"/> <mapEntry key="org.eclipse.osgi/eclipseadaptor/debug" value="false"/> +<mapEntry key="org.eclipse.debug.core/debug" value="true"/> <mapEntry key="org.eclipse.help/debug" value="true"/> <mapEntry key="org.eclipse.ui/trace/perspective" value="false"/> <mapEntry key="org.eclipse.ui/debug" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/indexmanager" value="false"/> <mapEntry key="org.eclipse.osgi/debug/packageadmin" value="false"/> <mapEntry key="org.eclipse.osgi/debug/loader" value="false"/> -<mapEntry key="org.eclipse.ecf.provider/debug/container" value="true"/> <mapEntry key="org.eclipse.core.resources/build/failure" value="false"/> +<mapEntry key="org.eclipse.ecf.provider/debug/container" value="true"/> <mapEntry key="org.eclipse.ui/trace/handlers" value="false"/> <mapEntry key="org.eclipse.ecf.ui/debug" value="true"/> <mapEntry key="org.eclipse.core.resources/save/tree" value="false"/> <mapEntry key="org.eclipse.core.runtime/config/debug" value="false"/> -<mapEntry key="org.eclipse.help.ui/debug" value="true"/> <mapEntry key="org.eclipse.osgi/trace/classLoading" value="false"/> +<mapEntry key="org.eclipse.help.ui/debug" value="true"/> <mapEntry key="org.eclipse.core.resources/restore/metainfo" value="false"/> -<mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> <mapEntry key="org.eclipse.debug.ui/debug" value="true"/> +<mapEntry key="org.eclipse.core.resources/save/mastertable" value="false"/> <mapEntry key="org.eclipse.jdt.debug/debug" value="true"/> <mapEntry key="org.eclipse.core.runtime/debug" value="false"/> <mapEntry key="org.eclipse.ui/trace/handlers.verbose.commandId" value=""/> -<mapEntry key="org.eclipse.osgi/debug/filter" value="false"/> <mapEntry key="org.eclipse.jdt.core/debug/buffermanager" value="false"/> -<mapEntry key="org.eclipse.jdt.ui/debug/ASTProvider" value="false"/> +<mapEntry key="org.eclipse.osgi/debug/filter" value="false"/> <mapEntry key="org.eclipse.ui/trace/part.listeners" value="false"/> +<mapEntry key="org.eclipse.jdt.ui/debug/ASTProvider" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/success" value="false"/> -<mapEntry key="org.eclipse.ecf.example.collab/debug/filter" value="*"/> -<mapEntry key="org.eclipse.ui.intro/trace/logInfo" value="true"/> <mapEntry key="org.eclipse.core.resources/restore/mastertable" value="false"/> +<mapEntry key="org.eclipse.ui.intro/trace/logInfo" value="true"/> +<mapEntry key="org.eclipse.ecf.example.collab/debug/filter" value="*"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/filter/class" value="*"/> <mapEntry key="org.eclipse.ecf.provider/debug" value="true"/> <mapEntry key="org.eclipse.core.runtime/preferences/debug" value="false"/> <mapEntry key="org.eclipse.core.runtime/jobs/timing" value="false"/> <mapEntry key="org.eclipse.core.runtime/loader/debug/prefixes/failure" value="false"/> </mapAttribute> +<stringAttribute key="selectedPlugin" value="org.eclipse.ecf.provider.xmpp"/> +<booleanAttribute key="automaticAdd" value="false"/> +<stringAttribute key="checked" value="org.eclipse.ecf.provider.xmpp"/> +<booleanAttribute key="includeFragments" value="false"/> +<stringAttribute key="configLocation" value=""/> +<booleanAttribute key="clearws" value="false"/> +<stringAttribute key="location1" value="C:\eclipse3.1m4\eclipse\runtime-workspace"/> +<stringAttribute key="templateConfig" value=""/> +<booleanAttribute key="default" value="true"/> +<stringAttribute key="vmargs" value=""/> +<booleanAttribute key="clearConfig" value="true"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <booleanAttribute key="useDefaultConfigArea" value="true"/> -<booleanAttribute key="useDefaultConfig" value="true"/> +<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="progargs" value=""/> -<booleanAttribute key="automaticAdd" value="false"/> -<stringAttribute key="checked" value="org.eclipse.ecf.example.collab,org.eclipse.ecf.provider,org.eclipse.ecf.provider.xmpp"/> +<booleanAttribute key="useDefaultConfig" value="true"/> <booleanAttribute key="askclear" value="true"/> -<booleanAttribute key="includeFragments" value="false"/> -<stringAttribute key="configLocation" value=""/> +<mapAttribute key="org.eclipse.debug.core.environmentVariables"> +<mapEntry key="smack.debugEnabled" value="true"/> +</mapAttribute> +<booleanAttribute key="includeOptional" value="true"/> <stringAttribute key="location0" value="C:\eclipse3.1m4\eclipse\runtime-workspace"/> </launchConfiguration> diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java index 3e4f32199..efff0e7b2 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/Client.java @@ -41,7 +41,9 @@ import org.eclipse.ecf.presence.IMessageSender; import org.eclipse.ecf.presence.IPresence; import org.eclipse.ecf.presence.IPresenceContainer; import org.eclipse.ecf.presence.IPresenceListener; +import org.eclipse.ecf.presence.ISubscribeListener; import org.eclipse.ecf.presence.IRosterEntry; +import org.eclipse.ecf.presence.impl.Presence; import org.eclipse.ecf.ui.views.ITextInputHandler; import org.eclipse.ecf.ui.views.RosterView; import org.eclipse.swt.widgets.Display; @@ -389,7 +391,9 @@ public class Client { public void handleContainerDeparted(final ID departedContainer) { Display.getDefault().syncExec(new Runnable() { public void run() { - rosterView.memberDeparted(departedContainer); + if (rosterView != null) { + rosterView.memberDeparted(departedContainer); + } } }); messageSender = null; @@ -397,7 +401,28 @@ public class Client { } }); - } + pc.addSubscribeListener(new ISubscribeListener() { + + public void handleSubscribeRequest(ID fromID, IPresence presence) { + System.out.println("subscribe request from "+fromID); + if (messageSender != null) { + messageSender.sendPresenceUpdate(localUser,fromID,new Presence(IPresence.Type.SUBSCRIBED)); + } + } + + public void handleUnsubscribeRequest(ID fromID, IPresence presence) { + System.out.println("unsubscribe request from "+fromID); + } + + public void handleSubscribed(ID fromID, IPresence presence) { + System.out.println("subscribed from "+fromID); + } + + public void handleUnsubscribed(ID fromID, IPresence presence) { + System.out.println("unsubscribed from "+fromID); + } + }); + } public synchronized void disposeClient(IResource proj, ClientEntry entry) { entry.dispose(); removeClientEntry(proj,entry.getType()); diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IMessageSender.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IMessageSender.java index 3dfb2dee2..9ab209395 100644 --- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IMessageSender.java +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IMessageSender.java @@ -16,5 +16,6 @@ import org.eclipse.ecf.presence.IMessageListener.Type; public interface IMessageSender { public void sendMessage(ID fromID, ID toID, Type type, String subject, String message); - + public void sendPresenceUpdate(ID fromID, ID toID, IPresence presence); + } diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresence.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresence.java index ab897220f..aaae836b8 100644 --- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresence.java +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresence.java @@ -30,7 +30,9 @@ public interface IPresence extends IAdaptable, Serializable { */ public static class Type implements Serializable { - private static final String AVAILABLE_NAME = "available"; + private static final long serialVersionUID = 3546921402750743089L; + + 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 SUBSCRIBED_NAME = "subscribed"; @@ -97,7 +99,8 @@ public interface IPresence extends IAdaptable, Serializable { */ public static class Mode implements Serializable { - private static final String AVAILABLE_NAME = "available"; + private static final long serialVersionUID = 3834588811853640499L; + 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"; diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresenceContainer.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresenceContainer.java index 9df56423c..f1f47be6a 100644 --- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresenceContainer.java +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/IPresenceContainer.java @@ -15,6 +15,8 @@ import org.eclipse.ecf.core.SharedObjectContainerInstantiationException; public interface IPresenceContainer { + public void addSubscribeListener(ISubscribeListener listener); + public void addPresenceListener(IPresenceListener listener); public void addMessageListener(IMessageListener listener); public void addSharedObjectMessageListener(ISharedObjectMessageListener listener); diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/ISubscribeListener.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/ISubscribeListener.java new file mode 100644 index 000000000..74ffb74d6 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/ISubscribeListener.java @@ -0,0 +1,21 @@ +/**************************************************************************** +* Copyright (c) 2004 Composent, Inc. and others. +* All rights reserved. This program and the accompanying materials +* are made available under the terms of the Eclipse Public License v1.0 +* which accompanies this distribution, and is available at +* http://www.eclipse.org/legal/epl-v10.html +* +* Contributors: +* Composent, Inc. - initial API and implementation +*****************************************************************************/ +package org.eclipse.ecf.presence; + +import org.eclipse.ecf.core.identity.ID; + +public interface ISubscribeListener { + + public void handleSubscribeRequest(ID fromID, IPresence presence); + public void handleUnsubscribeRequest(ID fromID, IPresence presence); + public void handleSubscribed(ID fromID, IPresence presence); + public void handleUnsubscribed(ID fromID, IPresence presence); +} diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/impl/Presence.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/impl/Presence.java index fab8d9493..7a9c0f5d6 100644 --- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/impl/Presence.java +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/impl/Presence.java @@ -17,7 +17,9 @@ import org.eclipse.ecf.presence.IPresence; public class Presence implements IPresence { - protected Type type; + private static final long serialVersionUID = 3906369346107618354L; + + protected Type type; protected Mode mode; protected int priority; protected String status; diff --git a/framework/bundles/org.eclipse.ecf.ui/icons/disabled/presence_member.gif b/framework/bundles/org.eclipse.ecf.ui/icons/disabled/presence_member.gif Binary files differnew file mode 100644 index 000000000..758be455a --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.ui/icons/disabled/presence_member.gif diff --git a/framework/bundles/org.eclipse.ecf.ui/icons/presence_member.gif b/framework/bundles/org.eclipse.ecf.ui/icons/enabled/presence_member.gif Binary files differindex d307b2006..d307b2006 100644 --- a/framework/bundles/org.eclipse.ecf.ui/icons/presence_member.gif +++ b/framework/bundles/org.eclipse.ecf.ui/icons/enabled/presence_member.gif diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/SWTResourceManager.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/SWTResourceManager.java new file mode 100644 index 000000000..4d572f5df --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/SWTResourceManager.java @@ -0,0 +1,423 @@ +package org.eclipse.ecf.ui; +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Iterator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.widgets.*; + +/** + * Utility class for managing OS resources associated with SWT controls such as + * colors, fonts, images, etc. + * + * !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> + * method to release the operating system resources managed by cached objects + * when those objects and OS resources are no longer needed (e.g. on + * application shutdown) + * + * This class may be freely distributed as part of any application or plugin. + * <p> + * Copyright (c) 2003 - 2005, Instantiations, Inc. <br>All Rights Reserved + * + * @version $Revision: 1.1 $ + * @author scheglov_ke + * @author Dan Rubel + */ +public class SWTResourceManager { + + /** + * Dispose of cached objects and their underlying OS resources. This should + * only be called when the cached objects are no longer needed (e.g. on + * application shutdown) + */ + public static void dispose() { + disposeColors(); + disposeFonts(); + disposeImages(); + disposeCursors(); + } + + ////////////////////////////// + // Color support + ////////////////////////////// + + /** + * Maps RGB values to colors + */ + private static HashMap m_ColorMap = new HashMap(); + + /** + * Returns the system color matching the specific ID + * @param systemColorID int The ID value for the color + * @return Color The system color matching the specific ID + */ + public static Color getColor(int systemColorID) { + Display display = Display.getCurrent(); + return display.getSystemColor(systemColorID); + } + + /** + * Returns a color given its red, green and blue component values + * @param r int The red component of the color + * @param g int The green component of the color + * @param b int The blue component of the color + * @return Color The color matching the given red, green and blue componet values + */ + public static Color getColor(int r, int g, int b) { + return getColor(new RGB(r, g, b)); + } + + /** + * Returns a color given its RGB value + * @param rgb RGB The RGB value of the color + * @return Color The color matching the RGB value + */ + public static Color getColor(RGB rgb) { + Color color = (Color) m_ColorMap.get(rgb); + if (color == null) { + Display display = Display.getCurrent(); + color = new Color(display, rgb); + m_ColorMap.put(rgb, color); + } + return color; + } + + /** + * Dispose of all the cached colors + */ + public static void disposeColors() { + for (Iterator iter = m_ColorMap.values().iterator(); iter.hasNext();) + ((Color) iter.next()).dispose(); + m_ColorMap.clear(); + } + + ////////////////////////////// + // Image support + ////////////////////////////// + + /** + * Maps image names to images + */ + private static HashMap m_ClassImageMap = new HashMap(); + + /** + * Maps images to image decorators + */ + private static HashMap m_ImageToDecoratorMap = new HashMap(); + + /** + * Returns an image encoded by the specified input stream + * @param is InputStream The input stream encoding the image data + * @return Image The image encoded by the specified input stream + */ + protected static Image getImage(InputStream is) { + Display display = Display.getCurrent(); + ImageData data = new ImageData(is); + if (data.transparentPixel > 0) + return new Image(display, data, data.getTransparencyMask()); + return new Image(display, data); + } + + /** + * Returns an image stored in the file at the specified path + * @param path String The path to the image file + * @return Image The image stored in the file at the specified path + */ + public static Image getImage(String path) { + return getImage("default", path); + } + + /** + * Returns an image stored in the file at the specified path + * @param section The section to which belongs specified image + * @param path String The path to the image file + * @return Image The image stored in the file at the specified path + */ + public static Image getImage(String section, String path) { + String key = section + "|" + SWTResourceManager.class.getName() + "|" + path; + Image image = (Image) m_ClassImageMap.get(key); + if (image == null) { + try { + FileInputStream fis = new FileInputStream(path); + image = getImage(fis); + m_ClassImageMap.put(key, image); + fis.close(); + } catch (Exception e) { + return null; + } + } + return image; + } + + /** + * Returns an image stored in the file at the specified path relative to the specified class + * @param clazz Class The class relative to which to find the image + * @param path String The path to the image file + * @return Image The image stored in the file at the specified path + */ + public static Image getImage(Class clazz, String path) { + String key = clazz.getName() + "|" + path; + Image image = (Image) m_ClassImageMap.get(key); + if (image == null) { + if (path.length() > 0 && path.charAt(0) == '/') { + String newPath = path.substring(1, path.length()); + image = getImage(new BufferedInputStream(clazz.getClassLoader().getResourceAsStream(newPath))); + } else { + image = getImage(clazz.getResourceAsStream(path)); + } + m_ClassImageMap.put(key, image); + } + return image; + } + + /** + * Style constant for placing decorator image in top left corner of base image. + */ + public static final int TOP_LEFT = 1; + /** + * Style constant for placing decorator image in top right corner of base image. + */ + public static final int TOP_RIGHT = 2; + /** + * Style constant for placing decorator image in bottom left corner of base image. + */ + public static final int BOTTOM_LEFT = 3; + /** + * Style constant for placing decorator image in bottom right corner of base image. + */ + public static final int BOTTOM_RIGHT = 4; + + /** + * Returns an image composed of a base image decorated by another image + * @param baseImage Image The base image that should be decorated + * @param decorator Image The image to decorate the base image + * @return Image The resulting decorated image + */ + public static Image decorateImage(Image baseImage, Image decorator) { + return decorateImage(baseImage, decorator, BOTTOM_RIGHT); + } + + /** + * Returns an image composed of a base image decorated by another image + * @param baseImage Image The base image that should be decorated + * @param decorator Image The image to decorate the base image + * @param corner The corner to place decorator image + * @return Image The resulting decorated image + */ + public static Image decorateImage(Image baseImage, Image decorator, int corner) { + HashMap decoratedMap = (HashMap) m_ImageToDecoratorMap.get(baseImage); + if (decoratedMap == null) { + decoratedMap = new HashMap(); + m_ImageToDecoratorMap.put(baseImage, decoratedMap); + } + Image result = (Image) decoratedMap.get(decorator); + if (result == null) { + Rectangle bid = baseImage.getBounds(); + Rectangle did = decorator.getBounds(); + result = new Image(Display.getCurrent(), bid.width, bid.height); + GC gc = new GC(result); + gc.drawImage(baseImage, 0, 0); + // + if (corner == TOP_LEFT) { + gc.drawImage(decorator, 0, 0); + } else if (corner == TOP_RIGHT) { + gc.drawImage(decorator, bid.width - did.width - 1, 0); + } else if (corner == BOTTOM_LEFT) { + gc.drawImage(decorator, 0, bid.height - did.height - 1); + } else if (corner == BOTTOM_RIGHT) { + gc.drawImage(decorator, bid.width - did.width - 1, bid.height - did.height - 1); + } + // + gc.dispose(); + decoratedMap.put(decorator, result); + } + return result; + } + + /** + * Dispose all of the cached images + */ + public static void disposeImages() { + for (Iterator I = m_ClassImageMap.values().iterator(); I.hasNext();) + ((Image) I.next()).dispose(); + m_ClassImageMap.clear(); + // + for (Iterator I = m_ImageToDecoratorMap.values().iterator(); I.hasNext();) { + HashMap decoratedMap = (HashMap) I.next(); + for (Iterator J = decoratedMap.values().iterator(); J.hasNext();) { + Image image = (Image) J.next(); + image.dispose(); + } + } + } + + /** + * Dispose cached images in specified section + * @param section the section do dispose + */ + public static void disposeImages(String section) { + for (Iterator I = m_ClassImageMap.keySet().iterator(); I.hasNext();) { + String key = (String) I.next(); + if (!key.startsWith(section + "|")) + continue; + Image image = (Image) m_ClassImageMap.get(key); + image.dispose(); + I.remove(); + } + } + + ////////////////////////////// + // Font support + ////////////////////////////// + + /** + * Maps font names to fonts + */ + private static HashMap m_FontMap = new HashMap(); + + /** + * Maps fonts to their bold versions + */ + private static HashMap m_FontToBoldFontMap = new HashMap(); + + /** + * Returns a font based on its name, height and style + * @param name String The name of the font + * @param height int The height of the font + * @param style int The style of the font + * @return Font The font matching the name, height and style + */ + public static Font getFont(String name, int height, int style) { + return getFont(name, height, style, false, false); + } + + + /** + * Returns a font based on its name, height and style. + * Windows-specific strikeout and underline flags are also supported. + * @param name String The name of the font + * @param height int The height of the font + * @param style int The style of the font + * @param strikeout boolean The strikeout flag (warning: Windows only) + * @param underline boolean The underline flag (warning: Windows only) + * @return Font The font matching the name, height, style, strikeout and underline + */ + public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) { + String fontName = name + "|" + size + "|" + style + "|" + strikeout + "|" + underline; + Font font = (Font) m_FontMap.get(fontName); + if (font == null) { + FontData fontData = new FontData(name, size, style); + if (strikeout || underline) { + try { + Class logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); + Object logFont = FontData.class.getField("data").get(fontData); + if (logFont != null && logFontClass != null) { + if (strikeout) { + logFontClass.getField("lfStrikeOut").set(logFont, new Byte((byte) 1)); + } + if (underline) { + logFontClass.getField("lfUnderline").set(logFont, new Byte((byte) 1)); + } + } + } catch (Throwable e) { + System.err.println( + "Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); + } + } + font = new Font(Display.getCurrent(), fontData); + m_FontMap.put(fontName, font); + } + return font; + } + + + /** + * Return a bold version of the give font + * @param baseFont Font The font for whoch a bold version is desired + * @return Font The bold version of the give font + */ + public static Font getBoldFont(Font baseFont) { + Font font = (Font) m_FontToBoldFontMap.get(baseFont); + if (font == null) { + FontData fontDatas[] = baseFont.getFontData(); + FontData data = fontDatas[0]; + font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); + m_FontToBoldFontMap.put(baseFont, font); + } + return font; + } + + /** + * Dispose all of the cached fonts + */ + public static void disposeFonts() { + for (Iterator iter = m_FontMap.values().iterator(); iter.hasNext();) + ((Font) iter.next()).dispose(); + m_FontMap.clear(); + } + + ////////////////////////////// + // CoolBar support + ////////////////////////////// + + /** + * Fix the layout of the specified CoolBar + * @param bar CoolBar The CoolBar that shgoud be fixed + */ + public static void fixCoolBarSize(CoolBar bar) { + CoolItem[] items = bar.getItems(); + // ensure that each item has control (at least empty one) + for (int i = 0; i < items.length; i++) { + CoolItem item = items[i]; + if (item.getControl() == null) + item.setControl(new Canvas(bar, SWT.NONE) { + public Point computeSize(int wHint, int hHint, boolean changed) { + return new Point(20, 20); + } + }); + } + // compute size for each item + for (int i = 0; i < items.length; i++) { + CoolItem item = items[i]; + Control control = item.getControl(); + control.pack(); + Point size = control.getSize(); + item.setSize(item.computeSize(size.x, size.y)); + } + } + + ////////////////////////////// + // Cursor support + ////////////////////////////// + + /** + * Maps IDs to cursors + */ + private static HashMap m_IdToCursorMap = new HashMap(); + + /** + * Returns the system cursor matching the specific ID + * @param id int The ID value for the cursor + * @return Cursor The system cursor matching the specific ID + */ + public static Cursor getCursor(int id) { + Integer key = new Integer(id); + Cursor cursor = (Cursor) m_IdToCursorMap.get(key); + if (cursor == null) { + cursor = new Cursor(Display.getDefault(), id); + m_IdToCursorMap.put(key, cursor); + } + return cursor; + } + + /** + * Dispose all of the cached cursors + */ + public static void disposeCursors() { + for (Iterator iter = m_IdToCursorMap.values().iterator(); iter.hasNext();) + ((Cursor) iter.next()).dispose(); + m_IdToCursorMap.clear(); + } +}
\ No newline at end of file diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPlugin.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPlugin.java index 3bdcbe709..8e7af414f 100644 --- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPlugin.java +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPlugin.java @@ -95,10 +95,10 @@ public class UiPlugin extends AbstractUIPlugin { */ protected ImageRegistry createImageRegistry() { registry = super.createImageRegistry(); - - + registry.put(UiPluginConstants.DECORATION_PROJECT, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)); - registry.put(UiPluginConstants.DECORATION_USER, AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.ecf.example.collab", "icons/presence_member.gif").createImage()); + registry.put(UiPluginConstants.DECORATION_USER, AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, "icons/enabled/presence_member.gif").createImage()); + registry.put(UiPluginConstants.DECORATION_USER_INACTIVE, AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, "icons/disabled/presence_member.gif").createImage()); registry.put(UiPluginConstants.DECORATION_TIME, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD)); registry.put(UiPluginConstants.DECORATION_TASK, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT)); diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPluginConstants.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPluginConstants.java index 68de49193..365faf87c 100644 --- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPluginConstants.java +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/UiPluginConstants.java @@ -18,6 +18,7 @@ public interface UiPluginConstants { public static final String DECORATION_PROJECT = "project"; public static final String DECORATION_USER = "user"; + public static final String DECORATION_USER_INACTIVE = "userinactive"; public static final String DECORATION_TIME = "time"; public static final String DECORATION_TASK = "task"; public static final String DECORATION_SEND = "send"; diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/dialogs/AuthorizeRequest.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/dialogs/AuthorizeRequest.java new file mode 100644 index 000000000..138f36d86 --- /dev/null +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/dialogs/AuthorizeRequest.java @@ -0,0 +1,91 @@ +package org.eclipse.ecf.ui.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; + +public class AuthorizeRequest extends Dialog { + + private Label target_username; + private Label requester_userid; + private static final int REFUSE_ID = IDialogConstants.CLIENT_ID + 3; + private static final int AUTHORIZE_AND_ADD = IDialogConstants.CLIENT_ID + 2; + private static final int AUTHORIZE_ID = IDialogConstants.CLIENT_ID + 1; + + public AuthorizeRequest(Shell parentShell) { + super(parentShell); + } + + protected Control createDialogArea(Composite parent) { + Composite container = (Composite) super.createDialogArea(parent); + + final Composite composite = new Composite(container, SWT.NONE); + final GridLayout gridLayout = new GridLayout(); + gridLayout.horizontalSpacing = 0; + gridLayout.numColumns = 4; + composite.setLayout(gridLayout); + final GridData gridData_1 = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_VERTICAL); + gridData_1.heightHint = 22; + gridData_1.verticalSpan = 2; + composite.setLayoutData(gridData_1); + + requester_userid = new Label(composite, SWT.NONE); + final GridData gridData_2 = new GridData(); + requester_userid.setLayoutData(gridData_2); + requester_userid.setText("slewis@cerf.composent.com"); + + final Label label_4 = new Label(composite, SWT.NONE); + label_4.setText(" would like to add "); + + target_username = new Label(composite, SWT.NONE); + target_username.setLayoutData(new GridData()); + target_username.setText("slewis@composent.com"); + + final Label label_5 = new Label(composite, SWT.NONE); + label_5.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + label_5.setText(" to their buddy list"); + + final Composite composite_1 = new Composite(container, SWT.NONE); + composite_1.setLayout(new FillLayout(SWT.VERTICAL)); + final GridData gridData = new GridData(GridData.FILL_BOTH); + gridData.heightHint = 82; + composite_1.setLayoutData(gridData); + + final Label label = new Label(composite_1, SWT.WRAP); + label.setText("\nYou can choose to authorize and also add them to your own buddy list, authorize them without adding them to your buddy list, or refuse to authorize"); + + final Label label_3 = new Label(container, SWT.SEPARATOR | SWT.HORIZONTAL); + final GridData gridData_3 = new GridData(GridData.FILL_HORIZONTAL); + gridData_3.heightHint = 6; + gridData_3.widthHint = 469; + label_3.setLayoutData(gridData_3); + // + return container; + } + + protected void createButtonsForButtonBar(Composite parent) { + + createButton(parent, AUTHORIZE_AND_ADD, "Authorize and Add Buddy", false); + + createButton(parent, AUTHORIZE_ID, "Authorize Only", false); + + createButton(parent, REFUSE_ID, "Refuse", true); + } + + protected Point getInitialSize() { + return new Point(507, 196); + } + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("ECF Authorization Request"); + } + +} diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java index f5e2abcf9..cc2f7768b 100644 --- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java @@ -132,7 +132,6 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL super(name, userID); children = new ArrayList(); } - public void addChild(TreeObject child) { children.add(child); child.setParent(this); @@ -159,7 +158,50 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL public boolean hasChildren() { return children.size() > 0; } - } + + } + + class TreeGroup extends TreeParent { + + public TreeGroup(String name) { + super(name); + } + public int getActiveCount() { + TreeObject [] childs = getChildren(); + int totCount = 0; + for(int i=0; i < childs.length; i++) { + if (childs[i] instanceof TreeBuddy) { + TreeBuddy tb = (TreeBuddy) childs[i]; + if (tb.isActive()) { + totCount++; + } + } + } + return totCount; + } + public int getTotalCount() { + return getChildren().length; + } + } + + class TreeBuddy extends TreeParent { + IPresence presence = null; + public TreeBuddy(String name, ID id, IPresence p) { + super(name,id); + this.presence = p; + } + public IPresence getPresence() { + return presence; + } + public void setPresence(IPresence p) { + this.presence = p; + } + public boolean isActive() { + IPresence p = getPresence(); + if (p == null) return false; + return presence.getType().equals(IPresence.Type.AVAILABLE); + } + } class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider { @@ -201,35 +243,17 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL return false; } - public TreeParent hasGroup(IRosterGroup group) { - if (group == null) - return null; - TreeObject[] children = root.getChildren(); - if (children == null) - return null; - for (int i = 0; i < children.length; i++) { - if (group.getName().equals(children[i].getName())) { - return (TreeParent) children[i]; - } - } - return null; - } - - public TreeParent fillPresence(TreeParent obj, IPresence presence) { + public TreeBuddy fillPresence(TreeBuddy obj, IPresence presence) { if (presence == null) return obj; + obj.removeChildren(); TreeObject type = new TreeObject("Status: " + presence.getType().toString()); - obj.addChild(type); + obj.addChild(type); String status = presence.getStatus(); if (status != null && !status.equals("")) { TreeObject stat = new TreeObject("Status Details: " + status); - obj.addChild(stat); - } - int priority = presence.getPriority(); - if (priority != -1) { - TreeObject prior = new TreeObject("Priority: " + priority); - obj.addChild(prior); + obj.addChild(stat); } Map props = presence.getProperties(); for (Iterator i = props.keySet().iterator(); i.hasNext();) { @@ -237,45 +261,24 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL String value = (String) props.get(key); if (key != null && value != null) { TreeObject prop = new TreeObject(key + ": " + value); - obj.addChild(prop); + obj.addChild(prop); } } return obj; } - public TreeParent fillWithEntry(TreeParent obj, IRosterEntry entry) { - obj.removeChildren(); - String name = entry.getName(); - if (name != null) { - obj.addChild(new TreeObject("Name: " + name)); - } - return fillPresence(obj, entry.getPresenceState()); + public TreeBuddy createBuddy(TreeBuddy oldBuddy, IRosterEntry entry) { + TreeBuddy newBuddy = (oldBuddy==null)?new TreeBuddy(entry.getUserID().getName(),entry.getUserID(),entry.getPresenceState()):oldBuddy; + IPresence presence = entry.getPresenceState(); + if (presence != null) { + newBuddy.setPresence(presence); + newBuddy.addChild(new TreeObject("Name: "+entry.getName())); + fillPresence(newBuddy, presence); + } + return newBuddy; } - public void addGroupEntry(TreeParent group, String groupName, IRosterEntry entry) { - TreeObject[] objs = group.getChildren(); - TreeParent found = null; - if (objs != null) { - for (int i = 0; i < objs.length; i++) { - if (objs[i].getName().equals(entry.getUserID().getName())) { - // Found it...replace values with new - found = fillWithEntry((TreeParent) objs[i], entry); - } - } - } - - if (found == null) { - found = new TreeParent(entry.getUserID().getName(), entry - .getUserID()); - found = fillWithEntry(found, entry); - group.addChild(found); - } else { - group.removeChild(found); - group.addChild(found); - } - } - - public TreeParent findGroup(TreeParent parent, IRosterEntry entry) { + public TreeParent findGroup(TreeParent parent, IRosterEntry entry) { TreeObject [] objs = parent.getChildren(); Iterator groups = entry.getGroups(); for( ; groups.hasNext(); ) { @@ -289,49 +292,58 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL } } } + return null; } - public void findAndReplaceEntry(TreeParent parent, IRosterEntry entry) { - TreeObject [] objs = parent.getChildren(); - TreeParent found = null; - if (objs != null) { - for (int i = 0; i < objs.length; i++) { - if (objs[i].getName().equals(entry.getUserID().getName())) { - // Found it...replace values with new - found = fillWithEntry((TreeParent) objs[i], entry); - } - } - - } - if (found == null) { - found = new TreeParent(entry.getUserID().getName(), entry - .getUserID()); - found = fillWithEntry(found, entry); - parent.addChild(found); - } else { - parent.removeChild(found); - parent.addChild(found); - } + + public TreeBuddy findBuddy(TreeParent parent, IRosterEntry entry) { + TreeObject [] objs = parent.getChildren(); + if (objs == null) return null; + for(int i=0; i < objs.length; i++) { + if (objs[i] instanceof TreeBuddy) { + TreeBuddy tb = (TreeBuddy) objs[i]; + ID tbid = tb.getUserID(); + if (tbid != null && tbid.equals(entry.getUserID())) { + return (TreeBuddy) objs[i]; + } + } else if (objs[i] instanceof TreeGroup) { + TreeBuddy found = findBuddy((TreeParent) objs[i],entry); + if (found != null) return found; + } + } + return null; + } + + public TreeBuddy findAndReplaceEntry(TreeParent parent, IRosterEntry entry) { + TreeBuddy tb = findBuddy(parent,entry); + TreeBuddy result = createBuddy(tb,entry); + // If buddy found already, then remove old and add new + if (tb != null) { + TreeParent tbparent = tb.getParent(); + tbparent.removeChild(tb); + tbparent.addChild(result); + } + return result; } public void addEntry(TreeParent parent, IRosterEntry entry) { - TreeParent group = findGroup(parent,entry); - if (group != null) { - findAndReplaceEntry(group,entry); - } else { + + TreeBuddy newBuddy = findAndReplaceEntry(parent,entry); + TreeParent buddyParent = newBuddy.getParent(); + + if (buddyParent == null) { // Existing group not found, so see if entry has a group associated with it Iterator groups = entry.getGroups(); if (groups.hasNext()) { // There's a group associated with entry...so add with group name String groupName = ((IRosterGroup) groups.next()).getName(); - TreeParent newgrp = new TreeParent(groupName); - findAndReplaceEntry(newgrp,entry); + TreeGroup newgrp = new TreeGroup(groupName); + newgrp.addChild(newBuddy); parent.addChild(newgrp); } else { - // No group for entry...just add to parent - findAndReplaceEntry(parent,entry); + parent.addChild(newBuddy); } - } - } + } + } public void addEntry(IRosterEntry entry) { addEntry(root, entry); } @@ -341,9 +353,6 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL } private void initialize() { root = new TreeParent("Buddy List"); - /* - * root.addChild(p1); root.addChild(p2); - */ invisibleRoot = new TreeParent(""); invisibleRoot.addChild(root); } @@ -351,17 +360,25 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL class ViewLabelProvider extends LabelProvider { public String getText(Object obj) { - return obj.toString(); + String label = null; + if (obj instanceof TreeGroup) { + TreeGroup tg = (TreeGroup) obj; + label = tg.getName() + " ("+tg.getActiveCount()+"/"+tg.getTotalCount()+")"; + return label; + } else return obj.toString(); } public Image getImage(Object obj) { Image image = null; //By default, no image exists for obj, but if found to be a specific instance, load from plugin repository. - ImageRegistry registry = UiPlugin.getDefault().getImageRegistry(); - - if (obj instanceof TreeParent) { - TreeParent o = (TreeParent) obj; + if (obj instanceof TreeBuddy) { + ImageRegistry registry = UiPlugin.getDefault().getImageRegistry(); + TreeBuddy o = (TreeBuddy) obj; if (o.getUserID() != null) { - image = registry.get(UiPluginConstants.DECORATION_USER); + if (o.isActive()) { + image = registry.get(UiPluginConstants.DECORATION_USER); + } else { + image = registry.get(UiPluginConstants.DECORATION_USER_INACTIVE); + } } } return image; @@ -396,7 +413,7 @@ public class RosterView extends ViewPart implements IPresenceListener, IMessageL viewer.setLabelProvider(new ViewLabelProvider()); viewer.setSorter(new NameSorter()); viewer.setInput(getViewSite()); - viewer.setAutoExpandLevel(2); + viewer.setAutoExpandLevel(3); makeActions(); hookContextMenu(); hookDoubleClickAction(); diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath b/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath index f6df51f0f..2c3d6b606 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath @@ -1,10 +1,28 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="lib/smack.jar"/> - <classpathentry kind="lib" path="lib/smackx.jar"/> - <classpathentry kind="lib" path="lib/smackx-debug.jar"/> + <classpathentry kind="src" path="src"> + <attributes> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"> + <attributes> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> + <attributes> + </attributes> + </classpathentry> + <classpathentry sourcepath="C:/Documents and Settings/slewis/Desktop/smack-dev-1.5.0/source" kind="lib" path="lib/smack.jar"> + <attributes> + </attributes> + </classpathentry> + <classpathentry sourcepath="C:/Documents and Settings/slewis/Desktop/smack-dev-1.5.0/source" kind="lib" path="lib/smackx.jar"> + <attributes> + </attributes> + </classpathentry> + <classpathentry sourcepath="C:/Documents and Settings/slewis/Desktop/smack-dev-1.5.0/source" kind="lib" path="lib/smackx-debug.jar"> + <attributes> + </attributes> + </classpathentry> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.xmpp/META-INF/MANIFEST.MF index a84fd9f7a..b6417b93e 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/META-INF/MANIFEST.MF +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/META-INF/MANIFEST.MF @@ -2,7 +2,10 @@ Manifest-Version: 1.0 Bundle-Name: ECF XMPP Provider Plug-in Bundle-SymbolicName: org.eclipse.ecf.provider.xmpp Bundle-Version: 1.0.0 -Bundle-ClassPath: xmpp.jar,lib/smack.jar,lib/smackx.jar,lib/smackx-debug.jar +Bundle-ClassPath: xmpp.jar, + lib/smackx-debug.jar, + lib/smack.jar, + lib/smackx.jar Bundle-Activator: org.eclipse.ecf.provider.xmpp.XmppPlugin Bundle-Vendor: Eclipse.org Bundle-Localization: plugin diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smack.jar b/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smack.jar Binary files differindex 71491d6a4..2d5141729 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smack.jar +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smack.jar diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx-debug.jar b/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx-debug.jar Binary files differindex dfc67c999..bba7348d2 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx-debug.jar +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx-debug.jar diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx.jar b/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx.jar Binary files differindex 1e29fd33a..bf5884e18 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx.jar +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/lib/smackx.jar diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/IIMMessageSender.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/IIMMessageSender.java index d750cc140..eee180899 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/IIMMessageSender.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/IIMMessageSender.java @@ -11,6 +11,7 @@ package org.eclipse.ecf.provider.xmpp.container; import java.io.IOException; import org.eclipse.ecf.core.identity.ID; import org.jivesoftware.smack.Roster; +import org.jivesoftware.smack.packet.Presence; /** * @author slewis @@ -19,7 +20,8 @@ import org.jivesoftware.smack.Roster; public interface IIMMessageSender { public void sendMessage(ID target, String message) throws IOException; - + public void sendPresenceUpdate(ID target, Presence presence) throws IOException; + public Roster getRoster() throws IOException; } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java index c1c5877be..e0976daa7 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java @@ -11,6 +11,7 @@ package org.eclipse.ecf.provider.xmpp.container; import java.io.IOException; import java.io.Serializable; import java.util.HashMap; + import org.eclipse.ecf.core.ISharedObjectContainer; import org.eclipse.ecf.core.SharedObjectAddException; import org.eclipse.ecf.core.SharedObjectContainerInstantiationException; @@ -26,9 +27,11 @@ import org.eclipse.ecf.core.identity.IDFactory; import org.eclipse.ecf.core.util.IQueueEnqueue; import org.eclipse.ecf.presence.IMessageListener; import org.eclipse.ecf.presence.IMessageSender; +import org.eclipse.ecf.presence.IPresence; import org.eclipse.ecf.presence.IPresenceContainer; import org.eclipse.ecf.presence.IPresenceListener; import org.eclipse.ecf.presence.ISharedObjectMessageListener; +import org.eclipse.ecf.presence.ISubscribeListener; import org.eclipse.ecf.presence.IMessageListener.Type; import org.eclipse.ecf.provider.generic.ClientSOContainer; import org.eclipse.ecf.provider.generic.ContainerMessage; @@ -288,6 +291,16 @@ public class XMPPClientSOContainer extends ClientSOContainer { } } + protected Presence makePresenceFromIPresence(IPresence presence) { + return sharedObject.makePresence(presence); + } + public void sendPresenceUpdate(ID target, Presence presence) throws IOException { + if (messageSender != null) { + if (presence == null) throw new NullPointerException("presence cannot be null"); + messageSender.sendPresenceUpdate(target, presence); + } + } + public Object getAdapter(Class clazz) { if (clazz.equals(IPresenceContainer.class)) { return new IPresenceContainer() { @@ -315,6 +328,15 @@ public class XMPPClientSOContainer extends ClientSOContainer { } } + + public void sendPresenceUpdate(ID fromID, ID toID, IPresence presence) { + try { + Presence newPresence = makePresenceFromIPresence(presence); + XMPPClientSOContainer.this.sendPresenceUpdate(toID,newPresence); + } catch (IOException e) { + dumpStack("Exception in sendPresenceUpdate to "+toID+" with presence "+presence,e); + } + } }; } @@ -322,6 +344,10 @@ public class XMPPClientSOContainer extends ClientSOContainer { public ISharedObjectContainer makeSharedObjectContainer(Class[] types, Object[] args) throws SharedObjectContainerInstantiationException { return null; } + + public void addSubscribeListener(ISubscribeListener listener) { + sharedObject.addSubscribeListener(listener); + } }; } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPContainerContext.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPContainerContext.java index c92b5d9f8..a17115804 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPContainerContext.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPContainerContext.java @@ -12,9 +12,11 @@ import java.io.IOException; import java.util.Map; import org.eclipse.ecf.core.identity.ID; import org.eclipse.ecf.core.util.IQueueEnqueue; +import org.eclipse.ecf.presence.IPresence; import org.eclipse.ecf.provider.generic.SOContainer; import org.eclipse.ecf.provider.generic.SOContext; import org.jivesoftware.smack.Roster; +import org.jivesoftware.smack.packet.Presence; /** * @author slewis @@ -32,9 +34,15 @@ public class XMPPContainerContext extends SOContext { public void sendMessage(ID target, String message) throws IOException { ((XMPPClientSOContainer) container).sendMessage(target,message); } + public void sendPresenceUpdate(ID target, IPresence presence) throws IOException { + } public Roster getRoster() throws IOException { return ((XMPPClientSOContainer) container).getRoster(); } + public void sendPresenceUpdate(ID target, Presence presence) throws IOException { + if (presence == null) throw new NullPointerException("presence cannot be null"); + ((XMPPClientSOContainer) container).sendPresenceUpdate(target,presence); + } }; } else return null; } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java index 95c999aa9..3334f76fa 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPPresenceSharedObject.java @@ -25,6 +25,7 @@ import org.eclipse.ecf.core.util.Event; import org.eclipse.ecf.presence.IMessageListener; import org.eclipse.ecf.presence.IPresence; import org.eclipse.ecf.presence.IPresenceListener; +import org.eclipse.ecf.presence.ISubscribeListener; import org.eclipse.ecf.presence.IRosterEntry; import org.eclipse.ecf.presence.IRosterGroup; import org.eclipse.ecf.presence.ISharedObjectMessageListener; @@ -56,7 +57,8 @@ public class XMPPPresenceSharedObject implements ISharedObject { Vector messageListeners = new Vector(); Vector presenceListeners = new Vector(); Vector sharedObjectMessageListeners = new Vector(); - + Vector subscribeListeners = new Vector(); + protected void addPresenceListener(IPresenceListener listener) { presenceListeners.add(listener); } @@ -75,6 +77,12 @@ public class XMPPPresenceSharedObject implements ISharedObject { protected void removeSharedObjectMessageListener(ISharedObjectMessageListener listener) { sharedObjectMessageListeners.remove(listener); } + protected void addSubscribeListener(ISubscribeListener listener) { + subscribeListeners.add(listener); + } + protected void removeSubscribeListener(ISubscribeListener listener) { + subscribeListeners.remove(listener); + } protected String canonicalizePresenceFrom(String from) { if (from == null) return null; @@ -142,6 +150,21 @@ public class XMPPPresenceSharedObject implements ISharedObject { } } + protected void fireSubscribe(ID fromID, IPresence presence) { + for (Iterator i = subscribeListeners.iterator(); i.hasNext();) { + ISubscribeListener l = (ISubscribeListener) i.next(); + if (presence.getType().equals(IPresence.Type.SUBSCRIBE)) { + l.handleSubscribeRequest(fromID,presence); + } else if (presence.getType().equals(IPresence.Type.SUBSCRIBED)) { + l.handleSubscribed(fromID,presence); + } else if (presence.getType().equals(IPresence.Type.UNSUBSCRIBE)) { + l.handleUnsubscribeRequest(fromID,presence); + } else if (presence.getType().equals(IPresence.Type.UNSUBSCRIBED)) { + l.handleUnsubscribed(fromID,presence); + } + } + } + protected void fireRosterEntry(IRosterEntry entry) { for (Iterator i = presenceListeners.iterator(); i.hasNext();) { IPresenceListener l = (IPresenceListener) i.next(); @@ -265,9 +288,14 @@ public class XMPPPresenceSharedObject implements ISharedObject { Type type = xmppPresence.getType(); int priority = xmppPresence.getPriority(); String status = xmppPresence.getStatus(); - IPresence newPresence = makePresence(xmppPresence); + IPresence newPresence = makeIPresence(xmppPresence); ID fromID = makeIDFromName(from); - firePresence(fromID, newPresence); + if (newPresence.getType().equals(IPresence.Type.SUBSCRIBE) || + newPresence.getType().equals(IPresence.Type.UNSUBSCRIBE) || + newPresence.getType().equals(IPresence.Type.SUBSCRIBED) || + newPresence.getType().equals(IPresence.Type.UNSUBSCRIBED)) { + fireSubscribe(fromID,newPresence); + } else firePresence(fromID, newPresence); } protected void handleRoster(Roster roster) { @@ -331,18 +359,29 @@ public class XMPPPresenceSharedObject implements ISharedObject { return IMessageListener.Type.NORMAL; } - protected IPresence makePresence(Presence xmppPresence) { + protected IPresence makeIPresence(Presence xmppPresence) { Mode mode = xmppPresence.getMode(); Type type = xmppPresence.getType(); int priority = xmppPresence.getPriority(); String status = xmppPresence.getStatus(); IPresence newPresence = new org.eclipse.ecf.presence.impl.Presence( - makePresenceType(xmppPresence), priority, status, - makePresenceMode(xmppPresence)); + makeIPresenceType(xmppPresence), priority, status, + makeIPresenceMode(xmppPresence)); + return newPresence; + } + + protected Presence makePresence(IPresence ipresence) { + IPresence.Mode mode = ipresence.getMode(); + IPresence.Type type = ipresence.getType(); + int priority = ipresence.getPriority(); + String status = ipresence.getStatus(); + Presence newPresence = new Presence( + makePresenceType(ipresence), status, priority, + makePresenceMode(ipresence)); return newPresence; } - protected IPresence.Mode makePresenceMode(Presence xmppPresence) { + protected IPresence.Mode makeIPresenceMode(Presence xmppPresence) { if (xmppPresence == null) return IPresence.Mode.AVAILABLE; Mode mode = xmppPresence.getMode(); @@ -362,7 +401,27 @@ public class XMPPPresenceSharedObject implements ISharedObject { return IPresence.Mode.AVAILABLE; } - protected IPresence.Type makePresenceType(Presence xmppPresence) { + protected Presence.Mode makePresenceMode(IPresence ipresence) { + if (ipresence == null) + return Presence.Mode.AVAILABLE; + IPresence.Mode mode = ipresence.getMode(); + if (mode == IPresence.Mode.AVAILABLE) { + return Presence.Mode.AVAILABLE; + } else if (mode == IPresence.Mode.AWAY) { + return Presence.Mode.AWAY; + } else if (mode == IPresence.Mode.CHAT) { + return Presence.Mode.CHAT; + } else if (mode == IPresence.Mode.DND) { + return Presence.Mode.DO_NOT_DISTURB; + } else if (mode == IPresence.Mode.EXTENDED_AWAY) { + return Presence.Mode.EXTENDED_AWAY; + } else if (mode == IPresence.Mode.INVISIBLE) { + return Presence.Mode.INVISIBLE; + } + return Presence.Mode.AVAILABLE; + } + + protected IPresence.Type makeIPresenceType(Presence xmppPresence) { if (xmppPresence == null) return IPresence.Type.AVAILABLE; Type type = xmppPresence.getType(); @@ -384,6 +443,28 @@ public class XMPPPresenceSharedObject implements ISharedObject { return IPresence.Type.AVAILABLE; } + protected Presence.Type makePresenceType(IPresence ipresence) { + if (ipresence == null) + return Presence.Type.AVAILABLE; + IPresence.Type type = ipresence.getType(); + if (type == IPresence.Type.AVAILABLE) { + return Presence.Type.AVAILABLE; + } else if (type == IPresence.Type.ERROR) { + return Presence.Type.ERROR; + } else if (type == IPresence.Type.SUBSCRIBE) { + return Presence.Type.SUBSCRIBE; + } else if (type == IPresence.Type.SUBSCRIBED) { + return Presence.Type.SUBSCRIBED; + } else if (type == IPresence.Type.UNSUBSCRIBE) { + return Presence.Type.UNSUBSCRIBE; + } else if (type == IPresence.Type.UNSUBSCRIBED) { + return Presence.Type.UNSUBSCRIBED; + } else if (type == IPresence.Type.UNAVAILABLE) { + return Presence.Type.UNAVAILABLE; + } + return Presence.Type.AVAILABLE; + } + protected IRosterEntry makeRosterEntry(RosterEntry entry) { try { ID userID = makeIDFromName(entry.getUser()); diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java index 175c71a36..25c8405e3 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java @@ -29,6 +29,7 @@ import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Packet; +import org.jivesoftware.smack.packet.Presence; public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender { @@ -80,7 +81,7 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender } public ChatConnection(IAsynchConnectionEventHandler h) { this.handler = h; - if (Trace.create("smackdebug") != null) { + if (smack != null) { XMPPConnection.DEBUG_ENABLED = true; } } @@ -92,6 +93,9 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender debug("connect(" + remote + "," + data + "," + timeout + ")"); if (timeout > 0) SmackConfiguration.setPacketReplyTimeout(timeout); + + Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL); + XMPPID jabberURI = null; try { jabberURI = (XMPPID) remote; @@ -120,8 +124,18 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender } else { connection = new XMPPConnection(serverName, serverPort); } + connection.addPacketListener(new PacketListener() { + /* + * (non-Javadoc) + * + * @see org.jivesoftware.smack.PacketListener#processPacket(org.jivesoftware.smack.packet.Packet) + */ + public void processPacket(Packet arg0) { + handlePacket(arg0); + } + }, null); // Login - connection.login(username, (String) data); + connection.login(username, (String) data, "ECF"); isConnected = true; debug("User: " + username + " logged into " + serverName); roster = getRoster(); @@ -145,16 +159,6 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender } }); - connection.addPacketListener(new PacketListener() { - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.PacketListener#processPacket(org.jivesoftware.smack.packet.Packet) - */ - public void processPacket(Packet arg0) { - handlePacket(arg0); - } - }, null); return roster; } @@ -247,7 +251,7 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender } } } - + public synchronized void sendAsynch(ID receiver, byte[] data) throws IOException { if (data == null) @@ -292,6 +296,20 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender sendMessage(target, aMsg); } + public void sendPresenceUpdate(ID target, Presence presence) throws IOException { + if (target == null) + throw new IOException("target cannot be null"); + if (presence == null) + throw new IOException("presence cannot be null"); + debug("sendPresenceUpdate(" + target + "," + presence + ")"); + presence.setFrom(connection.getUser()); + presence.setTo(target.getName()); + synchronized (this) { + if (!isConnected()) + throw new IOException("not connected"); + connection.sendPacket(presence); + } + } /* * (non-Javadoc) * @@ -303,7 +321,6 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender if (!connection.isConnected()) return null; Roster roster = connection.getRoster(); - roster.setSubscriptionMode(Roster.SUBSCRIPTION_ACCEPT_ALL); return roster; } } |
