Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-11-04 03:11:27 -0500
committerslewis2009-11-04 03:11:27 -0500
commitdcd2546aea4a977980cb726b8be50f7a6813e8b9 (patch)
tree8c1744a95c390c825d5034c54dbe58ca24199034 /providers/bundles/org.eclipse.ecf.provider.xmpp
parentb0644eb7e959a13d0dfa02bef85aae2b85437fb5 (diff)
downloadorg.eclipse.ecf-dcd2546aea4a977980cb726b8be50f7a6813e8b9.tar.gz
org.eclipse.ecf-dcd2546aea4a977980cb726b8be50f7a6813e8b9.tar.xz
org.eclipse.ecf-dcd2546aea4a977980cb726b8be50f7a6813e8b9.zip
Updates to use smack 3.1.0 library rather than 2.2.0
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.xmpp')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.core.prefs13
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.ui.prefs4
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/META-INF/MANIFEST.MF7
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/build.properties6
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatManager.java12
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatRoomContainerHelper.java86
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerAccountManager.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java167
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPIncomingFileTransfer.java110
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPOutgoingFileTransfer.java154
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java123
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPSContainer.java3
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java9
15 files changed, 360 insertions, 341 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath b/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath
index 6f3b481ac..64c5e31b7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/.classpath
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.1%Foundation-1.1"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.core.prefs b/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.core.prefs
index 9e05681b3..77c4167ff 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.core.prefs
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Thu Feb 12 13:11:10 PST 2009
+#Tue Nov 03 11:28:51 PST 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -8,11 +8,12 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
@@ -21,7 +22,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@@ -75,6 +76,6 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.3
+org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.ui.prefs b/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.ui.prefs
index 9bb86c1d3..6edd74dc6 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.ui.prefs
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/.settings/org.eclipse.jdt.ui.prefs
@@ -1,11 +1,11 @@
-#Wed Oct 10 22:18:36 EDT 2007
+#Mon Apr 27 19:50:17 CEST 2009
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_core
formatter_settings_version=11
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=;
-org.eclipse.jdt.ui.ondemandthreshold=3
+org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=99
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
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 c2f7bfbfe..e9eb2c7b5 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,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ecf.provider.xmpp;singleton:=true
-Bundle-Version: 3.0.0.qualifier
+Bundle-Version: 3.1.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.provider.xmpp.XmppPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.equinox.common,
org.eclipse.ecf.sharedobject,
org.eclipse.ecf.datashare,
org.eclipse.ecf.provider.datashare,
- org.jivesoftware.smack;bundle-version="[2.2.1,3.0.0)",
+ org.jivesoftware.smack;bundle-version="3.1.0",
org.eclipse.ecf.remoteservice,
org.eclipse.ecf.provider.remoteservice
Eclipse-LazyStart: true
@@ -25,8 +25,7 @@ Export-Package: org.eclipse.ecf.internal.provider.xmpp;x-internal:=true,
org.eclipse.ecf.provider.xmpp,
org.eclipse.ecf.provider.xmpp.identity
Eclipse-BuddyPolicy: global
-Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
- J2SE-1.4
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-ExtensibleAPI: true
Import-Package: org.eclipse.core.runtime.jobs,
org.eclipse.equinox.concurrent.future;version="1.0.0",
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/build.properties b/providers/bundles/org.eclipse.ecf.provider.xmpp/build.properties
index d638dd545..1b594a821 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/build.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/build.properties
@@ -5,10 +5,8 @@ bin.includes = .,\
asl-v20.txt,\
plugin.properties,\
schema/
-src.includes = .,\
- about.html,\
+src.includes = about.html,\
asl-v20.txt,\
- schema/,\
- plugin.properties
+ schema/
source.. = src/
output.. = bin/
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatManager.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatManager.java
index a6daef81a..033c4e7eb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatManager.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatManager.java
@@ -136,9 +136,9 @@ public class XMPPChatManager implements IChatManager {
protected IChatMessage.Type createMessageType(Message.Type type) {
if (type == null)
return IChatMessage.Type.CHAT;
- if (type == Message.Type.CHAT) {
+ if (type == Message.Type.chat) {
return IChatMessage.Type.CHAT;
- } else if (type == Message.Type.HEADLINE) {
+ } else if (type == Message.Type.headline) {
return IChatMessage.Type.SYSTEM;
} else
return IChatMessage.Type.CHAT;
@@ -146,13 +146,13 @@ public class XMPPChatManager implements IChatManager {
protected Message.Type createMessageType(IChatMessage.Type type) {
if (type == null)
- return Message.Type.NORMAL;
+ return Message.Type.normal;
if (type == IChatMessage.Type.CHAT) {
- return Message.Type.CHAT;
+ return Message.Type.chat;
} else if (type == IChatMessage.Type.SYSTEM) {
- return Message.Type.HEADLINE;
+ return Message.Type.headline;
} else
- return Message.Type.NORMAL;
+ return Message.Type.normal;
}
/*
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatRoomContainerHelper.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatRoomContainerHelper.java
index 9b71d921f..69221fafb 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatRoomContainerHelper.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPChatRoomContainerHelper.java
@@ -11,28 +11,17 @@
package org.eclipse.ecf.internal.provider.xmpp;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
+import java.util.*;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.core.sharedobject.ISharedObject;
-import org.eclipse.ecf.core.sharedobject.ISharedObjectConfig;
-import org.eclipse.ecf.core.sharedobject.ISharedObjectContext;
-import org.eclipse.ecf.core.sharedobject.SharedObjectInitException;
+import org.eclipse.ecf.core.sharedobject.*;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.core.util.Event;
-import org.eclipse.ecf.internal.provider.xmpp.events.ChatMembershipEvent;
-import org.eclipse.ecf.internal.provider.xmpp.events.MessageEvent;
-import org.eclipse.ecf.internal.provider.xmpp.events.PresenceEvent;
+import org.eclipse.ecf.internal.provider.xmpp.events.*;
import org.eclipse.ecf.presence.IIMMessageListener;
import org.eclipse.ecf.presence.IPresence;
-import org.eclipse.ecf.presence.chatroom.ChatRoomMessage;
-import org.eclipse.ecf.presence.chatroom.ChatRoomMessageEvent;
-import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
+import org.eclipse.ecf.presence.chatroom.*;
import org.eclipse.ecf.provider.xmpp.identity.XMPPID;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
import org.jivesoftware.smack.XMPPConnection;
@@ -51,25 +40,29 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
private final List participantListeners = new ArrayList();
private ID roomID = null;
- private final List chatRoomContainerParticipants = Collections.synchronizedList(new ArrayList());
+ private final List chatRoomContainerParticipants = Collections
+ .synchronizedList(new ArrayList());
protected void trace(String message) {
}
- protected void addChatParticipantListener(IChatRoomParticipantListener listener) {
+ protected void addChatParticipantListener(
+ IChatRoomParticipantListener listener) {
synchronized (participantListeners) {
participantListeners.add(listener);
}
}
- protected void removeChatParticipantListener(IChatRoomParticipantListener listener) {
+ protected void removeChatParticipantListener(
+ IChatRoomParticipantListener listener) {
synchronized (participantListeners) {
participantListeners.remove(listener);
}
}
- public XMPPChatRoomContainerHelper(Namespace usernamespace, XMPPConnection conn) {
+ public XMPPChatRoomContainerHelper(Namespace usernamespace,
+ XMPPConnection conn) {
super();
this.usernamespace = usernamespace;
this.connection = conn;
@@ -84,7 +77,8 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
*
* @see org.eclipse.ecf.core.ISharedObject#init(org.eclipse.ecf.core.ISharedObjectConfig)
*/
- public void init(ISharedObjectConfig initData) throws SharedObjectInitException {
+ public void init(ISharedObjectConfig initData)
+ throws SharedObjectInitException {
this.config = initData;
}
@@ -98,7 +92,7 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
}
}
- protected Message.Type[] ALLOWED_MESSAGES = {Message.Type.GROUP_CHAT};
+ protected Message.Type[] ALLOWED_MESSAGES = { Message.Type.groupchat };
protected Message filterMessageType(Message msg) {
for (int i = 0; i < ALLOWED_MESSAGES.length; i++) {
@@ -131,7 +125,8 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
}
for (final Iterator i = toNotify.iterator(); i.hasNext();) {
final IIMMessageListener l = (IIMMessageListener) i.next();
- l.handleMessageEvent(new ChatRoomMessageEvent(from, new ChatRoomMessage(from, roomID, body)));
+ l.handleMessageEvent(new ChatRoomMessageEvent(from,
+ new ChatRoomMessage(from, roomID, body)));
}
}
@@ -156,26 +151,27 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
protected void handleMessageEvent(MessageEvent evt) {
final Message msg = filterMessageType(evt.getMessage());
if (msg != null)
- fireMessageListeners(createUserIDFromName(canonicalizeRoomFrom(msg.getFrom())), msg.getBody());
+ fireMessageListeners(createUserIDFromName(canonicalizeRoomFrom(msg
+ .getFrom())), msg.getBody());
}
protected IPresence.Type createIPresenceType(Presence xmppPresence) {
if (xmppPresence == null)
return IPresence.Type.AVAILABLE;
final Type type = xmppPresence.getType();
- if (type == Presence.Type.AVAILABLE) {
+ if (type == Presence.Type.available) {
return IPresence.Type.AVAILABLE;
- } else if (type == Presence.Type.ERROR) {
+ } else if (type == Presence.Type.error) {
return IPresence.Type.ERROR;
- } else if (type == Presence.Type.SUBSCRIBE) {
+ } else if (type == Presence.Type.subscribe) {
return IPresence.Type.SUBSCRIBE;
- } else if (type == Presence.Type.SUBSCRIBED) {
+ } else if (type == Presence.Type.subscribed) {
return IPresence.Type.SUBSCRIBED;
- } else if (type == Presence.Type.UNSUBSCRIBE) {
+ } else if (type == Presence.Type.unsubscribe) {
return IPresence.Type.UNSUBSCRIBE;
- } else if (type == Presence.Type.UNSUBSCRIBED) {
+ } else if (type == Presence.Type.unsubscribed) {
return IPresence.Type.UNSUBSCRIBED;
- } else if (type == Presence.Type.UNAVAILABLE) {
+ } else if (type == Presence.Type.unavailable) {
return IPresence.Type.UNAVAILABLE;
}
return IPresence.Type.AVAILABLE;
@@ -185,25 +181,27 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
if (xmppPresence == null)
return IPresence.Mode.AVAILABLE;
final Mode mode = xmppPresence.getMode();
- if (mode == Presence.Mode.AVAILABLE) {
+ if (mode == Presence.Mode.available) {
return IPresence.Mode.AVAILABLE;
- } else if (mode == Presence.Mode.AWAY) {
+ } else if (mode == Presence.Mode.away) {
return IPresence.Mode.AWAY;
- } else if (mode == Presence.Mode.CHAT) {
+ } else if (mode == Presence.Mode.chat) {
return IPresence.Mode.CHAT;
- } else if (mode == Presence.Mode.DO_NOT_DISTURB) {
+ } else if (mode == Presence.Mode.dnd) {
return IPresence.Mode.DND;
- } else if (mode == Presence.Mode.EXTENDED_AWAY) {
+ } else if (mode == Presence.Mode.xa) {
return IPresence.Mode.EXTENDED_AWAY;
- } else if (mode == Presence.Mode.INVISIBLE) {
+ } /*else if (mode == Presence.Mode.invisible) {
return IPresence.Mode.INVISIBLE;
- }
+ }*/
return IPresence.Mode.AVAILABLE;
}
protected IPresence createIPresence(Presence xmppPresence) {
final String status = xmppPresence.getStatus();
- final IPresence newPresence = new org.eclipse.ecf.presence.Presence(createIPresenceType(xmppPresence), status, createIPresenceMode(xmppPresence));
+ final IPresence newPresence = new org.eclipse.ecf.presence.Presence(
+ createIPresenceType(xmppPresence), status,
+ createIPresenceMode(xmppPresence));
return newPresence;
}
@@ -237,7 +235,8 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
toNotify = new ArrayList(participantListeners);
}
for (final Iterator i = toNotify.iterator(); i.hasNext();) {
- final IChatRoomParticipantListener l = (IChatRoomParticipantListener) i.next();
+ final IChatRoomParticipantListener l = (IChatRoomParticipantListener) i
+ .next();
l.handlePresenceUpdated(fromID, presence);
}
}
@@ -248,7 +247,8 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
toNotify = new ArrayList(participantListeners);
}
for (final Iterator i = toNotify.iterator(); i.hasNext();) {
- final IChatRoomParticipantListener l = (IChatRoomParticipantListener) i.next();
+ final IChatRoomParticipantListener l = (IChatRoomParticipantListener) i
+ .next();
if (join) {
l.handleArrived(new User(fromID));
} else {
@@ -315,8 +315,10 @@ public class XMPPChatRoomContainerHelper implements ISharedObject {
return null;
if (adapter.isInstance(this))
return this;
- final IAdapterManager adapterManager = XmppPlugin.getDefault().getAdapterManager();
- return (adapterManager == null) ? null : adapterManager.loadAdapter(this, adapter.getName());
+ final IAdapterManager adapterManager = XmppPlugin.getDefault()
+ .getAdapterManager();
+ return (adapterManager == null) ? null : adapterManager.loadAdapter(
+ this, adapter.getName());
}
/**
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerAccountManager.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerAccountManager.java
index e184ec7f2..fa3e9deb3 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerAccountManager.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerAccountManager.java
@@ -12,7 +12,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.presence.IAccountManager;
import org.jivesoftware.smack.AccountManager;
@@ -87,7 +86,7 @@ public class XMPPContainerAccountManager implements IAccountManager {
public String[] getAccountAttributeNames() {
if (accountManager == null)
return new String[0];
- Iterator i = accountManager.getAccountAttributes();
+ Iterator i = accountManager.getAccountAttributes().iterator();
List l = new ArrayList();
for (; i.hasNext();) {
l.add(i.next());
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java
index 74a2af0dc..c2d44f172 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/XMPPContainerPresenceHelper.java
@@ -9,32 +9,57 @@
package org.eclipse.ecf.internal.provider.xmpp;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.core.sharedobject.*;
-import org.eclipse.ecf.core.sharedobject.events.*;
+import org.eclipse.ecf.core.sharedobject.ISharedObject;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectConfig;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContext;
+import org.eclipse.ecf.core.sharedobject.SharedObjectInitException;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent;
+import org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageListener;
import org.eclipse.ecf.core.user.IUser;
import org.eclipse.ecf.core.user.User;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.core.util.Event;
-import org.eclipse.ecf.internal.provider.xmpp.events.*;
+import org.eclipse.ecf.internal.provider.xmpp.events.IQEvent;
+import org.eclipse.ecf.internal.provider.xmpp.events.MessageEvent;
+import org.eclipse.ecf.internal.provider.xmpp.events.PresenceEvent;
import org.eclipse.ecf.internal.provider.xmpp.smack.ECFConnection;
-import org.eclipse.ecf.presence.*;
-import org.eclipse.ecf.presence.im.*;
-import org.eclipse.ecf.presence.roster.*;
+import org.eclipse.ecf.presence.IPresence;
+import org.eclipse.ecf.presence.IPresenceListener;
+import org.eclipse.ecf.presence.IPresenceSender;
+import org.eclipse.ecf.presence.im.IChatManager;
+import org.eclipse.ecf.presence.im.ITypingMessage;
+import org.eclipse.ecf.presence.im.TypingMessage;
+import org.eclipse.ecf.presence.roster.AbstractRosterManager;
+import org.eclipse.ecf.presence.roster.IRosterEntry;
+import org.eclipse.ecf.presence.roster.IRosterGroup;
+import org.eclipse.ecf.presence.roster.IRosterItem;
+import org.eclipse.ecf.presence.roster.IRosterManager;
+import org.eclipse.ecf.presence.roster.IRosterSubscriptionSender;
+import org.eclipse.ecf.presence.roster.RosterGroup;
import org.eclipse.ecf.provider.xmpp.XMPPContainer;
import org.eclipse.ecf.provider.xmpp.identity.XMPPID;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
-import org.eclipse.equinox.concurrent.future.*;
-import org.jivesoftware.smack.*;
+import org.eclipse.equinox.concurrent.future.IFuture;
+import org.eclipse.equinox.concurrent.future.IProgressRunnable;
+import org.eclipse.equinox.concurrent.future.ThreadsExecutor;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry;
-import org.jivesoftware.smack.RosterGroup;
-import org.jivesoftware.smack.packet.*;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.IQ;
+import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.Presence.Mode;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smackx.packet.VCard;
@@ -366,9 +391,13 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
}
}
- private void addToRoster(IRosterItem[] items) {
- for (int i = 0; i < items.length; i++) {
- roster.addItem(items[i]);
+ private void addUniqueToRoster(IRosterItem[] newItems) {
+ Collection existingItems = roster.getItems();
+ synchronized (existingItems) {
+ for (int i = 0; i < newItems.length; i++) {
+ if (!existingItems.contains(newItems[i]))
+ existingItems.add(newItems[i]);
+ }
}
rosterManager.notifyRosterUpdate(roster);
}
@@ -385,14 +414,14 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
final XMPPID xmppid = createIDFromName(entry.getUser());
final String name = (entry.getName() == null) ? xmppid.getUsername()
: XMPPID.unfixEscapeInNode(entry.getName());
- return createRosterEntry(xmppid, name, entry.getGroups());
+ return createRosterEntry(xmppid, name, entry.getGroups().iterator());
}
protected IRosterEntry createRosterEntry(XMPPID xmppid,
RosterPacket.Item entry) {
final String name = (entry.getName() == null) ? xmppid.getUsername()
: XMPPID.unfixEscapeInNode(entry.getName());
- return createRosterEntry(xmppid, name, entry.getGroupNames());
+ return createRosterEntry(xmppid, name, entry.getGroupNames().iterator());
}
protected void handleIQEvent(IQEvent evt) {
@@ -402,22 +431,22 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
final RosterPacket rosterPacket = (RosterPacket) iq;
if (rosterPacket.getType() == IQ.Type.SET
|| rosterPacket.getType() == IQ.Type.RESULT) {
- for (final Iterator i = rosterPacket.getRosterItems(); i
- .hasNext();) {
+ for (final Iterator i = rosterPacket.getRosterItems()
+ .iterator(); i.hasNext();) {
final RosterPacket.Item item = (RosterPacket.Item) i.next();
final RosterPacket.ItemType itemType = item.getItemType();
boolean remove = false;
XMPPID newID = createIDFromName(item.getUser());
final IRosterItem items[] = createRosterEntries(newID, item);
final IRosterEntry entry = createRosterEntry(newID, item);
- if (itemType == RosterPacket.ItemType.NONE
- || itemType == RosterPacket.ItemType.REMOVE) {
+ if (itemType == RosterPacket.ItemType.none
+ || itemType == RosterPacket.ItemType.remove) {
removeItemFromRoster(roster.getItems(),
createIDFromName(item.getUser()));
remove = true;
} else {
remove = false;
- addToRoster(items);
+ addUniqueToRoster(items);
}
// In both cases fire set roster entry
fireSetRosterEntry(remove, entry);
@@ -564,20 +593,18 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
AdditionalClientRosterEntry[] entrys = (AdditionalClientRosterEntry[]) newEntrys
.toArray(new AdditionalClientRosterEntry[] {});
- IRosterEntry entry = null;
if (entrys.length > 0) {
for (int i = 0; i < entrys.length; i++) {
if (entrys[i].add) {
- entry = new org.eclipse.ecf.presence.roster.RosterEntry(
+ IRosterEntry entry = new org.eclipse.ecf.presence.roster.RosterEntry(
entrys[i].parent, entrys[i].user,
entrys[i].presence);
- // roster.addItem(entry);
+ addUniqueToRoster(new IRosterItem[] { entry });
+ fireSetRosterEntry(false, entry);
} else {
removeItemFromRoster(rosterItems, fromID);
}
}
- rosterManager.notifyRosterUpdate(roster);
- fireSetRosterEntry(false, entry);
}
}
@@ -708,7 +735,7 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
}
protected void handleRoster(Roster roster) {
- for (final Iterator i = roster.getEntries(); i.hasNext();) {
+ for (final Iterator i = roster.getEntries().iterator(); i.hasNext();) {
final IRosterItem[] items = createRosterEntries((RosterEntry) i
.next());
for (int j = 0; j < items.length; j++) {
@@ -886,59 +913,61 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
if (xmppPresence == null)
return IPresence.Mode.AVAILABLE;
final Mode mode = xmppPresence.getMode();
- if (mode == Presence.Mode.AVAILABLE) {
+ if (mode == Presence.Mode.available) {
return IPresence.Mode.AVAILABLE;
- } else if (mode == Presence.Mode.AWAY) {
+ } else if (mode == Presence.Mode.away) {
return IPresence.Mode.AWAY;
- } else if (mode == Presence.Mode.CHAT) {
+ } else if (mode == Presence.Mode.chat) {
return IPresence.Mode.CHAT;
- } else if (mode == Presence.Mode.DO_NOT_DISTURB) {
+ } else if (mode == Presence.Mode.dnd) {
return IPresence.Mode.DND;
- } else if (mode == Presence.Mode.EXTENDED_AWAY) {
+ } else if (mode == Presence.Mode.xa) {
return IPresence.Mode.EXTENDED_AWAY;
- } else if (mode == Presence.Mode.INVISIBLE) {
- return IPresence.Mode.INVISIBLE;
- }
+ } /*
+ * else if (mode == Presence.Mode.INVISIBLE) { return
+ * IPresence.Mode.INVISIBLE; }
+ */
return IPresence.Mode.AVAILABLE;
}
protected Presence.Mode createPresenceMode(IPresence ipresence) {
if (ipresence == null)
- return Presence.Mode.AVAILABLE;
+ return Presence.Mode.available;
final IPresence.Mode mode = ipresence.getMode();
if (mode == IPresence.Mode.AVAILABLE) {
- return Presence.Mode.AVAILABLE;
+ return Presence.Mode.available;
} else if (mode == IPresence.Mode.AWAY) {
- return Presence.Mode.AWAY;
+ return Presence.Mode.away;
} else if (mode == IPresence.Mode.CHAT) {
- return Presence.Mode.CHAT;
+ return Presence.Mode.chat;
} else if (mode == IPresence.Mode.DND) {
- return Presence.Mode.DO_NOT_DISTURB;
+ return Presence.Mode.dnd;
} 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;
+ return Presence.Mode.xa;
+ } /*
+ * else if (mode == IPresence.Mode.INVISIBLE) { return
+ * Presence.Mode.INVISIBLE; }
+ */
+ return Presence.Mode.available;
}
protected IPresence.Type createIPresenceType(Presence xmppPresence) {
if (xmppPresence == null)
return IPresence.Type.AVAILABLE;
final Type type = xmppPresence.getType();
- if (type == Presence.Type.AVAILABLE) {
+ if (type == Presence.Type.available) {
return IPresence.Type.AVAILABLE;
- } else if (type == Presence.Type.ERROR) {
+ } else if (type == Presence.Type.error) {
return IPresence.Type.ERROR;
- } else if (type == Presence.Type.SUBSCRIBE) {
+ } else if (type == Presence.Type.subscribe) {
return IPresence.Type.SUBSCRIBE;
- } else if (type == Presence.Type.SUBSCRIBED) {
+ } else if (type == Presence.Type.subscribed) {
return IPresence.Type.SUBSCRIBED;
- } else if (type == Presence.Type.UNSUBSCRIBE) {
+ } else if (type == Presence.Type.unsubscribe) {
return IPresence.Type.UNSUBSCRIBE;
- } else if (type == Presence.Type.UNSUBSCRIBED) {
+ } else if (type == Presence.Type.unsubscribed) {
return IPresence.Type.UNSUBSCRIBED;
- } else if (type == Presence.Type.UNAVAILABLE) {
+ } else if (type == Presence.Type.unavailable) {
return IPresence.Type.UNAVAILABLE;
}
return IPresence.Type.AVAILABLE;
@@ -946,24 +975,24 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
protected Presence.Type createPresenceType(IPresence ipresence) {
if (ipresence == null)
- return Presence.Type.AVAILABLE;
+ return Presence.Type.available;
final IPresence.Type type = ipresence.getType();
if (type == IPresence.Type.AVAILABLE) {
- return Presence.Type.AVAILABLE;
+ return Presence.Type.available;
} else if (type == IPresence.Type.ERROR) {
- return Presence.Type.ERROR;
+ return Presence.Type.error;
} else if (type == IPresence.Type.SUBSCRIBE) {
- return Presence.Type.SUBSCRIBE;
+ return Presence.Type.subscribe;
} else if (type == IPresence.Type.SUBSCRIBED) {
- return Presence.Type.SUBSCRIBED;
+ return Presence.Type.subscribed;
} else if (type == IPresence.Type.UNSUBSCRIBE) {
- return Presence.Type.UNSUBSCRIBE;
+ return Presence.Type.unsubscribe;
} else if (type == IPresence.Type.UNSUBSCRIBED) {
- return Presence.Type.UNSUBSCRIBED;
+ return Presence.Type.unsubscribed;
} else if (type == IPresence.Type.UNAVAILABLE) {
- return Presence.Type.UNAVAILABLE;
+ return Presence.Type.unavailable;
}
- return Presence.Type.AVAILABLE;
+ return Presence.Type.available;
}
protected IRosterItem[] createRosterEntries(RosterEntry entry) {
@@ -972,7 +1001,8 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
final User newUser = (name == null) ? new User(xmppid, xmppid
.getUsername()) : new User(xmppid, XMPPID
.unfixEscapeInNode(name));
- return createRosterEntries(entry.getGroups(), roster, newUser);
+ return createRosterEntries(entry.getGroups().iterator(), roster,
+ newUser);
}
private IRosterItem[] createRosterEntries(Iterator grps,
@@ -1031,7 +1061,10 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
IRosterEntry newEntry = null;
if (groups.size() == 0)
return new org.eclipse.ecf.presence.roster.RosterEntry(roster,
- user, null);
+ user, new org.eclipse.ecf.presence.Presence(
+ IPresence.Type.UNAVAILABLE,
+ IPresence.Type.UNAVAILABLE.toString(),
+ IPresence.Mode.AWAY));
else
for (int i = 0; i < groups.size(); i++) {
final IRosterGroup grp = (IRosterGroup) groups.get(i);
@@ -1086,8 +1119,8 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
if (name == null)
name = id.getUsername();
name = XMPPID.unfixEscapeInNode(name);
- return createRosterEntries(entry.getGroupNames(), roster, new User(id,
- name));
+ return createRosterEntries(entry.getGroupNames().iterator(), roster,
+ new User(id, name));
}
protected org.eclipse.ecf.presence.roster.RosterGroup findRosterGroup(
@@ -1145,8 +1178,8 @@ public class XMPPContainerPresenceHelper implements ISharedObject {
}
}
- protected Message.Type[] ALLOWED_MESSAGES = { Message.Type.CHAT,
- Message.Type.ERROR, Message.Type.HEADLINE, Message.Type.NORMAL };
+ protected Message.Type[] ALLOWED_MESSAGES = { Message.Type.chat,
+ Message.Type.error, Message.Type.headline, Message.Type.normal };
protected Message filterMessageType(Message msg) {
for (int i = 0; i < ALLOWED_MESSAGES.length; i++) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPIncomingFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPIncomingFileTransfer.java
index 53524a310..13a635aec 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPIncomingFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPIncomingFileTransfer.java
@@ -15,7 +15,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
-
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -62,11 +61,14 @@ public class XMPPIncomingFileTransfer implements IIncomingFileTransfer {
protected IStatus run(IProgressMonitor monitor) {
final byte[] buf = new byte[buff_length];
final int totalWork = ((fileLength == -1) ? 100 : (int) fileLength);
- monitor.beginTask(getID().getName() + Messages.XMPPIncomingFileTransfer_Progress_Data, totalWork);
+ monitor.beginTask(getID().getName()
+ + Messages.XMPPIncomingFileTransfer_Progress_Data,
+ totalWork);
try {
while (!isDone()) {
if (monitor.isCanceled())
- throw new UserCancelledException(Messages.XMPPIncomingFileTransfer_Exception_User_Cancelled);
+ throw new UserCancelledException(
+ Messages.XMPPIncomingFileTransfer_Exception_User_Cancelled);
final int bytes = remoteFileContents.read(buf);
if (bytes != -1) {
bytesReceived += bytes;
@@ -91,7 +93,13 @@ public class XMPPIncomingFileTransfer implements IIncomingFileTransfer {
}
protected IStatus getFinalStatus(Throwable exception) {
- return (exception == null) ? new Status(IStatus.OK, XmppPlugin.PLUGIN_ID, 0, Messages.XMPPIncomingFileTransfer_Status_Transfer_Completed_OK, null) : new Status(IStatus.ERROR, XmppPlugin.PLUGIN_ID, IStatus.ERROR, Messages.XMPPIncomingFileTransfer_Status_Transfer_Exception, exception);
+ return (exception == null) ? new Status(IStatus.OK,
+ XmppPlugin.PLUGIN_ID, 0,
+ Messages.XMPPIncomingFileTransfer_Status_Transfer_Completed_OK,
+ null) : new Status(IStatus.ERROR, XmppPlugin.PLUGIN_ID,
+ IStatus.ERROR,
+ Messages.XMPPIncomingFileTransfer_Status_Transfer_Exception,
+ exception);
}
protected void hardClose() {
@@ -108,58 +116,64 @@ public class XMPPIncomingFileTransfer implements IIncomingFileTransfer {
protected void fireTransferReceiveDoneEvent() {
if (listener != null)
- listener.handleTransferEvent(new IIncomingFileTransferReceiveDoneEvent() {
-
- private static final long serialVersionUID = 6925524078226825710L;
-
- public IIncomingFileTransfer getSource() {
- return XMPPIncomingFileTransfer.this;
- }
-
- public Exception getException() {
- return XMPPIncomingFileTransfer.this.getException();
- }
-
- public String toString() {
- final StringBuffer sb = new StringBuffer("IIncomingFileTransferReceiveDoneEvent["); //$NON-NLS-1$
- sb.append("isDone=").append(done).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append("bytesReceived=").append(bytesReceived) //$NON-NLS-1$
- .append("]"); //$NON-NLS-1$
- return sb.toString();
- }
- });
+ listener
+ .handleTransferEvent(new IIncomingFileTransferReceiveDoneEvent() {
+
+ private static final long serialVersionUID = 6925524078226825710L;
+
+ public IIncomingFileTransfer getSource() {
+ return XMPPIncomingFileTransfer.this;
+ }
+
+ public Exception getException() {
+ return XMPPIncomingFileTransfer.this.getException();
+ }
+
+ public String toString() {
+ final StringBuffer sb = new StringBuffer(
+ "IIncomingFileTransferReceiveDoneEvent["); //$NON-NLS-1$
+ sb.append("isDone=").append(done).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append("bytesReceived=").append(bytesReceived) //$NON-NLS-1$
+ .append("]"); //$NON-NLS-1$
+ return sb.toString();
+ }
+ });
}
protected void fireTransferReceiveDataEvent() {
if (listener != null)
- listener.handleTransferEvent(new IIncomingFileTransferReceiveDataEvent() {
- private static final long serialVersionUID = -5656328374614130161L;
-
- public IIncomingFileTransfer getSource() {
- return XMPPIncomingFileTransfer.this;
- }
-
- public String toString() {
- final StringBuffer sb = new StringBuffer("IIncomingFileTransferReceiveDataEvent["); //$NON-NLS-1$
- sb.append("isDone=").append(done).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append("bytesReceived=").append(bytesReceived) //$NON-NLS-1$
- .append(";"); //$NON-NLS-1$
- sb.append("percentComplete=").append( //$NON-NLS-1$
- getPercentComplete() * 100).append("]"); //$NON-NLS-1$
- return sb.toString();
- }
- });
+ listener
+ .handleTransferEvent(new IIncomingFileTransferReceiveDataEvent() {
+ private static final long serialVersionUID = -5656328374614130161L;
+
+ public IIncomingFileTransfer getSource() {
+ return XMPPIncomingFileTransfer.this;
+ }
+
+ public String toString() {
+ final StringBuffer sb = new StringBuffer(
+ "IIncomingFileTransferReceiveDataEvent["); //$NON-NLS-1$
+ sb.append("isDone=").append(done).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ sb.append("bytesReceived=").append(bytesReceived) //$NON-NLS-1$
+ .append(";"); //$NON-NLS-1$
+ sb.append("percentComplete=").append( //$NON-NLS-1$
+ getPercentComplete() * 100).append("]"); //$NON-NLS-1$
+ return sb.toString();
+ }
+ });
}
/**
- * @param threadID
- * @param fileName
+ * @param threadID
+ * @param fileName
* @param inputStream
* @param outputStream
- * @param fileSize
+ * @param fileSize
* @param listener
*/
- public XMPPIncomingFileTransfer(ID threadID, String fileName, InputStream inputStream, OutputStream outputStream, long fileSize, IFileTransferListener listener) {
+ public XMPPIncomingFileTransfer(ID threadID, String fileName,
+ InputStream inputStream, OutputStream outputStream, long fileSize,
+ IFileTransferListener listener) {
this.threadID = threadID;
this.fileName = fileName;
this.remoteFileContents = inputStream;
@@ -235,8 +249,10 @@ public class XMPPIncomingFileTransfer implements IIncomingFileTransfer {
return null;
if (adapter.isInstance(this))
return this;
- final IAdapterManager adapterManager = XmppPlugin.getDefault().getAdapterManager();
- return (adapterManager == null) ? null : adapterManager.loadAdapter(this, adapter.getName());
+ final IAdapterManager adapterManager = XmppPlugin.getDefault()
+ .getAdapterManager();
+ return (adapterManager == null) ? null : adapterManager.loadAdapter(
+ this, adapter.getName());
}
/*
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPOutgoingFileTransfer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPOutgoingFileTransfer.java
index 780b3c72c..a310023d5 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPOutgoingFileTransfer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/filetransfer/XMPPOutgoingFileTransfer.java
@@ -12,10 +12,6 @@ package org.eclipse.ecf.internal.provider.xmpp.filetransfer;
import java.io.File;
import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
@@ -27,7 +23,6 @@ import org.eclipse.ecf.filetransfer.IOutgoingFileTransfer;
import org.eclipse.ecf.filetransfer.UserCancelledException;
import org.eclipse.ecf.filetransfer.events.IFileTransferEvent;
import org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferResponseEvent;
-import org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferSendDataEvent;
import org.eclipse.ecf.filetransfer.events.IOutgoingFileTransferSendDoneEvent;
import org.eclipse.ecf.internal.provider.xmpp.XmppPlugin;
import org.eclipse.ecf.provider.xmpp.identity.XMPPID;
@@ -37,12 +32,9 @@ import org.jivesoftware.smackx.filetransfer.FileTransfer;
import org.jivesoftware.smackx.filetransfer.FileTransferManager;
import org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer;
import org.jivesoftware.smackx.filetransfer.FileTransfer.Status;
-import org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer.NegotiationProgress;
public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
- private static final int BUFFER_SIZE = 4096;
-
private final ID sessionID;
private final XMPPID remoteTarget;
private final IFileTransferListener listener;
@@ -53,8 +45,6 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
private final OutgoingFileTransfer outgoingFileTransfer;
- private long amountWritten = 0;
-
private Status status;
private Exception exception;
@@ -63,24 +53,29 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
private boolean localCancelled = false;
- public XMPPOutgoingFileTransfer(FileTransferManager manager, XMPPID remoteTarget, IFileTransferInfo fileTransferInfo, IFileTransferListener listener, int outgoingRequestTimeout) {
+ public XMPPOutgoingFileTransfer(FileTransferManager manager,
+ XMPPID remoteTarget, IFileTransferInfo fileTransferInfo,
+ IFileTransferListener listener, int outgoingRequestTimeout) {
this.remoteTarget = remoteTarget;
this.listener = listener;
this.sessionID = createSessionID();
final String fullyQualifiedName = remoteTarget.getFQName();
- // Set request timeout if we have a new value
+ // Set request timeout if we have a new value
if (outgoingRequestTimeout != -1) {
- originalOutputRequestTimeout = OutgoingFileTransfer.getResponseTimeout();
+ originalOutputRequestTimeout = OutgoingFileTransfer
+ .getResponseTimeout();
OutgoingFileTransfer.setResponseTimeout(outgoingRequestTimeout);
}
- outgoingFileTransfer = manager.createOutgoingFileTransfer(fullyQualifiedName);
+ outgoingFileTransfer = manager
+ .createOutgoingFileTransfer(fullyQualifiedName);
}
private ID createSessionID() {
try {
return IDFactory.getDefault().createGUID();
} catch (final IDCreateException e) {
- throw new NullPointerException("cannot create id for XMPPOutgoingFileTransfer"); //$NON-NLS-1$
+ throw new NullPointerException(
+ "cannot create id for XMPPOutgoingFileTransfer"); //$NON-NLS-1$
}
}
@@ -109,17 +104,17 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
}
private void setErrorStatus(Exception e) {
- setStatus(FileTransfer.Status.ERROR);
+ setStatus(FileTransfer.Status.error);
setException(e);
}
- public synchronized void startSend(File localFile, String description) throws XMPPException {
+ public synchronized void startSend(File localFile, String description)
+ throws XMPPException {
this.localFile = localFile;
this.fileSize = localFile.length();
- setStatus(Status.INITIAL);
- final NegotiationProgress progress = new NegotiationProgress();
+ setStatus(Status.initial);
- outgoingFileTransfer.sendFile(localFile.getAbsolutePath(), this.fileSize, description, progress);
+ outgoingFileTransfer.sendFile(localFile, description);
final Thread transferThread = new Thread(new Runnable() {
public void run() {
@@ -134,10 +129,15 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
setErrorStatus(e);
return;
}
- final Status s = progress.getStatus();
+ final Status s = outgoingFileTransfer.getStatus();
setStatus(s);
- final boolean negotiated = getStatus().equals(Status.NEGOTIATED);
- if (s.equals(Status.NEGOTIATED) || s.equals(Status.CANCLED) || s.equals(Status.COMPLETE) || s.equals(Status.ERROR) || s.equals(Status.REFUSED)) {
+ final boolean negotiated = getStatus().equals(
+ Status.negotiated);
+ if (s.equals(Status.negotiated)
+ || s.equals(Status.cancelled)
+ || s.equals(Status.complete)
+ || s.equals(Status.error)
+ || s.equals(Status.refused)) {
fireTransferListenerEvent(new IOutgoingFileTransferResponseEvent() {
private static final long serialVersionUID = -5940612388464073240L;
@@ -150,12 +150,15 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
}
public String toString() {
- final StringBuffer buf = new StringBuffer("OutgoingFileTransferResponseEvent["); //$NON-NLS-1$
- buf.append("requestAccepted=").append(requestAccepted()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ final StringBuffer buf = new StringBuffer(
+ "OutgoingFileTransferResponseEvent["); //$NON-NLS-1$
+ buf
+ .append("requestAccepted=").append(requestAccepted()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return buf.toString();
}
- public void setFileTransferJob(FileTransferJob job) {
+ public void setFileTransferJob(
+ FileTransferJob job) {
// does nothing with this implementation
}
});
@@ -165,26 +168,24 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
}
if (localCancelled) {
- setErrorStatus(new UserCancelledException("Transfer cancelled by sender")); //$NON-NLS-1$
- return;
- }
-
- final OutputStream outs = progress.getOutputStream();
-
- if (outs == null) {
- setErrorStatus(new IOException("No output stream available")); //$NON-NLS-1$
+ setErrorStatus(new UserCancelledException(
+ "Transfer cancelled by sender")); //$NON-NLS-1$
return;
}
- writeToStream(new FileInputStream(XMPPOutgoingFileTransfer.this.localFile), outs);
- setStatus(Status.COMPLETE);
+ outgoingFileTransfer.sendStream(new FileInputStream(
+ XMPPOutgoingFileTransfer.this.localFile),
+ XMPPOutgoingFileTransfer.this.localFile.getName(),
+ fileSize, "Ein File");
+ setStatus(Status.complete);
} catch (final Exception e) {
- setStatus(FileTransfer.Status.ERROR);
+ setStatus(FileTransfer.Status.error);
setException(e);
} finally {
// Reset request timeout
if (originalOutputRequestTimeout != -1) {
- OutgoingFileTransfer.setResponseTimeout(originalOutputRequestTimeout);
+ OutgoingFileTransfer
+ .setResponseTimeout(originalOutputRequestTimeout);
}
// Then notify that the sending is done
fireTransferListenerEvent(new IOutgoingFileTransferSendDoneEvent() {
@@ -195,10 +196,13 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
}
public String toString() {
- final StringBuffer buf = new StringBuffer("IOutgoingFileTransferSendDoneEvent["); //$NON-NLS-1$
+ final StringBuffer buf = new StringBuffer(
+ "IOutgoingFileTransferSendDoneEvent["); //$NON-NLS-1$
buf.append("isDone=" + getSource().isDone()); //$NON-NLS-1$
- buf.append(";bytesSent=").append(getSource().getBytesSent()); //$NON-NLS-1$
- buf.append(";exception=").append(getException()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
+ buf
+ .append(";bytesSent=").append(getSource().getBytesSent()); //$NON-NLS-1$
+ buf
+ .append(";exception=").append(getException()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return buf.toString();
}
});
@@ -217,7 +221,9 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
return localFile;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
@@ -225,12 +231,14 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
return null;
if (adapter.isInstance(this))
return this;
- final IAdapterManager adapterManager = XmppPlugin.getDefault().getAdapterManager();
- return (adapterManager == null) ? null : adapterManager.loadAdapter(this, adapter.getName());
+ final IAdapterManager adapterManager = XmppPlugin.getDefault()
+ .getAdapterManager();
+ return (adapterManager == null) ? null : adapterManager.loadAdapter(
+ this, adapter.getName());
}
public long getBytesSent() {
- return amountWritten;
+ return outgoingFileTransfer.getBytesSent();
}
public Exception getException() {
@@ -238,64 +246,22 @@ public class XMPPOutgoingFileTransfer implements IOutgoingFileTransfer {
}
public double getPercentComplete() {
- return (fileSize <= 0) ? 1.0 : (((double) amountWritten) / ((double) fileSize));
+ return (fileSize <= 0) ? 1.0 : (((double) outgoingFileTransfer
+ .getAmountWritten()) / ((double) fileSize));
}
public boolean isDone() {
- return status == Status.CANCLED || status == Status.ERROR || status == Status.COMPLETE;
+ return status == Status.cancelled || status == Status.error
+ || status == Status.complete;
}
public ID getSessionID() {
return sessionID;
}
- protected void writeToStream(final InputStream in, final OutputStream out) throws XMPPException, IOException, UserCancelledException {
- final byte[] b = new byte[BUFFER_SIZE];
- int count = 0;
- amountWritten = 0;
- try {
- do {
-
- if (localCancelled)
- throw new UserCancelledException("Transfer cancelled by sender"); //$NON-NLS-1$
-
- out.write(b, 0, count);
-
- amountWritten += count;
-
- if (count > 0) {
- fireTransferListenerEvent(new IOutgoingFileTransferSendDataEvent() {
- private static final long serialVersionUID = 2327297070577249812L;
-
- public IOutgoingFileTransfer getSource() {
- return XMPPOutgoingFileTransfer.this;
- }
-
- public String toString() {
- final StringBuffer buf = new StringBuffer("IOutgoingFileTransferSendDataEvent["); //$NON-NLS-1$
- buf.append("bytesSent=").append(getSource().getBytesSent()); //$NON-NLS-1$
- buf.append(";percentComplete=").append(getSource().getPercentComplete()).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
- return buf.toString();
- }
-
- });
- }
- // read more bytes from the input stream
- count = in.read(b);
- } while (count != -1 && !getStatus().equals(Status.CANCLED));
-
- // the connection was likely terminated abruptly if these are not equal
- if (!getStatus().equals(Status.CANCLED) && amountWritten != fileSize) {
- setStatus(Status.ERROR);
- }
- } finally {
- out.flush();
- out.close();
- in.close();
- }
- }
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.ecf.filetransfer.IFileTransfer#getFileLength()
*/
public long getFileLength() {
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java
index fc1974a67..026e3513e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java
@@ -9,18 +9,36 @@
package org.eclipse.ecf.internal.provider.xmpp.smack;
import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.ecf.core.ContainerAuthenticationException;
import org.eclipse.ecf.core.ContainerConnectException;
-import org.eclipse.ecf.core.identity.*;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.util.ECFException;
import org.eclipse.ecf.internal.provider.xmpp.XmppPlugin;
-import org.eclipse.ecf.provider.comm.*;
+import org.eclipse.ecf.provider.comm.DisconnectEvent;
+import org.eclipse.ecf.provider.comm.IAsynchEventHandler;
+import org.eclipse.ecf.provider.comm.IConnectionListener;
+import org.eclipse.ecf.provider.comm.ISynchAsynchConnection;
import org.eclipse.ecf.provider.xmpp.identity.XMPPID;
import org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID;
-import org.jivesoftware.smack.*;
-import org.jivesoftware.smack.packet.*;
+import org.jivesoftware.smack.Chat;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.ConnectionListener;
+import org.jivesoftware.smack.MessageListener;
+import org.jivesoftware.smack.PacketListener;
+import org.jivesoftware.smack.Roster;
+import org.jivesoftware.smack.RosterEntry;
+import org.jivesoftware.smack.SASLAuthentication;
+import org.jivesoftware.smack.SmackConfiguration;
+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;
import org.jivesoftware.smack.packet.Message.Type;
public class ECFConnection implements ISynchAsynchConnection {
@@ -50,8 +68,6 @@ public class ECFConnection implements ISynchAsynchConnection {
private boolean google = false;
- private boolean secure = false;
-
private boolean disconnecting = false;
private final PacketListener packetListener = new PacketListener() {
@@ -68,6 +84,15 @@ public class ECFConnection implements ISynchAsynchConnection {
public void connectionClosedOnError(Exception e) {
handleConnectionClosed(e);
}
+
+ public void reconnectingIn(int seconds) {
+ }
+
+ public void reconnectionFailed(Exception e) {
+ }
+
+ public void reconnectionSuccessful() {
+ }
};
protected void logException(String msg, Throwable t) {
@@ -98,20 +123,14 @@ public class ECFConnection implements ISynchAsynchConnection {
return connection;
}
- public ECFConnection(boolean google, Namespace ns, IAsynchEventHandler h,
- boolean secure) {
+ public ECFConnection(boolean google, Namespace ns, IAsynchEventHandler h) {
this.handler = h;
this.namespace = ns;
this.google = google;
- this.secure = secure;
if (DEBUG)
XMPPConnection.DEBUG_ENABLED = true;
}
- public ECFConnection(boolean google, Namespace ns, IAsynchEventHandler h) {
- this(google, ns, h, false);
- }
-
protected String getPasswordForObject(Object data) {
String password = null;
try {
@@ -138,7 +157,7 @@ public class ECFConnection implements ISynchAsynchConnection {
throw new ECFException("already connected");
if (timeout > 0)
SmackConfiguration.setPacketReplyTimeout(timeout);
- Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL);
+ Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
final XMPPID jabberURI = getXMPPID(remote);
@@ -176,44 +195,34 @@ public class ECFConnection implements ISynchAsynchConnection {
jabberURI.setResourceName(serverResource);
}
try {
+ ConnectionConfiguration config;
if (hostnameOverride != null) {
- if (secure) {
- if (serverPort == -1) {
- serverPort = XMPPS_DEFAULT_PORT;
- }
- connection = new SSLXMPPConnection(hostnameOverride,
- serverPort, serviceName);
- } else {
- if (serverPort == -1) {
- serverPort = XMPP_DEFAULT_PORT;
- }
- connection = new XMPPConnection(hostnameOverride,
- serverPort, serviceName);
- }
+ config = new ConnectionConfiguration(hostnameOverride,
+ XMPP_DEFAULT_PORT, serviceName);
} else if (serverPort == -1) {
- if (secure) {
- connection = new SSLXMPPConnection(serviceName);
- } else {
- connection = new XMPPConnection(serviceName);
- }
+ config = new ConnectionConfiguration(serviceName);
} else {
- if (secure) {
- connection = new SSLXMPPConnection(serviceName, serverPort);
- } else {
- connection = new XMPPConnection(serviceName, serverPort);
- }
+ config = new ConnectionConfiguration(serviceName, serverPort);
+ }
+ config.setSendPresence(true);
+ connection = new XMPPConnection(config);
+ connection.connect();
+
+ SASLAuthentication.supportSASLMechanism("PLAIN", 0);
+
+ if (google || GOOGLE_TALK_HOST.equals(hostnameOverride)) {
+ username = username + "@" + serviceName;
}
connection.addPacketListener(packetListener, null);
connection.addConnectionListener(connectionListener);
+
// Login
connection.login(username, (String) data, serverResource);
+
isConnected = true;
} catch (final XMPPException e) {
- if (e.getMessage().equals("(401)"))
- throw new ContainerAuthenticationException(
- "Password incorrect", e);
- throw new ContainerConnectException(e.getLocalizedMessage(), e);
+ throw new ContainerConnectException("Login attempt failed", e);
}
return null;
}
@@ -235,7 +244,7 @@ public class ECFConnection implements ISynchAsynchConnection {
if (connection != null) {
connection.removePacketListener(packetListener);
connection.removeConnectionListener(connectionListener);
- connection.close();
+ connection.disconnect();
isConnected = false;
connection = null;
}
@@ -317,13 +326,18 @@ public class ECFConnection implements ISynchAsynchConnection {
"receiver cannot be null for xmpp instant messaging");
else if (receiver instanceof XMPPID) {
final XMPPID rcvr = (XMPPID) receiver;
- aMsg.setType(Message.Type.CHAT);
+ aMsg.setType(Message.Type.chat);
final String receiverName = rcvr.getFQName();
- final Chat localChat = connection.createChat(receiverName);
+ final Chat localChat = connection.getChatManager()
+ .createChat(receiverName, new MessageListener() {
+ public void processMessage(Chat chat,
+ Message message) {
+ }
+ });
localChat.sendMessage(aMsg);
} else if (receiver instanceof XMPPRoomID) {
final XMPPRoomID roomID = (XMPPRoomID) receiver;
- aMsg.setType(Message.Type.GROUP_CHAT);
+ aMsg.setType(Message.Type.groupchat);
final String to = roomID.getMucString();
aMsg.setTo(to);
connection.sendPacket(aMsg);
@@ -368,7 +382,7 @@ public class ECFConnection implements ISynchAsynchConnection {
public static Map getPropertiesFromPacket(Packet packet) {
final Map result = new HashMap();
- final Iterator i = packet.getPropertyNames();
+ final Iterator i = packet.getPropertyNames().iterator();
for (; i.hasNext();) {
final String name = (String) i.next();
result.put(name, packet.getProperty(name));
@@ -383,18 +397,7 @@ public class ECFConnection implements ISynchAsynchConnection {
final Object val = properties.get(keyo);
final String key = (keyo instanceof String) ? (String) keyo
: keyo.toString();
- if (val instanceof Boolean)
- input.setProperty(key, ((Boolean) val).booleanValue());
- else if (val instanceof Double)
- input.setProperty(key, ((Double) val).doubleValue());
- else if (val instanceof Float)
- input.setProperty(key, ((Float) val).floatValue());
- else if (val instanceof Integer)
- input.setProperty(key, ((Integer) val).intValue());
- else if (val instanceof Long)
- input.setProperty(key, ((Long) val).floatValue());
- else if (val instanceof Object)
- input.setProperty(key, val);
+ input.setProperty(key, val);
}
}
return input;
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java
index 488990226..75587760f 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPContainer.java
@@ -366,7 +366,7 @@ public class XMPPContainer extends ClientSOContainer implements
}
protected boolean handleAsExtension(Packet packet) {
- final Iterator i = packet.getExtensions();
+ final Iterator i = packet.getExtensions().iterator();
for (; i.hasNext();) {
final Object extension = i.next();
if (extension instanceof XHTMLExtension) {
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPSContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPSContainer.java
index 4f210a9a0..498fbb3e9 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPSContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/XMPPSContainer.java
@@ -48,8 +48,7 @@ public class XMPPSContainer extends XMPPContainer {
protected ISynchAsynchConnection createConnection(ID remoteSpace,
Object data) throws ConnectionCreateException {
boolean google = isGoogle(remoteSpace);
- return new ECFConnection(google, getConnectNamespace(), receiver,
- true);
+ return new ECFConnection(google, getConnectNamespace(), receiver);
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
index 8daabf257..ccb8d1c26 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
@@ -151,9 +151,12 @@ public class XMPPID extends BaseID implements IChatID, IFQID {
// The resources are considered equal if either one is null (not known
// yet), or they are equal by
// string comparison
- boolean resourceEquals = (thisResourceName == null && otherResourceName == null)
- || (thisResourceName != null && otherResourceName != null && thisResourceName
- .equals(otherResourceName));
+ boolean resourceEquals = false;
+ if (thisResourceName == null) {
+ resourceEquals = (otherResourceName == null) ? true : false;
+ } else {
+ resourceEquals = thisResourceName.equals(otherResourceName);
+ }
return resourceEquals
&& getUsernameAtHost().equals(other.getUsernameAtHost());
}

Back to the top