Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j.buddies.server')
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/about.properties62
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/copyright.txt14
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/plugin.properties22
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/plugin.xml48
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java530
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java124
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java204
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java130
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/Messages.java82
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/messages.properties22
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java172
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java78
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java78
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java102
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java84
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java104
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java186
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java184
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java96
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java208
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerBuddyStateIndication.java90
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java124
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java74
-rw-r--r--plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java42
25 files changed, 1433 insertions, 1433 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.server/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.net4j.buddies.server/.settings/org.eclipse.core.resources.prefs
index 497e283e24..64203dec4b 100644
--- a/plugins/org.eclipse.net4j.buddies.server/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.net4j.buddies.server/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Jul 04 12:55:26 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 12:55:26 CEST 2011
+eclipse.preferences.version=1
+encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
diff --git a/plugins/org.eclipse.net4j.buddies.server/about.properties b/plugins/org.eclipse.net4j.buddies.server/about.properties
index 8062fca294..60fd204dbf 100644
--- a/plugins/org.eclipse.net4j.buddies.server/about.properties
+++ b/plugins/org.eclipse.net4j.buddies.server/about.properties
@@ -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
-
-# NLS_MESSAGEFORMAT_VAR
-
-# ==============================================================================
-# Do not change the properties between this line and the last line containing:
-# %%% END OF TRANSLATED PROPERTIES %%%
-# Instead, either redefine an existing property, or create a new property,
-# append it to the end of the file, and change the code to use the new name.
-# ==============================================================================
-
-featureName = Net4j Buddies Server
-featureText = Net4j Buddies Server\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\
-\n\
-Visit http://wiki.eclipse.org/Net4j
-
-# ==============================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# The above properties have been shipped for translation.
-# ==============================================================================
+# 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
+
+# NLS_MESSAGEFORMAT_VAR
+
+# ==============================================================================
+# Do not change the properties between this line and the last line containing:
+# %%% END OF TRANSLATED PROPERTIES %%%
+# Instead, either redefine an existing property, or create a new property,
+# append it to the end of the file, and change the code to use the new name.
+# ==============================================================================
+
+featureName = Net4j Buddies Server
+featureText = Net4j Buddies Server\n\
+Version: {featureVersion}\n\
+Build id: {0}\n\
+\n\
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. All rights reserved.\n\
+\n\
+Visit http://wiki.eclipse.org/Net4j
+
+# ==============================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# The above properties have been shipped for translation.
+# ==============================================================================
diff --git a/plugins/org.eclipse.net4j.buddies.server/copyright.txt b/plugins/org.eclipse.net4j.buddies.server/copyright.txt
index 8f6328980e..0a0f67e6d7 100644
--- a/plugins/org.eclipse.net4j.buddies.server/copyright.txt
+++ b/plugins/org.eclipse.net4j.buddies.server/copyright.txt
@@ -1,8 +1,8 @@
-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:
+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 \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.buddies.server/plugin.properties b/plugins/org.eclipse.net4j.buddies.server/plugin.properties
index 0066761750..37832925b1 100644
--- a/plugins/org.eclipse.net4j.buddies.server/plugin.properties
+++ b/plugins/org.eclipse.net4j.buddies.server/plugin.properties
@@ -1,11 +1,11 @@
-# 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
-
-pluginName = Net4j Buddies Server
-providerName = Eclipse Modeling Project
+# 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
+
+pluginName = Net4j Buddies Server
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.net4j.buddies.server/plugin.xml b/plugins/org.eclipse.net4j.buddies.server/plugin.xml
index 6709be82cd..cbef80e5e2 100644
--- a/plugins/org.eclipse.net4j.buddies.server/plugin.xml
+++ b/plugins/org.eclipse.net4j.buddies.server/plugin.xml
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- 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
--->
-
-<plugin>
-
- <extension
- point="org.eclipse.net4j.util.factories">
- <factory
- class="org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocol$Factory"
- productGroup="org.eclipse.net4j.serverProtocols"
- type="buddies"/>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<!--
+ 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
+-->
+
+<plugin>
+
+ <extension
+ point="org.eclipse.net4j.util.factories">
+ <factory
+ class="org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocol$Factory"
+ productGroup="org.eclipse.net4j.serverProtocols"
+ type="buddies"/>
+ </extension>
+
+</plugin>
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
index f4ca83f070..18ebce26a6 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/BuddyAdmin.java
@@ -1,265 +1,265 @@
-/*
- * 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.internal.server;
-
-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.ICollaboration;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.common.Account;
-import org.eclipse.net4j.buddies.internal.common.Buddy;
-import org.eclipse.net4j.buddies.internal.common.Collaboration;
-import org.eclipse.net4j.buddies.internal.common.CollaborationContainer;
-import org.eclipse.net4j.buddies.internal.common.Membership;
-import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateNotification;
-import org.eclipse.net4j.buddies.internal.server.bundle.OM;
-import org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocol;
-import org.eclipse.net4j.buddies.internal.server.protocol.BuddyRemovedNotification;
-import org.eclipse.net4j.buddies.internal.server.protocol.CollaborationInitiatedNotification;
-import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.buddies.spi.common.ServerFacilityFactory;
-import org.eclipse.net4j.channel.IChannel;
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.container.IPluginContainer;
-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.trace.ContextTracer;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * @author Eike Stepper
- */
-public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin
-{
- public static final BuddyAdmin INSTANCE = new BuddyAdmin();
-
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, BuddyAdmin.class);
-
- private ConcurrentMap<String, IAccount> accounts = new ConcurrentHashMap<String, IAccount>();
-
- private ConcurrentMap<String, ISession> sessions = new ConcurrentHashMap<String, ISession>();
-
- private long lastCollaborationID;
-
- public BuddyAdmin()
- {
- activate();
- }
-
- public Map<String, IAccount> getAccounts()
- {
- return accounts;
- }
-
- public ISession getSession(IBuddy buddy)
- {
- return getSession(buddy.getUserID());
- }
-
- public ISession getSession(String userID)
- {
- return sessions.get(userID);
- }
-
- public ISession[] getSessions()
- {
- return sessions.values().toArray(new ISession[sessions.size()]);
- }
-
- public IBuddy[] getBuddies()
- {
- List<IBuddy> buddies = new ArrayList<IBuddy>();
- for (ISession session : sessions.values())
- {
- buddies.add(session.getSelf());
- }
-
- return buddies.toArray(new IBuddy[buddies.size()]);
- }
-
- public IBuddy getBuddy(String userID)
- {
- ISession session = getSession(userID);
- if (session == null)
- {
- return null;
- }
-
- return session.getSelf();
- }
-
- public synchronized ISession openSession(IChannel channel, String userID, String password, String[] facilityTypes)
- {
- if (sessions.containsKey(userID))
- {
- return null;
- }
-
- IAccount account = accounts.get(userID);
- if (account != null)
- {
- if (!account.authenticate(password))
- {
- return null;
- }
- }
- else
- {
- account = new Account(userID, password);
- accounts.put(userID, account);
- }
-
- ServerBuddy buddy = new ServerBuddy(account, facilityTypes);
- buddy.activate();
- buddy.addListener(this);
-
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)channel.getReceiveHandler();
- ServerSession session = new ServerSession(protocol, buddy);
- protocol.setInfraStructure(session);
- session.addListener(this);
- buddy.setSession(session);
- LifecycleUtil.activate(session);
-
- if (TRACER.isEnabled())
- {
- TRACER.trace("Opened session: " + userID); //$NON-NLS-1$
- }
-
- sessions.put(userID, session);
- return session;
- }
-
- public ICollaboration initiateCollaboration(IBuddy initiator, String... userIDs)
- {
- long collaborationID;
- synchronized (this)
- {
- collaborationID = ++lastCollaborationID;
- }
-
- Collaboration collaboration = new Collaboration(collaborationID);
- collaboration.activate();
- Membership.create(initiator, collaboration);
-
- Set<IBuddy> buddies = new HashSet<IBuddy>();
- buddies.add(initiator);
- for (String userID : userIDs)
- {
- Buddy buddy = (Buddy)getBuddy(userID);
- if (buddy != null)
- {
- buddies.add(buddy);
- Membership.create(buddy, collaboration);
- }
- }
-
- addCollaboration(collaboration);
-
- Set<IBuddy> invitations = new HashSet<IBuddy>(buddies);
- for (IBuddy buddy : buddies)
- {
- if (buddy != initiator)
- {
- try
- {
- invitations.remove(buddy);
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new CollaborationInitiatedNotification(protocol, collaborationID, invitations, null).sendAsync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- finally
- {
- invitations.add(buddy);
- }
- }
- }
-
- return collaboration;
- }
-
- @Override
- public void notifyEvent(IEvent event)
- {
- if (event.getSource() instanceof ServerSession)
- {
- if (event instanceof ILifecycleEvent)
- {
- if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
- {
- String userID = ((ServerSession)event.getSource()).getSelf().getUserID();
- synchronized (this)
- {
- ServerSession removed = (ServerSession)sessions.remove(userID);
- if (removed != null)
- {
- removed.removeListener(this);
- removed.getSelf().removeListener(this);
- for (ISession session : sessions.values())
- {
- try
- {
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)session.getProtocol();
- new BuddyRemovedNotification(protocol, userID).sendAsync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
- }
- }
- }
- }
- else if (event.getSource() instanceof ServerBuddy)
- {
- if (event instanceof IBuddyStateEvent)
- {
- IBuddyStateEvent e = (IBuddyStateEvent)event;
- synchronized (this)
- {
- for (ISession session : sessions.values())
- {
- try
- {
- if (!ObjectUtil.equals(session.getSelf(), e.getSource()))
- {
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)session.getProtocol();
- new BuddyStateNotification(protocol, e.getSource().getUserID(), e.getNewState()).sendAsync();
- }
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
- }
- }
- }
-
- public static Set<String> getFacilityTypes()
- {
- return IPluginContainer.INSTANCE.getFactoryTypes(ServerFacilityFactory.PRODUCT_GROUP);
- }
-}
+/*
+ * 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.internal.server;
+
+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.ICollaboration;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.internal.common.Account;
+import org.eclipse.net4j.buddies.internal.common.Buddy;
+import org.eclipse.net4j.buddies.internal.common.Collaboration;
+import org.eclipse.net4j.buddies.internal.common.CollaborationContainer;
+import org.eclipse.net4j.buddies.internal.common.Membership;
+import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateNotification;
+import org.eclipse.net4j.buddies.internal.server.bundle.OM;
+import org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocol;
+import org.eclipse.net4j.buddies.internal.server.protocol.BuddyRemovedNotification;
+import org.eclipse.net4j.buddies.internal.server.protocol.CollaborationInitiatedNotification;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.buddies.spi.common.ServerFacilityFactory;
+import org.eclipse.net4j.channel.IChannel;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.container.IPluginContainer;
+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.trace.ContextTracer;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddyAdmin extends CollaborationContainer implements IBuddyAdmin
+{
+ public static final BuddyAdmin INSTANCE = new BuddyAdmin();
+
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, BuddyAdmin.class);
+
+ private ConcurrentMap<String, IAccount> accounts = new ConcurrentHashMap<String, IAccount>();
+
+ private ConcurrentMap<String, ISession> sessions = new ConcurrentHashMap<String, ISession>();
+
+ private long lastCollaborationID;
+
+ public BuddyAdmin()
+ {
+ activate();
+ }
+
+ public Map<String, IAccount> getAccounts()
+ {
+ return accounts;
+ }
+
+ public ISession getSession(IBuddy buddy)
+ {
+ return getSession(buddy.getUserID());
+ }
+
+ public ISession getSession(String userID)
+ {
+ return sessions.get(userID);
+ }
+
+ public ISession[] getSessions()
+ {
+ return sessions.values().toArray(new ISession[sessions.size()]);
+ }
+
+ public IBuddy[] getBuddies()
+ {
+ List<IBuddy> buddies = new ArrayList<IBuddy>();
+ for (ISession session : sessions.values())
+ {
+ buddies.add(session.getSelf());
+ }
+
+ return buddies.toArray(new IBuddy[buddies.size()]);
+ }
+
+ public IBuddy getBuddy(String userID)
+ {
+ ISession session = getSession(userID);
+ if (session == null)
+ {
+ return null;
+ }
+
+ return session.getSelf();
+ }
+
+ public synchronized ISession openSession(IChannel channel, String userID, String password, String[] facilityTypes)
+ {
+ if (sessions.containsKey(userID))
+ {
+ return null;
+ }
+
+ IAccount account = accounts.get(userID);
+ if (account != null)
+ {
+ if (!account.authenticate(password))
+ {
+ return null;
+ }
+ }
+ else
+ {
+ account = new Account(userID, password);
+ accounts.put(userID, account);
+ }
+
+ ServerBuddy buddy = new ServerBuddy(account, facilityTypes);
+ buddy.activate();
+ buddy.addListener(this);
+
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)channel.getReceiveHandler();
+ ServerSession session = new ServerSession(protocol, buddy);
+ protocol.setInfraStructure(session);
+ session.addListener(this);
+ buddy.setSession(session);
+ LifecycleUtil.activate(session);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Opened session: " + userID); //$NON-NLS-1$
+ }
+
+ sessions.put(userID, session);
+ return session;
+ }
+
+ public ICollaboration initiateCollaboration(IBuddy initiator, String... userIDs)
+ {
+ long collaborationID;
+ synchronized (this)
+ {
+ collaborationID = ++lastCollaborationID;
+ }
+
+ Collaboration collaboration = new Collaboration(collaborationID);
+ collaboration.activate();
+ Membership.create(initiator, collaboration);
+
+ Set<IBuddy> buddies = new HashSet<IBuddy>();
+ buddies.add(initiator);
+ for (String userID : userIDs)
+ {
+ Buddy buddy = (Buddy)getBuddy(userID);
+ if (buddy != null)
+ {
+ buddies.add(buddy);
+ Membership.create(buddy, collaboration);
+ }
+ }
+
+ addCollaboration(collaboration);
+
+ Set<IBuddy> invitations = new HashSet<IBuddy>(buddies);
+ for (IBuddy buddy : buddies)
+ {
+ if (buddy != initiator)
+ {
+ try
+ {
+ invitations.remove(buddy);
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
+ new CollaborationInitiatedNotification(protocol, collaborationID, invitations, null).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ finally
+ {
+ invitations.add(buddy);
+ }
+ }
+ }
+
+ return collaboration;
+ }
+
+ @Override
+ public void notifyEvent(IEvent event)
+ {
+ if (event.getSource() instanceof ServerSession)
+ {
+ if (event instanceof ILifecycleEvent)
+ {
+ if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
+ {
+ String userID = ((ServerSession)event.getSource()).getSelf().getUserID();
+ synchronized (this)
+ {
+ ServerSession removed = (ServerSession)sessions.remove(userID);
+ if (removed != null)
+ {
+ removed.removeListener(this);
+ removed.getSelf().removeListener(this);
+ for (ISession session : sessions.values())
+ {
+ try
+ {
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)session.getProtocol();
+ new BuddyRemovedNotification(protocol, userID).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (event.getSource() instanceof ServerBuddy)
+ {
+ if (event instanceof IBuddyStateEvent)
+ {
+ IBuddyStateEvent e = (IBuddyStateEvent)event;
+ synchronized (this)
+ {
+ for (ISession session : sessions.values())
+ {
+ try
+ {
+ if (!ObjectUtil.equals(session.getSelf(), e.getSource()))
+ {
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)session.getProtocol();
+ new BuddyStateNotification(protocol, e.getSource().getUserID(), e.getNewState()).sendAsync();
+ }
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static Set<String> getFacilityTypes()
+ {
+ return IPluginContainer.INSTANCE.getFactoryTypes(ServerFacilityFactory.PRODUCT_GROUP);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
index 704fc64ae3..cdb6a2a4ef 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerBuddy.java
@@ -1,62 +1,62 @@
-/*
- * 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.internal.server;
-
-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.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-
-/**
- * @author Eike Stepper
- */
-public class ServerBuddy extends Buddy
-{
- private IAccount account;
-
- public ServerBuddy(IAccount account, String[] facilityTypes)
- {
- super(null, new HashSet<String>(Arrays.asList(facilityTypes)));
- this.account = account;
- }
-
- public String getUserID()
- {
- return account.getUserID();
- }
-
- public IAccount getAccount()
- {
- return account;
- }
-
- public IMembership[] initiate(Collection<IBuddy> buddies)
- {
- // TODO Implement method ServerBuddy.initiate()
- throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
- }
-
- public IMembership join(long collaborationID)
- {
- // TODO Implement method ServerBuddy.join()
- throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
- }
-
- public IMembership join(Object invitationToken)
- {
- // TODO Implement method ServerBuddy.join()
- 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.buddies.internal.server;
+
+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.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author Eike Stepper
+ */
+public class ServerBuddy extends Buddy
+{
+ private IAccount account;
+
+ public ServerBuddy(IAccount account, String[] facilityTypes)
+ {
+ super(null, new HashSet<String>(Arrays.asList(facilityTypes)));
+ this.account = account;
+ }
+
+ public String getUserID()
+ {
+ return account.getUserID();
+ }
+
+ public IAccount getAccount()
+ {
+ return account;
+ }
+
+ public IMembership[] initiate(Collection<IBuddy> buddies)
+ {
+ // TODO Implement method ServerBuddy.initiate()
+ throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
+ }
+
+ public IMembership join(long collaborationID)
+ {
+ // TODO Implement method ServerBuddy.join()
+ throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
+ }
+
+ public IMembership join(Object invitationToken)
+ {
+ // TODO Implement method ServerBuddy.join()
+ throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java
index 2ef52123b1..d1fb2b17e6 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/ServerSession.java
@@ -1,102 +1,102 @@
-/*
- * 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.internal.server;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocol;
-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 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;
-
-/**
- * @author Eike Stepper
- */
-public class ServerSession extends Lifecycle implements ISession, IListener
-{
- private BuddiesServerProtocol protocol;
-
- private IBuddy self;
-
- /**
- * @since 2.0
- */
- public ServerSession(BuddiesServerProtocol protocol, IBuddy self)
- {
- this.protocol = protocol;
- this.self = self;
- }
-
- /**
- * @since 2.0
- */
- public BuddiesServerProtocol getProtocol()
- {
- return protocol;
- }
-
- public IBuddy getSelf()
- {
- return self;
- }
-
- 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);
- }
-
- public void notifyEvent(IEvent event)
- {
- if (event.getSource() == protocol)
- {
- if (event instanceof ILifecycleEvent)
- {
- if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
- {
- deactivate();
- }
- }
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- protocol.addListener(this);
- self.getAccount().touch();
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- self.getAccount().touch();
- protocol.removeListener(this);
- 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.buddies.internal.server;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.internal.server.protocol.BuddiesServerProtocol;
+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 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;
+
+/**
+ * @author Eike Stepper
+ */
+public class ServerSession extends Lifecycle implements ISession, IListener
+{
+ private BuddiesServerProtocol protocol;
+
+ private IBuddy self;
+
+ /**
+ * @since 2.0
+ */
+ public ServerSession(BuddiesServerProtocol protocol, IBuddy self)
+ {
+ this.protocol = protocol;
+ this.self = self;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public BuddiesServerProtocol getProtocol()
+ {
+ return protocol;
+ }
+
+ public IBuddy getSelf()
+ {
+ return self;
+ }
+
+ 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);
+ }
+
+ public void notifyEvent(IEvent event)
+ {
+ if (event.getSource() == protocol)
+ {
+ if (event instanceof ILifecycleEvent)
+ {
+ if (((ILifecycleEvent)event).getKind() == ILifecycleEvent.Kind.DEACTIVATED)
+ {
+ deactivate();
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ protocol.addListener(this);
+ self.getAccount().touch();
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ self.getAccount().touch();
+ protocol.removeListener(this);
+ super.doDeactivate();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java
index efc8c9ce0d..b68c3a4c25 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/bundle/OM.java
@@ -1,65 +1,65 @@
-/*
- * 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.internal.server.bundle;
-
-import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
-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.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.server"; //$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 OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_REPOSITORY = DEBUG.tracer("repository"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_RESOURCE = DEBUG.tracer("resource"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_STORE = DEBUG.tracer("store"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_TYPES = DEBUG.tracer("types"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
-
- @Override
- protected void doStop() throws Exception
- {
- BuddyAdmin.INSTANCE.deactivate();
- }
- }
-}
+/*
+ * 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.internal.server.bundle;
+
+import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
+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.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.server"; //$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 OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_REPOSITORY = DEBUG.tracer("repository"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_SESSION = DEBUG.tracer("session"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_RESOURCE = DEBUG.tracer("resource"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_STORE = DEBUG.tracer("store"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_TYPES = DEBUG.tracer("types"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ BuddyAdmin.INSTANCE.deactivate();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/Messages.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/Messages.java
index fb538eb646..99e76b786e 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/Messages.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/Messages.java
@@ -1,41 +1,41 @@
-/*
- * 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.net4j.buddies.internal.server.messages;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class Messages
-{
- private static final String BUNDLE_NAME = "org.eclipse.net4j.buddies.internal.server.messages.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages()
- {
- }
-
- public static String getString(String key)
- {
- try
- {
- return RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e)
- {
- return '!' + key + '!';
- }
- }
-}
+/*
+ * 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:
+ * Victor Roldan Betancort - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.net4j.buddies.internal.server.messages;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author Victor Roldan Betancort
+ */
+public class Messages
+{
+ private static final String BUNDLE_NAME = "org.eclipse.net4j.buddies.internal.server.messages.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/messages.properties b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/messages.properties
index bf91c875f3..f7c5d2df50 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/messages.properties
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/messages/messages.properties
@@ -1,11 +1,11 @@
-# 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:
-# Victor Roldan Betancort - initial API and implementation
-# Eike Stepper - maintenance
-
-OpenSessionIndication.0=User denied {0}
+# 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:
+# Victor Roldan Betancort - initial API and implementation
+# Eike Stepper - maintenance
+
+OpenSessionIndication.0=User denied {0}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
index 1d2063c1e2..369f259eda 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddiesServerProtocol.java
@@ -1,86 +1,86 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.MessageIndication;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.server.ServerSession;
-import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.signal.SignalReactor;
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class BuddiesServerProtocol extends SignalProtocol<ServerSession>
-{
- public BuddiesServerProtocol()
- {
- super(ProtocolConstants.PROTOCOL_NAME);
- }
-
- @Override
- protected SignalReactor createSignalReactor(short signalID)
- {
- switch (signalID)
- {
- case ProtocolConstants.SIGNAL_OPEN_SESSION:
- return new OpenSessionIndication(this);
-
- case ProtocolConstants.SIGNAL_LOAD_ACCOUNT:
- return new LoadAccountIndication(this);
-
- case ProtocolConstants.SIGNAL_BUDDY_STATE:
- return new ServerBuddyStateIndication(this);
-
- case ProtocolConstants.SIGNAL_INSTALL_FACILITY:
- return new InstallFacilityIndication(this);
-
- case ProtocolConstants.SIGNAL_INITIATE_COLLABORATION:
- return new InitiateCollaborationIndication(this);
-
- case ProtocolConstants.SIGNAL_INVITE_BUDDIES:
- return new InviteBuddiesIndication(this);
-
- case ProtocolConstants.SIGNAL_COLLABORATION_LEFT:
- return new ServerCollaborationLeftIndication(this);
-
- case ProtocolConstants.SIGNAL_MESSAGE:
- return new MessageIndication(this, IBuddyAdmin.INSTANCE);
-
- default:
- return super.createSignalReactor(signalID);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Factory extends org.eclipse.spi.net4j.ServerProtocolFactory
- {
- public Factory()
- {
- super(ProtocolConstants.PROTOCOL_NAME);
- }
-
- public BuddiesServerProtocol create(String description)
- {
- return new BuddiesServerProtocol();
- }
-
- public static BuddiesServerProtocol get(IManagedContainer container, String description)
- {
- return (BuddiesServerProtocol)container.getElement(PRODUCT_GROUP, ProtocolConstants.PROTOCOL_NAME, description);
- }
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.internal.common.protocol.MessageIndication;
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.internal.server.ServerSession;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.signal.SignalReactor;
+import org.eclipse.net4j.util.container.IManagedContainer;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public class BuddiesServerProtocol extends SignalProtocol<ServerSession>
+{
+ public BuddiesServerProtocol()
+ {
+ super(ProtocolConstants.PROTOCOL_NAME);
+ }
+
+ @Override
+ protected SignalReactor createSignalReactor(short signalID)
+ {
+ switch (signalID)
+ {
+ case ProtocolConstants.SIGNAL_OPEN_SESSION:
+ return new OpenSessionIndication(this);
+
+ case ProtocolConstants.SIGNAL_LOAD_ACCOUNT:
+ return new LoadAccountIndication(this);
+
+ case ProtocolConstants.SIGNAL_BUDDY_STATE:
+ return new ServerBuddyStateIndication(this);
+
+ case ProtocolConstants.SIGNAL_INSTALL_FACILITY:
+ return new InstallFacilityIndication(this);
+
+ case ProtocolConstants.SIGNAL_INITIATE_COLLABORATION:
+ return new InitiateCollaborationIndication(this);
+
+ case ProtocolConstants.SIGNAL_INVITE_BUDDIES:
+ return new InviteBuddiesIndication(this);
+
+ case ProtocolConstants.SIGNAL_COLLABORATION_LEFT:
+ return new ServerCollaborationLeftIndication(this);
+
+ case ProtocolConstants.SIGNAL_MESSAGE:
+ return new MessageIndication(this, IBuddyAdmin.INSTANCE);
+
+ default:
+ return super.createSignalReactor(signalID);
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Factory extends org.eclipse.spi.net4j.ServerProtocolFactory
+ {
+ public Factory()
+ {
+ super(ProtocolConstants.PROTOCOL_NAME);
+ }
+
+ public BuddiesServerProtocol create(String description)
+ {
+ return new BuddiesServerProtocol();
+ }
+
+ public static BuddiesServerProtocol get(IManagedContainer container, String description)
+ {
+ return (BuddiesServerProtocol)container.getElement(PRODUCT_GROUP, ProtocolConstants.PROTOCOL_NAME, description);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
index f962edfd3b..130f6a31f3 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyAddedNotification.java
@@ -1,39 +1,39 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.signal.Request;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class BuddyAddedNotification extends Request
-{
- private String buddy;
-
- /**
- * @since 2.0
- */
- public BuddyAddedNotification(SignalProtocol<?> protocol, String buddy)
- {
- super(protocol, ProtocolConstants.SIGNAL_BUDDY_ADDED);
- this.buddy = buddy;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(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.buddies.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddyAddedNotification extends Request
+{
+ private String buddy;
+
+ /**
+ * @since 2.0
+ */
+ public BuddyAddedNotification(SignalProtocol<?> protocol, String buddy)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_BUDDY_ADDED);
+ this.buddy = buddy;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(buddy);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
index 7bd9b67572..9ae054f5e6 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/BuddyRemovedNotification.java
@@ -1,39 +1,39 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.signal.Request;
-import org.eclipse.net4j.signal.SignalProtocol;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class BuddyRemovedNotification extends Request
-{
- private String buddy;
-
- /**
- * @since 2.0
- */
- public BuddyRemovedNotification(SignalProtocol<?> protocol, String buddy)
- {
- super(protocol, ProtocolConstants.SIGNAL_BUDDY_REMOVED);
- this.buddy = buddy;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeString(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.buddies.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddyRemovedNotification extends Request
+{
+ private String buddy;
+
+ /**
+ * @since 2.0
+ */
+ public BuddyRemovedNotification(SignalProtocol<?> protocol, String buddy)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_BUDDY_REMOVED);
+ this.buddy = buddy;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(buddy);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
index f8cacc7733..2b92a0e5c2 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/CollaborationInitiatedNotification.java
@@ -1,51 +1,51 @@
-/*
- * 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.internal.server.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 CollaborationInitiatedNotification extends Request
-{
- private long collaborationID;
-
- private Collection<IBuddy> buddies;
-
- private String[] facilityTypes;
-
- /**
- * @since 2.0
- */
- public CollaborationInitiatedNotification(BuddiesServerProtocol protocol, long collaborationID,
- Collection<IBuddy> buddies, String[] facilityTypes)
- {
- super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_INITIATED);
- this.collaborationID = collaborationID;
- this.buddies = buddies;
- this.facilityTypes = facilityTypes;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeLong(collaborationID);
- ProtocolUtil.writeBuddies(out, buddies);
- ProtocolUtil.writeFacilityTypes(out, facilityTypes);
- }
-}
+/*
+ * 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.internal.server.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 CollaborationInitiatedNotification extends Request
+{
+ private long collaborationID;
+
+ private Collection<IBuddy> buddies;
+
+ private String[] facilityTypes;
+
+ /**
+ * @since 2.0
+ */
+ public CollaborationInitiatedNotification(BuddiesServerProtocol protocol, long collaborationID,
+ Collection<IBuddy> buddies, String[] facilityTypes)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_INITIATED);
+ this.collaborationID = collaborationID;
+ this.buddies = buddies;
+ this.facilityTypes = facilityTypes;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeLong(collaborationID);
+ ProtocolUtil.writeBuddies(out, buddies);
+ ProtocolUtil.writeFacilityTypes(out, facilityTypes);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
index 4594989f4b..1c2e35f54f 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/FacilityInstalledNotification.java
@@ -1,42 +1,42 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.signal.Request;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class FacilityInstalledNotification extends Request
-{
- private long collaborationID;
-
- private String facilityType;
-
- /**
- * @since 2.0
- */
- public FacilityInstalledNotification(BuddiesServerProtocol protocol, long collaborationID, String facilityType)
- {
- super(protocol, ProtocolConstants.SIGNAL_FACILITY_INSTALLED);
- this.collaborationID = collaborationID;
- this.facilityType = facilityType;
- }
-
- @Override
- protected void requesting(ExtendedDataOutputStream out) throws Exception
- {
- out.writeLong(collaborationID);
- out.writeString(facilityType);
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class FacilityInstalledNotification extends Request
+{
+ private long collaborationID;
+
+ private String facilityType;
+
+ /**
+ * @since 2.0
+ */
+ public FacilityInstalledNotification(BuddiesServerProtocol protocol, long collaborationID, String facilityType)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_FACILITY_INSTALLED);
+ this.collaborationID = collaborationID;
+ this.facilityType = facilityType;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeLong(collaborationID);
+ out.writeString(facilityType);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
index 18cddad673..4ccd2d1070 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InitiateCollaborationIndication.java
@@ -1,52 +1,52 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.ICollaboration;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class InitiateCollaborationIndication extends IndicationWithResponse
-{
- private ICollaboration collaboration;
-
- /**
- * @since 2.0
- */
- public InitiateCollaborationIndication(BuddiesServerProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_INITIATE_COLLABORATION);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- String[] userIDs = ProtocolUtil.readUserIDs(in);
- ISession session = (ISession)getProtocol().getInfraStructure();
- IBuddy initiator = session.getSelf();
- collaboration = IBuddyAdmin.INSTANCE.initiateCollaboration(initiator, userIDs);
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeLong(collaboration.getID());
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class InitiateCollaborationIndication extends IndicationWithResponse
+{
+ private ICollaboration collaboration;
+
+ /**
+ * @since 2.0
+ */
+ public InitiateCollaborationIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_INITIATE_COLLABORATION);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ String[] userIDs = ProtocolUtil.readUserIDs(in);
+ ISession session = (ISession)getProtocol().getInfraStructure();
+ IBuddy initiator = session.getSelf();
+ collaboration = IBuddyAdmin.INSTANCE.initiateCollaboration(initiator, userIDs);
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeLong(collaboration.getID());
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
index 0864a180e9..34d449adf3 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InstallFacilityIndication.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.buddies.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IFacility;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.common.Collaboration;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
-import org.eclipse.net4j.buddies.internal.server.bundle.OM;
-import org.eclipse.net4j.buddies.spi.common.ServerFacilityFactory;
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class InstallFacilityIndication extends IndicationWithResponse
-{
- private static final String FACILITY_GROUP = ServerFacilityFactory.PRODUCT_GROUP;
-
- private boolean success;
-
- /**
- * @since 2.0
- */
- public InstallFacilityIndication(BuddiesServerProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_INSTALL_FACILITY);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- long collaborationID = in.readLong();
- String facilityType = in.readString();
-
- try
- {
- String description = String.valueOf(collaborationID);
- IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType, description);
-
- Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
- if (collaboration != null)
- {
- facility.setCollaboration(collaboration);
- collaboration.addFacility(facility, true);
-
- ISession session = (ISession)getProtocol().getInfraStructure();
- IBuddy initiator = session.getSelf();
-
- for (IBuddy buddy : collaboration.getBuddies())
- {
- if (buddy != initiator)
- {
- try
- {
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new FacilityInstalledNotification(protocol, collaborationID, facilityType).sendAsync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
-
- success = true;
- }
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- out.writeBoolean(success);
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.IFacility;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.internal.common.Collaboration;
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
+import org.eclipse.net4j.buddies.internal.server.bundle.OM;
+import org.eclipse.net4j.buddies.spi.common.ServerFacilityFactory;
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class InstallFacilityIndication extends IndicationWithResponse
+{
+ private static final String FACILITY_GROUP = ServerFacilityFactory.PRODUCT_GROUP;
+
+ private boolean success;
+
+ /**
+ * @since 2.0
+ */
+ public InstallFacilityIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_INSTALL_FACILITY);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ long collaborationID = in.readLong();
+ String facilityType = in.readString();
+
+ try
+ {
+ String description = String.valueOf(collaborationID);
+ IFacility facility = (IFacility)IPluginContainer.INSTANCE.getElement(FACILITY_GROUP, facilityType, description);
+
+ Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
+ if (collaboration != null)
+ {
+ facility.setCollaboration(collaboration);
+ collaboration.addFacility(facility, true);
+
+ ISession session = (ISession)getProtocol().getInfraStructure();
+ IBuddy initiator = session.getSelf();
+
+ for (IBuddy buddy : collaboration.getBuddies())
+ {
+ if (buddy != initiator)
+ {
+ try
+ {
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
+ new FacilityInstalledNotification(protocol, collaborationID, facilityType).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+
+ success = true;
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeBoolean(success);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
index c847dfc007..269d577eb2 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/InviteBuddiesIndication.java
@@ -1,92 +1,92 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.internal.common.Collaboration;
-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.buddies.internal.server.BuddyAdmin;
-import org.eclipse.net4j.signal.Indication;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class InviteBuddiesIndication extends Indication
-{
- /**
- * @since 2.0
- */
- public InviteBuddiesIndication(BuddiesServerProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_INVITE_BUDDIES);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- long collaborationID = in.readLong();
- String[] userIDs = ProtocolUtil.readUserIDs(in);
-
- Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
- if (collaboration != null)
- {
- Set<IBuddy> added = new HashSet<IBuddy>();
- for (String userID : userIDs)
- {
- IBuddy buddy = BuddyAdmin.INSTANCE.getBuddy(userID);
- if (buddy != null && collaboration.getMembership(buddy) == null)
- {
- Membership.create(buddy, collaboration);
- added.add(buddy);
- }
- }
-
- List<IBuddy> buddies = Arrays.asList(collaboration.getBuddies());
- for (IBuddy buddy : buddies)
- {
- String[] facilityTypes = null;
- Set<IBuddy> set = new HashSet<IBuddy>();
- if (added.contains(buddy))
- {
- set.addAll(buddies);
- set.remove(buddy);
- facilityTypes = collaboration.getFacilityTypes();
- }
- else
- {
- set.addAll(added);
- }
-
- if (!set.isEmpty())
- {
- try
- {
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new CollaborationInitiatedNotification(protocol, collaborationID, set, facilityTypes).sendAsync();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- }
- }
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.internal.common.Collaboration;
+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.buddies.internal.server.BuddyAdmin;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class InviteBuddiesIndication extends Indication
+{
+ /**
+ * @since 2.0
+ */
+ public InviteBuddiesIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_INVITE_BUDDIES);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ long collaborationID = in.readLong();
+ String[] userIDs = ProtocolUtil.readUserIDs(in);
+
+ Collaboration collaboration = (Collaboration)BuddyAdmin.INSTANCE.getCollaboration(collaborationID);
+ if (collaboration != null)
+ {
+ Set<IBuddy> added = new HashSet<IBuddy>();
+ for (String userID : userIDs)
+ {
+ IBuddy buddy = BuddyAdmin.INSTANCE.getBuddy(userID);
+ if (buddy != null && collaboration.getMembership(buddy) == null)
+ {
+ Membership.create(buddy, collaboration);
+ added.add(buddy);
+ }
+ }
+
+ List<IBuddy> buddies = Arrays.asList(collaboration.getBuddies());
+ for (IBuddy buddy : buddies)
+ {
+ String[] facilityTypes = null;
+ Set<IBuddy> set = new HashSet<IBuddy>();
+ if (added.contains(buddy))
+ {
+ set.addAll(buddies);
+ set.remove(buddy);
+ facilityTypes = collaboration.getFacilityTypes();
+ }
+ else
+ {
+ set.addAll(added);
+ }
+
+ if (!set.isEmpty())
+ {
+ try
+ {
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
+ new CollaborationInitiatedNotification(protocol, collaborationID, set, facilityTypes).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
index 499ca0fa61..8a3ac387df 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/LoadAccountIndication.java
@@ -1,48 +1,48 @@
-/*
- * 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.internal.server.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.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-/**
- * @author Eike Stepper
- */
-public class LoadAccountIndication extends IndicationWithResponse
-{
- private IAccount account;
-
- /**
- * @since 2.0
- */
- public LoadAccountIndication(BuddiesServerProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_LOAD_ACCOUNT);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- String userID = in.readString();
- account = IBuddyAdmin.INSTANCE.getAccounts().get(userID);
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- ProtocolUtil.writeAccount(out, account);
- }
-}
+/*
+ * 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.internal.server.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.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class LoadAccountIndication extends IndicationWithResponse
+{
+ private IAccount account;
+
+ /**
+ * @since 2.0
+ */
+ public LoadAccountIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_LOAD_ACCOUNT);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ String userID = in.readString();
+ account = IBuddyAdmin.INSTANCE.getAccounts().get(userID);
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ ProtocolUtil.writeAccount(out, account);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
index 0f07b32007..304c9be517 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/OpenSessionIndication.java
@@ -1,104 +1,104 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
-import org.eclipse.net4j.buddies.internal.server.bundle.OM;
-import org.eclipse.net4j.buddies.internal.server.messages.Messages;
-import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.signal.IndicationWithResponse;
-import org.eclipse.net4j.util.io.ExtendedDataInputStream;
-import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class OpenSessionIndication extends IndicationWithResponse
-{
- private IAccount account;
-
- private IBuddy[] buddies;
-
- /**
- * @since 2.0
- */
- public OpenSessionIndication(BuddiesServerProtocol protocol)
- {
- super(protocol, ProtocolConstants.SIGNAL_OPEN_SESSION);
- }
-
- @Override
- protected void indicating(ExtendedDataInputStream in) throws Exception
- {
- String userID = in.readString();
- String password = in.readString();
- int size = in.readInt();
- String[] facilityTypes = new String[size];
- for (int i = 0; i < size; i++)
- {
- facilityTypes[i] = in.readString();
- }
-
- synchronized (IBuddyAdmin.INSTANCE)
- {
- buddies = IBuddyAdmin.INSTANCE.getBuddies();
- ISession session = IBuddyAdmin.INSTANCE.openSession(getProtocol().getChannel(), userID, password, facilityTypes);
- if (session != null)
- {
- account = session.getSelf().getAccount();
- }
- else
- {
- OM.LOG.info(MessageFormat.format(Messages.getString("OpenSessionIndication.0"), userID)); //$NON-NLS-1$
- }
- }
- }
-
- @Override
- protected void responding(ExtendedDataOutputStream out) throws Exception
- {
- ProtocolUtil.writeAccount(out, account);
- if (account != null)
- {
- List<BuddiesServerProtocol> protocols = new ArrayList<BuddiesServerProtocol>();
- out.writeInt(buddies.length);
- for (IBuddy buddy : buddies)
- {
- out.writeString(buddy.getUserID());
- ISession buddySession = IBuddyAdmin.INSTANCE.getSession(buddy);
- if (buddySession != null)
- {
- protocols.add((BuddiesServerProtocol)buddySession.getProtocol());
- }
- }
-
- for (BuddiesServerProtocol protocol : protocols)
- {
- try
- {
- new BuddyAddedNotification(protocol, account.getUserID()).sendAsync();
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.common.IAccount;
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolUtil;
+import org.eclipse.net4j.buddies.internal.server.bundle.OM;
+import org.eclipse.net4j.buddies.internal.server.messages.Messages;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.signal.IndicationWithResponse;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class OpenSessionIndication extends IndicationWithResponse
+{
+ private IAccount account;
+
+ private IBuddy[] buddies;
+
+ /**
+ * @since 2.0
+ */
+ public OpenSessionIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_OPEN_SESSION);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ String userID = in.readString();
+ String password = in.readString();
+ int size = in.readInt();
+ String[] facilityTypes = new String[size];
+ for (int i = 0; i < size; i++)
+ {
+ facilityTypes[i] = in.readString();
+ }
+
+ synchronized (IBuddyAdmin.INSTANCE)
+ {
+ buddies = IBuddyAdmin.INSTANCE.getBuddies();
+ ISession session = IBuddyAdmin.INSTANCE.openSession(getProtocol().getChannel(), userID, password, facilityTypes);
+ if (session != null)
+ {
+ account = session.getSelf().getAccount();
+ }
+ else
+ {
+ OM.LOG.info(MessageFormat.format(Messages.getString("OpenSessionIndication.0"), userID)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ protected void responding(ExtendedDataOutputStream out) throws Exception
+ {
+ ProtocolUtil.writeAccount(out, account);
+ if (account != null)
+ {
+ List<BuddiesServerProtocol> protocols = new ArrayList<BuddiesServerProtocol>();
+ out.writeInt(buddies.length);
+ for (IBuddy buddy : buddies)
+ {
+ out.writeString(buddy.getUserID());
+ ISession buddySession = IBuddyAdmin.INSTANCE.getSession(buddy);
+ if (buddySession != null)
+ {
+ protocols.add((BuddiesServerProtocol)buddySession.getProtocol());
+ }
+ }
+
+ for (BuddiesServerProtocol protocol : protocols)
+ {
+ try
+ {
+ new BuddyAddedNotification(protocol, account.getUserID()).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerBuddyStateIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerBuddyStateIndication.java
index 1e5cce850f..1d4525d898 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerBuddyStateIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerBuddyStateIndication.java
@@ -1,45 +1,45 @@
-/*
- * 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.internal.server.protocol;
-
-import org.eclipse.net4j.buddies.common.IBuddy.State;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateIndication;
-import org.eclipse.net4j.buddies.internal.server.ServerBuddy;
-import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-
-/**
- * @author Eike Stepper
- */
-public class ServerBuddyStateIndication extends BuddyStateIndication
-{
- /**
- * @since 2.0
- */
- public ServerBuddyStateIndication(BuddiesServerProtocol protocol)
- {
- super(protocol);
- }
-
- @Override
- protected void stateChanged(String userID, State state)
- {
- synchronized (IBuddyAdmin.INSTANCE)
- {
- ISession session = IBuddyAdmin.INSTANCE.getSession(userID);
- if (session != null)
- {
- ServerBuddy buddy = (ServerBuddy)session.getSelf();
- 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.buddies.internal.server.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddy.State;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.internal.common.protocol.BuddyStateIndication;
+import org.eclipse.net4j.buddies.internal.server.ServerBuddy;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+
+/**
+ * @author Eike Stepper
+ */
+public class ServerBuddyStateIndication extends BuddyStateIndication
+{
+ /**
+ * @since 2.0
+ */
+ public ServerBuddyStateIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol);
+ }
+
+ @Override
+ protected void stateChanged(String userID, State state)
+ {
+ synchronized (IBuddyAdmin.INSTANCE)
+ {
+ ISession session = IBuddyAdmin.INSTANCE.getSession(userID);
+ if (session != null)
+ {
+ ServerBuddy buddy = (ServerBuddy)session.getSelf();
+ buddy.setState(state);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java
index d619089513..045226e5f8 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/internal/server/protocol/ServerCollaborationLeftIndication.java
@@ -1,62 +1,62 @@
-/*
- * 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.internal.server.protocol;
-
-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.Collaboration;
-import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftIndication;
-import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftNotification;
-import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
-import org.eclipse.net4j.buddies.server.IBuddyAdmin;
-import org.eclipse.net4j.util.WrappedException;
-
-/**
- * @author Eike Stepper
- */
-public class ServerCollaborationLeftIndication extends CollaborationLeftIndication
-{
- /**
- * @since 2.0
- */
- public ServerCollaborationLeftIndication(BuddiesServerProtocol protocol)
- {
- super(protocol, IBuddyAdmin.INSTANCE, IBuddyAdmin.INSTANCE);
- }
-
- @Override
- protected void collaborationLeft(Buddy buddy, Collaboration collaboration)
- {
- for (IMembership membership : collaboration.getMemberships())
- {
- IBuddy member = membership.getBuddy();
- if (member != buddy)
- {
- try
- {
- BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
- new CollaborationLeftNotification(protocol, collaboration.getID(), buddy.getUserID()).sendAsync();
- }
- catch (Exception ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- }
-
- super.collaborationLeft(buddy, collaboration);
- if (collaboration.getBuddies().length == 0 && !collaboration.isPublic())
- {
- BuddyAdmin.INSTANCE.removeCollaboration(collaboration.getID());
- }
- }
-}
+/*
+ * 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.internal.server.protocol;
+
+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.Collaboration;
+import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftIndication;
+import org.eclipse.net4j.buddies.internal.common.protocol.CollaborationLeftNotification;
+import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
+import org.eclipse.net4j.buddies.server.IBuddyAdmin;
+import org.eclipse.net4j.util.WrappedException;
+
+/**
+ * @author Eike Stepper
+ */
+public class ServerCollaborationLeftIndication extends CollaborationLeftIndication
+{
+ /**
+ * @since 2.0
+ */
+ public ServerCollaborationLeftIndication(BuddiesServerProtocol protocol)
+ {
+ super(protocol, IBuddyAdmin.INSTANCE, IBuddyAdmin.INSTANCE);
+ }
+
+ @Override
+ protected void collaborationLeft(Buddy buddy, Collaboration collaboration)
+ {
+ for (IMembership membership : collaboration.getMemberships())
+ {
+ IBuddy member = membership.getBuddy();
+ if (member != buddy)
+ {
+ try
+ {
+ BuddiesServerProtocol protocol = (BuddiesServerProtocol)buddy.getSession().getProtocol();
+ new CollaborationLeftNotification(protocol, collaboration.getID(), buddy.getUserID()).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+
+ super.collaborationLeft(buddy, collaboration);
+ if (collaboration.getBuddies().length == 0 && !collaboration.isPublic())
+ {
+ BuddyAdmin.INSTANCE.removeCollaboration(collaboration.getID());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java
index ecfad99ac0..57b330abe9 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/IBuddyAdmin.java
@@ -1,37 +1,37 @@
-/*
- * 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.server;
-
-import org.eclipse.net4j.buddies.common.IAccount;
-import org.eclipse.net4j.buddies.common.IBuddy;
-import org.eclipse.net4j.buddies.common.IBuddyProvider;
-import org.eclipse.net4j.buddies.common.ICollaboration;
-import org.eclipse.net4j.buddies.common.ICollaborationContainer;
-import org.eclipse.net4j.buddies.common.ISession;
-import org.eclipse.net4j.buddies.common.ISessionProvider;
-import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
-import org.eclipse.net4j.channel.IChannel;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public interface IBuddyAdmin extends ICollaborationContainer, IBuddyProvider, ISessionProvider
-{
- public static final IBuddyAdmin INSTANCE = BuddyAdmin.INSTANCE;
-
- public Map<String, IAccount> getAccounts();
-
- public ISession openSession(IChannel channel, String userID, String password, String[] facilityTypes);
-
- public ICollaboration initiateCollaboration(IBuddy initiator, String... userIDs);
-}
+/*
+ * 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.server;
+
+import org.eclipse.net4j.buddies.common.IAccount;
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.IBuddyProvider;
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.ICollaborationContainer;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.buddies.common.ISessionProvider;
+import org.eclipse.net4j.buddies.internal.server.BuddyAdmin;
+import org.eclipse.net4j.channel.IChannel;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IBuddyAdmin extends ICollaborationContainer, IBuddyProvider, ISessionProvider
+{
+ public static final IBuddyAdmin INSTANCE = BuddyAdmin.INSTANCE;
+
+ public Map<String, IAccount> getAccounts();
+
+ public ISession openSession(IChannel channel, String userID, String password, String[] facilityTypes);
+
+ public ICollaboration initiateCollaboration(IBuddy initiator, String... userIDs);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java
index ba5b766a9a..02a51a1cb5 100644
--- a/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java
+++ b/plugins/org.eclipse.net4j.buddies.server/src/org/eclipse/net4j/buddies/server/ServerConstants.java
@@ -1,21 +1,21 @@
-/*
- * 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.server;
-
-import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
-
-/**
- * @author Eike Stepper
- */
-public interface ServerConstants
-{
- public static final String TYPE = ProtocolConstants.PROTOCOL_NAME + "server"; //$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.buddies.server;
+
+import org.eclipse.net4j.buddies.internal.common.protocol.ProtocolConstants;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ServerConstants
+{
+ public static final String TYPE = ProtocolConstants.PROTOCOL_NAME + "server"; //$NON-NLS-1$
+}

Back to the top