diff options
author | Eike Stepper | 2007-10-16 18:36:32 +0000 |
---|---|---|
committer | Eike Stepper | 2007-10-16 18:36:32 +0000 |
commit | fc88843d9feef67e8d492962e00288261d21e234 (patch) | |
tree | 1c64e2012f6a4876beab69e1664ec0d6fac07e61 | |
parent | 59924eae7c4e46412ca8a9a3597887e2344d9ca2 (diff) | |
download | cdo-fc88843d9feef67e8d492962e00288261d21e234.tar.gz cdo-fc88843d9feef67e8d492962e00288261d21e234.tar.xz cdo-fc88843d9feef67e8d492962e00288261d21e234.zip |
[206224] Provide chat example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206224
4 files changed, 52 insertions, 5 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java index b92466e6e2..4d60348f90 100644 --- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java +++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java @@ -3,6 +3,7 @@ package org.eclipse.net4j.buddies.internal.server.protocol; import org.eclipse.net4j.buddies.internal.protocol.Collaboration; import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftIndication; import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftNotification; +import org.eclipse.net4j.buddies.internal.server.BuddyAdmin; import org.eclipse.net4j.buddies.protocol.IBuddy; import org.eclipse.net4j.buddies.server.IBuddyAdmin; import org.eclipse.net4j.util.ObjectUtil; @@ -37,5 +38,9 @@ public class ServerCollaborationLeftIndication extends CollaborationLeftIndicati } super.collaborationLeft(collaboration, userID); + if (collaboration.getBuddies().length == 0 && !collaboration.isPublic()) + { + BuddyAdmin.INSTANCE.removeCollaboration(collaboration.getID()); + } } }
\ No newline at end of file diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java index 80e17ecb66..6716fe8987 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/Self.java @@ -62,6 +62,11 @@ public class Self extends Buddy BuddyCollaboration collaboration = new BuddyCollaboration(session, id, buddies); LifecycleUtil.activate(collaboration); addCollaboration(collaboration); + for (IBuddy buddy : buddies) + { + ((Buddy)buddy).addCollaboration(collaboration); + } + return collaboration; } catch (Exception ex) diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientCollaborationLeftIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientCollaborationLeftIndication.java new file mode 100644 index 0000000000..3064146c44 --- /dev/null +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientCollaborationLeftIndication.java @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.internal.protocol.Buddy; +import org.eclipse.net4j.buddies.internal.protocol.Collaboration; +import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftIndication; +import org.eclipse.net4j.internal.buddies.Self; + +/** + * @author Eike Stepper + */ +public class ClientCollaborationLeftIndication extends CollaborationLeftIndication +{ + private Self self; + + public ClientCollaborationLeftIndication(Self self) + { + super(self); + this.self = self; + } + + @Override + protected void collaborationLeft(Collaboration collaboration, String userID) + { + Buddy buddy = (Buddy)self.getSession().getBuddy(userID); + buddy.removeCollaboration(collaboration.getID()); + super.collaborationLeft(collaboration, userID); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java index aaded8efe5..ac1ca69e75 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientProtocol.java @@ -10,11 +10,10 @@ **************************************************************************/ package org.eclipse.net4j.internal.buddies.protocol; -import org.eclipse.net4j.buddies.internal.protocol.CollaborationLeftIndication; import org.eclipse.net4j.buddies.internal.protocol.MessageIndication; import org.eclipse.net4j.buddies.internal.protocol.ProtocolConstants; -import org.eclipse.net4j.buddies.protocol.IBuddy; import org.eclipse.net4j.buddies.protocol.ISession; +import org.eclipse.net4j.internal.buddies.Self; import org.eclipse.net4j.signal.SignalProtocol; import org.eclipse.net4j.signal.SignalReactor; @@ -50,7 +49,7 @@ public class ClientProtocol extends SignalProtocol return new CollaborationInitiatedIndication(); case ProtocolConstants.SIGNAL_COLLABORATION_LEFT: - return new CollaborationLeftIndication(getSelf()); + return new ClientCollaborationLeftIndication(getSelf()); case ProtocolConstants.SIGNAL_FACILITY_INSTALLED: return new FacilityInstalledIndication(); @@ -62,9 +61,9 @@ public class ClientProtocol extends SignalProtocol return null; } - protected IBuddy getSelf() + protected Self getSelf() { ISession session = (ISession)getInfraStructure(); - return session.getSelf(); + return (Self)session.getSelf(); } } |