diff options
author | Eike Stepper | 2012-01-14 10:27:01 +0000 |
---|---|---|
committer | Eike Stepper | 2012-01-14 10:27:01 +0000 |
commit | 0266166cb9ff9535c150250073ea1e57b42d2693 (patch) | |
tree | c006a3bc0ba1f6e1d8a2bc032eedc346f71eab0d /plugins/org.eclipse.net4j.buddies.common | |
parent | 7416443692cdda72d1f704ea4fc5ececcc669df7 (diff) | |
download | cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.gz cdo-0266166cb9ff9535c150250073ea1e57b42d2693.tar.xz cdo-0266166cb9ff9535c150250073ea1e57b42d2693.zip |
Adjusted copyrights to 2012
Diffstat (limited to 'plugins/org.eclipse.net4j.buddies.common')
44 files changed, 2683 insertions, 2683 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.common/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.net4j.buddies.common/.settings/org.eclipse.jdt.ui.prefs index aaef0ccba1..6726e7034a 100644 --- a/plugins/org.eclipse.net4j.buddies.common/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.net4j.buddies.common/.settings/org.eclipse.jdt.ui.prefs @@ -1,120 +1,120 @@ -#Thu Feb 04 09:44:24 CET 2010 -cleanup.add_default_serial_version_id=true -cleanup.add_generated_serial_version_id=false -cleanup.add_missing_annotations=true -cleanup.add_missing_deprecated_annotations=true -cleanup.add_missing_methods=false -cleanup.add_missing_nls_tags=false -cleanup.add_missing_override_annotations=true -cleanup.add_missing_override_annotations_interface_methods=true -cleanup.add_serial_version_id=true -cleanup.always_use_blocks=true -cleanup.always_use_parentheses_in_expressions=false -cleanup.always_use_this_for_non_static_field_access=false -cleanup.always_use_this_for_non_static_method_access=false -cleanup.convert_to_enhanced_for_loop=false -cleanup.correct_indentation=true -cleanup.format_source_code=true -cleanup.format_source_code_changes_only=false -cleanup.make_local_variable_final=true -cleanup.make_parameters_final=false -cleanup.make_private_fields_final=true -cleanup.make_type_abstract_if_missing_method=false -cleanup.make_variable_declarations_final=false -cleanup.never_use_blocks=false -cleanup.never_use_parentheses_in_expressions=true -cleanup.organize_imports=true -cleanup.qualify_static_field_accesses_with_declaring_class=false -cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -cleanup.qualify_static_member_accesses_with_declaring_class=false -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_trailing_whitespaces=true -cleanup.remove_trailing_whitespaces_all=true -cleanup.remove_trailing_whitespaces_ignore_empty=false -cleanup.remove_unnecessary_casts=true -cleanup.remove_unnecessary_nls_tags=true -cleanup.remove_unused_imports=true -cleanup.remove_unused_local_variables=false -cleanup.remove_unused_private_fields=true -cleanup.remove_unused_private_members=false -cleanup.remove_unused_private_methods=true -cleanup.remove_unused_private_types=true -cleanup.sort_members=false -cleanup.sort_members_all=false -cleanup.use_blocks=true -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_parentheses_in_expressions=true -cleanup.use_this_for_non_static_field_access=true -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=true -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=_EMFT -cleanup_settings_version=2 -eclipse.preferences.version=1 -editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_EMFT -formatter_settings_version=11 -org.eclipse.jdt.ui.exception.name=ex -org.eclipse.jdt.ui.gettersetter.use.is=true -org.eclipse.jdt.ui.ignorelowercasenames=true -org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java; -org.eclipse.jdt.ui.javadoc=true -org.eclipse.jdt.ui.keywordthis=false -org.eclipse.jdt.ui.ondemandthreshold=99 -org.eclipse.jdt.ui.overrideannotation=true -org.eclipse.jdt.ui.staticondemandthreshold=99 -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> -sp_cleanup.add_default_serial_version_id=true -sp_cleanup.add_generated_serial_version_id=false -sp_cleanup.add_missing_annotations=true -sp_cleanup.add_missing_deprecated_annotations=true -sp_cleanup.add_missing_methods=false -sp_cleanup.add_missing_nls_tags=false -sp_cleanup.add_missing_override_annotations=true -sp_cleanup.add_missing_override_annotations_interface_methods=false -sp_cleanup.add_serial_version_id=false -sp_cleanup.always_use_blocks=true -sp_cleanup.always_use_parentheses_in_expressions=false -sp_cleanup.always_use_this_for_non_static_field_access=false -sp_cleanup.always_use_this_for_non_static_method_access=false -sp_cleanup.convert_to_enhanced_for_loop=false -sp_cleanup.correct_indentation=true -sp_cleanup.format_source_code=true -sp_cleanup.format_source_code_changes_only=false -sp_cleanup.make_local_variable_final=false -sp_cleanup.make_parameters_final=false -sp_cleanup.make_private_fields_final=true -sp_cleanup.make_type_abstract_if_missing_method=false -sp_cleanup.make_variable_declarations_final=false -sp_cleanup.never_use_blocks=false -sp_cleanup.never_use_parentheses_in_expressions=true -sp_cleanup.on_save_use_additional_actions=true -sp_cleanup.organize_imports=true -sp_cleanup.qualify_static_field_accesses_with_declaring_class=false -sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true -sp_cleanup.qualify_static_member_accesses_with_declaring_class=false -sp_cleanup.qualify_static_method_accesses_with_declaring_class=false -sp_cleanup.remove_private_constructors=true -sp_cleanup.remove_trailing_whitespaces=true -sp_cleanup.remove_trailing_whitespaces_all=true -sp_cleanup.remove_trailing_whitespaces_ignore_empty=false -sp_cleanup.remove_unnecessary_casts=true -sp_cleanup.remove_unnecessary_nls_tags=true -sp_cleanup.remove_unused_imports=true -sp_cleanup.remove_unused_local_variables=false -sp_cleanup.remove_unused_private_fields=true -sp_cleanup.remove_unused_private_members=false -sp_cleanup.remove_unused_private_methods=true -sp_cleanup.remove_unused_private_types=true -sp_cleanup.sort_members=false -sp_cleanup.sort_members_all=false -sp_cleanup.use_blocks=true -sp_cleanup.use_blocks_only_for_return_and_throw=false -sp_cleanup.use_parentheses_in_expressions=true -sp_cleanup.use_this_for_non_static_field_access=true -sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true -sp_cleanup.use_this_for_non_static_method_access=true -sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true +#Thu Feb 04 09:44:24 CET 2010
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=false
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_missing_override_annotations_interface_methods=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=false
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=true
+cleanup.format_source_code=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=false
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=true
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_EMFT
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_EMFT
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=ex
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.ignorelowercasenames=true
+org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java;
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.ondemandthreshold=99
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.staticondemandthreshold=99
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=false
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=true
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/plugins/org.eclipse.net4j.buddies.common/build.properties b/plugins/org.eclipse.net4j.buddies.common/build.properties index d6cd99e548..a23538dd08 100644 --- a/plugins/org.eclipse.net4j.buddies.common/build.properties +++ b/plugins/org.eclipse.net4j.buddies.common/build.properties @@ -1,21 +1,21 @@ -# Copyright (c) 2004 - 2011 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 - -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - about.html,\ - copyright.txt,\ - plugin.properties,\ - .options -src.includes = about.html,\ - copyright.txt +# 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
+
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ copyright.txt,\
+ plugin.properties,\
+ .options
+src.includes = about.html,\
+ copyright.txt
diff --git a/plugins/org.eclipse.net4j.buddies.common/copyright.txt b/plugins/org.eclipse.net4j.buddies.common/copyright.txt index e921242cf0..8f6328980e 100644 --- a/plugins/org.eclipse.net4j.buddies.common/copyright.txt +++ b/plugins/org.eclipse.net4j.buddies.common/copyright.txt @@ -1,8 +1,8 @@ -Copyright (c) 2004 - 2011 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.common/plugin.properties b/plugins/org.eclipse.net4j.buddies.common/plugin.properties index a8f7edf1e8..556969df2d 100644 --- a/plugins/org.eclipse.net4j.buddies.common/plugin.properties +++ b/plugins/org.eclipse.net4j.buddies.common/plugin.properties @@ -1,11 +1,11 @@ -# Copyright (c) 2004 - 2011 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 Common -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 Common
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IAccount.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IAccount.java index d62af2818d..a71816c5a4 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IAccount.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IAccount.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.security.IUserAware; - -import java.util.Map; - -/** - * @author Eike Stepper - */ -public interface IAccount extends IUserAware -{ - public void setPassword(String password); - - public boolean authenticate(String password); - - public Map<String, String> getProperties(); - - public void touch(); - - public long getTimeStamp(); -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.security.IUserAware;
+
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IAccount extends IUserAware
+{
+ public void setPassword(String password);
+
+ public boolean authenticate(String password);
+
+ public Map<String, String> getProperties();
+
+ public void touch();
+
+ public long getTimeStamp();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddy.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddy.java index 5a5000ee53..14663439c3 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddy.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddy.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.security.IUserAware; - -import org.eclipse.core.runtime.IAdaptable; - -import java.util.Collection; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public interface IBuddy extends IUserAware, IMembershipContainer, ICollaborationProvider, IAdaptable -{ - public State getState(); - - public IAccount getAccount(); - - public ISession getSession(); - - public Set<String> getFacilityTypes(); - - public IMembership initiate(); - - public IMembership initiate(IBuddy buddy); - - public IMembership[] initiate(Collection<IBuddy> buddies); - - public IMembership join(long collaborationID); - - public IMembership join(Object invitationToken); - - /** - * @author Eike Stepper - */ - public enum State - { - AVAILABLE, LONESOME, AWAY, DO_NOT_DISTURB - } -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.security.IUserAware;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IBuddy extends IUserAware, IMembershipContainer, ICollaborationProvider, IAdaptable
+{
+ public State getState();
+
+ public IAccount getAccount();
+
+ public ISession getSession();
+
+ public Set<String> getFacilityTypes();
+
+ public IMembership initiate();
+
+ public IMembership initiate(IBuddy buddy);
+
+ public IMembership[] initiate(Collection<IBuddy> buddies);
+
+ public IMembership join(long collaborationID);
+
+ public IMembership join(Object invitationToken);
+
+ /**
+ * @author Eike Stepper
+ */
+ public enum State
+ {
+ AVAILABLE, LONESOME, AWAY, DO_NOT_DISTURB
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyContainer.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyContainer.java index ad0275ad6a..3789e1ab43 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyContainer.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyContainer.java @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.container.IContainer; - -/** - * @author Eike Stepper - */ -public interface IBuddyContainer extends IBuddyProvider, IContainer<IBuddy> -{ -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.container.IContainer;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IBuddyContainer extends IBuddyProvider, IContainer<IBuddy>
+{
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyProvider.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyProvider.java index d879da9428..a48b85cf0b 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyProvider.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyProvider.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -/** - * @author Eike Stepper - */ -public interface IBuddyProvider -{ - public IBuddy[] getBuddies(); - - public IBuddy getBuddy(String userID); -} +/*
+ * 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.common;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IBuddyProvider
+{
+ public IBuddy[] getBuddies();
+
+ public IBuddy getBuddy(String userID);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyStateEvent.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyStateEvent.java index ec66577832..1cb9f4f793 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyStateEvent.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IBuddyStateEvent.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface IBuddyStateEvent extends IEvent -{ - /** - * @since 3.0 - */ - public IBuddy getSource(); - - public IBuddy.State getOldState(); - - public IBuddy.State getNewState(); -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IBuddyStateEvent extends IEvent
+{
+ /**
+ * @since 3.0
+ */
+ public IBuddy getSource();
+
+ public IBuddy.State getOldState();
+
+ public IBuddy.State getNewState();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaboration.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaboration.java index 2e798d6756..44981c5f1d 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaboration.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaboration.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * @author Eike Stepper - */ -public interface ICollaboration extends IMembershipContainer, IBuddyProvider, IAdaptable -{ - public long getID(); - - public String getTitle(); - - public String getDescription(); - - public Visibility getVisibility(); - - public boolean isPublic(); - - public void setPublic(String title, String description); - - public void setPrivate(); - - public String[] getFacilityTypes(); - - public IFacility[] getFacilities(); - - public IFacility getFacility(String type); - - public enum Visibility - { - PRIVATE, PUBLIC - } -} +/*
+ * 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.common;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ICollaboration extends IMembershipContainer, IBuddyProvider, IAdaptable
+{
+ public long getID();
+
+ public String getTitle();
+
+ public String getDescription();
+
+ public Visibility getVisibility();
+
+ public boolean isPublic();
+
+ public void setPublic(String title, String description);
+
+ public void setPrivate();
+
+ public String[] getFacilityTypes();
+
+ public IFacility[] getFacilities();
+
+ public IFacility getFacility(String type);
+
+ public enum Visibility
+ {
+ PRIVATE, PUBLIC
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationContainer.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationContainer.java index 1cde06d7a0..cbff595029 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationContainer.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationContainer.java @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.container.IContainer; - -/** - * @author Eike Stepper - */ -public interface ICollaborationContainer extends ICollaborationProvider, IContainer<ICollaboration> -{ -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.container.IContainer;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ICollaborationContainer extends ICollaborationProvider, IContainer<ICollaboration>
+{
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationProvider.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationProvider.java index e279c47798..7dcedb238f 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationProvider.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ICollaborationProvider.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -/** - * @author Eike Stepper - */ -public interface ICollaborationProvider -{ - public ICollaboration[] getCollaborations(); - - public ICollaboration getCollaboration(long id); -} +/*
+ * 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.common;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ICollaborationProvider
+{
+ public ICollaboration[] getCollaborations();
+
+ public ICollaboration getCollaboration(long id);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacility.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacility.java index 030c447c82..aa623bc3fe 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacility.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacility.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.event.INotifier; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * @author Eike Stepper - */ -public interface IFacility extends INotifier, IAdaptable -{ - public String getType(); - - public ICollaboration getCollaboration(); - - public void setCollaboration(ICollaboration collaboration); - - public void sendMessage(IMessage message); -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.event.INotifier;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IFacility extends INotifier, IAdaptable
+{
+ public String getType();
+
+ public ICollaboration getCollaboration();
+
+ public void setCollaboration(ICollaboration collaboration);
+
+ public void sendMessage(IMessage message);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacilityInstalledEvent.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacilityInstalledEvent.java index 266d95adac..3cb3eb61d9 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacilityInstalledEvent.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IFacilityInstalledEvent.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface IFacilityInstalledEvent extends IEvent -{ - /** - * @since 3.0 - */ - public ICollaboration getSource(); - - public IFacility getFacility(); - - public boolean fromRemote(); -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IFacilityInstalledEvent extends IEvent
+{
+ /**
+ * @since 3.0
+ */
+ public ICollaboration getSource();
+
+ public IFacility getFacility();
+
+ public boolean fromRemote();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembership.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembership.java index 283abfb8c2..ebffb6e182 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembership.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembership.java @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.container.IContainer; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * @author Eike Stepper - */ -public interface IMembership extends IMembershipKey, IContainer<Object>, IAdaptable -{ - public long getStartTime(); -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.container.IContainer;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMembership extends IMembershipKey, IContainer<Object>, IAdaptable
+{
+ public long getStartTime();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipContainer.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipContainer.java index 8a1c33f296..8162bc9df0 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipContainer.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipContainer.java @@ -1,20 +1,20 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.container.IContainer; - -/** - * @author Eike Stepper - */ -public interface IMembershipContainer extends IMembershipProvider, IContainer<IMembership> -{ -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.container.IContainer;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMembershipContainer extends IMembershipProvider, IContainer<IMembership>
+{
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipKey.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipKey.java index 290e272176..0644d7d47d 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipKey.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipKey.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -/** - * @author Eike Stepper - */ -public interface IMembershipKey -{ - public IBuddy getBuddy(); - - public ICollaboration getCollaboration(); -} +/*
+ * 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.common;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMembershipKey
+{
+ public IBuddy getBuddy();
+
+ public ICollaboration getCollaboration();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipProvider.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipProvider.java index ddcadb0ecd..fc3e1ffb75 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipProvider.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMembershipProvider.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -/** - * @author Eike Stepper - */ -public interface IMembershipProvider -{ - public IMembership[] getMemberships(); - - public IMembership getMembership(IBuddy buddy, ICollaboration collaboration); -} +/*
+ * 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.common;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMembershipProvider
+{
+ public IMembership[] getMemberships();
+
+ public IMembership getMembership(IBuddy buddy, ICollaboration collaboration);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessage.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessage.java index f8f0c2272a..7cd87d5e71 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessage.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessage.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * @author Eike Stepper - */ -public interface IMessage extends IAdaptable -{ - public String getSenderID(); -} +/*
+ * 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.common;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMessage extends IAdaptable
+{
+ public String getSenderID();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessageEvent.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessageEvent.java index bd58e5d484..d09bf2e835 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessageEvent.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/IMessageEvent.java @@ -1,21 +1,21 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * @author Eike Stepper - */ -public interface IMessageEvent extends IEvent -{ - public IMessage getMessage(); -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IMessageEvent extends IEvent
+{
+ public IMessage getMessage();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISession.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISession.java index 18deef8ccb..c2845c48b6 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISession.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISession.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.protocol.IProtocol; -import org.eclipse.net4j.util.event.INotifier; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * @author Eike Stepper - */ -public interface ISession extends INotifier, IAdaptable -{ - /** - * @since 2.0 - */ - public IProtocol<?> getProtocol(); - - public IBuddy getSelf(); - - public void close(); -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.buddies.common;
+
+import org.eclipse.net4j.protocol.IProtocol;
+import org.eclipse.net4j.util.event.INotifier;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ISession extends INotifier, IAdaptable
+{
+ /**
+ * @since 2.0
+ */
+ public IProtocol<?> getProtocol();
+
+ public IBuddy getSelf();
+
+ public void close();
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISessionProvider.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISessionProvider.java index e1261cec87..43ac446225 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISessionProvider.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/common/ISessionProvider.java @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -/** - * @author Eike Stepper - */ -public interface ISessionProvider -{ - public ISession[] getSessions(); - - public ISession getSession(String userID); - - public ISession getSession(IBuddy 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.common;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ISessionProvider
+{
+ public ISession[] getSessions();
+
+ public ISession getSession(String userID);
+
+ public ISession getSession(IBuddy buddy);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Account.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Account.java index bf9e5a82fa..e062c9d5b4 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Account.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Account.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IAccount; -import org.eclipse.net4j.util.ObjectUtil; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class Account implements IAccount, Serializable -{ - private static final long serialVersionUID = 1L; - - private String userID; - - private transient String password; - - private Map<String, String> properties = new HashMap<String, String>(); - - private long timeStamp; - - protected Account() - { - } - - public Account(String userID, String password) - { - this.userID = userID; - this.password = password; - } - - public String getUserID() - { - return userID; - } - - public String getPassword() - { - return password; - } - - public void setPassword(String password) - { - this.password = password; - } - - public boolean authenticate(String password) - { - return ObjectUtil.equals(password, this.password); - } - - public Map<String, String> getProperties() - { - return properties; - } - - public void touch() - { - timeStamp = System.currentTimeMillis(); - } - - public long getTimeStamp() - { - return timeStamp; - } -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.buddies.common.IAccount;
+import org.eclipse.net4j.util.ObjectUtil;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class Account implements IAccount, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private String userID;
+
+ private transient String password;
+
+ private Map<String, String> properties = new HashMap<String, String>();
+
+ private long timeStamp;
+
+ protected Account()
+ {
+ }
+
+ public Account(String userID, String password)
+ {
+ this.userID = userID;
+ this.password = password;
+ }
+
+ public String getUserID()
+ {
+ return userID;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ public boolean authenticate(String password)
+ {
+ return ObjectUtil.equals(password, this.password);
+ }
+
+ public Map<String, String> getProperties()
+ {
+ return properties;
+ }
+
+ public void touch()
+ {
+ timeStamp = System.currentTimeMillis();
+ }
+
+ public long getTimeStamp()
+ {
+ return timeStamp;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Buddy.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Buddy.java index 8d7b9e6486..0f6379ea24 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Buddy.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Buddy.java @@ -1,226 +1,226 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -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.IMembership; -import org.eclipse.net4j.buddies.common.ISession; -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.PlatformObject; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public abstract class Buddy extends MembershipContainer implements IBuddy -{ - private ISession session; - - private State state = State.AVAILABLE; - - private Set<String> facilityTypes; - - public Buddy(ISession session, Set<String> facilityTypes) - { - this.session = session; - this.facilityTypes = facilityTypes == null ? null : Collections.unmodifiableSet(facilityTypes); - } - - public ISession getSession() - { - return session; - } - - public void setSession(ISession session) - { - this.session = session; - } - - public State getState() - { - return state; - } - - public void setState(State state) - { - if (this.state != state) - { - IEvent event = new BuddyStateEvent(this.state, state); - this.state = state; - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(event, listeners); - } - } - } - - public Set<String> getFacilityTypes() - { - if (facilityTypes == null) - { - facilityTypes = Collections.unmodifiableSet(loadFacilityTypes()); - } - - return facilityTypes; - } - - public IMembership getMembership(Collaboration collaboration) - { - return getMembership(this, collaboration); - } - - public IMembership removeMembership(Collaboration collaboration) - { - return removeMembership(this, collaboration); - } - - public ICollaboration getCollaboration(long collaborationID) - { - for (IMembership membership : getMemberships()) - { - ICollaboration collaboration = membership.getCollaboration(); - if (collaboration.getID() == collaborationID) - { - return collaboration; - } - } - - return null; - } - - public ICollaboration[] getCollaborations() - { - List<ICollaboration> collaborations = new ArrayList<ICollaboration>(); - for (IMembership membership : getMemberships()) - { - ICollaboration collaboration = membership.getCollaboration(); - collaborations.add(collaboration); - } - - return collaborations.toArray(new ICollaboration[collaborations.size()]); - } - - public IMembership initiate() - { - return initiate((IBuddy)null); - } - - public IMembership initiate(IBuddy buddy) - { - HashSet<IBuddy> buddies = new HashSet<IBuddy>(); - if (buddy != null) - { - buddies.add(buddy); - } - - IMembership[] memberships = initiate(buddies); - return memberships.length == 0 ? null : memberships[0]; - } - - /** - * @see PlatformObject#getAdapter(Class) - */ - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) - { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof IBuddy) - { - IBuddy buddy = (IBuddy)obj; - return ObjectUtil.equals(getUserID(), buddy.getUserID()); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(getUserID()); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}[{1}]", getClass().getSimpleName(), getUserID()); //$NON-NLS-1$ - } - - protected Set<String> loadFacilityTypes() - { - throw new UnsupportedOperationException(); - } - - /** - * @author Eike Stepper - */ - private final class BuddyStateEvent extends Event implements IBuddyStateEvent - { - private static final long serialVersionUID = 1L; - - private State oldState; - - private State newState; - - public BuddyStateEvent(State oldState, State newState) - { - super(Buddy.this); - this.oldState = oldState; - this.newState = newState; - } - - @Override - public IBuddy getSource() - { - return (IBuddy)super.getSource(); - } - - public State getOldState() - { - return oldState; - } - - public State getNewState() - { - return newState; - } - - @Override - public String toString() - { - return MessageFormat.format("BuddyStateEvent[source={0}, oldState={1}, newState={2}]", getSource(), //$NON-NLS-1$ - getOldState(), getNewState()); - } - } -} +/*
+ * 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.common;
+
+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.IMembership;
+import org.eclipse.net4j.buddies.common.ISession;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Buddy extends MembershipContainer implements IBuddy
+{
+ private ISession session;
+
+ private State state = State.AVAILABLE;
+
+ private Set<String> facilityTypes;
+
+ public Buddy(ISession session, Set<String> facilityTypes)
+ {
+ this.session = session;
+ this.facilityTypes = facilityTypes == null ? null : Collections.unmodifiableSet(facilityTypes);
+ }
+
+ public ISession getSession()
+ {
+ return session;
+ }
+
+ public void setSession(ISession session)
+ {
+ this.session = session;
+ }
+
+ public State getState()
+ {
+ return state;
+ }
+
+ public void setState(State state)
+ {
+ if (this.state != state)
+ {
+ IEvent event = new BuddyStateEvent(this.state, state);
+ this.state = state;
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(event, listeners);
+ }
+ }
+ }
+
+ public Set<String> getFacilityTypes()
+ {
+ if (facilityTypes == null)
+ {
+ facilityTypes = Collections.unmodifiableSet(loadFacilityTypes());
+ }
+
+ return facilityTypes;
+ }
+
+ public IMembership getMembership(Collaboration collaboration)
+ {
+ return getMembership(this, collaboration);
+ }
+
+ public IMembership removeMembership(Collaboration collaboration)
+ {
+ return removeMembership(this, collaboration);
+ }
+
+ public ICollaboration getCollaboration(long collaborationID)
+ {
+ for (IMembership membership : getMemberships())
+ {
+ ICollaboration collaboration = membership.getCollaboration();
+ if (collaboration.getID() == collaborationID)
+ {
+ return collaboration;
+ }
+ }
+
+ return null;
+ }
+
+ public ICollaboration[] getCollaborations()
+ {
+ List<ICollaboration> collaborations = new ArrayList<ICollaboration>();
+ for (IMembership membership : getMemberships())
+ {
+ ICollaboration collaboration = membership.getCollaboration();
+ collaborations.add(collaboration);
+ }
+
+ return collaborations.toArray(new ICollaboration[collaborations.size()]);
+ }
+
+ public IMembership initiate()
+ {
+ return initiate((IBuddy)null);
+ }
+
+ public IMembership initiate(IBuddy buddy)
+ {
+ HashSet<IBuddy> buddies = new HashSet<IBuddy>();
+ if (buddy != null)
+ {
+ buddies.add(buddy);
+ }
+
+ IMembership[] memberships = initiate(buddies);
+ return memberships.length == 0 ? null : memberships[0];
+ }
+
+ /**
+ * @see PlatformObject#getAdapter(Class)
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ return ObjectUtil.equals(getUserID(), buddy.getUserID());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(getUserID());
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}[{1}]", getClass().getSimpleName(), getUserID()); //$NON-NLS-1$
+ }
+
+ protected Set<String> loadFacilityTypes()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class BuddyStateEvent extends Event implements IBuddyStateEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private State oldState;
+
+ private State newState;
+
+ public BuddyStateEvent(State oldState, State newState)
+ {
+ super(Buddy.this);
+ this.oldState = oldState;
+ this.newState = newState;
+ }
+
+ @Override
+ public IBuddy getSource()
+ {
+ return (IBuddy)super.getSource();
+ }
+
+ public State getOldState()
+ {
+ return oldState;
+ }
+
+ public State getNewState()
+ {
+ return newState;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("BuddyStateEvent[source={0}, oldState={1}, newState={2}]", getSource(), //$NON-NLS-1$
+ getOldState(), getNewState());
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/BuddyContainer.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/BuddyContainer.java index 2874bdd1cc..e92d4db9f2 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/BuddyContainer.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/BuddyContainer.java @@ -1,152 +1,152 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IBuddy; -import org.eclipse.net4j.buddies.common.IBuddyContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.SingleDeltaContainerEvent; -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.LifecycleEvent; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class BuddyContainer extends Lifecycle implements IBuddyContainer, IListener -{ - private Map<String, IBuddy> buddies = new HashMap<String, IBuddy>(); - - public BuddyContainer(Collection<IBuddy> buddies) - { - if (buddies != null) - { - for (IBuddy buddy : buddies) - { - this.buddies.put(buddy.getUserID(), buddy); - buddy.addListener(this); - } - } - } - - public BuddyContainer() - { - } - - public boolean addBuddy(IBuddy buddy) - { - String userID = buddy.getUserID(); - synchronized (buddies) - { - if (!buddies.containsKey(userID)) - { - buddies.put(userID, buddy); - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new SingleDeltaContainerEvent<IBuddy>(this, buddy, IContainerDelta.Kind.ADDED), listeners); - } - - buddy.addListener(this); - return true; - } - } - - return false; - } - - public IBuddy removeBuddy(String userID) - { - IBuddy buddy; - synchronized (buddies) - { - buddy = buddies.remove(userID); - } - - if (buddy != null) - { - buddy.removeListener(this); - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new SingleDeltaContainerEvent<IBuddy>(this, buddy, IContainerDelta.Kind.REMOVED), listeners); - } - } - - return buddy; - } - - public IBuddy[] getBuddies() - { - synchronized (buddies) - { - return buddies.values().toArray(new IBuddy[buddies.size()]); - } - } - - public IBuddy getBuddy(String userID) - { - synchronized (buddies) - { - return buddies.get(userID); - } - } - - public IBuddy[] getElements() - { - return getBuddies(); - } - - public boolean isEmpty() - { - synchronized (buddies) - { - return buddies.isEmpty(); - } - } - - public void notifyEvent(IEvent event) - { - if (event.getSource() instanceof IBuddy) - { - notifyBuddyEvent(event); - if (event instanceof LifecycleEvent) - { - LifecycleEvent e = (LifecycleEvent)event; - if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED) - { - removeBuddy(((IBuddy)e.getSource()).getUserID()); - } - } - } - } - - protected void notifyBuddyEvent(IEvent event) - { - } - - @Override - protected void doDeactivate() throws Exception - { - for (IBuddy buddy : getBuddies()) - { - buddy.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.common;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.IBuddyContainer;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.SingleDeltaContainerEvent;
+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.LifecycleEvent;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddyContainer extends Lifecycle implements IBuddyContainer, IListener
+{
+ private Map<String, IBuddy> buddies = new HashMap<String, IBuddy>();
+
+ public BuddyContainer(Collection<IBuddy> buddies)
+ {
+ if (buddies != null)
+ {
+ for (IBuddy buddy : buddies)
+ {
+ this.buddies.put(buddy.getUserID(), buddy);
+ buddy.addListener(this);
+ }
+ }
+ }
+
+ public BuddyContainer()
+ {
+ }
+
+ public boolean addBuddy(IBuddy buddy)
+ {
+ String userID = buddy.getUserID();
+ synchronized (buddies)
+ {
+ if (!buddies.containsKey(userID))
+ {
+ buddies.put(userID, buddy);
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new SingleDeltaContainerEvent<IBuddy>(this, buddy, IContainerDelta.Kind.ADDED), listeners);
+ }
+
+ buddy.addListener(this);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public IBuddy removeBuddy(String userID)
+ {
+ IBuddy buddy;
+ synchronized (buddies)
+ {
+ buddy = buddies.remove(userID);
+ }
+
+ if (buddy != null)
+ {
+ buddy.removeListener(this);
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new SingleDeltaContainerEvent<IBuddy>(this, buddy, IContainerDelta.Kind.REMOVED), listeners);
+ }
+ }
+
+ return buddy;
+ }
+
+ public IBuddy[] getBuddies()
+ {
+ synchronized (buddies)
+ {
+ return buddies.values().toArray(new IBuddy[buddies.size()]);
+ }
+ }
+
+ public IBuddy getBuddy(String userID)
+ {
+ synchronized (buddies)
+ {
+ return buddies.get(userID);
+ }
+ }
+
+ public IBuddy[] getElements()
+ {
+ return getBuddies();
+ }
+
+ public boolean isEmpty()
+ {
+ synchronized (buddies)
+ {
+ return buddies.isEmpty();
+ }
+ }
+
+ public void notifyEvent(IEvent event)
+ {
+ if (event.getSource() instanceof IBuddy)
+ {
+ notifyBuddyEvent(event);
+ if (event instanceof LifecycleEvent)
+ {
+ LifecycleEvent e = (LifecycleEvent)event;
+ if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED)
+ {
+ removeBuddy(((IBuddy)e.getSource()).getUserID());
+ }
+ }
+ }
+ }
+
+ protected void notifyBuddyEvent(IEvent event)
+ {
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ for (IBuddy buddy : getBuddies())
+ {
+ buddy.removeListener(this);
+ }
+
+ super.doDeactivate();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java index fc5cfe1086..765b57795f 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Collaboration.java @@ -1,297 +1,297 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IBuddy; -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.IFacility; -import org.eclipse.net4j.buddies.common.IFacilityInstalledEvent; -import org.eclipse.net4j.buddies.common.IMembership; -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.buddies.internal.common.bundle.OM; -import org.eclipse.net4j.buddies.internal.common.protocol.MessageNotification; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.lifecycle.LifecycleUtil; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.PlatformObject; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class Collaboration extends MembershipContainer implements ICollaboration -{ - private long id; - - private String title; - - private String description; - - private Visibility visibility = Visibility.PRIVATE; - - private ConcurrentMap<String, IFacility> facilities = new ConcurrentHashMap<String, IFacility>(); - - public Collaboration(long id) - { - this.id = id; - } - - public long getID() - { - return id; - } - - public String getTitle() - { - return title == null ? String.valueOf(id) : title; - } - - public String getDescription() - { - return description; - } - - public Visibility getVisibility() - { - return visibility; - } - - public boolean isPublic() - { - return visibility == Visibility.PUBLIC; - } - - public void setPublic(String title, String description) - { - visibility = Visibility.PUBLIC; - this.title = title; - this.description = description; - } - - public void setPrivate() - { - visibility = Visibility.PRIVATE; - title = null; - description = null; - } - - public IMembership getMembership(IBuddy buddy) - { - return getMembership(buddy, this); - } - - public IMembership removeMembership(IBuddy buddy) - { - return removeMembership(buddy, this); - } - - public IBuddy getBuddy(String userID) - { - for (IMembership membership : getMemberships()) - { - IBuddy buddy = membership.getBuddy(); - if (ObjectUtil.equals(buddy.getUserID(), userID)) - { - return buddy; - } - } - - return null; - } - - public IBuddy[] getBuddies() - { - List<IBuddy> buddies = new ArrayList<IBuddy>(); - for (IMembership membership : getMemberships()) - { - IBuddy buddy = membership.getBuddy(); - buddies.add(buddy); - } - - return buddies.toArray(new IBuddy[buddies.size()]); - } - - public String[] getFacilityTypes() - { - return facilities.keySet().toArray(new String[facilities.size()]); - } - - public IFacility[] getFacilities() - { - return facilities.values().toArray(new IFacility[facilities.size()]); - } - - public IFacility getFacility(String type) - { - return facilities.get(type); - } - - public boolean addFacility(IFacility facility, boolean remote) - { - String type = facility.getType(); - if (!facilities.containsKey(type)) - { - facilities.put(type, facility); - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new FacilityInstalledEvent(this, facility, remote), listeners); - } - - facility.addListener(this); - return true; - } - - return false; - } - - public void sendMessage(long collaborationID, String facilityType, IMessage message) - { - IMembership[] elements = getElements(); - for (IMembership membership : elements) - { - IBuddy receiver = membership.getBuddy(); - if (!ObjectUtil.equals(receiver.getUserID(), message.getSenderID())) - { - try - { - SignalProtocol<?> protocol = (SignalProtocol<?>)receiver.getSession().getProtocol(); - new MessageNotification(protocol, collaborationID, facilityType, message).sendAsync(); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - } - } - - /** - * @see PlatformObject#getAdapter(Class) - */ - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) - { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof ICollaboration) - { - ICollaboration collaboration = (ICollaboration)obj; - return getID() == collaboration.getID(); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(id); - } - - @Override - public String toString() - { - return MessageFormat.format("{0}[{1}]", getClass().getSimpleName(), getTitle()); //$NON-NLS-1$ - } - - @Override - public void notifyEvent(IEvent event) - { - super.notifyEvent(event); - if (event.getSource() instanceof IFacility) - { - notifyFacilityEvent(event); - } - } - - protected void notifyFacilityEvent(IEvent event) - { - } - - @Override - protected void doDeactivate() throws Exception - { - for (IFacility facility : getFacilities()) - { - facility.removeListener(this); - LifecycleUtil.deactivate(facility); - } - - for (IMembership membership : getMemberships()) - { - LifecycleUtil.deactivate(membership); - } - - super.doDeactivate(); - } - - /** - * @author Eike Stepper - */ - private static final class FacilityInstalledEvent extends Event implements IFacilityInstalledEvent - { - private static final long serialVersionUID = 1L; - - private IFacility facility; - - private boolean remote; - - public FacilityInstalledEvent(ICollaboration source, IFacility facility, boolean remote) - { - super(source); - this.facility = facility; - this.remote = remote; - } - - @Override - public ICollaboration getSource() - { - return (ICollaboration)super.getSource(); - } - - public IFacility getFacility() - { - return facility; - } - - public boolean fromRemote() - { - return remote; - } - - @Override - public String toString() - { - return MessageFormat.format("FacilityInstalledEvent[source={0}, facility={1}, remote={2}]", getSource(), //$NON-NLS-1$ - facility, remote); - } - } -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.IFacility;
+import org.eclipse.net4j.buddies.common.IFacilityInstalledEvent;
+import org.eclipse.net4j.buddies.common.IMembership;
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.buddies.internal.common.bundle.OM;
+import org.eclipse.net4j.buddies.internal.common.protocol.MessageNotification;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class Collaboration extends MembershipContainer implements ICollaboration
+{
+ private long id;
+
+ private String title;
+
+ private String description;
+
+ private Visibility visibility = Visibility.PRIVATE;
+
+ private ConcurrentMap<String, IFacility> facilities = new ConcurrentHashMap<String, IFacility>();
+
+ public Collaboration(long id)
+ {
+ this.id = id;
+ }
+
+ public long getID()
+ {
+ return id;
+ }
+
+ public String getTitle()
+ {
+ return title == null ? String.valueOf(id) : title;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public Visibility getVisibility()
+ {
+ return visibility;
+ }
+
+ public boolean isPublic()
+ {
+ return visibility == Visibility.PUBLIC;
+ }
+
+ public void setPublic(String title, String description)
+ {
+ visibility = Visibility.PUBLIC;
+ this.title = title;
+ this.description = description;
+ }
+
+ public void setPrivate()
+ {
+ visibility = Visibility.PRIVATE;
+ title = null;
+ description = null;
+ }
+
+ public IMembership getMembership(IBuddy buddy)
+ {
+ return getMembership(buddy, this);
+ }
+
+ public IMembership removeMembership(IBuddy buddy)
+ {
+ return removeMembership(buddy, this);
+ }
+
+ public IBuddy getBuddy(String userID)
+ {
+ for (IMembership membership : getMemberships())
+ {
+ IBuddy buddy = membership.getBuddy();
+ if (ObjectUtil.equals(buddy.getUserID(), userID))
+ {
+ return buddy;
+ }
+ }
+
+ return null;
+ }
+
+ public IBuddy[] getBuddies()
+ {
+ List<IBuddy> buddies = new ArrayList<IBuddy>();
+ for (IMembership membership : getMemberships())
+ {
+ IBuddy buddy = membership.getBuddy();
+ buddies.add(buddy);
+ }
+
+ return buddies.toArray(new IBuddy[buddies.size()]);
+ }
+
+ public String[] getFacilityTypes()
+ {
+ return facilities.keySet().toArray(new String[facilities.size()]);
+ }
+
+ public IFacility[] getFacilities()
+ {
+ return facilities.values().toArray(new IFacility[facilities.size()]);
+ }
+
+ public IFacility getFacility(String type)
+ {
+ return facilities.get(type);
+ }
+
+ public boolean addFacility(IFacility facility, boolean remote)
+ {
+ String type = facility.getType();
+ if (!facilities.containsKey(type))
+ {
+ facilities.put(type, facility);
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new FacilityInstalledEvent(this, facility, remote), listeners);
+ }
+
+ facility.addListener(this);
+ return true;
+ }
+
+ return false;
+ }
+
+ public void sendMessage(long collaborationID, String facilityType, IMessage message)
+ {
+ IMembership[] elements = getElements();
+ for (IMembership membership : elements)
+ {
+ IBuddy receiver = membership.getBuddy();
+ if (!ObjectUtil.equals(receiver.getUserID(), message.getSenderID()))
+ {
+ try
+ {
+ SignalProtocol<?> protocol = (SignalProtocol<?>)receiver.getSession().getProtocol();
+ new MessageNotification(protocol, collaborationID, facilityType, message).sendAsync();
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see PlatformObject#getAdapter(Class)
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof ICollaboration)
+ {
+ ICollaboration collaboration = (ICollaboration)obj;
+ return getID() == collaboration.getID();
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(id);
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}[{1}]", getClass().getSimpleName(), getTitle()); //$NON-NLS-1$
+ }
+
+ @Override
+ public void notifyEvent(IEvent event)
+ {
+ super.notifyEvent(event);
+ if (event.getSource() instanceof IFacility)
+ {
+ notifyFacilityEvent(event);
+ }
+ }
+
+ protected void notifyFacilityEvent(IEvent event)
+ {
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ for (IFacility facility : getFacilities())
+ {
+ facility.removeListener(this);
+ LifecycleUtil.deactivate(facility);
+ }
+
+ for (IMembership membership : getMemberships())
+ {
+ LifecycleUtil.deactivate(membership);
+ }
+
+ super.doDeactivate();
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class FacilityInstalledEvent extends Event implements IFacilityInstalledEvent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private IFacility facility;
+
+ private boolean remote;
+
+ public FacilityInstalledEvent(ICollaboration source, IFacility facility, boolean remote)
+ {
+ super(source);
+ this.facility = facility;
+ this.remote = remote;
+ }
+
+ @Override
+ public ICollaboration getSource()
+ {
+ return (ICollaboration)super.getSource();
+ }
+
+ public IFacility getFacility()
+ {
+ return facility;
+ }
+
+ public boolean fromRemote()
+ {
+ return remote;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("FacilityInstalledEvent[source={0}, facility={1}, remote={2}]", getSource(), //$NON-NLS-1$
+ facility, remote);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/CollaborationContainer.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/CollaborationContainer.java index da09f2350b..5d33d0440c 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/CollaborationContainer.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/CollaborationContainer.java @@ -1,152 +1,152 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.ICollaborationContainer; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.SingleDeltaContainerEvent; -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.LifecycleEvent; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Eike Stepper - */ -public class CollaborationContainer extends Lifecycle implements ICollaborationContainer, IListener -{ - private Map<Long, ICollaboration> collaborations = new HashMap<Long, ICollaboration>(); - - public CollaborationContainer(Collection<ICollaboration> collaborations) - { - if (collaborations != null) - { - for (ICollaboration collaboration : collaborations) - { - this.collaborations.put(collaboration.getID(), collaboration); - collaboration.addListener(this); - } - } - } - - public CollaborationContainer() - { - } - - public void addCollaboration(ICollaboration collaboration) - { - long id = collaboration.getID(); - synchronized (collaborations) - { - if (!collaborations.containsKey(id)) - { - collaborations.put(id, collaboration); - } - } - - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new SingleDeltaContainerEvent<ICollaboration>(this, collaboration, IContainerDelta.Kind.ADDED), - listeners); - } - - collaboration.addListener(this); - } - - public ICollaboration removeCollaboration(long id) - { - ICollaboration collaboration; - synchronized (collaborations) - { - collaboration = collaborations.remove(id); - } - - if (collaboration != null) - { - collaboration.removeListener(this); - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new SingleDeltaContainerEvent<ICollaboration>(this, collaboration, IContainerDelta.Kind.REMOVED), - listeners); - } - } - - return collaboration; - } - - public ICollaboration[] getCollaborations() - { - synchronized (collaborations) - { - return collaborations.values().toArray(new ICollaboration[collaborations.size()]); - } - } - - public ICollaboration getCollaboration(long id) - { - synchronized (collaborations) - { - return collaborations.get(id); - } - } - - public ICollaboration[] getElements() - { - return getCollaborations(); - } - - public boolean isEmpty() - { - synchronized (collaborations) - { - return collaborations.isEmpty(); - } - } - - public void notifyEvent(IEvent event) - { - if (event.getSource() instanceof ICollaboration) - { - notifyCollaborationEvent(event); - if (event instanceof LifecycleEvent) - { - LifecycleEvent e = (LifecycleEvent)event; - if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED) - { - removeCollaboration(((ICollaboration)e.getSource()).getID()); - } - } - } - } - - protected void notifyCollaborationEvent(IEvent event) - { - } - - @Override - protected void doDeactivate() throws Exception - { - for (ICollaboration collaboration : getCollaborations()) - { - collaboration.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.common;
+
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.ICollaborationContainer;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.SingleDeltaContainerEvent;
+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.LifecycleEvent;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Eike Stepper
+ */
+public class CollaborationContainer extends Lifecycle implements ICollaborationContainer, IListener
+{
+ private Map<Long, ICollaboration> collaborations = new HashMap<Long, ICollaboration>();
+
+ public CollaborationContainer(Collection<ICollaboration> collaborations)
+ {
+ if (collaborations != null)
+ {
+ for (ICollaboration collaboration : collaborations)
+ {
+ this.collaborations.put(collaboration.getID(), collaboration);
+ collaboration.addListener(this);
+ }
+ }
+ }
+
+ public CollaborationContainer()
+ {
+ }
+
+ public void addCollaboration(ICollaboration collaboration)
+ {
+ long id = collaboration.getID();
+ synchronized (collaborations)
+ {
+ if (!collaborations.containsKey(id))
+ {
+ collaborations.put(id, collaboration);
+ }
+ }
+
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new SingleDeltaContainerEvent<ICollaboration>(this, collaboration, IContainerDelta.Kind.ADDED),
+ listeners);
+ }
+
+ collaboration.addListener(this);
+ }
+
+ public ICollaboration removeCollaboration(long id)
+ {
+ ICollaboration collaboration;
+ synchronized (collaborations)
+ {
+ collaboration = collaborations.remove(id);
+ }
+
+ if (collaboration != null)
+ {
+ collaboration.removeListener(this);
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new SingleDeltaContainerEvent<ICollaboration>(this, collaboration, IContainerDelta.Kind.REMOVED),
+ listeners);
+ }
+ }
+
+ return collaboration;
+ }
+
+ public ICollaboration[] getCollaborations()
+ {
+ synchronized (collaborations)
+ {
+ return collaborations.values().toArray(new ICollaboration[collaborations.size()]);
+ }
+ }
+
+ public ICollaboration getCollaboration(long id)
+ {
+ synchronized (collaborations)
+ {
+ return collaborations.get(id);
+ }
+ }
+
+ public ICollaboration[] getElements()
+ {
+ return getCollaborations();
+ }
+
+ public boolean isEmpty()
+ {
+ synchronized (collaborations)
+ {
+ return collaborations.isEmpty();
+ }
+ }
+
+ public void notifyEvent(IEvent event)
+ {
+ if (event.getSource() instanceof ICollaboration)
+ {
+ notifyCollaborationEvent(event);
+ if (event instanceof LifecycleEvent)
+ {
+ LifecycleEvent e = (LifecycleEvent)event;
+ if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED)
+ {
+ removeCollaboration(((ICollaboration)e.getSource()).getID());
+ }
+ }
+ }
+ }
+
+ protected void notifyCollaborationEvent(IEvent event)
+ {
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ for (ICollaboration collaboration : getCollaborations())
+ {
+ collaboration.removeListener(this);
+ }
+
+ super.doDeactivate();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Membership.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Membership.java index 0a17215443..2b1954e7e0 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Membership.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/Membership.java @@ -1,118 +1,118 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IBuddy; -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.IMembership; -import org.eclipse.net4j.buddies.common.IMembershipKey; -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.lifecycle.Lifecycle; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.PlatformObject; - -/** - * @author Eike Stepper - */ -public class Membership extends Lifecycle implements IMembership -{ - private MembershipKey key; - - private long startTime; - - private transient Object[] elements; - - private Membership(IBuddy buddy, ICollaboration collaboration) - { - key = new MembershipKey(buddy, collaboration); - elements = new Object[] { buddy, collaboration }; - startTime = System.currentTimeMillis(); - activate(); - } - - public IBuddy getBuddy() - { - return key.getBuddy(); - } - - public ICollaboration getCollaboration() - { - return key.getCollaboration(); - } - - public long getStartTime() - { - return startTime; - } - - public Object[] getElements() - { - return elements; - } - - public boolean isEmpty() - { - return false; - } - - public MembershipKey getKey() - { - return key; - } - - /** - * @see PlatformObject#getAdapter(Class) - */ - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) - { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof IMembershipKey) - { - IMembershipKey key = (IMembershipKey)obj; - return ObjectUtil.equals(getBuddy(), key.getBuddy()) - && ObjectUtil.equals(getCollaboration(), key.getCollaboration()); - } - - return false; - } - - @Override - public int hashCode() - { - return key.hashCode(); - } - - @Override - public String toString() - { - return key.toString(); - } - - public static IMembership create(IBuddy buddy, ICollaboration collaboration) - { - Membership membership = new Membership(buddy, collaboration); - ((Buddy)buddy).addMembership(membership); - ((Collaboration)collaboration).addMembership(membership); - return membership; - } -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.IMembership;
+import org.eclipse.net4j.buddies.common.IMembershipKey;
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+
+/**
+ * @author Eike Stepper
+ */
+public class Membership extends Lifecycle implements IMembership
+{
+ private MembershipKey key;
+
+ private long startTime;
+
+ private transient Object[] elements;
+
+ private Membership(IBuddy buddy, ICollaboration collaboration)
+ {
+ key = new MembershipKey(buddy, collaboration);
+ elements = new Object[] { buddy, collaboration };
+ startTime = System.currentTimeMillis();
+ activate();
+ }
+
+ public IBuddy getBuddy()
+ {
+ return key.getBuddy();
+ }
+
+ public ICollaboration getCollaboration()
+ {
+ return key.getCollaboration();
+ }
+
+ public long getStartTime()
+ {
+ return startTime;
+ }
+
+ public Object[] getElements()
+ {
+ return elements;
+ }
+
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ public MembershipKey getKey()
+ {
+ return key;
+ }
+
+ /**
+ * @see PlatformObject#getAdapter(Class)
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof IMembershipKey)
+ {
+ IMembershipKey key = (IMembershipKey)obj;
+ return ObjectUtil.equals(getBuddy(), key.getBuddy())
+ && ObjectUtil.equals(getCollaboration(), key.getCollaboration());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return key.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return key.toString();
+ }
+
+ public static IMembership create(IBuddy buddy, ICollaboration collaboration)
+ {
+ Membership membership = new Membership(buddy, collaboration);
+ ((Buddy)buddy).addMembership(membership);
+ ((Collaboration)collaboration).addMembership(membership);
+ return membership;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipContainer.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipContainer.java index b66d0a0bc5..615ade15bf 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipContainer.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipContainer.java @@ -1,130 +1,130 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IBuddy; -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.IMembership; -import org.eclipse.net4j.buddies.common.IMembershipContainer; -import org.eclipse.net4j.buddies.common.IMembershipKey; -import org.eclipse.net4j.util.container.IContainerDelta; -import org.eclipse.net4j.util.container.SingleDeltaContainerEvent; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.lifecycle.ILifecycleEvent; -import org.eclipse.net4j.util.lifecycle.Lifecycle; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * @author Eike Stepper - */ -public class MembershipContainer extends Lifecycle implements IMembershipContainer, IListener -{ - private ConcurrentMap<IMembershipKey, IMembership> memberships = new ConcurrentHashMap<IMembershipKey, IMembership>(); - - public MembershipContainer() - { - } - - public void addMembership(IMembership membership) - { - if (memberships.putIfAbsent(membership, membership) == null) - { - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new SingleDeltaContainerEvent<IMembership>(this, membership, IContainerDelta.Kind.ADDED), listeners); - } - - membership.addListener(this); - } - } - - public IMembership removeMembership(IBuddy buddy, ICollaboration collaboration) - { - return removeMembership(new MembershipKey(buddy, collaboration)); - } - - public IMembership removeMembership(IMembershipKey key) - { - // for (IMembership membership : memberships.values()) - // { - // - // } - // - IMembership membership = memberships.remove(key); - if (membership != null) - { - membership.removeListener(this); - IListener[] listeners = getListeners(); - if (listeners != null) - { - fireEvent(new SingleDeltaContainerEvent<IMembership>(this, membership, IContainerDelta.Kind.REMOVED), listeners); - } - } - - return membership; - } - - public IMembership[] getMemberships() - { - return memberships.values().toArray(new IMembership[memberships.size()]); - } - - public IMembership getMembership(IBuddy buddy, ICollaboration collaboration) - { - return memberships.get(new MembershipKey(buddy, collaboration)); - } - - public IMembership[] getElements() - { - return getMemberships(); - } - - public boolean isEmpty() - { - return memberships.isEmpty(); - } - - public void notifyEvent(IEvent event) - { - if (event.getSource() instanceof IMembership) - { - IMembership membership = (IMembership)event.getSource(); - notifyMembershipEvent(event); - if (event instanceof ILifecycleEvent) - { - ILifecycleEvent e = (ILifecycleEvent)event; - if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED) - { - removeMembership(membership); - } - } - } - } - - protected void notifyMembershipEvent(IEvent event) - { - } - - @Override - protected void doDeactivate() throws Exception - { - for (IMembership membership : getMemberships()) - { - membership.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.common;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.IMembership;
+import org.eclipse.net4j.buddies.common.IMembershipContainer;
+import org.eclipse.net4j.buddies.common.IMembershipKey;
+import org.eclipse.net4j.util.container.IContainerDelta;
+import org.eclipse.net4j.util.container.SingleDeltaContainerEvent;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.ILifecycleEvent;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * @author Eike Stepper
+ */
+public class MembershipContainer extends Lifecycle implements IMembershipContainer, IListener
+{
+ private ConcurrentMap<IMembershipKey, IMembership> memberships = new ConcurrentHashMap<IMembershipKey, IMembership>();
+
+ public MembershipContainer()
+ {
+ }
+
+ public void addMembership(IMembership membership)
+ {
+ if (memberships.putIfAbsent(membership, membership) == null)
+ {
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new SingleDeltaContainerEvent<IMembership>(this, membership, IContainerDelta.Kind.ADDED), listeners);
+ }
+
+ membership.addListener(this);
+ }
+ }
+
+ public IMembership removeMembership(IBuddy buddy, ICollaboration collaboration)
+ {
+ return removeMembership(new MembershipKey(buddy, collaboration));
+ }
+
+ public IMembership removeMembership(IMembershipKey key)
+ {
+ // for (IMembership membership : memberships.values())
+ // {
+ //
+ // }
+ //
+ IMembership membership = memberships.remove(key);
+ if (membership != null)
+ {
+ membership.removeListener(this);
+ IListener[] listeners = getListeners();
+ if (listeners != null)
+ {
+ fireEvent(new SingleDeltaContainerEvent<IMembership>(this, membership, IContainerDelta.Kind.REMOVED), listeners);
+ }
+ }
+
+ return membership;
+ }
+
+ public IMembership[] getMemberships()
+ {
+ return memberships.values().toArray(new IMembership[memberships.size()]);
+ }
+
+ public IMembership getMembership(IBuddy buddy, ICollaboration collaboration)
+ {
+ return memberships.get(new MembershipKey(buddy, collaboration));
+ }
+
+ public IMembership[] getElements()
+ {
+ return getMemberships();
+ }
+
+ public boolean isEmpty()
+ {
+ return memberships.isEmpty();
+ }
+
+ public void notifyEvent(IEvent event)
+ {
+ if (event.getSource() instanceof IMembership)
+ {
+ IMembership membership = (IMembership)event.getSource();
+ notifyMembershipEvent(event);
+ if (event instanceof ILifecycleEvent)
+ {
+ ILifecycleEvent e = (ILifecycleEvent)event;
+ if (e.getKind() == ILifecycleEvent.Kind.DEACTIVATED)
+ {
+ removeMembership(membership);
+ }
+ }
+ }
+ }
+
+ protected void notifyMembershipEvent(IEvent event)
+ {
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ for (IMembership membership : getMemberships())
+ {
+ membership.removeListener(this);
+ }
+
+ super.doDeactivate();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipKey.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipKey.java index 67a005c8a6..21ff4deaf9 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipKey.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MembershipKey.java @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IBuddy; -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.IMembershipKey; -import org.eclipse.net4j.util.ObjectUtil; - -/** - * @author Eike Stepper - */ -public class MembershipKey implements IMembershipKey -{ - private IBuddy buddy; - - private ICollaboration collaboration; - - public MembershipKey(IBuddy buddy, ICollaboration collaboration) - { - this.buddy = buddy; - this.collaboration = collaboration; - } - - public IBuddy getBuddy() - { - return buddy; - } - - public ICollaboration getCollaboration() - { - return collaboration; - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj instanceof IMembershipKey) - { - IMembershipKey key = (IMembershipKey)obj; - return ObjectUtil.equals(getBuddy(), key.getBuddy()) - && ObjectUtil.equals(getCollaboration(), key.getCollaboration()); - } - - return false; - } - - @Override - public int hashCode() - { - return ObjectUtil.hashCode(buddy) ^ ObjectUtil.hashCode(collaboration); - } - - @Override - public String toString() - { - return buddy + "(" + collaboration + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.buddies.internal.common;
+
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.IMembershipKey;
+import org.eclipse.net4j.util.ObjectUtil;
+
+/**
+ * @author Eike Stepper
+ */
+public class MembershipKey implements IMembershipKey
+{
+ private IBuddy buddy;
+
+ private ICollaboration collaboration;
+
+ public MembershipKey(IBuddy buddy, ICollaboration collaboration)
+ {
+ this.buddy = buddy;
+ this.collaboration = collaboration;
+ }
+
+ public IBuddy getBuddy()
+ {
+ return buddy;
+ }
+
+ public ICollaboration getCollaboration()
+ {
+ return collaboration;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj instanceof IMembershipKey)
+ {
+ IMembershipKey key = (IMembershipKey)obj;
+ return ObjectUtil.equals(getBuddy(), key.getBuddy())
+ && ObjectUtil.equals(getCollaboration(), key.getCollaboration());
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return ObjectUtil.hashCode(buddy) ^ ObjectUtil.hashCode(collaboration);
+ }
+
+ @Override
+ public String toString()
+ {
+ return buddy + "(" + collaboration + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MessageEvent.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MessageEvent.java index ee1e20e71e..e1f1fa39eb 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MessageEvent.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/MessageEvent.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2004 - 2011 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.common; - -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.buddies.common.IMessageEvent; -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.INotifier; - -/** - * @author Eike Stepper - */ -public final class MessageEvent extends Event implements IMessageEvent -{ - private static final long serialVersionUID = 1L; - - private IMessage message; - - public MessageEvent(INotifier notifier, IMessage message) - { - super(notifier); - this.message = message; - } - - public IMessage getMessage() - { - return message; - } -} +/*
+ * 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.common;
+
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.buddies.common.IMessageEvent;
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.INotifier;
+
+/**
+ * @author Eike Stepper
+ */
+public final class MessageEvent extends Event implements IMessageEvent
+{
+ private static final long serialVersionUID = 1L;
+
+ private IMessage message;
+
+ public MessageEvent(INotifier notifier, IMessage message)
+ {
+ super(notifier);
+ this.message = message;
+ }
+
+ public IMessage getMessage()
+ {
+ return message;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/bundle/OM.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/bundle/OM.java index 143d8a16fc..dfcd3c4751 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/bundle/OM.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/bundle/OM.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2004 - 2011 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.common.bundle; - -import org.eclipse.net4j.util.om.OMBundle; -import org.eclipse.net4j.util.om.OMPlatform; -import org.eclipse.net4j.util.om.OSGiActivator; -import org.eclipse.net4j.util.om.log.OMLogger; -import org.eclipse.net4j.util.om.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.common"; //$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_MODEL = DEBUG.tracer("model"); //$NON-NLS-1$ - - public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$ - - public static final OMLogger LOG = BUNDLE.logger(); - - /** - * @author Eike Stepper - */ - public static final class Activator extends OSGiActivator - { - public Activator() - { - super(BUNDLE); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.buddies.internal.common.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.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.common"; //$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_MODEL = DEBUG.tracer("model"); //$NON-NLS-1$
+
+ public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java index 2127957552..b97d2ac1ee 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateIndication.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.buddies.common.IBuddy.State; -import org.eclipse.net4j.signal.Indication; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; - -/** - * @author Eike Stepper - */ -public abstract class BuddyStateIndication extends Indication -{ - public BuddyStateIndication(SignalProtocol<?> protocol) - { - super(protocol, ProtocolConstants.SIGNAL_BUDDY_STATE); - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws Exception - { - String userID = in.readString(); - State state = ProtocolUtil.readState(in); - stateChanged(userID, state); - } - - protected abstract void stateChanged(String userID, State 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.common.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddy.State;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class BuddyStateIndication extends Indication
+{
+ public BuddyStateIndication(SignalProtocol<?> protocol)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_BUDDY_STATE);
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ String userID = in.readString();
+ State state = ProtocolUtil.readState(in);
+ stateChanged(userID, state);
+ }
+
+ protected abstract void stateChanged(String userID, State state);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java index b87211d622..d641e32f47 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/BuddyStateNotification.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.buddies.common.IBuddy.State; -import org.eclipse.net4j.signal.Request; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class BuddyStateNotification extends Request -{ - private String userID; - - private State state; - - public BuddyStateNotification(SignalProtocol<?> protocol, String userID, State state) - { - super(protocol, ProtocolConstants.SIGNAL_BUDDY_STATE); - this.userID = userID; - this.state = state; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeString(userID); - ProtocolUtil.writeState(out, 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.common.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddy.State;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class BuddyStateNotification extends Request
+{
+ private String userID;
+
+ private State state;
+
+ public BuddyStateNotification(SignalProtocol<?> protocol, String userID, State state)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_BUDDY_STATE);
+ this.userID = userID;
+ this.state = state;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeString(userID);
+ ProtocolUtil.writeState(out, state);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java index 8cd35ba415..d16d6ca202 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftIndication.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.buddies.common.IBuddyProvider; -import org.eclipse.net4j.buddies.common.ICollaborationProvider; -import org.eclipse.net4j.buddies.internal.common.Buddy; -import org.eclipse.net4j.buddies.internal.common.Collaboration; -import org.eclipse.net4j.signal.Indication; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; - -/** - * @author Eike Stepper - */ -public class CollaborationLeftIndication extends Indication -{ - private IBuddyProvider buddyProvider; - - private ICollaborationProvider collaborationProvider; - - public CollaborationLeftIndication(SignalProtocol<?> protocol, IBuddyProvider buddyProvider, - ICollaborationProvider collaborationProvider) - { - super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_LEFT); - this.buddyProvider = buddyProvider; - this.collaborationProvider = collaborationProvider; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws Exception - { - long collaborationID = in.readLong(); - String userID = in.readString(); - - Collaboration collaboration = getCollaboration(collaborationID); - if (collaboration != null) - { - Buddy buddy = getBuddy(userID); - if (buddy != null) - { - collaborationLeft(buddy, collaboration); - } - } - } - - protected void collaborationLeft(Buddy buddy, Collaboration collaboration) - { - collaboration.removeMembership(buddy); - buddy.removeMembership(collaboration); - } - - protected Collaboration getCollaboration(long collaborationID) - { - return (Collaboration)collaborationProvider.getCollaboration(collaborationID); - } - - protected Buddy getBuddy(String userID) - { - return (Buddy)buddyProvider.getBuddy(userID); - } -} +/*
+ * 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.common.protocol;
+
+import org.eclipse.net4j.buddies.common.IBuddyProvider;
+import org.eclipse.net4j.buddies.common.ICollaborationProvider;
+import org.eclipse.net4j.buddies.internal.common.Buddy;
+import org.eclipse.net4j.buddies.internal.common.Collaboration;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class CollaborationLeftIndication extends Indication
+{
+ private IBuddyProvider buddyProvider;
+
+ private ICollaborationProvider collaborationProvider;
+
+ public CollaborationLeftIndication(SignalProtocol<?> protocol, IBuddyProvider buddyProvider,
+ ICollaborationProvider collaborationProvider)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_LEFT);
+ this.buddyProvider = buddyProvider;
+ this.collaborationProvider = collaborationProvider;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ long collaborationID = in.readLong();
+ String userID = in.readString();
+
+ Collaboration collaboration = getCollaboration(collaborationID);
+ if (collaboration != null)
+ {
+ Buddy buddy = getBuddy(userID);
+ if (buddy != null)
+ {
+ collaborationLeft(buddy, collaboration);
+ }
+ }
+ }
+
+ protected void collaborationLeft(Buddy buddy, Collaboration collaboration)
+ {
+ collaboration.removeMembership(buddy);
+ buddy.removeMembership(collaboration);
+ }
+
+ protected Collaboration getCollaboration(long collaborationID)
+ {
+ return (Collaboration)collaborationProvider.getCollaboration(collaborationID);
+ }
+
+ protected Buddy getBuddy(String userID)
+ {
+ return (Buddy)buddyProvider.getBuddy(userID);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java index 5da6fdb4c0..cfbf01f4ef 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/CollaborationLeftNotification.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.signal.Request; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class CollaborationLeftNotification extends Request -{ - private long collaborationID; - - private String userID; - - public CollaborationLeftNotification(SignalProtocol<?> protocol, long collaborationID, String userID) - { - super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_LEFT); - this.collaborationID = collaborationID; - this.userID = userID; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeLong(collaborationID); - out.writeString(userID); - } -} +/*
+ * 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.common.protocol;
+
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class CollaborationLeftNotification extends Request
+{
+ private long collaborationID;
+
+ private String userID;
+
+ public CollaborationLeftNotification(SignalProtocol<?> protocol, long collaborationID, String userID)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_COLLABORATION_LEFT);
+ this.collaborationID = collaborationID;
+ this.userID = userID;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeLong(collaborationID);
+ out.writeString(userID);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java index 1c3b609779..8d06c60263 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageIndication.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.ICollaborationProvider; -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.buddies.spi.common.Facility; -import org.eclipse.net4j.signal.Indication; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; - -/** - * @author Eike Stepper - */ -public class MessageIndication extends Indication -{ - private ICollaborationProvider collaborationProvider; - - public MessageIndication(SignalProtocol<?> protocol, ICollaborationProvider collaborationProvider) - { - super(protocol, ProtocolConstants.SIGNAL_MESSAGE); - this.collaborationProvider = collaborationProvider; - } - - @Override - protected void indicating(ExtendedDataInputStream in) throws Exception - { - long collaborationID = in.readLong(); - String facilityType = in.readString(); - Facility facility = getFacility(collaborationID, facilityType); - if (facility != null) - { - IMessage message = ProtocolUtil.readMessage(in, facility.getClass().getClassLoader()); - facility.handleMessage(message); - } - } - - private Facility getFacility(long collaborationID, String facilityType) - { - ICollaboration collaboration = collaborationProvider.getCollaboration(collaborationID); - if (collaboration == null) - { - return null; - } - - return (Facility)collaboration.getFacility(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.common.protocol;
+
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.ICollaborationProvider;
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.buddies.spi.common.Facility;
+import org.eclipse.net4j.signal.Indication;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class MessageIndication extends Indication
+{
+ private ICollaborationProvider collaborationProvider;
+
+ public MessageIndication(SignalProtocol<?> protocol, ICollaborationProvider collaborationProvider)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_MESSAGE);
+ this.collaborationProvider = collaborationProvider;
+ }
+
+ @Override
+ protected void indicating(ExtendedDataInputStream in) throws Exception
+ {
+ long collaborationID = in.readLong();
+ String facilityType = in.readString();
+ Facility facility = getFacility(collaborationID, facilityType);
+ if (facility != null)
+ {
+ IMessage message = ProtocolUtil.readMessage(in, facility.getClass().getClassLoader());
+ facility.handleMessage(message);
+ }
+ }
+
+ private Facility getFacility(long collaborationID, String facilityType)
+ {
+ ICollaboration collaboration = collaborationProvider.getCollaboration(collaborationID);
+ if (collaboration == null)
+ {
+ return null;
+ }
+
+ return (Facility)collaboration.getFacility(facilityType);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java index cb54800c58..7b6739cdcc 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/MessageNotification.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.signal.Request; -import org.eclipse.net4j.signal.SignalProtocol; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -/** - * @author Eike Stepper - */ -public class MessageNotification extends Request -{ - private long collaborationID; - - private String facilityType; - - private IMessage message; - - public MessageNotification(SignalProtocol<?> protocol, long collaborationID, String facilityType, IMessage message) - { - super(protocol, ProtocolConstants.SIGNAL_MESSAGE); - this.collaborationID = collaborationID; - this.facilityType = facilityType; - this.message = message; - } - - @Override - protected void requesting(ExtendedDataOutputStream out) throws Exception - { - out.writeLong(collaborationID); - out.writeString(facilityType); - ProtocolUtil.writeMessage(out, message); - } -} +/*
+ * 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.common.protocol;
+
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.signal.Request;
+import org.eclipse.net4j.signal.SignalProtocol;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class MessageNotification extends Request
+{
+ private long collaborationID;
+
+ private String facilityType;
+
+ private IMessage message;
+
+ public MessageNotification(SignalProtocol<?> protocol, long collaborationID, String facilityType, IMessage message)
+ {
+ super(protocol, ProtocolConstants.SIGNAL_MESSAGE);
+ this.collaborationID = collaborationID;
+ this.facilityType = facilityType;
+ this.message = message;
+ }
+
+ @Override
+ protected void requesting(ExtendedDataOutputStream out) throws Exception
+ {
+ out.writeLong(collaborationID);
+ out.writeString(facilityType);
+ ProtocolUtil.writeMessage(out, message);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolConstants.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolConstants.java index 9b2aefad73..ade2ef4d78 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolConstants.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolConstants.java @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -/** - * @author Eike Stepper - */ -public interface ProtocolConstants -{ - public static final String PROTOCOL_NAME = "buddies"; //$NON-NLS-1$ - - public static final short SIGNAL_OPEN_SESSION = 1; - - public static final short SIGNAL_LOAD_ACCOUNT = 2; - - public static final short SIGNAL_BUDDY_ADDED = 3; - - public static final short SIGNAL_BUDDY_REMOVED = 4; - - public static final short SIGNAL_BUDDY_STATE = 5; - - public static final short SIGNAL_INITIATE_COLLABORATION = 6; - - public static final short SIGNAL_COLLABORATION_INITIATED = 7; - - public static final short SIGNAL_COLLABORATION_LEFT = 8; - - public static final short SIGNAL_INVITE_BUDDIES = 9; - - public static final short SIGNAL_BUDDIES_INVITED = 10; - - public static final short SIGNAL_INSTALL_FACILITY = 11; - - public static final short SIGNAL_FACILITY_INSTALLED = 12; - - public static final short SIGNAL_MESSAGE = 13; - - public static final long TIMEOUT = 5000L; - - public static final byte STATE_AVAILABLE = 1; - - public static final byte STATE_LONESOME = 2; - - public static final byte STATE_AWAY = 3; - - public static final byte STATE_DO_NOT_DISTURB = 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
+ */
+package org.eclipse.net4j.buddies.internal.common.protocol;
+
+/**
+ * @author Eike Stepper
+ */
+public interface ProtocolConstants
+{
+ public static final String PROTOCOL_NAME = "buddies"; //$NON-NLS-1$
+
+ public static final short SIGNAL_OPEN_SESSION = 1;
+
+ public static final short SIGNAL_LOAD_ACCOUNT = 2;
+
+ public static final short SIGNAL_BUDDY_ADDED = 3;
+
+ public static final short SIGNAL_BUDDY_REMOVED = 4;
+
+ public static final short SIGNAL_BUDDY_STATE = 5;
+
+ public static final short SIGNAL_INITIATE_COLLABORATION = 6;
+
+ public static final short SIGNAL_COLLABORATION_INITIATED = 7;
+
+ public static final short SIGNAL_COLLABORATION_LEFT = 8;
+
+ public static final short SIGNAL_INVITE_BUDDIES = 9;
+
+ public static final short SIGNAL_BUDDIES_INVITED = 10;
+
+ public static final short SIGNAL_INSTALL_FACILITY = 11;
+
+ public static final short SIGNAL_FACILITY_INSTALLED = 12;
+
+ public static final short SIGNAL_MESSAGE = 13;
+
+ public static final long TIMEOUT = 5000L;
+
+ public static final byte STATE_AVAILABLE = 1;
+
+ public static final byte STATE_LONESOME = 2;
+
+ public static final byte STATE_AWAY = 3;
+
+ public static final byte STATE_DO_NOT_DISTURB = 4;
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolUtil.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolUtil.java index be37ff8626..7fcc66bfb5 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolUtil.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/internal/common/protocol/ProtocolUtil.java @@ -1,226 +1,226 @@ -/* - * Copyright (c) 2004 - 2011 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.common.protocol; - -import org.eclipse.net4j.buddies.common.IAccount; -import org.eclipse.net4j.buddies.common.IBuddy; -import org.eclipse.net4j.buddies.common.IBuddyContainer; -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.ObjectStreamClass; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Eike Stepper - */ -public final class ProtocolUtil -{ - private ProtocolUtil() - { - } - - public static void writeBuddies(ExtendedDataOutputStream out, Collection<IBuddy> buddies) throws IOException - { - if (buddies == null) - { - out.writeInt(0); - } - else - { - out.writeInt(buddies.size()); - for (IBuddy buddy : buddies) - { - out.writeString(buddy.getUserID()); - } - } - } - - public static Set<IBuddy> readBuddies(ExtendedDataInputStream in, IBuddyContainer buddyContainer) throws IOException - { - int size = in.readInt(); - Set<IBuddy> buddies = new HashSet<IBuddy>(); - for (int i = 0; i < size; i++) - { - String userID = in.readString(); - IBuddy buddy = buddyContainer.getBuddy(userID); - if (buddy != null) - { - buddies.add(buddy); - } - } - - return buddies; - } - - public static String[] readUserIDs(ExtendedDataInputStream in) throws IOException - { - int size = in.readInt(); - String[] userIDs = new String[size]; - for (int i = 0; i < size; i++) - { - userIDs[i] = in.readString(); - } - - return userIDs; - } - - public static void writeAccount(ExtendedDataOutputStream out, IAccount account) throws IOException - { - if (account != null) - { - out.writeBoolean(true); - ObjectOutputStream oos = new ObjectOutputStream(out); - oos.writeObject(account); - } - else - { - out.writeBoolean(false); - } - } - - public static IAccount readAccount(ExtendedDataInputStream in) throws IOException - { - boolean exists = in.readBoolean(); - if (!exists) - { - return null; - } - - try - { - ObjectInputStream ois = new ObjectInputStream(in); - return (IAccount)ois.readObject(); - } - catch (IOException ex) - { - throw ex; - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - public static void writeState(ExtendedDataOutputStream out, IBuddy.State state) throws IOException - { - switch (state) - { - case AVAILABLE: - out.writeByte(ProtocolConstants.STATE_AVAILABLE); - break; - - case LONESOME: - out.writeByte(ProtocolConstants.STATE_LONESOME); - break; - - case AWAY: - out.writeByte(ProtocolConstants.STATE_AWAY); - break; - - case DO_NOT_DISTURB: - out.writeByte(ProtocolConstants.STATE_DO_NOT_DISTURB); - break; - - default: - throw new IllegalArgumentException("Illegal state: " + state); //$NON-NLS-1$ - } - } - - public static IBuddy.State readState(ExtendedDataInputStream in) throws IOException - { - byte state = in.readByte(); - switch (state) - { - case ProtocolConstants.STATE_AVAILABLE: - return IBuddy.State.AVAILABLE; - - case ProtocolConstants.STATE_LONESOME: - return IBuddy.State.LONESOME; - - case ProtocolConstants.STATE_AWAY: - return IBuddy.State.AWAY; - - case ProtocolConstants.STATE_DO_NOT_DISTURB: - return IBuddy.State.DO_NOT_DISTURB; - - default: - throw new IllegalArgumentException("Illegal state: " + state); //$NON-NLS-1$ - } - } - - public static void writeFacilityTypes(ExtendedDataOutputStream out, String[] facilityTypes) throws IOException - { - if (facilityTypes == null) - { - out.writeInt(0); - } - else - { - out.writeInt(facilityTypes.length); - for (String facilityType : facilityTypes) - { - out.writeString(facilityType); - } - } - } - - public static String[] readFacilityTypes(ExtendedDataInputStream in) throws IOException - { - int size = in.readInt(); - String[] facilityTypes = new String[size]; - for (int i = 0; i < size; i++) - { - facilityTypes[i] = in.readString(); - } - - return facilityTypes; - } - - public static void writeMessage(ExtendedDataOutputStream out, IMessage message) throws IOException - { - ObjectOutputStream oos = new ObjectOutputStream(out); - oos.writeObject(message); - } - - public static IMessage readMessage(ExtendedDataInputStream in, final ClassLoader classLoader) throws IOException - { - try - { - ObjectInputStream ois = new ObjectInputStream(in) - { - @Override - protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException - { - String className = desc.getName(); - return classLoader.loadClass(className); - } - }; - - return (IMessage)ois.readObject(); - } - catch (IOException ex) - { - throw ex; - } - 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.common.protocol;
+
+import org.eclipse.net4j.buddies.common.IAccount;
+import org.eclipse.net4j.buddies.common.IBuddy;
+import org.eclipse.net4j.buddies.common.IBuddyContainer;
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ProtocolUtil
+{
+ private ProtocolUtil()
+ {
+ }
+
+ public static void writeBuddies(ExtendedDataOutputStream out, Collection<IBuddy> buddies) throws IOException
+ {
+ if (buddies == null)
+ {
+ out.writeInt(0);
+ }
+ else
+ {
+ out.writeInt(buddies.size());
+ for (IBuddy buddy : buddies)
+ {
+ out.writeString(buddy.getUserID());
+ }
+ }
+ }
+
+ public static Set<IBuddy> readBuddies(ExtendedDataInputStream in, IBuddyContainer buddyContainer) throws IOException
+ {
+ int size = in.readInt();
+ Set<IBuddy> buddies = new HashSet<IBuddy>();
+ for (int i = 0; i < size; i++)
+ {
+ String userID = in.readString();
+ IBuddy buddy = buddyContainer.getBuddy(userID);
+ if (buddy != null)
+ {
+ buddies.add(buddy);
+ }
+ }
+
+ return buddies;
+ }
+
+ public static String[] readUserIDs(ExtendedDataInputStream in) throws IOException
+ {
+ int size = in.readInt();
+ String[] userIDs = new String[size];
+ for (int i = 0; i < size; i++)
+ {
+ userIDs[i] = in.readString();
+ }
+
+ return userIDs;
+ }
+
+ public static void writeAccount(ExtendedDataOutputStream out, IAccount account) throws IOException
+ {
+ if (account != null)
+ {
+ out.writeBoolean(true);
+ ObjectOutputStream oos = new ObjectOutputStream(out);
+ oos.writeObject(account);
+ }
+ else
+ {
+ out.writeBoolean(false);
+ }
+ }
+
+ public static IAccount readAccount(ExtendedDataInputStream in) throws IOException
+ {
+ boolean exists = in.readBoolean();
+ if (!exists)
+ {
+ return null;
+ }
+
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(in);
+ return (IAccount)ois.readObject();
+ }
+ catch (IOException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ public static void writeState(ExtendedDataOutputStream out, IBuddy.State state) throws IOException
+ {
+ switch (state)
+ {
+ case AVAILABLE:
+ out.writeByte(ProtocolConstants.STATE_AVAILABLE);
+ break;
+
+ case LONESOME:
+ out.writeByte(ProtocolConstants.STATE_LONESOME);
+ break;
+
+ case AWAY:
+ out.writeByte(ProtocolConstants.STATE_AWAY);
+ break;
+
+ case DO_NOT_DISTURB:
+ out.writeByte(ProtocolConstants.STATE_DO_NOT_DISTURB);
+ break;
+
+ default:
+ throw new IllegalArgumentException("Illegal state: " + state); //$NON-NLS-1$
+ }
+ }
+
+ public static IBuddy.State readState(ExtendedDataInputStream in) throws IOException
+ {
+ byte state = in.readByte();
+ switch (state)
+ {
+ case ProtocolConstants.STATE_AVAILABLE:
+ return IBuddy.State.AVAILABLE;
+
+ case ProtocolConstants.STATE_LONESOME:
+ return IBuddy.State.LONESOME;
+
+ case ProtocolConstants.STATE_AWAY:
+ return IBuddy.State.AWAY;
+
+ case ProtocolConstants.STATE_DO_NOT_DISTURB:
+ return IBuddy.State.DO_NOT_DISTURB;
+
+ default:
+ throw new IllegalArgumentException("Illegal state: " + state); //$NON-NLS-1$
+ }
+ }
+
+ public static void writeFacilityTypes(ExtendedDataOutputStream out, String[] facilityTypes) throws IOException
+ {
+ if (facilityTypes == null)
+ {
+ out.writeInt(0);
+ }
+ else
+ {
+ out.writeInt(facilityTypes.length);
+ for (String facilityType : facilityTypes)
+ {
+ out.writeString(facilityType);
+ }
+ }
+ }
+
+ public static String[] readFacilityTypes(ExtendedDataInputStream in) throws IOException
+ {
+ int size = in.readInt();
+ String[] facilityTypes = new String[size];
+ for (int i = 0; i < size; i++)
+ {
+ facilityTypes[i] = in.readString();
+ }
+
+ return facilityTypes;
+ }
+
+ public static void writeMessage(ExtendedDataOutputStream out, IMessage message) throws IOException
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(out);
+ oos.writeObject(message);
+ }
+
+ public static IMessage readMessage(ExtendedDataInputStream in, final ClassLoader classLoader) throws IOException
+ {
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(in)
+ {
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
+ {
+ String className = desc.getName();
+ return classLoader.loadClass(className);
+ }
+ };
+
+ return (IMessage)ois.readObject();
+ }
+ catch (IOException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ClientFacilityFactory.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ClientFacilityFactory.java index ba12dc9037..7bdc045c5a 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ClientFacilityFactory.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ClientFacilityFactory.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 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.spi.common; - -import org.eclipse.net4j.util.factory.Factory; - -/** - * @author Eike Stepper - */ -public abstract class ClientFacilityFactory extends Factory -{ - public static final String PRODUCT_GROUP = "org.eclipse.net4j.buddies.clientFacilities"; //$NON-NLS-1$ - - public ClientFacilityFactory(String type) - { - super(PRODUCT_GROUP, type); - } -} +/*
+ * 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.spi.common;
+
+import org.eclipse.net4j.util.factory.Factory;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ClientFacilityFactory extends Factory
+{
+ public static final String PRODUCT_GROUP = "org.eclipse.net4j.buddies.clientFacilities"; //$NON-NLS-1$
+
+ public ClientFacilityFactory(String type)
+ {
+ super(PRODUCT_GROUP, type);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Facility.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Facility.java index 7678888746..d6e3bf9e97 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Facility.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Facility.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2004 - 2011 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.spi.common; - -import org.eclipse.net4j.buddies.common.ICollaboration; -import org.eclipse.net4j.buddies.common.IFacility; -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.buddies.internal.common.Collaboration; -import org.eclipse.net4j.util.lifecycle.Lifecycle; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.PlatformObject; - -/** - * @author Eike Stepper - */ -public abstract class Facility extends Lifecycle implements IFacility -{ - private String type; - - private Collaboration collaboration; - - public Facility(String type) - { - this.type = type; - } - - public String getType() - { - return type; - } - - public Collaboration getCollaboration() - { - return collaboration; - } - - public void setCollaboration(ICollaboration collaboration) - { - this.collaboration = (Collaboration)collaboration; - } - - /** - * @see PlatformObject#getAdapter(Class) - */ - @SuppressWarnings("rawtypes") - public Object getAdapter(Class adapter) - { - return Platform.getAdapterManager().getAdapter(this, adapter); - } - - public void sendMessage(IMessage message) - { - collaboration.sendMessage(collaboration.getID(), type, message); - } - - public abstract void handleMessage(IMessage message); -} +/*
+ * 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.spi.common;
+
+import org.eclipse.net4j.buddies.common.ICollaboration;
+import org.eclipse.net4j.buddies.common.IFacility;
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.buddies.internal.common.Collaboration;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PlatformObject;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Facility extends Lifecycle implements IFacility
+{
+ private String type;
+
+ private Collaboration collaboration;
+
+ public Facility(String type)
+ {
+ this.type = type;
+ }
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public Collaboration getCollaboration()
+ {
+ return collaboration;
+ }
+
+ public void setCollaboration(ICollaboration collaboration)
+ {
+ this.collaboration = (Collaboration)collaboration;
+ }
+
+ /**
+ * @see PlatformObject#getAdapter(Class)
+ */
+ @SuppressWarnings("rawtypes")
+ public Object getAdapter(Class adapter)
+ {
+ return Platform.getAdapterManager().getAdapter(this, adapter);
+ }
+
+ public void sendMessage(IMessage message)
+ {
+ collaboration.sendMessage(collaboration.getID(), type, message);
+ }
+
+ public abstract void handleMessage(IMessage message);
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Message.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Message.java index 93e682de2a..701f99dff6 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Message.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/Message.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2004 - 2011 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.spi.common; - -import org.eclipse.net4j.buddies.common.IMessage; -import org.eclipse.net4j.util.StringUtil; - -import org.eclipse.core.runtime.PlatformObject; - -import java.io.Serializable; - -/** - * @author Eike Stepper - */ -public abstract class Message extends PlatformObject implements IMessage, Serializable -{ - private static final long serialVersionUID = 1L; - - private String senderID; - - protected Message() - { - } - - public String getSenderID() - { - return senderID; - } - - public void setSenderID(String senderID) - { - this.senderID = senderID; - } - - protected String encode(String text) - { - return text.replaceAll(StringUtil.NL, "\n"); //$NON-NLS-1$ - } - - protected String decode(String text) - { - return text.replaceAll("\n", StringUtil.NL); //$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.spi.common;
+
+import org.eclipse.net4j.buddies.common.IMessage;
+import org.eclipse.net4j.util.StringUtil;
+
+import org.eclipse.core.runtime.PlatformObject;
+
+import java.io.Serializable;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class Message extends PlatformObject implements IMessage, Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private String senderID;
+
+ protected Message()
+ {
+ }
+
+ public String getSenderID()
+ {
+ return senderID;
+ }
+
+ public void setSenderID(String senderID)
+ {
+ this.senderID = senderID;
+ }
+
+ protected String encode(String text)
+ {
+ return text.replaceAll(StringUtil.NL, "\n"); //$NON-NLS-1$
+ }
+
+ protected String decode(String text)
+ {
+ return text.replaceAll("\n", StringUtil.NL); //$NON-NLS-1$
+ }
+}
diff --git a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ServerFacilityFactory.java b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ServerFacilityFactory.java index c1464d1e0e..feacd32365 100644 --- a/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ServerFacilityFactory.java +++ b/plugins/org.eclipse.net4j.buddies.common/src/org/eclipse/net4j/buddies/spi/common/ServerFacilityFactory.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 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.spi.common; - -import org.eclipse.net4j.util.factory.Factory; - -/** - * @author Eike Stepper - */ -public abstract class ServerFacilityFactory extends Factory -{ - public static final String PRODUCT_GROUP = "org.eclipse.net4j.buddies.serverFacilities"; //$NON-NLS-1$ - - public ServerFacilityFactory(String type) - { - super(PRODUCT_GROUP, type); - } -} +/*
+ * 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.spi.common;
+
+import org.eclipse.net4j.util.factory.Factory;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class ServerFacilityFactory extends Factory
+{
+ public static final String PRODUCT_GROUP = "org.eclipse.net4j.buddies.serverFacilities"; //$NON-NLS-1$
+
+ public ServerFacilityFactory(String type)
+ {
+ super(PRODUCT_GROUP, type);
+ }
+}
|