diff options
author | Eike Stepper | 2012-07-19 08:22:04 +0000 |
---|---|---|
committer | Eike Stepper | 2012-07-19 08:22:04 +0000 |
commit | 1460904fd3c193ffaf809913b2983a400fce9d94 (patch) | |
tree | 72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.net4j.buddies/src/org | |
parent | 5f360965ae87478e0681899bf310a210cafc2c44 (diff) | |
download | cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip |
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.net4j.buddies/src/org')
23 files changed, 1619 insertions, 1619 deletions
diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java index 6834ef10c1..bab955a655 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/BuddiesUtil.java @@ -1,55 +1,55 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.buddies;
-
-import org.eclipse.net4j.buddies.spi.common.ClientFacilityFactory;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol;
-import org.eclipse.net4j.internal.buddies.protocol.OpenSessionRequest;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public final class BuddiesUtil
-{
- private BuddiesUtil()
- {
- }
-
- public static Set<String> getFacilityTypes()
- {
- return IPluginContainer.INSTANCE.getFactoryTypes(ClientFacilityFactory.PRODUCT_GROUP);
- }
-
- public static IBuddySession openSession(IConnector connector, String userID, String password, long timeout)
- {
- try
- {
- BuddiesClientProtocol protocol = new BuddiesClientProtocol(connector);
- OpenSessionRequest request = new OpenSessionRequest(protocol, userID, password, getFacilityTypes());
- return request.send(timeout);
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public static IBuddySession openSession(IConnector connector, String userID, String password)
- {
- return openSession(connector, userID, password, RequestWithConfirmation.NO_TIMEOUT);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.buddies; + +import org.eclipse.net4j.buddies.spi.common.ClientFacilityFactory; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol; +import org.eclipse.net4j.internal.buddies.protocol.OpenSessionRequest; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.container.IPluginContainer; + +import java.util.Set; + +/** + * @author Eike Stepper + */ +public final class BuddiesUtil +{ + private BuddiesUtil() + { + } + + public static Set<String> getFacilityTypes() + { + return IPluginContainer.INSTANCE.getFactoryTypes(ClientFacilityFactory.PRODUCT_GROUP); + } + + public static IBuddySession openSession(IConnector connector, String userID, String password, long timeout) + { + try + { + BuddiesClientProtocol protocol = new BuddiesClientProtocol(connector); + OpenSessionRequest request = new OpenSessionRequest(protocol, userID, password, getFacilityTypes()); + return request.send(timeout); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + + public static IBuddySession openSession(IConnector connector, String userID, String password) + { + return openSession(connector, userID, password, RequestWithConfirmation.NO_TIMEOUT); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java index 61176929c2..b3909297b7 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddyCollaboration.java @@ -1,31 +1,31 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.buddies;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.ICollaboration;
-import org.eclipse.net4j.buddies.common.IFacility;
-
-/**
- * @author Eike Stepper
- */
-public interface IBuddyCollaboration extends ICollaboration
-{
- public IBuddySession getSession();
-
- public IFacility installFacility(String type);
-
- public IBuddy[] invite(String... userIDs);
-
- public void invite(IBuddy... buddies);
-
- public void leave();
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.buddies; + +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.common.ICollaboration; +import org.eclipse.net4j.buddies.common.IFacility; + +/** + * @author Eike Stepper + */ +public interface IBuddyCollaboration extends ICollaboration +{ + public IBuddySession getSession(); + + public IFacility installFacility(String type); + + public IBuddy[] invite(String... userIDs); + + public void invite(IBuddy... buddies); + + public void leave(); +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java index 11eccf21be..32bd044193 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/IBuddySession.java @@ -1,25 +1,25 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.buddies;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IBuddyContainer;
-import org.eclipse.net4j.buddies.common.ISession;
-
-/**
- * @author Eike Stepper
- */
-public interface IBuddySession extends ISession, IBuddyContainer
-{
- public IBuddy getSelf();
-
- public void close();
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.buddies; + +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.common.IBuddyContainer; +import org.eclipse.net4j.buddies.common.ISession; + +/** + * @author Eike Stepper + */ +public interface IBuddySession extends ISession, IBuddyContainer +{ + public IBuddy getSelf(); + + public void close(); +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManager.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManager.java index e278f1873c..1ac90de932 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManager.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManager.java @@ -1,43 +1,43 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.buddies;
-
-import org.eclipse.net4j.util.event.INotifier;
-
-/**
- * @author Eike Stepper
- */
-public interface ISessionManager extends INotifier
-{
- public static final ISessionManager INSTANCE = org.eclipse.net4j.internal.buddies.SessionManager.INSTANCE;
-
- public IBuddySession getSession();
-
- public State getState();
-
- public boolean isConnecting();
-
- public void connect();
-
- public void disconnect();
-
- public void flashMe();
-
- public boolean isFlashing();
-
- /**
- * @author Eike Stepper
- */
- public enum State
- {
- CONNECTING, CONNECTED, DISCONNECTED
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.buddies; + +import org.eclipse.net4j.util.event.INotifier; + +/** + * @author Eike Stepper + */ +public interface ISessionManager extends INotifier +{ + public static final ISessionManager INSTANCE = org.eclipse.net4j.internal.buddies.SessionManager.INSTANCE; + + public IBuddySession getSession(); + + public State getState(); + + public boolean isConnecting(); + + public void connect(); + + public void disconnect(); + + public void flashMe(); + + public boolean isFlashing(); + + /** + * @author Eike Stepper + */ + public enum State + { + CONNECTING, CONNECTED, DISCONNECTED + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManagerEvent.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManagerEvent.java index 7851a4bf2c..d34e1aa7f0 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManagerEvent.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/buddies/ISessionManagerEvent.java @@ -1,25 +1,25 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.buddies;
-
-import org.eclipse.net4j.util.event.IEvent;
-
-/**
- * @author Eike Stepper
- */
-public interface ISessionManagerEvent extends IEvent
-{
- public ISessionManager.State getOldState();
-
- public ISessionManager.State getNewState();
-
- public IBuddySession getSession();
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.buddies; + +import org.eclipse.net4j.util.event.IEvent; + +/** + * @author Eike Stepper + */ +public interface ISessionManagerEvent extends IEvent +{ + public ISessionManager.State getOldState(); + + public ISessionManager.State getNewState(); + + public IBuddySession getSession(); +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java index d0fff0df5f..5196f4a678 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/BuddyCollaboration.java @@ -1,167 +1,167 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies;
-
-import org.eclipse.net4j.buddies.IBuddyCollaboration;
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IFacility;
-import org.eclipse.net4j.buddies.common.IMessage;
-import org.eclipse.net4j.buddies.internal.common.Collaboration;
-import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftNotification;
-import org.eclipse.net4j.buddies.internal.common.protocol.MessageNotification;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.spi.common.ClientFacilityFactory;
-import org.eclipse.net4j.buddies.spi.common.Message;
-import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol;
-import org.eclipse.net4j.internal.buddies.protocol.InstallFacilityRequest;
-import org.eclipse.net4j.internal.buddies.protocol.InviteBuddiesNotification;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class BuddyCollaboration extends Collaboration implements IBuddyCollaboration
-{
- private static final String FACILITY_GROUP = ClientFacilityFactory.PRODUCT_GROUP;
-
- private IBuddySession session;
-
- public BuddyCollaboration(IBuddySession session, long id)
- {
- super(id);
- this.session = session;
- }
-
- public IBuddySession getSession()
- {
- return session;
- }
-
- public IFacility installFacility(String type)
- {
- return installFacility(type, true);
- }
-
- public IFacility installFacility(String type, boolean request)
- {
- IFacility facility = createFacility(type);
- if (request)
- {
- try
- {
- BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- boolean success = new InstallFacilityRequest(protocol, getID(), type).send(ProtocolConstants.TIMEOUT);
- if (!success)
- {
- return null;
- }
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- addFacility(facility, !request);
- return facility;
- }
-
- public IFacility createFacility(String type)
- {
- IFacility facility = (IFacility)getContainer().getElement(FACILITY_GROUP, type, String.valueOf(getID()));
- facility.setCollaboration(this);
- return facility;
- }
-
- @Override
- public void sendMessage(long collaborationID, String facilityType, IMessage message)
- {
- if (message instanceof Message)
- {
- ((Message)message).setSenderID(session.getSelf().getUserID());
- }
-
- try
- {
- BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- new MessageNotification(protocol, collaborationID, facilityType, message).sendAsync();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public IBuddy[] invite(String... userIDs)
- {
- List<IBuddy> buddies = new ArrayList<IBuddy>();
- for (String userID : userIDs)
- {
- IBuddy buddy = session.getBuddy(userID);
- buddies.add(buddy);
- }
-
- IBuddy[] array = buddies.toArray(new IBuddy[buddies.size()]);
- invite(array);
- return array;
- }
-
- public void invite(IBuddy... buddies)
- {
- List<IBuddy> invitations = new ArrayList<IBuddy>();
- for (IBuddy buddy : buddies)
- {
- if (getMembership(buddy) == null)
- {
- invitations.add(buddy);
- }
- }
-
- if (!invitations.isEmpty())
- {
- try
- {
- BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- new InviteBuddiesNotification(protocol, getID(), invitations).sendAsync();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- }
-
- public void leave()
- {
- try
- {
- BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol();
- new CollaborationLeftNotification(protocol, getID(), session.getSelf().getUserID()).sendAsync();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- deactivate();
- }
-
- protected IManagedContainer getContainer()
- {
- return IPluginContainer.INSTANCE;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies; + +import org.eclipse.net4j.buddies.IBuddyCollaboration; +import org.eclipse.net4j.buddies.IBuddySession; +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.common.IFacility; +import org.eclipse.net4j.buddies.common.IMessage; +import org.eclipse.net4j.buddies.internal.common.Collaboration; +import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftNotification; +import org.eclipse.net4j.buddies.internal.common.protocol.MessageNotification; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.buddies.spi.common.ClientFacilityFactory; +import org.eclipse.net4j.buddies.spi.common.Message; +import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol; +import org.eclipse.net4j.internal.buddies.protocol.InstallFacilityRequest; +import org.eclipse.net4j.internal.buddies.protocol.InviteBuddiesNotification; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IPluginContainer; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class BuddyCollaboration extends Collaboration implements IBuddyCollaboration +{ + private static final String FACILITY_GROUP = ClientFacilityFactory.PRODUCT_GROUP; + + private IBuddySession session; + + public BuddyCollaboration(IBuddySession session, long id) + { + super(id); + this.session = session; + } + + public IBuddySession getSession() + { + return session; + } + + public IFacility installFacility(String type) + { + return installFacility(type, true); + } + + public IFacility installFacility(String type, boolean request) + { + IFacility facility = createFacility(type); + if (request) + { + try + { + BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol(); + boolean success = new InstallFacilityRequest(protocol, getID(), type).send(ProtocolConstants.TIMEOUT); + if (!success) + { + return null; + } + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + + addFacility(facility, !request); + return facility; + } + + public IFacility createFacility(String type) + { + IFacility facility = (IFacility)getContainer().getElement(FACILITY_GROUP, type, String.valueOf(getID())); + facility.setCollaboration(this); + return facility; + } + + @Override + public void sendMessage(long collaborationID, String facilityType, IMessage message) + { + if (message instanceof Message) + { + ((Message)message).setSenderID(session.getSelf().getUserID()); + } + + try + { + BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol(); + new MessageNotification(protocol, collaborationID, facilityType, message).sendAsync(); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + + public IBuddy[] invite(String... userIDs) + { + List<IBuddy> buddies = new ArrayList<IBuddy>(); + for (String userID : userIDs) + { + IBuddy buddy = session.getBuddy(userID); + buddies.add(buddy); + } + + IBuddy[] array = buddies.toArray(new IBuddy[buddies.size()]); + invite(array); + return array; + } + + public void invite(IBuddy... buddies) + { + List<IBuddy> invitations = new ArrayList<IBuddy>(); + for (IBuddy buddy : buddies) + { + if (getMembership(buddy) == null) + { + invitations.add(buddy); + } + } + + if (!invitations.isEmpty()) + { + try + { + BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol(); + new InviteBuddiesNotification(protocol, getID(), invitations).sendAsync(); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + } + + public void leave() + { + try + { + BuddiesClientProtocol protocol = (BuddiesClientProtocol)session.getProtocol(); + new CollaborationLeftNotification(protocol, getID(), session.getSelf().getUserID()).sendAsync(); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + + deactivate(); + } + + protected IManagedContainer getContainer() + { + return IPluginContainer.INSTANCE; + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java index 1842faefb1..dc19ff82a2 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientBuddy.java @@ -1,84 +1,84 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies;
-
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IMembership;
-import org.eclipse.net4j.buddies.internal.common.Buddy;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class ClientBuddy extends Buddy
-{
- private String userID;
-
- private IAccount account;
-
- public ClientBuddy(ClientSession session, String userID)
- {
- super(session, null);
- this.userID = userID;
- }
-
- @Override
- public ClientSession getSession()
- {
- return (ClientSession)super.getSession();
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public IAccount getAccount()
- {
- if (account == null)
- {
- account = loadAccount(userID);
- }
-
- return account;
- }
-
- public IMembership[] initiate(Collection<IBuddy> buddies)
- {
- throw new UnsupportedOperationException();
- }
-
- public IMembership join(long collaborationID)
- {
- throw new UnsupportedOperationException();
- }
-
- public IMembership join(Object invitationToken)
- {
- throw new UnsupportedOperationException();
- }
-
- protected IAccount loadAccount(String userID)
- {
- // TODO Implement method ClientBuddy.loadAccount()
- throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
- }
-
- @Override
- protected Set<String> loadFacilityTypes()
- {
- // TODO Implement method ClientBuddy.loadFacilityTypes()
- throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies; + +import org.eclipse.net4j.buddies.common.IAccount; +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.common.IMembership; +import org.eclipse.net4j.buddies.internal.common.Buddy; + +import java.util.Collection; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class ClientBuddy extends Buddy +{ + private String userID; + + private IAccount account; + + public ClientBuddy(ClientSession session, String userID) + { + super(session, null); + this.userID = userID; + } + + @Override + public ClientSession getSession() + { + return (ClientSession)super.getSession(); + } + + public String getUserID() + { + return userID; + } + + public IAccount getAccount() + { + if (account == null) + { + account = loadAccount(userID); + } + + return account; + } + + public IMembership[] initiate(Collection<IBuddy> buddies) + { + throw new UnsupportedOperationException(); + } + + public IMembership join(long collaborationID) + { + throw new UnsupportedOperationException(); + } + + public IMembership join(Object invitationToken) + { + throw new UnsupportedOperationException(); + } + + protected IAccount loadAccount(String userID) + { + // TODO Implement method ClientBuddy.loadAccount() + throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$ + } + + @Override + protected Set<String> loadFacilityTypes() + { + // TODO Implement method ClientBuddy.loadFacilityTypes() + throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java index 4caead8e4d..0cc7a39c04 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/ClientSession.java @@ -1,145 +1,145 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies;
-
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IBuddyStateEvent;
-import org.eclipse.net4j.buddies.common.IMembership;
-import org.eclipse.net4j.buddies.internal.common.BuddyContainer;
-import org.eclipse.net4j.buddies.internal.common.Collaboration;
-import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateNotification;
-import org.eclipse.net4j.internal.buddies.bundle.OM;
-import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.log.OMLogger;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PlatformObject;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class ClientSession extends BuddyContainer implements IBuddySession
-{
- private BuddiesClientProtocol protocol;
-
- private Self self;
-
- public ClientSession(BuddiesClientProtocol protocol)
- {
- this.protocol = protocol;
- }
-
- public BuddiesClientProtocol getProtocol()
- {
- return protocol;
- }
-
- public Self getSelf()
- {
- return self;
- }
-
- public void setSelf(IAccount account, Set<String> facilityTypes)
- {
- self = new Self(this, account, facilityTypes);
- self.activate();
- self.addListener(this);
- }
-
- public void close()
- {
- protocol.close();
- protocol = null;
- LifecycleUtil.deactivate(this, OMLogger.Level.DEBUG);
- }
-
- /**
- * @see PlatformObject#getAdapter(Class)
- */
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter)
- {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- @Override
- public void notifyEvent(IEvent event)
- {
- if (event.getSource() == protocol)
- {
- if (event instanceof ILifecycleEvent)
- {
- if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
- {
- deactivate();
- }
- }
- }
- else if (event.getSource() == self)
- {
- if (event instanceof IBuddyStateEvent)
- {
- try
- {
- new BuddyStateNotification(protocol, self.getUserID(), ((IBuddyStateEvent)event).getNewState()).sendAsync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
- }
-
- public void buddyAdded(String userID)
- {
- ClientBuddy buddy = new ClientBuddy(this, userID);
- buddy.activate();
- addBuddy(buddy);
- }
-
- public void buddyRemoved(String userID)
- {
- IBuddy buddy = removeBuddy(userID);
- if (buddy != null)
- {
- for (IMembership membership : self.getMemberships())
- {
- Collaboration collaboration = (Collaboration)membership.getCollaboration();
- collaboration.removeMembership(buddy);
- }
-
- LifecycleUtil.deactivate(buddy);
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- protocol.addListener(this);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- protocol.removeListener(this);
- LifecycleUtil.deactivate(self);
- super.doDeactivate();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies; + +import org.eclipse.net4j.buddies.IBuddySession; +import org.eclipse.net4j.buddies.common.IAccount; +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.common.IBuddyStateEvent; +import org.eclipse.net4j.buddies.common.IMembership; +import org.eclipse.net4j.buddies.internal.common.BuddyContainer; +import org.eclipse.net4j.buddies.internal.common.Collaboration; +import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateNotification; +import org.eclipse.net4j.internal.buddies.bundle.OM; +import org.eclipse.net4j.internal.buddies.protocol.BuddiesClientProtocol; +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.om.log.OMLogger; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.PlatformObject; + +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class ClientSession extends BuddyContainer implements IBuddySession +{ + private BuddiesClientProtocol protocol; + + private Self self; + + public ClientSession(BuddiesClientProtocol protocol) + { + this.protocol = protocol; + } + + public BuddiesClientProtocol getProtocol() + { + return protocol; + } + + public Self getSelf() + { + return self; + } + + public void setSelf(IAccount account, Set<String> facilityTypes) + { + self = new Self(this, account, facilityTypes); + self.activate(); + self.addListener(this); + } + + public void close() + { + protocol.close(); + protocol = null; + LifecycleUtil.deactivate(this, OMLogger.Level.DEBUG); + } + + /** + * @see PlatformObject#getAdapter(Class) + */ + @SuppressWarnings("rawtypes") + public Object getAdapter(Class adapter) + { + return Platform.getAdapterManager().getAdapter(this, adapter); + } + + @Override + public void notifyEvent(IEvent event) + { + if (event.getSource() == protocol) + { + if (event instanceof ILifecycleEvent) + { + if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED) + { + deactivate(); + } + } + } + else if (event.getSource() == self) + { + if (event instanceof IBuddyStateEvent) + { + try + { + new BuddyStateNotification(protocol, self.getUserID(), ((IBuddyStateEvent)event).getNewState()).sendAsync(); + } + catch (Exception ex) + { + OM.LOG.error(ex); + } + } + } + } + + public void buddyAdded(String userID) + { + ClientBuddy buddy = new ClientBuddy(this, userID); + buddy.activate(); + addBuddy(buddy); + } + + public void buddyRemoved(String userID) + { + IBuddy buddy = removeBuddy(userID); + if (buddy != null) + { + for (IMembership membership : self.getMemberships()) + { + Collaboration collaboration = (Collaboration)membership.getCollaboration(); + collaboration.removeMembership(buddy); + } + + LifecycleUtil.deactivate(buddy); + } + } + + @Override + protected void doActivate() throws Exception + { + super.doActivate(); + protocol.addListener(this); + } + + @Override + protected void doDeactivate() throws Exception + { + protocol.removeListener(this); + LifecycleUtil.deactivate(self); + super.doDeactivate(); + } +} 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 d9a7aca93c..f41bc96c32 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 @@ -1,105 +1,105 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies;
-
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IMembership;
-import org.eclipse.net4j.buddies.internal.common.Buddy;
-import org.eclipse.net4j.buddies.internal.common.Membership;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.protocol.InitiateCollaborationRequest;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class Self extends Buddy
-{
- private IAccount account;
-
- protected Self(ClientSession session, IAccount account, Set<String> facilityTypes)
- {
- super(session, facilityTypes);
- this.account = account;
- }
-
- @Override
- public ClientSession getSession()
- {
- return (ClientSession)super.getSession();
- }
-
- public String getUserID()
- {
- return account.getUserID();
- }
-
- public IAccount getAccount()
- {
- return account;
- }
-
- public IMembership[] initiate(Collection<IBuddy> buddies)
- {
- try
- {
- ClientSession session = getSession();
- long id = new InitiateCollaborationRequest(session.getProtocol(), buddies).send(ProtocolConstants.TIMEOUT);
-
- BuddyCollaboration collaboration = new BuddyCollaboration(session, id);
- collaboration.activate();
- Membership.create(this, collaboration);
-
- List<IMembership> memberships = new ArrayList<IMembership>();
- for (IBuddy buddy : buddies)
- {
- IMembership membership = Membership.create(buddy, collaboration);
- memberships.add(membership);
- }
-
- return memberships.toArray(new IMembership[memberships.size()]);
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- public IMembership join(long collaborationID)
- {
- // TODO Implement method Self.join()
- throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
- }
-
- public IMembership join(Object invitationToken)
- {
- // TODO Implement method Self.join()
- throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- for (IMembership membership : getMemberships())
- {
- LifecycleUtil.deactivate(membership.getCollaboration());
- }
-
- super.doDeactivate();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies; + +import org.eclipse.net4j.buddies.common.IAccount; +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.common.IMembership; +import org.eclipse.net4j.buddies.internal.common.Buddy; +import org.eclipse.net4j.buddies.internal.common.Membership; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.internal.buddies.protocol.InitiateCollaborationRequest; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class Self extends Buddy +{ + private IAccount account; + + protected Self(ClientSession session, IAccount account, Set<String> facilityTypes) + { + super(session, facilityTypes); + this.account = account; + } + + @Override + public ClientSession getSession() + { + return (ClientSession)super.getSession(); + } + + public String getUserID() + { + return account.getUserID(); + } + + public IAccount getAccount() + { + return account; + } + + public IMembership[] initiate(Collection<IBuddy> buddies) + { + try + { + ClientSession session = getSession(); + long id = new InitiateCollaborationRequest(session.getProtocol(), buddies).send(ProtocolConstants.TIMEOUT); + + BuddyCollaboration collaboration = new BuddyCollaboration(session, id); + collaboration.activate(); + Membership.create(this, collaboration); + + List<IMembership> memberships = new ArrayList<IMembership>(); + for (IBuddy buddy : buddies) + { + IMembership membership = Membership.create(buddy, collaboration); + memberships.add(membership); + } + + return memberships.toArray(new IMembership[memberships.size()]); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + + public IMembership join(long collaborationID) + { + // TODO Implement method Self.join() + throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$ + } + + public IMembership join(Object invitationToken) + { + // TODO Implement method Self.join() + throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$ + } + + @Override + protected void doDeactivate() throws Exception + { + for (IMembership membership : getMemberships()) + { + LifecycleUtil.deactivate(membership.getCollaboration()); + } + + super.doDeactivate(); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/SessionManager.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/SessionManager.java index 41d7784a8b..ccd7cf8f85 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/SessionManager.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/SessionManager.java @@ -1,278 +1,278 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.buddies.BuddiesUtil;
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.ISessionManager;
-import org.eclipse.net4j.buddies.ISessionManagerEvent;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.internal.buddies.bundle.OM;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.container.IContainerDelta;
-import org.eclipse.net4j.util.container.IContainerEvent;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.event.Event;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import java.text.MessageFormat;
-
-public class SessionManager extends Lifecycle implements ISessionManager, IListener
-{
- public static final SessionManager INSTANCE = new SessionManager();
-
- private IBuddySession session;
-
- private State state = State.DISCONNECTED;
-
- private boolean connecting;
-
- private boolean flashing;
-
- private SessionManager()
- {
- }
-
- public IBuddySession getSession()
- {
- return session;
- }
-
- public State getState()
- {
- return state;
- }
-
- public void setState(State state)
- {
- if (this.state != state)
- {
- IEvent event = new SessionManagerEvent(this.state, state, session);
- this.state = state;
- IListener[] listeners = getListeners();
- if (listeners != null)
- {
- fireEvent(event, listeners);
- }
- }
- }
-
- public boolean isFlashing()
- {
- return flashing;
- }
-
- public boolean isConnecting()
- {
- return state == ISessionManager.State.CONNECTING;
- }
-
- public String getConnectorDescription()
- {
- return OM.PREF_CONNECTOR_DESCRIPTION.getValue();
- }
-
- public String getUserID()
- {
- return OM.PREF_USER_ID.getValue();
- }
-
- public String getPassword()
- {
- return OM.PREF_PASSWORD.getValue();
- }
-
- public Boolean isAutoConnect()
- {
- return OM.PREF_AUTO_CONNECT.getValue();
- }
-
- public void connect()
- {
- new Thread("buddies-connector") //$NON-NLS-1$
- {
- @Override
- public void run()
- {
- try
- {
- setState(ISessionManager.State.CONNECTING);
- connecting = true;
- while (session == null && connecting)
- {
- IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, getConnectorDescription());
- if (connector == null)
- {
- throw new IllegalStateException("connector == null"); //$NON-NLS-1$
- }
-
- session = BuddiesUtil.openSession(connector, getUserID(), getPassword(), 5000L);
- if (session != null)
- {
- if (connecting)
- {
- session.addListener(SessionManager.this);
- setState(ISessionManager.State.CONNECTED);
- }
- else
- {
- session.close();
- session = null;
- setState(ISessionManager.State.DISCONNECTED);
- }
- }
- }
- }
- finally
- {
- connecting = false;
- }
- }
- }.start();
- }
-
- public void disconnect()
- {
- connecting = false;
- if (session != null)
- {
- session.removeListener(this);
- session.close();
- session = null;
- }
-
- setState(ISessionManager.State.DISCONNECTED);
- }
-
- public void flashMe()
- {
- if (session != null && !flashing)
- {
- final Self self = (Self)session.getSelf();
- final IBuddy.State original = self.getState();
- new Thread("buddies-flasher") //$NON-NLS-1$
- {
- @Override
- public void run()
- {
- flashing = true;
- IBuddy.State state = original == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE;
- for (int i = 0; i < 15; i++)
- {
- self.setState(state);
- ConcurrencyUtil.sleep(200);
- state = state == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE;
- }
-
- self.setState(original);
- flashing = false;
- }
- }.start();
- }
- }
-
- public void notifyEvent(IEvent event)
- {
- if (event.getSource() == session)
- {
- if (event instanceof ILifecycleEvent)
- {
- if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
- {
- disconnect();
- if (isAutoConnect())
- {
- connect();
- }
- }
- }
- else if (event instanceof IContainerEvent<?>)
- {
- @SuppressWarnings("unchecked")
- IContainerEvent<IBuddy> e = (IContainerEvent<IBuddy>)event;
- if (e.getDeltaKind() == IContainerDelta.Kind.ADDED)
- {
- e.getDeltaElement().addListener(this);
- }
- else if (e.getDeltaKind() == IContainerDelta.Kind.REMOVED)
- {
- e.getDeltaElement().removeListener(this);
- }
- }
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- if (isAutoConnect())
- {
- connect();
- }
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- disconnect();
- super.doDeactivate();
- }
-
- /**
- * @author Eike Stepper
- */
- private final class SessionManagerEvent extends Event implements ISessionManagerEvent
- {
- private static final long serialVersionUID = 1L;
-
- private State oldState;
-
- private State newState;
-
- private IBuddySession session;
-
- public SessionManagerEvent(State oldState, State newState, IBuddySession session)
- {
- super(SessionManager.this);
- this.oldState = oldState;
- this.newState = newState;
- this.session = session;
- }
-
- public State getOldState()
- {
- return oldState;
- }
-
- public State getNewState()
- {
- return newState;
- }
-
- public IBuddySession getSession()
- {
- return session;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("SessionManagerEvent[source={0}, oldState={1}, newState={2}, session={3}]", //$NON-NLS-1$
- getSource(), getOldState(), getNewState(), getSession());
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies; + +import org.eclipse.net4j.Net4jUtil; +import org.eclipse.net4j.buddies.BuddiesUtil; +import org.eclipse.net4j.buddies.IBuddySession; +import org.eclipse.net4j.buddies.ISessionManager; +import org.eclipse.net4j.buddies.ISessionManagerEvent; +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.internal.buddies.bundle.OM; +import org.eclipse.net4j.util.concurrent.ConcurrencyUtil; +import org.eclipse.net4j.util.container.IContainerDelta; +import org.eclipse.net4j.util.container.IContainerEvent; +import org.eclipse.net4j.util.container.IPluginContainer; +import org.eclipse.net4j.util.event.Event; +import org.eclipse.net4j.util.event.IEvent; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; +import org.eclipse.net4j.util.lifecycle.Lifecycle; + +import java.text.MessageFormat; + +public class SessionManager extends Lifecycle implements ISessionManager, IListener +{ + public static final SessionManager INSTANCE = new SessionManager(); + + private IBuddySession session; + + private State state = State.DISCONNECTED; + + private boolean connecting; + + private boolean flashing; + + private SessionManager() + { + } + + public IBuddySession getSession() + { + return session; + } + + public State getState() + { + return state; + } + + public void setState(State state) + { + if (this.state != state) + { + IEvent event = new SessionManagerEvent(this.state, state, session); + this.state = state; + IListener[] listeners = getListeners(); + if (listeners != null) + { + fireEvent(event, listeners); + } + } + } + + public boolean isFlashing() + { + return flashing; + } + + public boolean isConnecting() + { + return state == ISessionManager.State.CONNECTING; + } + + public String getConnectorDescription() + { + return OM.PREF_CONNECTOR_DESCRIPTION.getValue(); + } + + public String getUserID() + { + return OM.PREF_USER_ID.getValue(); + } + + public String getPassword() + { + return OM.PREF_PASSWORD.getValue(); + } + + public Boolean isAutoConnect() + { + return OM.PREF_AUTO_CONNECT.getValue(); + } + + public void connect() + { + new Thread("buddies-connector") //$NON-NLS-1$ + { + @Override + public void run() + { + try + { + setState(ISessionManager.State.CONNECTING); + connecting = true; + while (session == null && connecting) + { + IConnector connector = Net4jUtil.getConnector(IPluginContainer.INSTANCE, getConnectorDescription()); + if (connector == null) + { + throw new IllegalStateException("connector == null"); //$NON-NLS-1$ + } + + session = BuddiesUtil.openSession(connector, getUserID(), getPassword(), 5000L); + if (session != null) + { + if (connecting) + { + session.addListener(SessionManager.this); + setState(ISessionManager.State.CONNECTED); + } + else + { + session.close(); + session = null; + setState(ISessionManager.State.DISCONNECTED); + } + } + } + } + finally + { + connecting = false; + } + } + }.start(); + } + + public void disconnect() + { + connecting = false; + if (session != null) + { + session.removeListener(this); + session.close(); + session = null; + } + + setState(ISessionManager.State.DISCONNECTED); + } + + public void flashMe() + { + if (session != null && !flashing) + { + final Self self = (Self)session.getSelf(); + final IBuddy.State original = self.getState(); + new Thread("buddies-flasher") //$NON-NLS-1$ + { + @Override + public void run() + { + flashing = true; + IBuddy.State state = original == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE; + for (int i = 0; i < 15; i++) + { + self.setState(state); + ConcurrencyUtil.sleep(200); + state = state == IBuddy.State.AVAILABLE ? IBuddy.State.LONESOME : IBuddy.State.AVAILABLE; + } + + self.setState(original); + flashing = false; + } + }.start(); + } + } + + public void notifyEvent(IEvent event) + { + if (event.getSource() == session) + { + if (event instanceof ILifecycleEvent) + { + if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED) + { + disconnect(); + if (isAutoConnect()) + { + connect(); + } + } + } + else if (event instanceof IContainerEvent<?>) + { + @SuppressWarnings("unchecked") + IContainerEvent<IBuddy> e = (IContainerEvent<IBuddy>)event; + if (e.getDeltaKind() == IContainerDelta.Kind.ADDED) + { + e.getDeltaElement().addListener(this); + } + else if (e.getDeltaKind() == IContainerDelta.Kind.REMOVED) + { + e.getDeltaElement().removeListener(this); + } + } + } + } + + @Override + protected void doActivate() throws Exception + { + super.doActivate(); + if (isAutoConnect()) + { + connect(); + } + } + + @Override + protected void doDeactivate() throws Exception + { + disconnect(); + super.doDeactivate(); + } + + /** + * @author Eike Stepper + */ + private final class SessionManagerEvent extends Event implements ISessionManagerEvent + { + private static final long serialVersionUID = 1L; + + private State oldState; + + private State newState; + + private IBuddySession session; + + public SessionManagerEvent(State oldState, State newState, IBuddySession session) + { + super(SessionManager.this); + this.oldState = oldState; + this.newState = newState; + this.session = session; + } + + public State getOldState() + { + return oldState; + } + + public State getNewState() + { + return newState; + } + + public IBuddySession getSession() + { + return session; + } + + @Override + public String toString() + { + return MessageFormat.format("SessionManagerEvent[source={0}, oldState={1}, newState={2}, session={3}]", //$NON-NLS-1$ + getSource(), getOldState(), getNewState(), getSession()); + } + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/bundle/OM.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/bundle/OM.java index 93489e59fe..b61a2fbbe8 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/bundle/OM.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/bundle/OM.java @@ -1,60 +1,60 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.pref.OMPreference;
-import org.eclipse.net4j.util.om.pref.OMPreferences;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.net4j.buddies"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- public static final OMPreferences PREFS = BUNDLE.preferences();
-
- public static final OMPreference<String> PREF_CONNECTOR_DESCRIPTION = //
- PREFS.init("PREF_CONNECTOR_DESCRIPTION", "tcp://localhost"); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static final OMPreference<String> PREF_USER_ID = //
- PREFS.init("PREF_USER_ID", System.getProperty("user.name")); //$NON-NLS-1$ //$NON-NLS-2$
-
- public static final OMPreference<String> PREF_PASSWORD = //
- PREFS.initString("PREF_PASSWORD"); //$NON-NLS-1$
-
- public static final OMPreference<Boolean> PREF_AUTO_CONNECT = //
- PREFS.init("PREF_AUTO_CONNECT", false); //$NON-NLS-1$
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.pref.OMPreference; +import org.eclipse.net4j.util.om.pref.OMPreferences; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.net4j.buddies"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + public static final OMPreferences PREFS = BUNDLE.preferences(); + + public static final OMPreference<String> PREF_CONNECTOR_DESCRIPTION = // + PREFS.init("PREF_CONNECTOR_DESCRIPTION", "tcp://localhost"); //$NON-NLS-1$ //$NON-NLS-2$ + + public static final OMPreference<String> PREF_USER_ID = // + PREFS.init("PREF_USER_ID", System.getProperty("user.name")); //$NON-NLS-1$ //$NON-NLS-2$ + + public static final OMPreference<String> PREF_PASSWORD = // + PREFS.initString("PREF_PASSWORD"); //$NON-NLS-1$ + + public static final OMPreference<Boolean> PREF_AUTO_CONNECT = // + PREFS.init("PREF_AUTO_CONNECT", false); //$NON-NLS-1$ + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java index 33e7cfab2a..bbb780c94c 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddiesClientProtocol.java @@ -1,93 +1,93 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.common.protocol.MessageIndication;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.internal.buddies.ClientSession;
-import org.eclipse.net4j.internal.buddies.Self;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-
-/**
- * @author Eike Stepper
- */
-public class BuddiesClientProtocol extends SignalProtocol<ClientSession>
-{
- private static final long GET_SESSION_TIMEOUT = 20000;
-
- private static final int GET_SESSION_INTERVAL = 100;
-
- public BuddiesClientProtocol(IConnector connector)
- {
- super(ProtocolConstants.PROTOCOL_NAME);
- open(connector);
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case ProtocolConstants.SIGNAL_BUDDY_ADDED:
- return new BuddyAddedIndication(this);
-
- case ProtocolConstants.SIGNAL_BUDDY_REMOVED:
- return new BuddyRemovedIndication(this);
-
- case ProtocolConstants.SIGNAL_BUDDY_STATE:
- return new ClientBuddyStateIndication(this);
-
- case ProtocolConstants.SIGNAL_COLLABORATION_INITIATED:
- return new CollaborationInitiatedIndication(this);
-
- case ProtocolConstants.SIGNAL_COLLABORATION_LEFT:
- return new ClientCollaborationLeftIndication(this, getSelf());
-
- case ProtocolConstants.SIGNAL_FACILITY_INSTALLED:
- return new FacilityInstalledIndication(this);
-
- case ProtocolConstants.SIGNAL_MESSAGE:
- return new MessageIndication(this, getSelf());
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
-
- protected Self getSelf()
- {
- ISession session = getInfraStructure();
- return (Self)session.getSelf();
- }
-
- public ClientSession getSession()
- {
- int max = (int)(GET_SESSION_TIMEOUT / GET_SESSION_INTERVAL);
- for (int i = 0; i < max; i++)
- {
- ClientSession session = getInfraStructure();
- if (session == null)
- {
- ConcurrencyUtil.sleep(GET_SESSION_INTERVAL);
- }
- else
- {
- return session;
- }
- }
-
- throw new IllegalStateException("No session after " + max + " milliseconds"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.common.ISession; +import org.eclipse.net4j.buddies.internal.common.protocol.MessageIndication; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.connector.IConnector; +import org.eclipse.net4j.internal.buddies.ClientSession; +import org.eclipse.net4j.internal.buddies.Self; +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.signal.SignalReactor; +import org.eclipse.net4j.util.concurrent.ConcurrencyUtil; + +/** + * @author Eike Stepper + */ +public class BuddiesClientProtocol extends SignalProtocol<ClientSession> +{ + private static final long GET_SESSION_TIMEOUT = 20000; + + private static final int GET_SESSION_INTERVAL = 100; + + public BuddiesClientProtocol(IConnector connector) + { + super(ProtocolConstants.PROTOCOL_NAME); + open(connector); + } + + @Override + protected SignalReactor createSignalReactor(short signalID) + { + switch (signalID) + { + case ProtocolConstants.SIGNAL_BUDDY_ADDED: + return new BuddyAddedIndication(this); + + case ProtocolConstants.SIGNAL_BUDDY_REMOVED: + return new BuddyRemovedIndication(this); + + case ProtocolConstants.SIGNAL_BUDDY_STATE: + return new ClientBuddyStateIndication(this); + + case ProtocolConstants.SIGNAL_COLLABORATION_INITIATED: + return new CollaborationInitiatedIndication(this); + + case ProtocolConstants.SIGNAL_COLLABORATION_LEFT: + return new ClientCollaborationLeftIndication(this, getSelf()); + + case ProtocolConstants.SIGNAL_FACILITY_INSTALLED: + return new FacilityInstalledIndication(this); + + case ProtocolConstants.SIGNAL_MESSAGE: + return new MessageIndication(this, getSelf()); + + default: + return super.createSignalReactor(signalID); + } + } + + protected Self getSelf() + { + ISession session = getInfraStructure(); + return (Self)session.getSelf(); + } + + public ClientSession getSession() + { + int max = (int)(GET_SESSION_TIMEOUT / GET_SESSION_INTERVAL); + for (int i = 0; i < max; i++) + { + ClientSession session = getInfraStructure(); + if (session == null) + { + ConcurrencyUtil.sleep(GET_SESSION_INTERVAL); + } + else + { + return session; + } + } + + throw new IllegalStateException("No session after " + max + " milliseconds"); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java index fbb4048098..f92f2730a3 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyAddedIndication.java @@ -1,36 +1,36 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.ClientSession;
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
-/**
- * @author Eike Stepper
- */
-public class BuddyAddedIndication extends Indication
-{
- public BuddyAddedIndication(SignalProtocol<?> protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_BUDDY_ADDED);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- String buddy = in.readString();
- ClientSession session = ((BuddiesClientProtocol)getProtocol()).getSession();
- session.buddyAdded(buddy);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.internal.buddies.ClientSession; +import org.eclipse.net4j.signal.Indication; +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; + +/** + * @author Eike Stepper + */ +public class BuddyAddedIndication extends Indication +{ + public BuddyAddedIndication(SignalProtocol<?> protocol) + { + super(protocol, ProtocolConstants.SIGNAL_BUDDY_ADDED); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws Exception + { + String buddy = in.readString(); + ClientSession session = ((BuddiesClientProtocol)getProtocol()).getSession(); + session.buddyAdded(buddy); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java index 637c198d5b..36072df9a7 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/BuddyRemovedIndication.java @@ -1,36 +1,36 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.ClientSession;
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
-/**
- * @author Eike Stepper
- */
-public class BuddyRemovedIndication extends Indication
-{
- public BuddyRemovedIndication(SignalProtocol<?> protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_BUDDY_REMOVED);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- String buddy = in.readString();
- ClientSession session = ((BuddiesClientProtocol)getProtocol()).getSession();
- session.buddyRemoved(buddy);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.internal.buddies.ClientSession; +import org.eclipse.net4j.signal.Indication; +import org.eclipse.net4j.signal.SignalProtocol; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; + +/** + * @author Eike Stepper + */ +public class BuddyRemovedIndication extends Indication +{ + public BuddyRemovedIndication(SignalProtocol<?> protocol) + { + super(protocol, ProtocolConstants.SIGNAL_BUDDY_REMOVED); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws Exception + { + String buddy = in.readString(); + ClientSession session = ((BuddiesClientProtocol)getProtocol()).getSession(); + session.buddyRemoved(buddy); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientBuddyStateIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientBuddyStateIndication.java index d7a8e5e2e8..a4824c5440 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientBuddyStateIndication.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/ClientBuddyStateIndication.java @@ -1,38 +1,38 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy.State;
-import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateIndication;
-import org.eclipse.net4j.internal.buddies.ClientBuddy;
-import org.eclipse.net4j.internal.buddies.ClientSession;
-
-/**
- * @author Eike Stepper
- */
-public class ClientBuddyStateIndication extends BuddyStateIndication
-{
- public ClientBuddyStateIndication(BuddiesClientProtocol protocol)
- {
- super(protocol);
- }
-
- @Override
- protected void stateChanged(final String userID, final State state)
- {
- ClientSession session = ((BuddiesClientProtocol)getProtocol()).getSession();
- ClientBuddy buddy = (ClientBuddy)session.getBuddy(userID);
- if (buddy != null)
- {
- buddy.setState(state);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.common.IBuddy.State; +import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateIndication; +import org.eclipse.net4j.internal.buddies.ClientBuddy; +import org.eclipse.net4j.internal.buddies.ClientSession; + +/** + * @author Eike Stepper + */ +public class ClientBuddyStateIndication extends BuddyStateIndication +{ + public ClientBuddyStateIndication(BuddiesClientProtocol protocol) + { + super(protocol); + } + + @Override + protected void stateChanged(final String userID, final State state) + { + ClientSession session = ((BuddiesClientProtocol)getProtocol()).getSession(); + ClientBuddy buddy = (ClientBuddy)session.getBuddy(userID); + if (buddy != null) + { + buddy.setState(state); + } + } +} 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 index 923b615d61..4180c89e59 100644 --- 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 @@ -1,25 +1,25 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftIndication;
-import org.eclipse.net4j.internal.buddies.Self;
-
-/**
- * @author Eike Stepper
- */
-public class ClientCollaborationLeftIndication extends CollaborationLeftIndication
-{
- public ClientCollaborationLeftIndication(BuddiesClientProtocol protocol, Self self)
- {
- super(protocol, self.getSession(), self);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftIndication; +import org.eclipse.net4j.internal.buddies.Self; + +/** + * @author Eike Stepper + */ +public class ClientCollaborationLeftIndication extends CollaborationLeftIndication +{ + public ClientCollaborationLeftIndication(BuddiesClientProtocol protocol, Self self) + { + super(protocol, self.getSession(), self); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java index 69949977a4..9deee5b493 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/CollaborationInitiatedIndication.java @@ -1,70 +1,70 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.internal.common.Membership;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.internal.buddies.BuddyCollaboration;
-import org.eclipse.net4j.internal.buddies.Self;
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class CollaborationInitiatedIndication extends Indication
-{
- public CollaborationInitiatedIndication(BuddiesClientProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_INITIATED);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- IBuddySession session = (IBuddySession)getProtocol().getInfraStructure();
- Self self = (Self)session.getSelf();
-
- long collaborationID = in.readLong();
- Set<IBuddy> buddies = ProtocolUtil.readBuddies(in, session);
- String[] facilityTypes = ProtocolUtil.readFacilityTypes(in);
-
- BuddyCollaboration collaboration = (BuddyCollaboration)self.getCollaboration(collaborationID);
- if (collaboration == null)
- {
- collaboration = new BuddyCollaboration(session, collaborationID);
- collaboration.activate();
-
- Membership.create(self, collaboration);
- for (IBuddy buddy : buddies)
- {
- Membership.create(buddy, collaboration);
- }
- }
- else
- {
- for (IBuddy buddy : buddies)
- {
- Membership.create(buddy, collaboration);
- }
- }
-
- for (String facilityType : facilityTypes)
- {
- collaboration.installFacility(facilityType, false);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.IBuddySession; +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.internal.common.Membership; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil; +import org.eclipse.net4j.internal.buddies.BuddyCollaboration; +import org.eclipse.net4j.internal.buddies.Self; +import org.eclipse.net4j.signal.Indication; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; + +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class CollaborationInitiatedIndication extends Indication +{ + public CollaborationInitiatedIndication(BuddiesClientProtocol protocol) + { + super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_INITIATED); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws Exception + { + IBuddySession session = (IBuddySession)getProtocol().getInfraStructure(); + Self self = (Self)session.getSelf(); + + long collaborationID = in.readLong(); + Set<IBuddy> buddies = ProtocolUtil.readBuddies(in, session); + String[] facilityTypes = ProtocolUtil.readFacilityTypes(in); + + BuddyCollaboration collaboration = (BuddyCollaboration)self.getCollaboration(collaborationID); + if (collaboration == null) + { + collaboration = new BuddyCollaboration(session, collaborationID); + collaboration.activate(); + + Membership.create(self, collaboration); + for (IBuddy buddy : buddies) + { + Membership.create(buddy, collaboration); + } + } + else + { + for (IBuddy buddy : buddies) + { + Membership.create(buddy, collaboration); + } + } + + for (String facilityType : facilityTypes) + { + collaboration.installFacility(facilityType, false); + } + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java index 6b4807f9cc..9805413d73 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/FacilityInstalledIndication.java @@ -1,46 +1,46 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.common.IFacility;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.internal.buddies.BuddyCollaboration;
-import org.eclipse.net4j.internal.buddies.Self;
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
-/**
- * @author Eike Stepper
- */
-public class FacilityInstalledIndication extends Indication
-{
- public FacilityInstalledIndication(BuddiesClientProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_FACILITY_INSTALLED);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- long collaborationID = in.readLong();
- String facilityType = in.readString();
-
- IBuddySession session = (IBuddySession)getProtocol().getInfraStructure();
- Self self = (Self)session.getSelf();
- BuddyCollaboration collaboration = (BuddyCollaboration)self.getCollaboration(collaborationID);
- if (collaboration != null)
- {
- IFacility facility = collaboration.createFacility(facilityType);
- collaboration.addFacility(facility, true);
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.IBuddySession; +import org.eclipse.net4j.buddies.common.IFacility; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.internal.buddies.BuddyCollaboration; +import org.eclipse.net4j.internal.buddies.Self; +import org.eclipse.net4j.signal.Indication; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; + +/** + * @author Eike Stepper + */ +public class FacilityInstalledIndication extends Indication +{ + public FacilityInstalledIndication(BuddiesClientProtocol protocol) + { + super(protocol, ProtocolConstants.SIGNAL_FACILITY_INSTALLED); + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws Exception + { + long collaborationID = in.readLong(); + String facilityType = in.readString(); + + IBuddySession session = (IBuddySession)getProtocol().getInfraStructure(); + Self self = (Self)session.getSelf(); + BuddyCollaboration collaboration = (BuddyCollaboration)self.getCollaboration(collaborationID); + if (collaboration != null) + { + IFacility facility = collaboration.createFacility(facilityType); + collaboration.addFacility(facility, true); + } + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java index ee6c2a0718..536c767f93 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InitiateCollaborationRequest.java @@ -1,46 +1,46 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.util.Collection;
-
-/**
- * @author Eike Stepper
- */
-public class InitiateCollaborationRequest extends RequestWithConfirmation<Long>
-{
- private Collection<IBuddy> buddies;
-
- public InitiateCollaborationRequest(BuddiesClientProtocol protocol, Collection<IBuddy> buddies)
- {
- super(protocol, ProtocolConstants.SIGNAL_INITIATE_COLLABORATION);
- this.buddies = buddies;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- ProtocolUtil.writeBuddies(out, buddies);
- }
-
- @Override
- protected Long confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readLong();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +import java.util.Collection; + +/** + * @author Eike Stepper + */ +public class InitiateCollaborationRequest extends RequestWithConfirmation<Long> +{ + private Collection<IBuddy> buddies; + + public InitiateCollaborationRequest(BuddiesClientProtocol protocol, Collection<IBuddy> buddies) + { + super(protocol, ProtocolConstants.SIGNAL_INITIATE_COLLABORATION); + this.buddies = buddies; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + ProtocolUtil.writeBuddies(out, buddies); + } + + @Override + protected Long confirming(ExtendedDataInputStream in) throws Exception + { + return in.readLong(); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java index a0eca7c65d..547ed3d3fd 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InstallFacilityRequest.java @@ -1,46 +1,46 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class InstallFacilityRequest extends RequestWithConfirmation<Boolean>
-{
- private long collaborationID;
-
- private String facilityType;
-
- public InstallFacilityRequest(BuddiesClientProtocol protocol, long collaborationID, String facilityType)
- {
- super(protocol, ProtocolConstants.SIGNAL_INSTALL_FACILITY);
- this.collaborationID = collaborationID;
- this.facilityType = facilityType;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeLong(collaborationID);
- out.writeString(facilityType);
- }
-
- @Override
- protected Boolean confirming(ExtendedDataInputStream in) throws Exception
- {
- return in.readBoolean();
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +/** + * @author Eike Stepper + */ +public class InstallFacilityRequest extends RequestWithConfirmation<Boolean> +{ + private long collaborationID; + + private String facilityType; + + public InstallFacilityRequest(BuddiesClientProtocol protocol, long collaborationID, String facilityType) + { + super(protocol, ProtocolConstants.SIGNAL_INSTALL_FACILITY); + this.collaborationID = collaborationID; + this.facilityType = facilityType; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + out.writeLong(collaborationID); + out.writeString(facilityType); + } + + @Override + protected Boolean confirming(ExtendedDataInputStream in) throws Exception + { + return in.readBoolean(); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java index 26a5a24430..0ba6ad1c81 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/InviteBuddiesNotification.java @@ -1,43 +1,43 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.signal.Request;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.util.Collection;
-
-/**
- * @author Eike Stepper
- */
-public class InviteBuddiesNotification extends Request
-{
- private long collaborationID;
-
- private Collection<IBuddy> buddies;
-
- public InviteBuddiesNotification(BuddiesClientProtocol protocol, long collaborationID, Collection<IBuddy> buddies)
- {
- super(protocol, ProtocolConstants.SIGNAL_INVITE_BUDDIES);
- this.buddies = buddies;
- this.collaborationID = collaborationID;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeLong(collaborationID);
- ProtocolUtil.writeBuddies(out, buddies);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.common.IBuddy; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil; +import org.eclipse.net4j.signal.Request; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +import java.util.Collection; + +/** + * @author Eike Stepper + */ +public class InviteBuddiesNotification extends Request +{ + private long collaborationID; + + private Collection<IBuddy> buddies; + + public InviteBuddiesNotification(BuddiesClientProtocol protocol, long collaborationID, Collection<IBuddy> buddies) + { + super(protocol, ProtocolConstants.SIGNAL_INVITE_BUDDIES); + this.buddies = buddies; + this.collaborationID = collaborationID; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + out.writeLong(collaborationID); + ProtocolUtil.writeBuddies(out, buddies); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java index 1d2a8e585d..0afdf839e8 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/LoadAccountRequest.java @@ -1,44 +1,44 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class LoadAccountRequest extends RequestWithConfirmation<IAccount>
-{
- private String userID;
-
- public LoadAccountRequest(BuddiesClientProtocol protocol, String userID)
- {
- super(protocol, ProtocolConstants.SIGNAL_LOAD_ACCOUNT);
- this.userID = userID;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(userID);
- }
-
- @Override
- protected IAccount confirming(ExtendedDataInputStream in) throws Exception
- {
- return ProtocolUtil.readAccount(in);
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.common.IAccount; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +/** + * @author Eike Stepper + */ +public class LoadAccountRequest extends RequestWithConfirmation<IAccount> +{ + private String userID; + + public LoadAccountRequest(BuddiesClientProtocol protocol, String userID) + { + super(protocol, ProtocolConstants.SIGNAL_LOAD_ACCOUNT); + this.userID = userID; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + out.writeString(userID); + } + + @Override + protected IAccount confirming(ExtendedDataInputStream in) throws Exception + { + return ProtocolUtil.readAccount(in); + } +} diff --git a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java index 0e923fb326..d6996af089 100644 --- a/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java +++ b/plugins/org.eclipse.net4j.buddies/src/org/eclipse/net4j/internal/buddies/protocol/OpenSessionRequest.java @@ -1,78 +1,78 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.buddies.protocol;
-
-import org.eclipse.net4j.buddies.IBuddySession;
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.internal.buddies.ClientSession;
-import org.eclipse.net4j.signal.RequestWithConfirmation;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession>
-{
- private String userID;
-
- private String password;
-
- private Set<String> facilityTypes;
-
- public OpenSessionRequest(BuddiesClientProtocol protocol, String userID, String password, Set<String> facilityTypes)
- {
- super(protocol, ProtocolConstants.SIGNAL_OPEN_SESSION);
- this.userID = userID;
- this.password = password;
- this.facilityTypes = facilityTypes;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(userID);
- out.writeString(password);
- out.writeInt(facilityTypes.size());
- for (String facilityType : facilityTypes)
- {
- out.writeString(facilityType);
- }
- }
-
- @Override
- protected IBuddySession confirming(ExtendedDataInputStream in) throws Exception
- {
- IAccount account = ProtocolUtil.readAccount(in);
- if (account == null)
- {
- return null;
- }
-
- BuddiesClientProtocol protocol = (BuddiesClientProtocol)getProtocol();
- ClientSession session = new ClientSession(protocol);
- protocol.setInfraStructure(session);
- session.setSelf(account, facilityTypes);
-
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- session.buddyAdded(in.readString());
- }
-
- session.activate();
- return session;
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.net4j.internal.buddies.protocol; + +import org.eclipse.net4j.buddies.IBuddySession; +import org.eclipse.net4j.buddies.common.IAccount; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants; +import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil; +import org.eclipse.net4j.internal.buddies.ClientSession; +import org.eclipse.net4j.signal.RequestWithConfirmation; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class OpenSessionRequest extends RequestWithConfirmation<IBuddySession> +{ + private String userID; + + private String password; + + private Set<String> facilityTypes; + + public OpenSessionRequest(BuddiesClientProtocol protocol, String userID, String password, Set<String> facilityTypes) + { + super(protocol, ProtocolConstants.SIGNAL_OPEN_SESSION); + this.userID = userID; + this.password = password; + this.facilityTypes = facilityTypes; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws Exception + { + out.writeString(userID); + out.writeString(password); + out.writeInt(facilityTypes.size()); + for (String facilityType : facilityTypes) + { + out.writeString(facilityType); + } + } + + @Override + protected IBuddySession confirming(ExtendedDataInputStream in) throws Exception + { + IAccount account = ProtocolUtil.readAccount(in); + if (account == null) + { + return null; + } + + BuddiesClientProtocol protocol = (BuddiesClientProtocol)getProtocol(); + ClientSession session = new ClientSession(protocol); + protocol.setInfraStructure(session); + session.setSelf(account, facilityTypes); + + int size = in.readInt(); + for (int i = 0; i < size; i++) + { + session.buddyAdded(in.readString()); + } + + session.activate(); + return session; + } +} |