diff --git a/de.fu_berlin.inf.dpp/.classpath b/de.fu_berlin.inf.dpp/.classpath deleted file mode 100644 index c05e1868bacb71bb7c33dc2ad70b1c454aad1e3c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.classpath +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/> - <classpathentry kind="lib" path="lib/smack.jar" sourcepath="../../smack-3_1/source"/> - <classpathentry kind="lib" path="lib/smackx-debug.jar"/> - <classpathentry kind="lib" path="lib/smackx-jingle.jar" sourcepath="../../smack-3_1/jingle/extension/source"/> - <classpathentry kind="lib" path="lib/smackx.jar" sourcepath="../../smack-3_1/source"/> - <classpathentry kind="lib" path="lib/lw-rudp.jar" sourcepath="../../limewire/components/rudp/src"/> - <classpathentry kind="lib" path="lib/lw-nio.jar" sourcepath="../../limewire/components/nio/src/main/java"/> - <classpathentry kind="lib" path="lib/lw-common.jar"/> - <classpathentry kind="lib" path="lib/lw-io.jar"/> - <classpathentry kind="lib" path="lib/lw-collection.jar"/> - <classpathentry kind="lib" path="lib/commons-logging.jar"/> - <classpathentry kind="output" path="bin"/> -</classpath> diff --git a/de.fu_berlin.inf.dpp/.project b/de.fu_berlin.inf.dpp/.project deleted file mode 100644 index 8b794760e1e3d76196f8a79105cc5dff17332ac9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>Saros</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.core.prefs b/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 9583590921486b6d7c09d1e086793b0112b85771..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,258 +0,0 @@ -#Mon Dec 08 16:39:09 CET 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.formatter.align_type_members_on_columns=false -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_assignment=0 -org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 -org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 -org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 -org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 -org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 -org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 -org.eclipse.jdt.core.formatter.blank_lines_before_method=1 -org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 -org.eclipse.jdt.core.formatter.blank_lines_before_package=0 -org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 -org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 -org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line -org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false -org.eclipse.jdt.core.formatter.comment.format_block_comments=true -org.eclipse.jdt.core.formatter.comment.format_header=false -org.eclipse.jdt.core.formatter.comment.format_html=true -org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true -org.eclipse.jdt.core.formatter.comment.format_line_comments=true -org.eclipse.jdt.core.formatter.comment.format_source_code=true -org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true -org.eclipse.jdt.core.formatter.comment.indent_root_tags=true -org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert -org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=80 -org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=2 -org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true -org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true -org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_empty_lines=false -org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.jdt.core.formatter.indentation.size=8 -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert -org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert -org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert -org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert -org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert -org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert -org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert -org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=80 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false -org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 -org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=space -org.eclipse.jdt.core.formatter.tabulation.size=4 -org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true diff --git a/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.ui.prefs b/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 6f4c5673c4b56d71655d7ef04140d8b091405b77..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,58 +0,0 @@ -#Mon Dec 08 16:39:09 CET 2008 -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_serial_version_id=false -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=false -cleanup.format_source_code=false -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=false -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=true -cleanup.qualify_static_method_accesses_with_declaring_class=false -cleanup.remove_private_constructors=true -cleanup.remove_trailing_whitespaces=false -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=false -cleanup.use_blocks_only_for_return_and_throw=false -cleanup.use_parentheses_in_expressions=false -cleanup.use_this_for_non_static_field_access=false -cleanup.use_this_for_non_static_field_access_only_if_necessary=true -cleanup.use_this_for_non_static_method_access=false -cleanup.use_this_for_non_static_method_access_only_if_necessary=true -cleanup_profile=org.eclipse.jdt.ui.default.eclipse_clean_up_profile -cleanup_settings_version=2 -eclipse.preferences.version=1 -formatter_profile=_Saros -formatter_settings_version=11 -internal.default.compliance=user -org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" 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 * \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 rdjemili\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><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\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" 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}\r\n// ${todo} Auto-generated constructor stub</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> diff --git a/de.fu_berlin.inf.dpp/CHANGELOG b/de.fu_berlin.inf.dpp/CHANGELOG deleted file mode 100644 index 49536bcd17246aac5287571860287cd5d9e0459b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/CHANGELOG +++ /dev/null @@ -1,33 +0,0 @@ - -Saros CHANGELOG - -1.0.1 - New Features - - Better selection support for both driver and observer. - - Usability Enhancements - - Added Confirm Dialog to before actually deleting a contact. - - Better tool-tip for connect button (shows current username). - - Disallow connect if username is not set. - - Allow to connect also if in Error-State (after a failed connect). - - Create Jabber-Account requires repeated password entry and - stores configuration by default. - - Can automatically start follow mode. - - On first install a configuration dialog is shown. - - Bugs - - Fixed leak of timer resources since sharing a project was actually never stopped. - - Fixed bug in rename action. - - Fixed [ 1607388 ] Invitation dialog should suggest project name - - Fixed [ 1607387 ] Invitation dialog fails if project already exists - -1.0 - - added skype support - -0.8.2 - - Fixed severe bug in project synchronization - - Fixed severe bug in account creation - - Show invitee name without XMPP-Resource on invitation wizard - -0.8.1 - - First beta release \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/DEV b/de.fu_berlin.inf.dpp/DEV deleted file mode 100644 index c953ae6d6069a25612bd0fa2cdf2427f9ad3d76a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/DEV +++ /dev/null @@ -1,145 +0,0 @@ - -Saros Developer Readme - ------------------------------------------------------------------ -Content - -1. Introduction -2. The repository -3. Java packages -4. Special Topics - ------------------------------------------------------------------ - -1. Introduction - - Saros is a Eclipse plugin for distributed pair programming. It - features code editing in real-time, view port and text - selection awareness and full project support. Saros is - is free open source software, licensed under the GPL. - - This document is for developing on the Saros project. If you're - completly new to Saros it's better to read the README file - first. - -2. The repository - - The official SVN code repository for Saros can be found at - - https://svn.sourceforge.net/svnroot/dpp - - For more information on how to access it, please see the - Sourceforge information at - - http://sourceforge.net/svn/?group_id=167540 - - The repository is laid out in the following structure. All main - development happens in the trunk. - - + root - + trunk - + de.fu_berlin.dpp - - Contains the code for the Saros plugin (including - necessary libs and resources) - - + de.fu_berlin.dpp.test - - Contains unit tests for the Saros plugin. - - + de.fu_berlin.dpp.feature - - Contains the feature project for the Saros plugin - - + de.fu_berlin.dpp.ecg - - Contains the SarosECG plugin - an extension of the ECG- - Eclipse sensor with new distributed-pair-programming - micro activities. - - + de.fu_berlin.dpp.ecg.feature - - Contains the feature project for the SarosECG plugin - - + de.fu_berlin.dpp.update - - Contains the update site for the Saros and SarosECG - plugins. - - + branches - - Contains stable releases and experimental feature branches. - - + tags - - Generally branches should be used over tags. - -3. Java packages - - The Saros plugin (located under /trunk/de.fu_berlin.dpp) uses - the following packages. Generally all main packages have a - package named 'internal'. This shouldn't be accessed outside of - the Saros plugin. - - + de.fu_berlin.dpp - + de.fu_berlin.dpp.activities - - An activity is a action that can be captured and replicated - on the remote system. It's the basic model for the Saros - system. This package contains all activity classes. - - + de.fu_berlin.dpp.editor - + de.fu_berlin.dpp.editor.internal - - Types that deal with editors and capturing and - replicated text changes, view port changes, text selections - and so on. - - + de.fu_berlin.dpp.editor.annotations - - Custom annotations that are used within the editors to add - visual information (e.g. the current view port of the - driver). - - + de.fu_berlin.dpp.editor.invitation - + de.fu_berlin.dpp.editor.invitation.internal - - Types that deal with incoming and outgoing invitations to - shared projects. They are used to initiate projects. - - + de.fu_berlin.dpp.editor.net - + de.fu_berlin.dpp.editor.net.internal - - Types that deal with sending and receiving data over the - network. Currently only a XMPP-implementation is supported. - - + de.fu_berlin.dpp.editor.project - + de.fu_berlin.dpp.editor.project.internal - - Types that deal with general shared project organization, - like handling the life cycle of a shared project or - managing floor control. - - + de.fu_berlin.dpp.editor.ui - + de.fu_berlin.dpp.editor.ui.actions - + de.fu_berlin.dpp.editor.ui.wizards - + de.fu_berlin.dpp.editor.ui.decorators - - Handles visual aspects, like showing wizards and adding - actions and decorators. - -4. Special topics - -4.1. About Selections - -SelectionAnnotation is the type used to represent a selection annotation. - -org.eclipse.jface.text.source.AnnotationPainter is the class that we need to watch. - -Tom Eicher answers good stuff about Painter - -http://dev.eclipse.org/newslists/news.eclipse.platform/msg55356.html - -Another interesting one: - -ttp://dev.eclipse.org/newslists/news.eclipse.platform/msg56587.html \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/LICENSE b/de.fu_berlin.inf.dpp/LICENSE deleted file mode 100644 index 45645b4b53c803dfd92453900f5a1fc83460e40b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/LICENSE +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/de.fu_berlin.inf.dpp/META-INF/MANIFEST.MF b/de.fu_berlin.inf.dpp/META-INF/MANIFEST.MF deleted file mode 100644 index 2eed994e64351b8b404f78b8f94ed15c480b5f90..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/META-INF/MANIFEST.MF +++ /dev/null @@ -1,358 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Saros Plug-in -Bundle-SymbolicName: de.fu_berlin.inf.dpp;singleton:=true -Bundle-Version: 9.1.5 -Bundle-Activator: de.fu_berlin.inf.dpp.Saros -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.jdt.ui, - org.eclipse.jdt.core, - org.eclipse.ui.workbench.texteditor, - org.eclipse.jface.text, - org.eclipse.ui.editors, - org.eclipse.core.resources, - org.eclipse.ui.ide -Bundle-ActivationPolicy: lazy -Bundle-ClassPath: bin/, - lib/log4j-1.2.15.jar, - ., - lib/smack.jar, - lib/smackx.jar, - lib/smackx-debug.jar, - lib/smackx-jingle.jar, - lib/lw-rudp.jar, - lib/lw-nio.jar, - lib/lw-io.jar, - lib/lw-common.jar, - lib/lw-collection.jar, - lib/commons-logging.jar -Export-Package: com.jcraft.jzlib, - de.fu_berlin.inf.dpp; - uses:="org.eclipse.core.runtime, - org.jivesoftware.smack.packet, - org.eclipse.ui.plugin, - org.eclipse.core.runtime.preferences, - de.fu_berlin.inf.dpp.ui, - de.fu_berlin.inf.dpp.net.internal, - org.jivesoftware.smackx.muc, - org.jivesoftware.smack, - de.fu_berlin.inf.dpp.project, - org.eclipse.core.resources, - org.osgi.framework, - org.jivesoftware.smackx, - de.fu_berlin.inf.dpp.net", - de.fu_berlin.inf.dpp.activities;uses:="org.eclipse.core.runtime,de.fu_berlin.inf.dpp.net", - de.fu_berlin.inf.dpp.concurrent, - de.fu_berlin.inf.dpp.concurrent.jupiter, - de.fu_berlin.inf.dpp.concurrent.jupiter.internal, - de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text, - de.fu_berlin.inf.dpp.concurrent.management, - de.fu_berlin.inf.dpp.editor; - uses:="org.eclipse.jface.text, - org.eclipse.core.runtime, - de.fu_berlin.inf.dpp.activities, - org.eclipse.ui, - de.fu_berlin.inf.dpp.project, - de.fu_berlin.inf.dpp.editor.internal, - org.xmlpull.v1, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.net", - de.fu_berlin.inf.dpp.editor.annotations; - uses:="org.eclipse.jface.text.source, - org.eclipse.swt.graphics, - org.eclipse.jface.util, - org.eclipse.swt.widgets", - de.fu_berlin.inf.dpp.editor.internal;x-friends:="de.fu_berlin.inf.dpp.test", - de.fu_berlin.inf.dpp.invitation; - uses:="org.eclipse.core.runtime, - de.fu_berlin.inf.dpp, - org.eclipse.core.resources, - de.fu_berlin.inf.dpp.net", - de.fu_berlin.inf.dpp.invitation.internal;x-friends:="de.fu_berlin.inf.dpp.test", - de.fu_berlin.inf.dpp.net; - uses:="org.eclipse.core.runtime, - de.fu_berlin.inf.dpp.activities, - de.fu_berlin.inf.dpp, - org.jivesoftware.smack.packet, - de.fu_berlin.inf.dpp.invitation, - org.jivesoftware.smack, - de.fu_berlin.inf.dpp.project, - org.eclipse.core.resources, - de.fu_berlin.inf.dpp.concurrent.jupiter, - de.fu_berlin.inf.dpp.concurrent", - de.fu_berlin.inf.dpp.net.internal;x-friends:="de.fu_berlin.inf.dpp.test", - de.fu_berlin.inf.dpp.project; - uses:="de.fu_berlin.inf.dpp.activities, - de.fu_berlin.inf.dpp, - org.jivesoftware.smack, - org.eclipse.core.resources, - org.xmlpull.v1, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.net", - de.fu_berlin.inf.dpp.project.internal;x-friends:="de.fu_berlin.inf.dpp.test", - de.fu_berlin.inf.dpp.ui; - uses:="org.eclipse.jface.window, - org.eclipse.jface.resource, - de.fu_berlin.inf.dpp, - org.eclipse.ui, - org.eclipse.ui.part, - de.fu_berlin.inf.dpp.invitation, - org.eclipse.jface.preference, - org.jivesoftware.smack, - de.fu_berlin.inf.dpp.project, - org.eclipse.swt.graphics, - org.eclipse.jface.util, - org.eclipse.swt.widgets, - de.fu_berlin.inf.dpp.net, - org.eclipse.jface.dialogs", - de.fu_berlin.inf.dpp.ui.actions; - uses:="org.eclipse.jface.action, - de.fu_berlin.inf.dpp, - org.jivesoftware.smack, - org.eclipse.ui, - de.fu_berlin.inf.dpp.project, - org.eclipse.ui.actions, - org.eclipse.jface.viewers, - de.fu_berlin.inf.dpp.invitation, - de.fu_berlin.inf.dpp.net", - de.fu_berlin.inf.dpp.ui.decorators; - uses:="org.eclipse.core.runtime, - de.fu_berlin.inf.dpp.project, - org.eclipse.jface.viewers, - de.fu_berlin.inf.dpp.editor, - de.fu_berlin.inf.dpp.invitation", - de.fu_berlin.inf.dpp.ui.wizards; - uses:="org.eclipse.jface.wizard, - org.eclipse.core.runtime, - de.fu_berlin.inf.dpp, - org.eclipse.core.resources, - org.eclipse.swt.widgets, - de.fu_berlin.inf.dpp.invitation", - de.fu_berlin.inf.dpp.util;uses:="org.eclipse.core.resources,org.jivesoftware.smack.packet", - de.javawi.jstun.attribute;uses:="junit.framework,de.javawi.jstun.util", - de.javawi.jstun.header;uses:="de.javawi.jstun.attribute", - de.javawi.jstun.test;uses:="de.javawi.jstun.attribute", - de.javawi.jstun.test.demo, - de.javawi.jstun.test.demo.ice;uses:="de.javawi.jstun.util", - de.javawi.jstun.util;uses:="junit.framework", - images, - org.apache.log4j;uses:="org.apache.log4j.helpers,org.apache.log4j.or,org.apache.log4j.spi", - org.apache.log4j.chainsaw; - uses:="org.apache.log4j, - javax.swing, - javax.swing.table, - org.apache.log4j.spi, - javax.swing.event, - org.xml.sax.helpers, - org.xml.sax", - org.apache.log4j.config;uses:="org.apache.log4j", - org.apache.log4j.helpers;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.jdbc;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.jmx;uses:="org.apache.log4j,org.apache.log4j.spi,javax.management", - org.apache.log4j.lf5;uses:="org.apache.log4j.lf5.viewer,org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.lf5.config, - org.apache.log4j.lf5.util;uses:="org.apache.log4j.lf5.viewer,org.apache.log4j.lf5", - org.apache.log4j.lf5.viewer; - uses:="org.apache.log4j.lf5.util, - org.apache.log4j.lf5.viewer.categoryexplorer, - org.apache.log4j.lf5, - javax.swing, - javax.swing.table, - javax.swing.event, - org.apache.log4j.lf5.viewer.configure", - org.apache.log4j.lf5.viewer.categoryexplorer; - uses:="javax.swing.tree, - org.apache.log4j.lf5, - javax.swing, - javax.swing.table, - javax.swing.event", - org.apache.log4j.lf5.viewer.configure;uses:="org.apache.log4j.lf5.viewer,javax.swing.tree,org.w3c.dom", - org.apache.log4j.lf5.viewer.images, - org.apache.log4j.net; - uses:="javax.naming, - javax.jms, - org.apache.log4j, - org.apache.log4j.helpers, - javax.mail.internet, - org.apache.log4j.spi, - org.w3c.dom, - org.apache.log4j.xml, - javax.mail", - org.apache.log4j.nt;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.or;uses:="org.apache.log4j.spi", - org.apache.log4j.or.jms;uses:="org.apache.log4j.or", - org.apache.log4j.or.sax;uses:="org.apache.log4j.or", - org.apache.log4j.spi;uses:="org.apache.log4j,org.apache.log4j.or", - org.apache.log4j.varia;uses:="org.apache.log4j,org.apache.log4j.spi", - org.apache.log4j.xml; - uses:="org.apache.log4j.config, - org.apache.log4j.helpers, - org.apache.log4j, - javax.xml.parsers, - org.apache.log4j.spi, - org.w3c.dom, - org.xml.sax", - org.jivesoftware.smack; - uses:="new org.jivesoftware.smack, - javax.net, - org.jivesoftware.smack.filter, - org.jivesoftware.smack.packet, - javax.net.ssl", - org.jivesoftware.smack.debugger; - uses:="javax.swing, - org.jivesoftware.smack, - org.jivesoftware.smack.packet, - org.jivesoftware.smack.util", - org.jivesoftware.smack.filter;uses:="org.jivesoftware.smack.packet", - org.jivesoftware.smack.packet;uses:="new org.jivesoftware.smack.packet", - org.jivesoftware.smack.provider;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1", - org.jivesoftware.smack.sasl;uses:="org.jivesoftware.smack", - org.jivesoftware.smack.util; - uses:="new new org.jivesoftware.smack.util, - org.jivesoftware.smack.util.collections, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - new org.jivesoftware.smack.util", - org.jivesoftware.smack.util.collections, - org.jivesoftware.smackx; - uses:="org.jivesoftware.smack.filter, - org.jivesoftware.smackx.provider, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - new org.jivesoftware.smackx, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.bookmark; - uses:="org.jivesoftware.smackx.provider, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack, - org.xmlpull.v1", - org.jivesoftware.smackx.debugger; - uses:="org.jivesoftware.smack.packet, - new org.jivesoftware.smackx.debugger, - javax.swing, - org.jivesoftware.smack, - javax.swing.table, - org.jivesoftware.smack.util, - org.jivesoftware.smack.debugger", - org.jivesoftware.smackx.filetransfer; - uses:="org.jivesoftware.smack.filter, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack, - org.jivesoftware.smack.packet", - org.jivesoftware.smackx.jingle; - uses:="org.jivesoftware.smack.filter, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smack, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx.jingle.listeners", - org.jivesoftware.smackx.jingle.listeners; - uses:="org.jivesoftware.smackx.jingle, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smack", - org.jivesoftware.smackx.jingle.media; - uses:="org.jivesoftware.smackx.jingle, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet", - org.jivesoftware.smackx.jingle.mediaimpl, - org.jivesoftware.smackx.jingle.mediaimpl.jmf; - uses:="org.jivesoftware.smackx.jingle, - javax.media.format, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.nat, - javax.media.rtp.event, - javax.media.rtp, - javax.media", - org.jivesoftware.smackx.jingle.mediaimpl.jspeex; - uses:="org.jivesoftware.smackx.jingle, - org.jivesoftware.smackx.jingle.media, - mil.jfcom.cie.media.session, - org.jivesoftware.smackx.jingle.nat, - javax.media.rtp.rtcp", - org.jivesoftware.smackx.jingle.mediaimpl.multi;uses:="org.jivesoftware.smackx.jingle,org.jivesoftware.smackx.jingle.media,org.jivesoftware.smackx.jingle.nat", - org.jivesoftware.smackx.jingle.mediaimpl.sshare; - uses:="org.jivesoftware.smackx.jingle, - org.jivesoftware.smackx.jingle.mediaimpl.sshare.api, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.nat", - org.jivesoftware.smackx.jingle.mediaimpl.sshare.api, - org.jivesoftware.smackx.jingle.nat; - uses:="new org.jivesoftware.smackx.jingle.nat, - de.javawi.jstun.test.demo.ice, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smackx.jingle, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack, - org.jivesoftware.smack.provider, - org.jivesoftware.smackx.jingle.listeners", - org.jivesoftware.smackx.muc; - uses:="org.jivesoftware.smack.filter, - org.jivesoftware.smack, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - new org.jivesoftware.smackx.muc, - org.jivesoftware.smackx", - org.jivesoftware.smackx.packet; - uses:="org.jivesoftware.smackx.jingle, - org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.jingle.nat, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.provider; - uses:="org.jivesoftware.smackx.jingle.media, - org.jivesoftware.smackx.packet, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.search; - uses:="org.jivesoftware.smack, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smack.provider, - org.jivesoftware.smackx", - org.jivesoftware.smackx.workgroup;uses:="org.jivesoftware.smack.packet", - org.jivesoftware.smackx.workgroup.agent; - uses:="org.jivesoftware.smackx.workgroup.packet, - org.jivesoftware.smackx.workgroup.settings, - org.jivesoftware.smackx.workgroup, - org.jivesoftware.smackx.workgroup.ext.history, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smackx.workgroup.ext.macros, - org.jivesoftware.smackx.workgroup.ext.notes, - org.jivesoftware.smack, - org.jivesoftware.smack.provider, - org.jivesoftware.smackx", - org.jivesoftware.smackx.workgroup.ext.forms;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.history;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.macros;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.ext.notes;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.packet; - uses:="org.jivesoftware.smackx.workgroup, - new org.jivesoftware.smackx.workgroup.packet, - org.jivesoftware.smackx.workgroup.agent, - org.jivesoftware.smack.packet, - org.xmlpull.v1, - org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.settings;uses:="org.jivesoftware.smack.packet,org.xmlpull.v1,org.jivesoftware.smack.provider", - org.jivesoftware.smackx.workgroup.user; - uses:="org.jivesoftware.smackx.workgroup.settings, - org.jivesoftware.smackx.workgroup, - org.jivesoftware.smackx.muc, - org.jivesoftware.smack, - org.jivesoftware.smack.packet, - org.jivesoftware.smackx", - org.jivesoftware.smackx.workgroup.util;uses:="org.xmlpull.v1", - org.xmlpull.mxp1;uses:="org.xmlpull.v1", - org.xmlpull.v1 -Bundle-Vendor: FU-Berlin -Import-Package: org.apache.log4j diff --git a/de.fu_berlin.inf.dpp/META-INF/stun-config.xml b/de.fu_berlin.inf.dpp/META-INF/stun-config.xml deleted file mode 100644 index e216185b27542383830e61a8f0f99844da086530..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/META-INF/stun-config.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<!-- Configuration for the STUN extension --> -<stunConfig> - - <stunServer> - <name>stun.xten.net</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>iphone-stun.freenet.de</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>larry.gloo.net</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun.fwdnet.net</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun.fwd.org</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun01.sipphone.com</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun.softjoys.com</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun.voipbuster.com</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun.voxgratia.org</name> - <port>3478</port> - </stunServer> - - <stunServer> - <name>stun.noc.ams-ix.net</name> - <port>3478</port> - </stunServer> - -</stunConfig> \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/build.properties b/de.fu_berlin.inf.dpp/build.properties deleted file mode 100644 index 65bb38b57b6ae9fa37b8d937161ad19844751e85..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/build.properties +++ /dev/null @@ -1,27 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - icons/,\ - bin/,\ - lib/log4j-1.2.15.jar,\ - log4j.properties,\ - src/,\ - plugin.xml,\ - lib/smack.jar,\ - lib/smackx-debug.jar,\ - lib/smackx.jar,\ - LICENSE,\ - log4j.properties,\ - lib/smackx-jingle.jar,\ - lib/lw-rudp.jar,\ - lib/lw-nio.jar,\ - lib/lw-io.jar,\ - lib/lw-common.jar,\ - lib/lw-collection.jar,\ - lib/commons-logging.jar,\ - readme.html -jars.compile.order = .,\ - lib/log4j-1.2.15.jar -bin.excludes = src/Temp.jpage diff --git a/de.fu_berlin.inf.dpp/build.xml b/de.fu_berlin.inf.dpp/build.xml deleted file mode 100644 index 620b7613ac7f26f7789fef27cf205c82f36b7ba5..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/build.xml +++ /dev/null @@ -1,258 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="de.fu_berlin.inf.dpp" default="build.update.jar" basedir="."> - - <property name="saros.version" value="8.11.07"/> - - <property name="basews" value="${ws}"/> - <property name="baseos" value="${os}"/> - <property name="basearch" value="${arch}"/> - <property name="basenl" value="${nl}"/> - - <!-- Compiler settings. --> - <property name="javacFailOnError" value="false"/> - <property name="javacDebugInfo" value="on"/> - <property name="javacVerbose" value="true"/> - <property name="logExtension" value=".log"/> - <property name="compilerArg" value=""/> - <property name="javacSource" value="1.5"/> - <property name="javacTarget" value="1.5"/> - <path id="path_bootclasspath"> - <fileset dir="${java.home}/lib"> - <include name="*.jar"/> - </fileset> - </path> - <property name="bootclasspath" refid="path_bootclasspath"/> - <property name="bundleJavacSource" value="${javacSource}"/> - <property name="bundleJavacTarget" value="${javacTarget}"/> - <property name="bundleBootClasspath" value="${bootclasspath}"/> - - <target name="init" depends="properties"> - <condition property="pluginTemp" value="${buildTempFolder}/plugins"> - <isset property="buildTempFolder"/> - </condition> - <property name="pluginTemp" value="${basedir}"/> - <condition property="build.result.folder" value="${pluginTemp}/Plugin"> - <isset property="buildTempFolder"/> - </condition> - <property name="build.result.folder" value="${basedir}"/> - <property name="temp.folder" value="${basedir}/temp.folder"/> - <property name="plugin.destination" value="${basedir}"/> - <property name="eclipse.dir" value="${basedir}/../../eclipse"/> - </target> - - <target name="properties" if="eclipse.running"> - <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/> - </target> - - <target name="build.update.jar" depends="init" description="Build the plug-in: de.fu_berlin.inf.dpp for an update site."> - <delete dir="${temp.folder}"/> - <mkdir dir="${temp.folder}"/> - <available property="@dot" file="${build.result.folder}/@dot"/> - <antcall target="@dot"/> - <antcall target="gather.bin.parts"> - <param name="destination.temp.folder" value="${temp.folder}/"/> - </antcall> - <zip destfile="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.jar" basedir="${temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" filesonly="false" whenempty="skip" update="false"/> - <delete dir="${temp.folder}"/> - <delete dir="${build.result.folder}/@dot"/> - </target> - - <target name="@dot" depends="init" unless="@dot" description="Create jar: de.fu_berlin.inf.dpp @dot."> - <delete dir="${temp.folder}/@dot.bin"/> - <mkdir dir="${temp.folder}/@dot.bin"/> - <path id="@dot.classpath"> - <!-- - <pathelement path="C:\dkfajfk\/plugins/org.eclipse.ui_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime_3.2.0.v20060601b.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.osgi_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.equinox.common_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.jobs_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060602/runtime_registry_compatibility.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060602"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.equinox.registry_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.equinox.preferences_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.0.v20060602/@dot"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.contenttype_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.swt_3.2.0.v3232l.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.swt.win32.win32.x86_3.2.0.v3232l.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jface_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.commands_3.2.0.I20060511-0800a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench.compatibility_3.2.0.I20060511-2000/@dot"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench.compatibility_3.2.0.I20060511-2000/compatibility.jar"/> - <pathelement path="${eclipse.home}/plugins/com.ibm.icu_3.4.4.1.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help_3.2.0.v20060518.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.expressions_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.resources_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.resources.compatibility_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.resources.win32_3.2.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.runtime.compatibility_3.1.100.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.configurator_3.2.0.v20060511.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ant.core_3.1.100.v20060531.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.variables_3.1.100.v20060517.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.filesystem_1.0.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.filesystem.win32.x86_1.0.0.v20060601a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.ui_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.console_3.1.100.v20060518.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jface.text_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.text_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.workbench.texteditor_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.core_3.2.0.v_670.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.team.core_3.2.0.I200605181830.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.search_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.core.filebuffers_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.ide_3.2.0.I20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.win32_3.2.0.I20060511-2000.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.views_3.2.0.I20060511-2000.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.core_3.2.0.v20060602.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.core.win32_3.2.0.v20060511.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.update.ui_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.forms_3.2.0.v20060530.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.debug.core_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.debug.ui_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.editors_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.launching_3.2.0.v20060525.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug_3.2.0.v20060601/jdi.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug_3.2.0.v20060601/jdimodel.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug_3.2.0.v20060601/tools.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.compare_3.2.0.v20060525.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.team.ui_3.2.0.I200606011710.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.navigator_3.2.0.I20060526-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.navigator.resources_3.2.0.I20060511-2000.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.views.properties.tabbed_3.2.0.I20060511-0800a.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ltk.core.refactoring_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ltk.ui.refactoring_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.core.manipulation_1.0.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt_3.2.0.v20060602-0010.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.intro_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.apache.lucene_1.4.103.v20060601/lucene-1.4.3.jar"/> - <pathelement path="${eclipse.home}/plugins/org.apache.lucene_1.4.103.v20060601/parser.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help.base_3.2.0.v20060601.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help.appserver_3.1.100.v20060510b.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.ui.cheatsheets_3.2.0.v20060516.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.help.ui_3.2.0.v20060510b.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.debug.ui_3.2.0.v20060517.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.doc.isv_3.2.0.v20060602-1130.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.doc.user_3.2.0.v20060602-1130.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.junit_3.2.0.v20060602-0010/junitsupport.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.junit.runtime_3.2.0.v20060602-0010/junitruntime.jar"/> - <pathelement path="${eclipse.home}/plugins/org.junit_3.8.1/junit.jar"/> - <pathelement path="${eclipse.home}/plugins/org.eclipse.jdt.source_3.2.0.v20060602-0010-F7snq0fulF-UQcP/@dot"/> - --> - <fileset dir="${eclipse.dir}/plugins/"> - <include name="**/*.jar"/> - <exclude name="**/org.jivesoftware.smack_2.2.1.jar"/> - </fileset> - <pathelement path="bin/"/> - <fileset dir="${basedir}/lib"> - <include name="**/*.jar"/> - </fileset> - <!-- - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/bin/"/> - <pathelement path="lib/smack.jar"/> - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/lib/smack.jar"/> - <pathelement path="lib/smackx.jar"/> - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/lib/smackx.jar"/> - <pathelement path="lib/smackx-debug.jar"/> - <pathelement path="${build.result.folder}/../de.fu_berlin.inf.dpp/lib/smackx-debug.jar"/> - --> - </path> - <!-- compile the source code --> - <javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" > - <compilerarg line="${compilerArg}" compiler="${build.compiler}"/> - <classpath refid="@dot.classpath" /> - <src path="src/" /> - <compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/> - <compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/> - </javac> - <!-- Copy necessary resources --> - <copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false"> - <fileset dir="src/" excludes="**/*.java, **/package.htm*" /> - </copy> - <mkdir dir="${build.result.folder}"/> - <copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false"> - <fileset dir="${temp.folder}/@dot.bin" /> - </copy> - <delete dir="${temp.folder}/@dot.bin"/> - </target> - - <target name="src.zip" depends="init" unless="src.zip"> - <mkdir dir="${build.result.folder}"/> - <zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false"> - <fileset dir="src/" includes="**/*.java" /> - </zip> - </target> - - <target name="build.sources" depends="init"> - <available property="src.zip" file="${build.result.folder}/src.zip"/> - <antcall target="src.zip"/> - </target> - - <target name="gather.bin.parts" depends="init" if="destination.temp.folder"> - <mkdir dir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}"/> - <copy todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="true" overwrite="false"> - <fileset dir="${build.result.folder}/@dot" includes="**" /> - </copy> - <copy todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="true" overwrite="false"> - <fileset dir="${basedir}"> - <include name="META-INF/"/> - <include name="plugin.xml"/> - <include name="icons/"/> - <include name="lib/smack*.jar"/> - <include name="lib/log*.jar"/> - <include name="log4j*"/> - </fileset> - <!--fileset dir="${basedir}" includes="META-INF/,plugin.xml,icons/,lib/smack.jar,lib/smackx-debug.jar,lib/smackx.jar,bin/" /--> - </copy> - </target> - - <target name="build.zips" depends="init"> - </target> - - <target name="gather.sources" depends="init" if="destination.temp.folder"> - <mkdir dir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}"/> - <copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="false" overwrite="false"/> - <copy todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="false" overwrite="false"> - <fileset dir="${basedir}" includes="icons/,src/,plugin.xml,lib/junit.jar,lib/smack.jar,lib/smackx-debug.jar,lib/smackx.jar" /> - </copy> - </target> - - <target name="gather.logs" depends="init" if="destination.temp.folder"> - <mkdir dir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}"/> - <copy file="${temp.folder}/@dot.bin${logExtension}" todir="${destination.temp.folder}/de.fu_berlin.inf.dpp_${saros.version}" failonerror="false" overwrite="false"/> - </target> - - <target name="clean" depends="init" description="Clean the plug-in: de.fu_berlin.inf.dpp of all the zips, jars and logs created."> - <delete dir="${build.result.folder}/@dot"/> - <delete file="${build.result.folder}/src.zip"/> - <delete file="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.jar"/> - <delete file="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.zip"/> - <delete dir="${temp.folder}"/> - </target> - - <target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder."> - <eclipse.convertPath fileSystemPath="D:/Coding/Java/Saros/Plugin" property="resourcePath"/> - <eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/> - </target> - - <target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: de.fu_berlin.inf.dpp."> - <delete dir="${temp.folder}"/> - <mkdir dir="${temp.folder}"/> - <available property="@dot" file="${build.result.folder}/@dot"/> - <antcall target="@dot"/> - <antcall target="build.sources"/> - <antcall target="gather.bin.parts"> - <param name="destination.temp.folder" value="${temp.folder}/"/> - </antcall> - <antcall target="gather.sources"> - <param name="destination.temp.folder" value="${temp.folder}/"/> - </antcall> - <delete> - <fileset dir="${temp.folder}" includes="**/*.bin${logExtension}" /> - </delete> - <zip destfile="${plugin.destination}/de.fu_berlin.inf.dpp_${saros.version}.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/> - <delete dir="${temp.folder}"/> - </target> - -</project> diff --git a/de.fu_berlin.inf.dpp/credits.txt b/de.fu_berlin.inf.dpp/credits.txt deleted file mode 100644 index 7808a28e04059a19a4fe2276c0d56982e5462bfd..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/credits.txt +++ /dev/null @@ -1,8 +0,0 @@ - - Author: Riad Djemili, Christopher Oezbek, Bj�rn Gustavs, Oliver Rieger - - Icons: Eclipse Org. & Silk Icon set by http://www.famfamfam.com - - Jupiter Algorithm Implementation taken from "ace - A Collaborative Editor" - - This project uses the following libraries: Log4J, Smack \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/header.txt b/de.fu_berlin.inf.dpp/header.txt deleted file mode 100644 index d0dcd6284a0685cd681da43a57ad41ada1fad077..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/header.txt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universit�t Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ diff --git a/de.fu_berlin.inf.dpp/icons/add.png b/de.fu_berlin.inf.dpp/icons/add.png deleted file mode 100644 index 6332fefea4be19eeadf211b0b202b272e8564898..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/bullet_feed.png b/de.fu_berlin.inf.dpp/icons/bullet_feed.png deleted file mode 100644 index 4367cd0df6b582b723da9aea197f2b77c1ad7379..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/bullet_feed.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/bullet_green.png b/de.fu_berlin.inf.dpp/icons/bullet_green.png deleted file mode 100644 index a2748cf726a11c8891da01acd45d6bf4197c1243..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/bullet_green.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/bullet_yellow.png b/de.fu_berlin.inf.dpp/icons/bullet_yellow.png deleted file mode 100644 index 29b10262b65ba9e572bbfd6542432cd9521fed05..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/bullet_yellow.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/comment.png b/de.fu_berlin.inf.dpp/icons/comment.png deleted file mode 100644 index 7bc9233ea63c89d52a99494dd0f0735a29a3ec3b..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/comment.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/connect.png b/de.fu_berlin.inf.dpp/icons/connect.png deleted file mode 100644 index 024138eb33b9124af6db8149747adbb41c1b8cfc..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/connect.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/disconnect.png b/de.fu_berlin.inf.dpp/icons/disconnect.png deleted file mode 100644 index b335cb11c4d1a397b307883adcfe1e00c4cf8e6a..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/disconnect.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/door_open.png b/de.fu_berlin.inf.dpp/icons/door_open.png deleted file mode 100644 index 64bab57ddd0e95ad9a73a3828ec29b5d0b4dd675..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/door_open.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/group.png b/de.fu_berlin.inf.dpp/icons/group.png deleted file mode 100644 index 7fb4e1f1e1cd6ee67d33ffd24f09ddd5c3478bec..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/group.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/ibb_connection.png b/de.fu_berlin.inf.dpp/icons/ibb_connection.png deleted file mode 100644 index db52b85a5f7fbe6258088192c264f1fcefb67c32..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/ibb_connection.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/invites.png b/de.fu_berlin.inf.dpp/icons/invites.png deleted file mode 100644 index 6f9a198bea5326d8c5b6cf4fcb864af496152377..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/invites.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/jingle_connection.png b/de.fu_berlin.inf.dpp/icons/jingle_connection.png deleted file mode 100644 index 9af2f636b0359af47c209c077ac8650ca1c44855..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/jingle_connection.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_add.png b/de.fu_berlin.inf.dpp/icons/monitor_add.png deleted file mode 100644 index a818066400860830a2e397c2f2a08039dd8284cb..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_delete.png b/de.fu_berlin.inf.dpp/icons/monitor_delete.png deleted file mode 100644 index 37332563f2418c8ec38dfb2191c6a2efff3983b3..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_delete.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_edit.png b/de.fu_berlin.inf.dpp/icons/monitor_edit.png deleted file mode 100644 index f772c562f4f5534cd81918f26d60ee96bb039511..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_edit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_go.png b/de.fu_berlin.inf.dpp/icons/monitor_go.png deleted file mode 100644 index 8af3eda9f2db79939652cb5f81e045dee47c5395..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_go.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/monitor_lightning.png b/de.fu_berlin.inf.dpp/icons/monitor_lightning.png deleted file mode 100644 index 06e53a9d196cd92062583424247872d50b31255e..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/monitor_lightning.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/read_only.gif b/de.fu_berlin.inf.dpp/icons/read_only.gif deleted file mode 100644 index dde3cbd615033cbb942d8b088f917dfbd2e04894..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/read_only.gif and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/sample.gif b/de.fu_berlin.inf.dpp/icons/sample.gif deleted file mode 100644 index 34fb3c9d8cb7d489681b7f7aee4bdcd7eaf53610..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/sample.gif and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/start_invitation.png b/de.fu_berlin.inf.dpp/icons/start_invitation.png deleted file mode 100644 index 0def963e879544834c6b7746a9885056387ac83a..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/start_invitation.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/stop.gif b/de.fu_berlin.inf.dpp/icons/stop.gif deleted file mode 100644 index dc47edf06955eca15fee8118b3be43f019cae3f4..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/stop.gif and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/table_edit.png b/de.fu_berlin.inf.dpp/icons/table_edit.png deleted file mode 100644 index bfcb0249afde587618c63a1eaf776e7af2179f9c..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/table_edit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/telephone.png b/de.fu_berlin.inf.dpp/icons/telephone.png deleted file mode 100644 index cecc436fbdcc58e9c40b9dc52112c89f3654cace..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/telephone.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/transmit.png b/de.fu_berlin.inf.dpp/icons/transmit.png deleted file mode 100644 index f54bf736cdc0d58a07c0a0171cc5a25b5e007e0e..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/transmit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/transmit_add.png b/de.fu_berlin.inf.dpp/icons/transmit_add.png deleted file mode 100644 index b7fd4e685f6069f24879e9f0e381bc410832a85d..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/transmit_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/transmit_blue.png b/de.fu_berlin.inf.dpp/icons/transmit_blue.png deleted file mode 100644 index 7b1142fc70adfd598ce6eac581421d7e6295f370..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/transmit_blue.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/user.png b/de.fu_berlin.inf.dpp/icons/user.png deleted file mode 100644 index 79f35ccbdad44489dbf07d1bf688c411aa3b612c..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/user.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/user_add.png b/de.fu_berlin.inf.dpp/icons/user_add.png deleted file mode 100644 index deae99bcff9815d8530a920e754d743700ddd5fb..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/user_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/user_edit.png b/de.fu_berlin.inf.dpp/icons/user_edit.png deleted file mode 100644 index c1974cda745278a404b9e29fa91e0503a84accb1..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/user_edit.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/icons/vcard_add.png b/de.fu_berlin.inf.dpp/icons/vcard_add.png deleted file mode 100644 index 2a68453811f26444e2d04da5713c9c757dc999c0..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/icons/vcard_add.png and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/commons-logging.jar b/de.fu_berlin.inf.dpp/lib/commons-logging.jar deleted file mode 100644 index 7b54c1065d3ecc8d0804d2f9160aa9972465c579..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/commons-logging.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/easymock.jar b/de.fu_berlin.inf.dpp/lib/easymock.jar deleted file mode 100644 index c4159f5a0a4c19d6afc89cbc271208acb8ba7dff..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/easymock.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/junit.jar b/de.fu_berlin.inf.dpp/lib/junit.jar deleted file mode 100644 index 674d71e89ea154dbe2e3cd032821c22b39e8fd68..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/junit.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/junitsrc.zip b/de.fu_berlin.inf.dpp/lib/junitsrc.zip deleted file mode 100644 index 88049093b58cdefdbd9f658e9efe0ea3538d4a79..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/junitsrc.zip and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/log4j-1.2.15.jar b/de.fu_berlin.inf.dpp/lib/log4j-1.2.15.jar deleted file mode 100644 index c930a6ab4d4b73c1a6feb9e929091205664bb340..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/log4j-1.2.15.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/lw-collection.jar b/de.fu_berlin.inf.dpp/lib/lw-collection.jar deleted file mode 100644 index 3a7e9aa26fb42af5a02378077d5401fe7de6b3b3..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/lw-collection.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/lw-common.jar b/de.fu_berlin.inf.dpp/lib/lw-common.jar deleted file mode 100644 index 1a532d6609100f435056bbf06105725efbd203bc..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/lw-common.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/lw-io.jar b/de.fu_berlin.inf.dpp/lib/lw-io.jar deleted file mode 100644 index fe434f2343181d64ed9fb45638b698f2a81b6aaa..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/lw-io.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/lw-nio.jar b/de.fu_berlin.inf.dpp/lib/lw-nio.jar deleted file mode 100644 index 056ad3819f0e6bc089f72040e0cf4d316465b2ce..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/lw-nio.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/lw-rudp.jar b/de.fu_berlin.inf.dpp/lib/lw-rudp.jar deleted file mode 100644 index 70f400d5f2e09e08882a7286a0126ca05541a308..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/lw-rudp.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smack.jar b/de.fu_berlin.inf.dpp/lib/smack.jar deleted file mode 100644 index 73d676a4013fdfe1729e7a2588ccaeb7eb9ee6ce..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smack.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx-debug.jar b/de.fu_berlin.inf.dpp/lib/smackx-debug.jar deleted file mode 100644 index 5d1d87603245876d2a9934873263f3b810ad17a1..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx-debug.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx-jingle.jar b/de.fu_berlin.inf.dpp/lib/smackx-jingle.jar deleted file mode 100644 index ae044e4bf48bb4354c183a462fe8bb9b690d86e6..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx-jingle.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/lib/smackx.jar b/de.fu_berlin.inf.dpp/lib/smackx.jar deleted file mode 100644 index ad73bed78e1a0b6e40d236efe9dd915c84350b7d..0000000000000000000000000000000000000000 Binary files a/de.fu_berlin.inf.dpp/lib/smackx.jar and /dev/null differ diff --git a/de.fu_berlin.inf.dpp/log4j.properties b/de.fu_berlin.inf.dpp/log4j.properties deleted file mode 100644 index 43e6caddc679da06586201213b4454fdd6c13d1f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/log4j.properties +++ /dev/null @@ -1,39 +0,0 @@ -log4j.rootLogger=WARN, MeinConsoleAppender, MeinDaRoFiAppender - -log4j.appender.MeinConsoleAppender=org.apache.log4j.ConsoleAppender -log4j.appender.MeinConsoleAppender.layout=org.apache.log4j.PatternLayout -log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd : HH:mm:ss} (%F:%L) : %m%n -#log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd : HH:mm:ss} %l %m%n -#log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%-5p %d %l:%n%m%n -#log4j.appender.MeinConsoleAppender.layout.ConversionPattern=%d{MM-dd@HH:mm:ss} %-5p (%13F:%L) %3x - %m%n - -#log4j.appender.MeinDaRoFiAppender=org.apache.log4j.FileAppender -log4j.appender.MeinDaRoFiAppender=org.apache.log4j.RollingFileAppender -#log4j.appender.MeinDaRoFiAppender.datePattern='.'yyyy-MM-dd_HH-mm -log4j.appender.MeinDaRoFiAppender.file=Saros.log -log4j.appender.MeinDaRoFiAppender.Append=false -log4j.appender.MeinDaRoFiAppender.layout=org.apache.log4j.PatternLayout -log4j.appender.MeinDaRoFiAppender.layout.ConversionPattern=%-5p %d{yyyy-MM-dd : HH:mm:ss} (%F:%L) : %m%n -#log4j.appender.MeinDaRoFiAppender.layout.ConversionPattern=%-5p %d %l: %n%m%n - -log4j.logger.de.fu_berlin.inf.dpp=ERROR -log4j.logger.de.fu_berlin.inf.dpp.MessagingManager=INFO -log4j.logger.de.fu_berlin.inf.dpp.concurrent=WARN -log4j.logger.de.fu_berlin.inf.dpp.concurrent.management.ConcurrentDocumentManager=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.project.internal=ERROR -log4j.logger.de.fu_berlin.inf.dpp.invitation.internal=ERROR -log4j.logger.de.fu_berlin.inf.dpp.editor.internal.EditorAPI=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.editor.EditorManager=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.net=ERROR -log4j.logger.de.fu_berlin.inf.dpp.util=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.internal=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.internal.XMPPChatTransmitter=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.net.internal.OutgoingInvitationProcess=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.net.internal.MultiUserChatManager=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.net.internal.PrivateChatManager=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.internal.ActivitySequencer=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.internal.ExecuterQueue=INFO -log4j.logger.de.fu_berlin.inf.dpp.net.jingle=ERROR -log4j.logger.de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferSession=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.project.internal.SharedProject=DEBUG -log4j.logger.de.fu_berlin.inf.dpp.ui.RosterView=ERROR diff --git a/de.fu_berlin.inf.dpp/plugin.xml b/de.fu_berlin.inf.dpp/plugin.xml deleted file mode 100644 index d299f0b17bb39126a82c1e8aa3527f382345a4e2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/plugin.xml +++ /dev/null @@ -1,398 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?eclipse version="3.0"?> -<plugin> - <extension - point="org.eclipse.ui.views"> - <category - id="Saros" - name="Saros"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.RosterView" - icon="icons/sample.gif" - id="de.fu_berlin.inf.dpp.ui.RosterView" - name="Roster"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.SessionView" - icon="icons/sample.gif" - id="de.fu_berlin.inf.dpp.ui.SessionView" - name="Saros Session"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.ChatView" - icon="icons/comment.png" - id="de.fu_berlin.inf.dpp.ui.ChatView" - name="Chat"/> - <view - category="Saros" - class="de.fu_berlin.inf.dpp.ui.NetworkView" - icon="icons/connect.png" - id="de.fu_berlin.inf.dpp.ui.NetworkViewView" - name="Network Monitor"/> - </extension> - <extension - point="org.eclipse.ui.perspectiveExtensions"> - <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> - <view - id="de.fu_berlin.inf.dpp.ui.RosterView" - ratio="0.5" - relationship="right" - relative="org.eclipse.ui.views.TaskList"/> - </perspectiveExtension> - <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> - <view - id="de.fu_berlin.inf.dpp.ui.SessionView" - ratio="0.5" - relationship="right" - relative="org.eclipse.ui.views.TaskList"/> - </perspectiveExtension> - </extension> - <extension - point="org.eclipse.ui.popupMenus"> - <objectContribution - adaptable="true" - id="de.fu_berlin.inf.dpp.ui.popupmenu" - objectClass="org.eclipse.core.resources.IResource"> - <menu - id="Saros.menu1" - label="Saros.menu1"/> - <action - class="de.fu_berlin.inf.dpp.ui.actions.NewSessionAction" - icon="icons/transmit.png" - id="Saros.action1" - label="Share project..."> - </action> - <visibility> - <or> - <objectClass name="org.eclipse.core.resources.IProject"/> - <objectClass name="org.eclipse.jdt.core.IJavaProject"/> - </or> - </visibility> - </objectContribution> - </extension> - <extension - point="org.eclipse.ui.decorators"> - <decorator - adaptable="true" - class="de.fu_berlin.inf.dpp.ui.decorators.SharedProjectDecorator" - id="de.fu_berlin.inf.dpp.ui.decorators.SharedProjectDecorator" - label="Shared Project Decorator" - lightweight="true" - state="true"> - <enablement> - <objectClass name="org.eclipse.core.resources.IFile"/> - </enablement> - </decorator> - </extension> - <extension - point="org.eclipse.ui.preferencePages"> - <page - class="de.fu_berlin.inf.dpp.ui.PreferencePage" - id="de.fu_berlin.inf.dpp.preferences" - name="Saros"/> - <page - category="de.fu_berlin.inf.dpp.preferences/" - class="de.fu_berlin.inf.dpp.ui.AdvancedPreferencePage" - id="de.fu_berlin.inf.dpp.preferences.advanced" - name="Advanced"/> - </extension> - <extension - point="org.eclipse.core.runtime.preferences"> - <initializer class="de.fu_berlin.inf.dpp.PreferenceInitializer"/> - </extension> - <extension - point="org.eclipse.ui.actionSets"> - <actionSet - id="de.fu_berlin.inf.dpp.actionSet" - label="Saros" - visible="true"> - <menu - id="de.fu_berlin.inf.dpp.menu" - label="Saros"> - <separator name="de.fu_berlin.inf.dpp.menu.group"/> - </menu> - <action - class="de.fu_berlin.inf.dpp.ui.actions.NewAccountAction" - icon="icons/vcard_add.png" - id="de.fu_berlin.inf.dpp.ui.actions.createAccountAction" - label="&Create Account" - menubarPath="de.fu_berlin.inf.dpp.menu/de.fu_berlin.inf.dpp.menu.group" - /> - </actionSet> - </extension> - <extension - point="org.eclipse.ui.editors.documentProviders"> - <provider - class="de.fu_berlin.inf.dpp.editor.internal.SharedDocumentProvider" - id="Saros.shared_document_provider" - inputTypes="org.eclipse.ui.IFileEditorInput"/> - </extension> - <extension - point="org.eclipse.ui.editors.annotationTypes"> - <type - markerType="de.fu_berlin.inf.dpp.annotations.viewport" - name="de.fu_berlin.inf.dpp.annotations.viewport"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution" - name="de.fu_berlin.inf.dpp.annotations.contribution"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.1" - name="de.fu_berlin.inf.dpp.annotations.contribution.1"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.2" - name="de.fu_berlin.inf.dpp.annotations.contribution.2"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution3" - name="de.fu_berlin.inf.dpp.annotations.contribution.3"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.4" - name="de.fu_berlin.inf.dpp.annotations.contribution.4"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.contribution.5" - name="de.fu_berlin.inf.dpp.annotations.contribution.5"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.1" - name="de.fu_berlin.inf.dpp.annotations.selection.1"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.2" - name="de.fu_berlin.inf.dpp.annotations.selection.2"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.3" - name="de.fu_berlin.inf.dpp.annotations.selection.3"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.4" - name="de.fu_berlin.inf.dpp.annotations.selection.4"/> - <type - markerType="de.fu_berlin.inf.dpp.annotations.selection.5" - name="de.fu_berlin.inf.dpp.annotations.selection.5"/> - </extension> - <extension - point="org.eclipse.ui.editors.markerAnnotationSpecification"> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.viewport" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.color" - colorPreferenceValue="0,255,0" - contributesToHeader="true" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.highlight" - highlightPreferenceValue="false" - includeOnPreferencePage="true" - label="DPP Viewport" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.overview" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.text" - textPreferenceValue="false" - textStylePreferenceValue="NONE" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.viewport.ruler" - verticalRulerPreferenceValue="true"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler" - colorPreferenceValue="138,165,189" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="NONE" - verticalRulerPreferenceValue="false"/> - - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.1" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.1" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.1" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.1" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.1" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.1" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.1" - colorPreferenceValue="255,0,0" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.2" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.2" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.2" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.2" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.2" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.2" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.2" - colorPreferenceValue="0,255,0" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.3" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.3" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.3" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.3" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.3" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.3" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.3" - colorPreferenceValue="0,0,255" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.4" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.4" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.4" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.4" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.4" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.4" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.4" - colorPreferenceValue="255,255,0" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.contribution.5" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.color.5" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.highlight.5" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.overview.5" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.text.5" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.textstyle.5" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.contribution.ruler.5" - colorPreferenceValue="0,255,255" - contributesToHeader="false" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP User" - overviewRulerPreferenceValue="false" - presentationLayer="7" - textPreferenceValue="true" - textStylePreferenceValue="UNDERLINE" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.1" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.1" - colorPreferenceValue="255,0,0" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.1" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 1" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.1" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.1" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.1" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.1" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.2" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.2" - colorPreferenceValue="0,255,0" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.2" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 2" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.2" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.2" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.2" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.2" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.3" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.3" - colorPreferenceValue="0,0,255" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.3" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 3" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.3" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.3" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.3" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.3" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.4" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.4" - colorPreferenceValue="255,255,0" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.4" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 4" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.4" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.4" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.4" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.4" - verticalRulerPreferenceValue="false"/> - <specification - annotationType="de.fu_berlin.inf.dpp.annotations.selection.5" - colorPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.color.5" - colorPreferenceValue="0,255,255" - contributesToHeader="false" - highlightPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.highlight.5" - highlightPreferenceValue="true" - includeOnPreferencePage="true" - label="DPP Selection of remote user 5" - overviewRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.overview.5" - overviewRulerPreferenceValue="true" - presentationLayer="8" - textPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.text.5" - textPreferenceValue="true" - textStylePreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.textstyle.5" - textStylePreferenceValue="BOX" - verticalRulerPreferenceKey="de.fu_berlin.inf.dpp.annotations.selection.ruler.5" - verticalRulerPreferenceValue="false"/> - - </extension> - <extension - id="de.fu_berlin.inf.dpp.modelProvider" - point="org.eclipse.core.resources.modelProviders"> - <modelProvider class="de.fu_berlin.inf.dpp.project.internal.SharedModelProvider"/> - <enablement> - <instanceof value="org.eclipse.core.resources.IResource"/> - </enablement> - </extension> -</plugin> diff --git a/de.fu_berlin.inf.dpp/readme.html b/de.fu_berlin.inf.dpp/readme.html deleted file mode 100644 index 4a4196df05a794fdd582d76f5e658c2d65add0c9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/readme.html +++ /dev/null @@ -1,137 +0,0 @@ -<html> -<body> - -<h1>DPP Readme</h1> - -<h2>Installation</h2> - -<ol> - <li>Open the software updates manager (Help > Software Updates > Find - and Install...)</li> - <li>Select 'Search for new features to install' and click on next</li> - <li>Click on 'New Remote Site...'</li> - <li>Enter 'Saros' as name and 'http://riad.de/thesis/update' as URL</li> - <li>The new location should've been added to the list and be checked. Click - on 'Finish'</li> - <li>Check the plugin in the 'Search Results' and select 'Next'</li> - <li>Accept the license agreement and select 'Next'</li> - <li>In the next window select 'Finish' to start installation</li> - <li>Select 'Install' on the Feature Verification</li> - <li>Select 'Yes' when you're asked to restart</li> -</ol> - -<h2>Limitations</h2> - -The following limitations need to be considered as of version 0.6.1 - -<ul> - <li>Sessions can only have one participant (besides the host).</li> - <li>Sometimes files are transmitted with wrong line delimiters, which results in - different checksums for files when checking them for identicalness.</li> -</ul> - -<h2>Connecting to a server</h2> - -You need a Jabber account to use Saros. You can create a new account from Saros -if you don't already have one. - -<h3>Creating a new account</h3> - -<ol> - <li>Open the Roster View (Select it from Window > Show View > - Other... > Roster)</li> - <li>Click on the second button on the Roster toolbar</li> - <li>Fill the fields (you can use jabber.org as a Jabber server)</li> - <li>Check the 'Store the new configuration in your preferences'</li> - <li>Select 'Finish'</li> -</ol> - -<h3>Using an existing account</h3> - -<ol> - <li>Open the preferences window (Window > Preferences...).</li> - <li>Select the 'Saros' category.</li> - <li>Enter your account data.</li> -</ol> - -To connect select the Roster View (Menu > Window > Show View > -Other... > Roster). Click on the connect button (1st button in the local -toolbar). The button will always show you, your current connection status. You -also see the status line of the Roster View for more detailed information. - -By default you will have to click the button to connect, but you in the Saros -preferences, you will also find the option to automatically connect on startup. -When you're connected your contacts will be loaded from the server and shown in -the roster viewer. - -<h2>Beginning a shared project sessions</h2> - -<h3>Hosting a shared project session</h3> - -<ol> - <li>Right-Click on a project in your resource navigator (or package navigator) - and select 'Share project...' from the context menu.</li> - <li>Now you see the 'Shared Project Session' viewer and yourself as - only participant.</li> - <li>To invite other users, select the 'Roster' viewer again.</li> - <li>Right-click on a user and select 'Invite user to shared project...'</li> -</ol> - -<h3>Joining a running shared project session</h3> - -To join a running shared project session you need to be invited by a -participant of that session (see above). - -<ol> - <li>If you're invited a wizard dialog will appear on your screen, stating - who the inviter is and an additional short description. Select 'Next' if you - want to accept the invitation.</li> - <li>Before being able to work on the shared project it needs to be fully - replicated to your system. You can accelerate this process by providing a local - project which will be used as base for the synchronization between your - system and the remotely shared project. Select the project from the list - which has the highest value in parentheses. The value states the identicalness - of the local project and the remotely shared project. The higher the number, - the less synchronization will be needed before starting the session.</li> - <li>Select wether you would like to overwrite your local project or to create - a new project. Practically this will create a new project, which contains all - files of your chosen base project.</li> - <li>Select 'Finish'.</li> -</ol> - -<h2>Using a shared project session</h2> - -Only the driver is allowed to edit the resources in the shared project. -There can only be one driver at any time. When starting a shared project -session the host is automatically the driver. - -When the driver opens a file, a small green dot will decorate the resource in the -navigator. This mark always shows the latest resource that the driver is using -or has used. - -<h3>Replicated actions</h3> - -The following types of actions are currently supported and replicated in real time.. - -<ul> - <li>Text changes</li> - <li>Cursor positions and selections</li> - <li>File additions/removals</li> -</ul> - -<h3>Changing the user role</h3> - -There are two ways to change the owner of the driver role. - -<ul> - <li>If you're the current driver or host of the session, you can give the - driver role to another user. To do this select a user in the 'Shared - Project Session' viewer and select 'Give driver role' from the context - menu.</li> - <li>If you're the host of the session, you can take back the driver role - at every moment. Select the 'Take driver role' button from the session - viewer.</li> -</ul> - -</body> -</html> diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/FileList.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/FileList.java deleted file mode 100644 index 820505a0d3462356596780e6316179bc66773adc..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/FileList.java +++ /dev/null @@ -1,385 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.xmlpull.mxp1.MXParser; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.util.FileUtil; - -/** - * A FileList is a list of resources - files and folders - which can be compared - * to other file lists. Folders are denoted by a trailing separator. - * - * @author rdjemili - */ -public class FileList { - private Map<IPath, Long> all = new HashMap<IPath, Long>(); - - private final Map<IPath, Long> added = new HashMap<IPath, Long>(); - - private final Map<IPath, Long> removed = new HashMap<IPath, Long>(); - - private final Map<IPath, Long> altered = new HashMap<IPath, Long>(); - - private final Map<IPath, Long> unaltered = new HashMap<IPath, Long>(); - - private final Comparator<IPath> comparator = new PathLengthComprarator(); - - private class PathLengthComprarator implements Comparator<IPath> { - /* - * (non-Javadoc) - * - * @see java.util.Comparator - */ - public int compare(IPath p1, IPath p2) { - int l1 = p1.toString().length(); - int l2 = p2.toString().length(); - - if (l1 < l2) { - return -1; - } else if (l1 > l2) { - return 1; - } else { - return 0; - } - } - } - - /** - * Creates an empty file list. - */ - public FileList() { - } - - /** - * Creates a new file list from the file tree in given container. - * - * @param container - * the resource container that should be represented by the new - * file list. - * @throws CoreException - * exception that might happen while fetching the files from the - * given container. - */ - public FileList(IContainer container) throws CoreException { - container.refreshLocal(IResource.DEPTH_INFINITE, null); - addMembers(container.members(), this.all, true); - this.unaltered.putAll(this.all); - } - - /** - * Creates a new file list from the file tree in given container. - * - * @param container - * the resource container that should be represented by the new - * file list. - * @param ignoreDerived - * <code>true</code> if derived resources should be ignored. - * @throws CoreException - * exception that might happen while fetching the files from the - * given container. - */ - public FileList(IContainer container, boolean ignoreDerived) - throws CoreException { - - container.refreshLocal(IResource.DEPTH_INFINITE, null); - addMembers(container.members(), this.all, ignoreDerived); - this.unaltered.putAll(this.all); - } - - /** - * Creates a new file list from given resources. - * - * @param resources - * the resources that should be added to this file list. - * @throws CoreException - */ - public FileList(IResource[] resources) throws CoreException { - - addMembers(resources, this.all, false); - this.unaltered.putAll(this.all); - } - - /** - * Build the FileList from its XML representation. - * - * @throws XmlPullParserException - * @throws IOException - */ - public FileList(String xml) throws XmlPullParserException, IOException { - MXParser parser = new MXParser(); - parser.setInput(new StringReader(xml)); - - Map<IPath, Long> context = this.added; - - boolean done = false; - while (!done) { - int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { - - if (parser.getName().equals("added")) { - context = this.added; - - } else if (parser.getName().equals("removed")) { - context = this.removed; - - } else if (parser.getName().equals("altered")) { - context = this.altered; - - } else if (parser.getName().equals("unaltered")) { - context = this.unaltered; - - } else if (parser.getName().equals("file")) { - IPath path = new Path(parser - .getAttributeValue(null, "path")); - Long checksum = Long.parseLong(parser.getAttributeValue( - null, "checksum")); - - context.put(path, checksum); - - if (context != this.removed) { - this.all.put(path, checksum); - } - - } else if (parser.getName().equals("folder")) { - IPath path = new Path(parser - .getAttributeValue(null, "path")); - - context.put(path, null); - - if (context != this.removed) { - this.all.put(path, null); - } - } - - } else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals("filelist")) { - done = true; - } - } - } - } - - // TODO invert diff direction - /** - * Returns a new FileList which contains the diff from the two FileLists. - * - * @param other - * the other FileList with which this FileList is compared with. - * - * @return a new FileList which contains the diff information from the two - * FileLists. The diff contains the operations which are needed to - * get from this FileList to the other FileList. - */ - public FileList diff(FileList other) { - FileList fileList = new FileList(); - - for (Map.Entry<IPath, Long> entry : this.all.entrySet()) { - if (!other.all.containsKey(entry.getKey())) { - fileList.removed.put(entry.getKey(), entry.getValue()); - } - } - - for (Map.Entry<IPath, Long> entry : other.all.entrySet()) { - if (!this.all.containsKey(entry.getKey())) { - fileList.added.put(entry.getKey(), entry.getValue()); - } - } - - for (Map.Entry<IPath, Long> entry : this.all.entrySet()) { - IPath path = entry.getKey(); - if (other.all.containsKey(path)) { - - if (path.hasTrailingSeparator()) { - fileList.unaltered.put(path, null); - - } else { - long checksum = entry.getValue(); - long otherChecksum = other.all.get(path); - - if (checksum == otherChecksum) { - fileList.unaltered.put(path, checksum); - } else { - fileList.altered.put(path, checksum); - } - } - - } - } - - fileList.all = new HashMap<IPath, Long>(other.all); - return fileList; - } - - /** - * @return the amount in percentage by which this file list has the same - * files as the other filelist. - */ - public int match(FileList other) { - return getPaths().size() == 0 ? 0 : 100 - * diff(other).getUnalteredPaths().size() / getPaths().size(); - } - - /** - * @return a sorted list of all paths in this file list. The paths are - * sorted by their character length. - */ - public List<IPath> getPaths() { - return sorted(this.all.keySet()); - } - - public List<IPath> getAddedPaths() { - return sorted(this.added.keySet()); - } - - public List<IPath> getRemovedPaths() { - return sorted(this.removed.keySet()); - } - - public List<IPath> getAlteredPaths() { - return sorted(this.altered.keySet()); - } - - public List<IPath> getUnalteredPaths() { - return sorted(this.unaltered.keySet()); - } - - /** - * @return the XML representation of this FileList. You can use the returned - * string to construct the same file list again. - */ - public String toXML() { - StringBuilder sb = new StringBuilder(); - sb.append("<filelist>"); - - appendFileGroup(sb, "added", this.added); - appendFileGroup(sb, "removed", this.removed); - appendFileGroup(sb, "altered", this.altered); - appendFileGroup(sb, "unaltered", this.unaltered); - - sb.append("</filelist>"); - - return sb.toString(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (!(obj instanceof FileList)) { - return false; - } - - FileList other = (FileList) obj; - return this.all.equals(other.all) && this.added.equals(other.added) - && this.removed.equals(other.removed) - && this.altered.equals(other.altered) - && this.unaltered.equals(other.unaltered); - } - - @Override - public String toString() { - return "FileList(files:" + this.all.size() + ")"; - } - - private List<IPath> sorted(Set<IPath> pathSet) { - List<IPath> paths = new ArrayList<IPath>(pathSet); - Collections.sort(paths, this.comparator); - return paths; - } - - private void addMembers(IResource[] resources, Map<IPath, Long> members, - boolean ignoreDerived) throws CoreException { - - for (IResource resource : resources) { - if (ignoreDerived && resource.isDerived()) { - continue; - } - - if (resource instanceof IFile) { - IFile file = (IFile) resource; - if (file.exists() == false) { - continue; - } - - Long checksum = FileUtil.checksum(file); - if (checksum != -1) { - members.put(file.getProjectRelativePath(), checksum); - } - - } else if (resource instanceof IFolder) { - IFolder folder = (IFolder) resource; - - IPath path = folder.getProjectRelativePath(); - if (!path.hasTrailingSeparator()) { - path = path.addTrailingSeparator(); - } - - members.put(path, null); - addMembers(folder.members(), members, ignoreDerived); - } - } - } - - private void appendFileGroup(StringBuilder sb, String element, - Map<IPath, Long> map) { - - if (map.size() == 0) { - return; - } - - sb.append('<').append(element).append('>'); - for (Map.Entry<IPath, Long> entry : map.entrySet()) { - IPath path = entry.getKey(); - - if (path.hasTrailingSeparator()) { - sb.append("<folder path=\"").append(path).append("\"/>"); - - } else { - long checksum = entry.getValue(); - sb.append("<file path=\"").append(path).append("\" "); - sb.append("checksum=\"").append(checksum).append("\"/>"); - } - - } - sb.append("</").append(element).append('>'); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/MessagingManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/MessagingManager.java deleted file mode 100644 index 6dc65fcaa5b0994f7751b4ab9f6493515c599d53..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/MessagingManager.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.apache.log4j.Logger; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.widgets.Display; -import org.jivesoftware.smack.Chat; -import org.jivesoftware.smack.MessageListener; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.filter.MessageTypeFilter; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smackx.MessageEventManager; -import org.jivesoftware.smackx.muc.InvitationListener; -import org.jivesoftware.smackx.muc.MultiUserChat; - -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.MultiUserChatManager; -import de.fu_berlin.inf.dpp.ui.MessagingWindow; - -/** - * MessagingManager handles all instant messaging related communications. - * - * @author rdjemili - */ -public class MessagingManager implements PacketListener, MessageListener, - IConnectionListener, InvitationListener { - - private static Logger log = Logger.getLogger(MessagingManager.class - .getName()); - - MessageEventManager messageEventManager; - - MultiUserChatManager multitrans = null; - - private final String CHAT_ROOM = "saros"; - - public class ChatLine { - public String sender; - - public String text; - - public Date date; - - public String packedID; - } - - /** - * Encapsulates the interface that is needed by the MessagingWindow. - */ - public interface SessionProvider { - public List<ChatLine> getHistory(); - - public String getName(); - - public void sendMessage(String msg); - } - - /** - * Sessions are one-to-one IM chat sessions. Sessions are responsible for * - * Since all sessions already handle their incoming messages, this method is - * only to handle incoming chat messages for which no sessions have been yet - * created. If it finds a chat message that belongs to no current session, - * it creates a new session. sending and receiving their messages. They also - * handle their IM chat window and save their history, even when their chat - * windows are disposed and reopened again. - * - * TODO CJ: Rework needed, we don't want one-to-one chats anymore wanted: - * messages to all developers of programming session use this class as - * fallback if muc fails? - */ - public class ChatSession implements SessionProvider, PacketListener, - MessageListener { - private final Logger logCH = Logger.getLogger(ChatSession.class - .getName()); - - private final String name; - - private final Chat chat; - - private final JID participant; - - private MessagingWindow window; // is null if disposed - - private final List<ChatLine> history = new ArrayList<ChatLine>(); - - public ChatSession(Chat chat, String name) { - this.chat = chat; - this.name = name; - this.participant = new JID(chat.getParticipant()); - - // TODO: this method is not exists in the new API version. - chat.addMessageListener(this); // HACK - openWindow(); - } - - public String getName() { - return this.name; - } - - public List<ChatLine> getHistory() { - return this.history; - } - - /** - * @return the participant associated to the chat object. - */ - public JID getParticipant() { - return this.participant; - } - - public void processPacket(Packet packet) { - this.logCH.debug("processPacket called"); - - final Message message = (Message) packet; - - if (message.getBody() == null) { - return; - } - - Display.getDefault().syncExec(new Runnable() { - public void run() { - openWindow(); - - addChatLine(ChatSession.this.name, message.getBody()); - } - }); - } - - public void processMessage(Chat chat, Message message) { - // TODO: new Method for messagelistener - - this.logCH.debug("processMessage called."); - processPacket(message); - - } - - /** - * Opens the chat window for this chat session. Refocuses the window if - * it is already opened. - */ - public void openWindow() { - if (this.window == null) { - this.window = new MessagingWindow(this); - this.window.open(); - } - - this.window.getShell().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - ChatSession.this.window = null; - } - }); - } - - /* - * @see de.fu_berlin.inf.dpp.MessagingManager.SessionProvider - */ - public void sendMessage(String text) { - try { - - Message msg = new Message(); - msg.setBody(text); - // send via muc process - this.chat.sendMessage(msg); - - // for Testing - addChatLine(Saros.getDefault().getMyJID().getName(), text); - - } catch (XMPPException e1) { - e1.printStackTrace(); - addChatLine("error", "Couldn't send message"); - } - } - - private void addChatLine(String sender, String text) { - ChatLine chatLine = new ChatLine(); - chatLine.sender = sender; - chatLine.text = text; - chatLine.date = new Date(); - - this.history.add(chatLine); - this.window.addChatLine(chatLine); - - for (IChatListener chatListener : MessagingManager.this.chatListeners) { - chatListener.chatMessageAdded(sender, text); - } - } - } - - public class MultiChatSession implements SessionProvider, PacketListener, - MessageListener { - private final Logger logCH = Logger.getLogger(ChatSession.class - .getName()); - - private final String name; - - private final MultiUserChat muc; - - private JID participant; - - private MessagingWindow window; // is null if disposed - - private final List<ChatLine> history = new ArrayList<ChatLine>(); - - public MultiChatSession(MultiUserChat muc) { - this.muc = muc; - this.name = "Multi User Chat (" - + Saros.getDefault().getMyJID().getName() + ")"; - muc.addMessageListener(this); - } - - public String getName() { - return this.name; - } - - public List<ChatLine> getHistory() { - return this.history; - } - - /** - * @return the participant associated to the chat object. - */ - public JID getParticipant() { - return this.participant; - } - - public void processPacket(Packet packet) { - this.logCH.debug("processPacket called"); - - final Message message = (Message) packet; - - if (message.getBody() == null) { - return; - } - - // notify chat listener - MessagingManager.log.debug("Notify Listener.."); - for (IChatListener l : MessagingManager.this.chatListeners) { - l.chatMessageAdded(message.getFrom(), message.getBody()); - MessagingManager.log.debug("Notified Listener"); - } - } - - public void processMessage(Chat chat, Message message) { - this.logCH.debug("processMessage called."); - processPacket(message); - } - - /* - * @see de.fu_berlin.inf.dpp.MessagingManager.SessionProvider - */ - public void sendMessage(String text) { - try { - - Message msg = this.muc.createMessage(); - msg.setBody(text); - - if (this.muc != null) { - this.muc.sendMessage(msg); - } - - } catch (XMPPException e1) { - e1.printStackTrace(); - addChatLine("error", "Couldn't send message"); - } - } - - private void addChatLine(String sender, String text) { - ChatLine chatLine = new ChatLine(); - chatLine.sender = sender; - chatLine.text = text; - chatLine.date = new Date(); - - this.history.add(chatLine); - this.window.addChatLine(chatLine); - - for (IChatListener chatListener : MessagingManager.this.chatListeners) { - chatListener.chatMessageAdded(sender, text); - } - } - - } - - /** - * Listener for incoming chat messages. - */ - public interface IChatListener { - public void chatMessageAdded(String sender, String message); - } - - private final List<ChatSession> sessions = new ArrayList<ChatSession>(); - - private MultiChatSession multiSession; - - private final List<IChatListener> chatListeners = new ArrayList<IChatListener>(); - - private MultiChatSession session; - - public MessagingManager() { - Saros.getDefault().addListener(this); - - this.multitrans = new MultiUserChatManager(this.CHAT_ROOM); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - if ((connection != null) && (newState == ConnectionState.NOT_CONNECTED)) { - // TODO CJ Review: connection.removePacketListener(this); - log.debug("unconnect"); - } - - if (newState == ConnectionState.CONNECTED) { - connection.addPacketListener(this, new MessageTypeFilter( - Message.Type.chat)); - initMultiChatListener(); - } - } - - /** - * Since all sessions already handle their incoming messages, this method is - * only to handle incoming chat messages for which no sessions have been yet - * created. If it finds a chat message that belongs to no current session, - * it creates a new session. - * - * @see org.jivesoftware.smack.PacketListener - */ - public void processPacket(Packet packet) { - MessagingManager.log.debug("messagePacket called"); - final Message message = (Message) packet; - final JID jid = new JID(message.getFrom()); - - if (message.getBody() == null) { - return; - } - - /* check for multi or single chat. */ - if (message.getFrom().contains(this.multitrans.getRoomName())) { - - if (this.multiSession == null) { - this.multiSession = new MultiChatSession(this.multitrans - .getMUC()); - this.multiSession.processPacket(message); - } - } else { - /* old chat based message communication. */ - for (ChatSession session : this.sessions) { - if (jid.equals(session.getParticipant())) { - return; // gets already handled by message handler in - // session - } - } - } - } - - public void processMessage(Chat chat, Message message) { - // TODO new method for message notify - MessagingManager.log.debug("processMessage called."); - processPacket(message); - } - - /** - * Adds the chat listener. - */ - public void addChatListener(IChatListener listener) { - this.chatListeners.add(listener); - } - - // TODO CJ Rework needed - public void invitationReceived(XMPPConnection conn, String room, - String inviter, String reason, String password, Message message) { - try { - // System.out.println(conn.getUser()); - if (this.multitrans.getMUC() == null) { - // this.muc = XMPPMultiChatTransmitter.joinMuc(conn, - // Saros.getDefault().getConnection().getUser(), room); - this.multitrans.initMUC(conn, conn.getUser()); - } - // muc.addMessageListener(mucl); - // TODO: check if still connected - if ((this.multiSession == null) - && (this.multitrans.getMUC() != null)) { - // muc.removeMessageListener(mucl); - MultiChatSession session = new MultiChatSession(this.multitrans - .getMUC()); - this.multiSession = session; - } - } catch (XMPPException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * invitation listener for multi chat invitations. - */ - public void initMultiChatListener() { - // listens for MUC invitations - MultiUserChat.addInvitationListener(Saros.getDefault().getConnection(), - this); - } - - public MultiChatSession getSession() { - return this.session; - } - - public void connectMultiUserChat() throws XMPPException { - if (!Saros.getDefault().isConnected()) { - throw new XMPPException("No connection "); - } - String user = Saros.getDefault().getConnection().getUser(); - if (this.session == null) { - MultiUserChat muc = this.multitrans.getMUC(); - if (muc == null) { - this.multitrans.initMUC(Saros.getDefault().getConnection(), - user); - muc = this.multitrans.getMUC(); - } - MessagingManager.log.debug("Creating MUC session.."); - this.session = new MultiChatSession(muc); - } else { - this.multitrans.getMUC().join(user); - } - } - - public void disconnectMultiUserChat() throws XMPPException { - MessagingManager.log.debug("Leaving MUC session.."); - this.multitrans.getMUC().leave(); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceConstants.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceConstants.java deleted file mode 100644 index ef28a95ccd171791b059982fd1fc0afedbb74eea..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceConstants.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -/** - * Constant definitions for plug-in preferences - * - * @author rdjemili - * @author coezbek - */ -public class PreferenceConstants { - - public static final String SERVER = "server"; - - public static final String USERNAME = "username"; - - public static final String PASSWORD = "password"; - - public static final String AUTO_CONNECT = "autoconnect"; - - public static final String AUTO_FOLLOW_MODE = "autofollowmode"; - - public static final String SKYPE_USERNAME = "skypename"; - - public static final String DEBUG = "debug"; - - public static final String FILE_TRANSFER_PORT = "port"; - - public static final String FORCE_FILETRANSFER_BY_CHAT = "chatfiletransfer"; - - public static final String CHATFILETRANSFER_CHUNKSIZE = "chatfiletransfer_chunksize"; - - // public static final String STUN = "stun_server"; - // public static final String STUN_PORT = "stun_server_port"; - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceInitializer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceInitializer.java deleted file mode 100644 index 4ed6d69cedb5cc77d903dc00406d7e7e6cb0399c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/PreferenceInitializer.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * Class used to initialize default preference values. - * - * @author rdjemili - */ -public class PreferenceInitializer extends AbstractPreferenceInitializer { - - /* - * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer - */ - @Override - public void initializeDefaultPreferences() { - IPreferenceStore store = Saros.getDefault().getPreferenceStore(); - store.setDefault(PreferenceConstants.SERVER, "jabber.org"); - store.setDefault(PreferenceConstants.USERNAME, ""); - store.setDefault(PreferenceConstants.PASSWORD, ""); - - store.setDefault(PreferenceConstants.AUTO_CONNECT, false); - store.setDefault(PreferenceConstants.AUTO_FOLLOW_MODE, true); - store.setDefault(PreferenceConstants.SKYPE_USERNAME, ""); - store.setDefault(PreferenceConstants.DEBUG, false); - store.setDefault(PreferenceConstants.FILE_TRANSFER_PORT, 7777); - store.setDefault(PreferenceConstants.FORCE_FILETRANSFER_BY_CHAT, false); - store.setDefault(PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE, 50000); - // store.setDefault(PreferenceConstants.STUN, "stun.xten.net"); - // store.setDefault(PreferenceConstants.STUN_PORT, 3478); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/Saros.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/Saros.java deleted file mode 100644 index f120af28ea7562f5636eb697b0bc665ddcbb8061..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/Saros.java +++ /dev/null @@ -1,530 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import java.awt.Toolkit; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.jivesoftware.smack.ConnectionConfiguration; -import org.jivesoftware.smack.ConnectionListener; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.SASLAuthentication; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.Roster.SubscriptionMode; -import org.jivesoftware.smackx.ServiceDiscoveryManager; -import org.osgi.framework.BundleContext; - -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.PacketExtensions; -import de.fu_berlin.inf.dpp.project.ActivityRegistry; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.SessionManager; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * The main plug-in of Saros. - * - * @author rdjemili - * @author coezbek - */ -public class Saros extends AbstractUIPlugin { - - public static enum ConnectionState { - NOT_CONNECTED, CONNECTING, CONNECTED, DISCONNECTING, ERROR - }; - - // The shared instance. - private static Saros plugin; - - public static final String SAROS = "de.fu_berlin.inf.dpp"; //$NON-NLS-1$ - - private static SarosUI uiInstance; - - private XMPPConnection connection; - - private JID myjid; - - private ConnectionState connectionState = ConnectionState.NOT_CONNECTED; - - private String connectionError; - - private MessagingManager messagingManager; - - private ISessionManager sessionManager; - - private final List<IConnectionListener> listeners = new CopyOnWriteArrayList<IConnectionListener>(); - - // Smack (XMPP) connection listener - private final ConnectionListener smackConnectionListener = new XMPPConnectionListener(); - - private Logger logger; - - static { - PacketExtensions.hookExtensionProviders(); - Roster.setDefaultSubscriptionMode(SubscriptionMode.accept_all); - } - - /** - * Create the shared instance. - */ - public Saros() { - Saros.plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - XMPPConnection.DEBUG_ENABLED = getPreferenceStore().getBoolean( - PreferenceConstants.DEBUG); - - setupLoggers(); - - this.messagingManager = new MessagingManager(); - this.sessionManager = new SessionManager(); - - ActivityRegistry.getDefault(); - SkypeManager.getDefault(); - - Saros.uiInstance = new SarosUI(this.sessionManager); - - boolean hasUserName = getPreferenceStore().getString( - PreferenceConstants.USERNAME).length() > 0; - - if (getPreferenceStore().getBoolean(PreferenceConstants.AUTO_CONNECT) - && hasUserName) { - asyncConnect(); - } - } - - /** - * This method is called when the plug-in is stopped - */ - @Override - public void stop(BundleContext context) throws Exception { - super.stop(context); - - this.sessionManager.leaveSession(); - disconnect(null); - - Saros.plugin = null; - } - - /** - * Returns the shared instance. - * - * @return the shared instance. - */ - public static Saros getDefault() { - return Saros.plugin; - } - - public JID getMyJID() { - return this.myjid; - } - - public Roster getRoster() { - if (!isConnected()) { - return null; - } - - return this.connection.getRoster(); - } - - /** - * @return the MessagingManager which is responsible for handling instant - * messaging. Is never <code>null</code>. - */ - public MessagingManager getMessagingManager() { - return this.messagingManager; - } - - /** - * @return the SessionManager. Is never <code>null</code>. - */ - public ISessionManager getSessionManager() { - return this.sessionManager; - } - - public void asyncConnect() { - new Thread(new Runnable() { - public void run() { - connect(); - } - }).start(); - } - - /** - * Connects according to the preferences. This is a blocking method. - * - * If there is already a established connection when calling this method, it - * disconnects before connecting. - */ - public void connect() { - - IPreferenceStore prefStore = getPreferenceStore(); - final String server = prefStore.getString(PreferenceConstants.SERVER); - final String username = prefStore - .getString(PreferenceConstants.USERNAME); - String password = prefStore.getString(PreferenceConstants.PASSWORD); - - try { - if (isConnected()) { - - this.connection.disconnect(); - this.connection - .removeConnectionListener(this.smackConnectionListener); - } - - ConnectionConfiguration conConfig = new ConnectionConfiguration( - server); - conConfig.setReconnectionAllowed(true); - - this.connection = new XMPPConnection(conConfig); - this.connection.connect(); - - // have to put this line to use new smack 3.1 - // without this line a NullPointerException happens but after a - // longer time it connects anyway, with this line it connects fast - // TODO: security issue? - SASLAuthentication.supportSASLMechanism("PLAIN", 0); - - this.connection.login(username, password); - - this.connection.getRoster().setSubscriptionMode( - SubscriptionMode.manual); - - this.connection.addConnectionListener(this.smackConnectionListener); - setConnectionState(ConnectionState.CONNECTED, null); - - this.myjid = new JID(this.connection.getUser()); - - } catch (final Exception e) { - - setConnectionState(ConnectionState.ERROR, e.getMessage()); - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog - .openError(Display.getDefault().getActiveShell(), - "Error Connecting", - "Could not connect to server '" + server - + "' as user '" + username - + "'.\nErrorMessage was: " - + e.getMessage()); - } - }); - } - } - - /** - * Disconnects. This is a blocking method. - * - * @param reason - * the error why the connection was closed. If the connection was - * not closed due to an error <code>null</code> should be passed. - */ - public void disconnect(String error) { - setConnectionState(ConnectionState.DISCONNECTING, error); - - if (this.connection != null) { - // leave running session before disconnecting - getSessionManager().leaveSession(); - - this.connection - .removeConnectionListener(this.smackConnectionListener); - - this.connection.disconnect(); - this.connection = null; - } - - setConnectionState(error == null ? ConnectionState.NOT_CONNECTED - : ConnectionState.ERROR, error); - - this.myjid = null; - - } - - /** - * Creates the given account on the given Jabber server. This is a blocking - * method. - * - * @param server - * the server on which to create the account. - * @param username - * the username for the new account. - * @param password - * the password for the new account. - * @param monitor - * the progressmonitor for the operation. - * @throws XMPPException - * exception that occcurs while registering. - */ - public void createAccount(String server, String username, String password, - IProgressMonitor monitor) throws XMPPException { - - monitor.beginTask("Registering account", 3); - - XMPPConnection connection = new XMPPConnection(server); - monitor.worked(1); - - connection.connect(); - monitor.worked(1); - - connection.getAccountManager().createAccount(username, password); - monitor.worked(1); - - connection.disconnect(); - monitor.done(); - } - - /** - * Adds given contact to the roster. This is a blocking method. - * - * @param jid - * the Jabber ID of the contact. - * @param nickname - * the nickname under which the new contact should appear in the - * roster. - * @param groups - * the groups to which the new contact should belong to. This - * information will be saved on the server. - * @throws XMPPException - * is thrown if no connection is established or the contact - * doesn't exist - */ - public void addContact(JID jid, String nickname, String[] groups) - throws XMPPException { - assertConnection(); - - // if roster already contains user with this jid do nothing - if (connection.getRoster().contains(jid.toString())) { - return; - } - - // if discovering user information is successful add contact to - // roster - ServiceDiscoveryManager sdm = new ServiceDiscoveryManager(connection); - try { - if (sdm.discoverInfo(jid.toString()).getIdentities().hasNext()) { - connection.getRoster().createEntry(jid.toString(), nickname, - groups); - } - } catch (XMPPException e) { - // if server doesn't support to get information add contact - // anyway (if entry would't exist it should be an error 404) - if (e.getMessage().contains("501"))/* feature-not-implemented */{ - connection.getRoster().createEntry(jid.toString(), nickname, - groups); - } else - throw e; - } - } - - /** - * Removes given contact from the roster. This is a blocking method. - * - * @param rosterEntry - * the contact that is to be removed - * @throws XMPPException - * is thrown if no connection is establised. - */ - public void removeContact(RosterEntry rosterEntry) throws XMPPException { - assertConnection(); - this.connection.getRoster().removeEntry(rosterEntry); - } - - public boolean isConnected() { - return (this.connection != null) && this.connection.isConnected(); - } - - /** - * @return the current state of the connection. - */ - public ConnectionState getConnectionState() { - return this.connectionState; - } - - /** - * @return an error string that contains the error message for the current - * connection error if the state is {@link ConnectionState.ERROR} or - * <code>null</code> if there is another state set. - */ - public String getConnectionError() { - return this.connectionError; - } - - /** - * @return the currently established connection or <code>null</code> if - * there is none. - */ - public XMPPConnection getConnection() { - return this.connection; - } - - public void addListener(IConnectionListener listener) { - if (!this.listeners.contains(listener)) { - this.listeners.add(listener); - } - } - - public void removeListener(IConnectionListener listener) { - this.listeners.remove(listener); - } - - private void assertConnection() throws XMPPException { - if (!isConnected()) { - throw new XMPPException("No connection"); - } - } - - /** - * Sets a new connection state and notifies all connection listeners. - */ - private void setConnectionState(ConnectionState state, String error) { - this.connectionState = state; - this.connectionError = error; - - for (IConnectionListener listener : this.listeners) { - listener.connectionStateChanged(this.connection, state); - } - } - - private void setupLoggers() { - try { - - PropertyConfigurator.configureAndWatch("log4j.properties", - 60 * 1000); - logger = Logger.getLogger("de.fu_berlin.inf.dpp"); - - } catch (SecurityException e) { - e.printStackTrace(); - } - } - - /** - * Log a message to the Eclipse ErrorLog. This method should be used to log - * all errors that occur in the plugin that cannot be corrected by the user - * and seem to be errors within the plug-in or the used libraries. - * - * @param message - * A meaningful description of during which operation the error - * occurred - * @param e - * The exception associated with the error (may be null) - */ - public static void log(String message, Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, message, - e)); - } - - private class XMPPConnectionListener implements ConnectionListener { - - public void connectionClosed() { - // self inflicted, controlled disconnect - setConnectionState(ConnectionState.NOT_CONNECTED, null); - } - - public void connectionClosedOnError(Exception e) { - - Toolkit.getDefaultToolkit().beep(); - logger.error("XMPP Connection Error: " + e.toString()); - - disconnect("XMPP Connection Error"); - - if (e.toString().equals("stream:error (conflict)")) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog - .openError( - Display.getDefault().getActiveShell(), - "Connection error", - "There is a conflict with the jabber connection." - + "The reason for this is mostly that another saros " - + "instance have connected with the same login."); - } - }); - - } else { - new Thread(new Runnable() { - - public void run() { - - int offlineAtTS = 0; - if (Saros.this.sessionManager.getSharedProject() != null) { - offlineAtTS = Saros.this.sessionManager - .getSharedProject().getSequencer() - .getTimestamp(); - } - - try { - do { - connect(); - - if (!Saros.this.connection.isConnected()) { - Thread.sleep(5000); - } - - } while (!Saros.this.connection.isConnected()); - - Saros.this.sessionManager.OnReconnect(offlineAtTS); - setConnectionState(ConnectionState.CONNECTED, null); - logger.debug("XMPP reconnected"); - - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }).start(); - } - } - - public void reconnectingIn(int seconds) { - logger.debug("saros reconnecting"); - setConnectionState(ConnectionState.CONNECTING, null); - } - - public void reconnectionFailed(Exception e) { - logger.debug("saros reconnection failed"); - setConnectionState(ConnectionState.ERROR, e.getMessage()); - } - - public void reconnectionSuccessful() { - logger.debug("saros reconnection successful"); - setConnectionState(ConnectionState.CONNECTED, null); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/SkypeManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/SkypeManager.java deleted file mode 100644 index 3bbf726e64b2ab6be90ace3a717b892b2fe4787c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/SkypeManager.java +++ /dev/null @@ -1,149 +0,0 @@ -package de.fu_berlin.inf.dpp; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.jivesoftware.smack.PacketCollector; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.filter.IQTypeFilter; -import org.jivesoftware.smack.filter.PacketIDFilter; -import org.jivesoftware.smack.packet.IQ; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.provider.ProviderManager; - -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.SkypeIQ; - -/** - * A manager class that allows to discover if a given XMPP entity supports Skype - * and that allows to initiate Skype VOiP sessions with that entity. - * - * @author rdjemili - */ -public class SkypeManager implements IConnectionListener { - private static SkypeManager instance; - - private final Map<JID, String> skypeNames = new HashMap<JID, String>(); - - private SkypeManager() { - Saros.getDefault().addListener(this); - ProviderManager providermanager = ProviderManager.getInstance(); - providermanager - .addIQProvider("query", "jabber:iq:skype", SkypeIQ.class); - } - - public static SkypeManager getDefault() { - if (SkypeManager.instance == null) { - SkypeManager.instance = new SkypeManager(); - } - - return SkypeManager.instance; - } - - /** - * Returns the Skype-URL for given roster entry. - * - * @return the skype url for given roster entry or <code>null</code> if - * roster entry has no skype name. - */ - public String getSkypeURL(RosterEntry rosterEntry) { - XMPPConnection connection = Saros.getDefault().getConnection(); - JID jid = new JID(rosterEntry.getUser()); - - String name; - if (this.skypeNames.containsKey(jid)) { - name = this.skypeNames.get(jid); - - } else { - name = SkypeManager.requestSkypeName(connection, jid); - this.skypeNames.put(jid, name); - } - - return name == null ? null : "skype:" + name; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IConnectionListener - */ - public void connectionStateChanged(final XMPPConnection connection, - ConnectionState newState) { - - if (newState == ConnectionState.CONNECTED) { - connection.addPacketListener(new PacketListener() { - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.PacketListener - */ - public void processPacket(Packet packet) { - if (packet instanceof SkypeIQ) { - SkypeIQ iq = (SkypeIQ) packet; - - SkypeIQ result = new SkypeIQ(); - result.setType(IQ.Type.RESULT); - result.setPacketID(iq.getPacketID()); - result.setTo(iq.getFrom()); // HACK - result.setName(getLocalSkypeName()); - - connection.sendPacket(result); - } - } - }, new IQTypeFilter(IQ.Type.GET)); - } - } - - /** - * @return the local skype name or <code>null</code> if none is set. - */ - private String getLocalSkypeName() { - IPreferenceStore prefs = Saros.getDefault().getPreferenceStore(); - return prefs.getString(PreferenceConstants.SKYPE_USERNAME); - } - - /** - * Requests the Skype user name of given user. This method blocks up to 5 - * seconds to receive the value. - * - * @param connection - * @param user - * the user for which the Skype name is requested. - * @return the Skype user name of given user or <code>null</code> if the - * user doesn't respond in time or has no Skype name. - */ - private static String requestSkypeName(XMPPConnection connection, JID user) { - if ((connection == null) || !connection.isConnected()) { - return null; - } - - // Request the time from a remote user. - SkypeIQ request = new SkypeIQ(); - - request.setType(IQ.Type.GET); - request.setTo(user.toString() + "/Smack"); // HACK - - // Create a packet collector to listen for a response. - PacketCollector collector = connection - .createPacketCollector(new PacketIDFilter(request.getPacketID())); - - connection.sendPacket(request); - - // Wait up to 5 seconds for a result. - IQ result = (IQ) collector.nextResult(5000); - if ((result != null) && (result.getType() == IQ.Type.RESULT)) { - SkypeIQ skypeResult = (SkypeIQ) result; - - return skypeResult.getName().length() == 0 ? null : skypeResult - .getName(); - } - - return null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/User.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/User.java deleted file mode 100644 index ed04de3cc95897cb726aacd61c81cd8ff87bf418..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/User.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp; - -import de.fu_berlin.inf.dpp.net.JID; - -public class User { - public enum UserConnectionState { - UNKNOWN, ONLINE, OFFLINE - }; - - public enum UserRole { - DRIVER, OBSERVER - }; - - private UserConnectionState presence = UserConnectionState.UNKNOWN; - - private final JID jid; - private int colorid = 0; - private long offlineTime = 0; - private UserRole role = UserRole.OBSERVER; - - public User(JID jid) { - this.jid = jid; - } - - public JID getJid() { - return this.jid; - } - - /** - * set the current user role of this user inside the current project. - * - * @param role - * (Driver, Observer) - */ - public void setUserRole(UserRole role) { - this.role = role; - } - - /** - * Gets current project role of this user. - * - * @return role (Driver, Observer) - */ - public UserRole getUserRole() { - return this.role; - } - - @Override - public String toString() { - return this.jid.getName(); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof User) { - User other = (User) obj; - return this.jid.equals(other.jid); - } - - return false; - } - - public int getColorID() { - return this.colorid; - } - - public void setColorID(int c) { - this.colorid = c; - } - - public UserConnectionState getPresence() { - return this.presence; - } - - public void setPresence(UserConnectionState p) { - this.presence = p; - if (this.presence == User.UserConnectionState.OFFLINE) { - this.offlineTime = (new java.util.Date().getTime()); - } - } - - public int getOfflineSecs() { - return (int) (((new java.util.Date().getTime()) - this.offlineTime) / 1000); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/EditorActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/EditorActivity.java deleted file mode 100644 index d29350f3a506691db877ba6f9c5e3c7717e905d6..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/EditorActivity.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -/** - * A text load activity activates a new resource. If the path is - * <code>null</code> no resouce is currently active. - * - * @author rdjemili - */ -public class EditorActivity implements IActivity { - public static enum Type { - Activated, Closed, Saved - }; - - private final Type type; - - private final IPath path; - - private String source; - - private long checksum = -1; - - /** - * @param path - * a valid project-relative path or <code>null</code> if former - * resource should be deactivated. - */ - public EditorActivity(Type type, IPath path) { - if ((type != Type.Activated) && (path == null)) { - throw new IllegalArgumentException( - "Null path for non-activation type editor activity given."); - } - - this.type = type; - this.path = path; - } - - /** - * @return the project-relative path to the resource that should be - * activated. - */ - public IPath getPath() { - return this.path; - } - - public Type getType() { - return this.type; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof EditorActivity)) { - return false; - } - - EditorActivity other = (EditorActivity) obj; - return (((this.path == null) && (other.path == null)) || this.path - .equals(other.path)) - && this.type.equals(other.type); - } - - @Override - public String toString() { - return "EditorActivity(type:" + this.type + ", path:" + this.path + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } - - public long getChecksum() { - return this.checksum; - } - - public void setChecksum(long checksum) { - this.checksum = checksum; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FileActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FileActivity.java deleted file mode 100644 index 96fe8ace4ef16f357a854f8cf0d0fea8cb85a982..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FileActivity.java +++ /dev/null @@ -1,91 +0,0 @@ -package de.fu_berlin.inf.dpp.activities; - -import java.io.InputStream; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.net.JID; - -public class FileActivity implements IActivity { - public static enum Type { - Created, Removed, Error - }; - - private String source; - - private final Type type; - - private final IPath path; - - /* exclusive file recipient for error file. */ - private JID errorRecipient; - - private InputStream inputStream; - - public FileActivity(Type type, IPath path) { - this.type = type; - this.path = path; - } - - /** - * construtor to send file activity to an exclusive recipient. - * - * @param type - * @param path - * @param to - */ - public FileActivity(Type type, IPath path, JID to) { - this(type, path); - this.errorRecipient = to; - } - - public FileActivity(Type type, IPath path, InputStream in) { - this(type, path); - this.inputStream = in; - } - - public IPath getPath() { - return this.path; - } - - public Type getType() { - return this.type; - } - - public JID getRecipient() { - return this.errorRecipient; - } - - /** - * @return the inputStream for the contents of this file for incoming file - * creation activities. <code>null</code> otherwise. - */ - public InputStream getContents() { - return this.inputStream; - } - - @Override - public String toString() { - return "FileActivity(type:" + this.type + ", path:" + this.path + ")"; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof FileActivity) { - FileActivity activity = (FileActivity) obj; - - return (getPath().equals(activity.getPath()) && getType().equals( - activity.getType())); - } - - return false; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FolderActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FolderActivity.java deleted file mode 100644 index 9e50e1853901f4d3e35ed125e2b847e93293cb1e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/FolderActivity.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -public class FolderActivity implements IActivity { - public static enum Type { - Created, Removed - }; - - private String source; - - private final Type type; - - private final IPath path; - - public FolderActivity(Type type, IPath path) { - this.type = type; - this.path = path; - } - - public IPath getPath() { - return this.path; - } - - public Type getType() { - return this.type; - } - - @Override - public String toString() { - return "FolderActivity(type:" + this.type + ", path:" + this.path + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/IActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/IActivity.java deleted file mode 100644 index 23ed4677eb2ba81c9adb96e71f809d5321b0c5ff..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/IActivity.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -/** - * A generic interface for activities that happen in sessions. All activities - * should be implemented by the value patter, i.e. created activities are - * immutable- - * - * @author rdjemili - */ -public interface IActivity { - - /** - * set source jabber_id of producer of this IActivity. - * - * @param source - * jabber_id string - */ - public void setSource(String source); - - /** - * get jabber_id of remote producer - * - * @return jabber_id - */ - public String getSource(); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/RoleActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/RoleActivity.java deleted file mode 100644 index 534ebd53f731623300aa715e58a05735cfb7d0c3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/RoleActivity.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import de.fu_berlin.inf.dpp.net.JID; - -public class RoleActivity implements IActivity { - - private String source; - - private final JID driver; - - public RoleActivity(JID newDriver) { - this.driver = newDriver; - } - - public JID getDriver() { - return this.driver; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof RoleActivity) { - RoleActivity driverChange = (RoleActivity) obj; - - return driverChange.getDriver().equals(this.driver); - } - - return false; - } - - @Override - public String toString() { - return "RoleActivity(driver:" + this.driver + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextEditActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextEditActivity.java deleted file mode 100644 index 463d27f2ff04eadbdfe11459bb53c4ebd47e9972..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextEditActivity.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -/** - * A simple immutable text activity. - * - * @author rdjemili - */ -public class TextEditActivity implements IActivity { - public final int offset; - - private String source; - - private IPath editor; - /** - * This string only uses \n as line delimiter. Keep this in mind when adding - * it to an IDocument with probably other line delimiters. - */ - public String text; - - public final int replace; - - /** - * @param offset - * the offset inside the document where this activity happend. - * @param text - * the text that was inserted. - * @param replace - * the length of text that was replaced by this activity. - * @param source - * the source ID of this activity - */ - public TextEditActivity(int offset, String text, int replace) { - this.offset = offset; - this.text = text; - this.replace = replace; - this.source = null; - } - - /** - * @param offset - * the offset inside the document where this activity happend. - * @param text - * the text that was inserted. - * @param replace - * the length of text that was replaced by this activity. - * @param source - * the source ID of this activity - */ - public TextEditActivity(int offset, String text, int replace, IPath editor) { - this.offset = offset; - this.text = text; - this.replace = replace; - this.source = null; - this.editor = editor; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof TextEditActivity) { - TextEditActivity other = (TextEditActivity) obj; - return (this.offset == other.offset) - && this.text.equals(other.text) - && (this.replace == other.replace) - && (this.source == other.source); - } - - return false; - } - - @Override - public String toString() { - return "TextEditActivity(offset:" + this.offset + ",text:" + this.text - + ",replace:" + this.replace + ", path : " - + this.editor.toString() + ")"; - } - - /** - * Compare text edit information without source settings. - * - * @param obj - * TextEditActivity Object - * @return true if edit information equals. false otherwise. - */ - public boolean sameLike(Object obj) { - if (obj instanceof TextEditActivity) { - TextEditActivity other = (TextEditActivity) obj; - return (this.offset == other.offset) - && ((this.editor != null) && (other.editor != null) && this.editor - .equals(other.editor)) - && this.text.equals(other.text) - && (this.replace == other.replace); - } - return false; - } - - public IPath getEditor() { - return this.editor; - } - - public void setEditor(IPath editor) { - this.editor = editor; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextSelectionActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextSelectionActivity.java deleted file mode 100644 index c2738634081fa7594037f4b85aad230e08f3dc57..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/TextSelectionActivity.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -public class TextSelectionActivity implements IActivity { - private final int offset; - - private final int length; - - private String source; - - private IPath editor; - - public TextSelectionActivity(int offset, int length, IPath path) { - this.offset = offset; - this.length = length; - this.source = null; - this.editor = path; - } - - public int getLength() { - return this.length; - } - - public int getOffset() { - return this.offset; - } - - public IPath getEditor() { - return this.editor; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof TextSelectionActivity) { - TextSelectionActivity activity = (TextSelectionActivity) obj; - return (this.offset == activity.offset) - && (this.length == activity.length) - && (this.source == activity.source) - && (this.editor == activity.editor); - } - - return false; - } - - @Override - public String toString() { - return "TextSelectionActivity(offset:" + this.offset + ", length:" - + this.length + ", " + this.editor + ")"; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/ViewportActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/ViewportActivity.java deleted file mode 100644 index 1af4a6b19ebb436f9a740d978797c7afc5596c5d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/activities/ViewportActivity.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.fu_berlin.inf.dpp.activities; - -import org.eclipse.core.runtime.IPath; - -public class ViewportActivity implements IActivity { - public final int topIndex; - - public final int bottomIndex; - - private String source; - - private IPath editor; - - public ViewportActivity(int topIndex, int bottomIndex, IPath editor) { - this.topIndex = topIndex; - this.bottomIndex = bottomIndex; - this.editor = editor; - } - - public int getBottomIndex() { - return this.bottomIndex; - } - - public int getTopIndex() { - return this.topIndex; - } - - public IPath getEditor() { - return this.editor; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof ViewportActivity) { - ViewportActivity other = (ViewportActivity) obj; - return (this.topIndex == other.topIndex) - && (this.bottomIndex == other.bottomIndex); - } - - return false; - } - - @Override - public String toString() { - return "ViewportActivity(top:" + this.topIndex + ",bottom:" - + this.bottomIndex + ")"; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/ConcurrentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/ConcurrentManager.java deleted file mode 100644 index 66ba311648031d7448b142586ec250c8257163ad..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/ConcurrentManager.java +++ /dev/null @@ -1,47 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -/** - * Interface for management controller class of all jupiter document server. - * - * @author orieger - * - */ -public interface ConcurrentManager extends IRequestManager, - ISharedProjectListener { - - public static enum Side { - CLIENT_SIDE, HOST_SIDE - } - - public void setActivitySequencer(IActivitySequencer sequencer); - - public void setRequestForwarder(RequestForwarder f); - - public RequestForwarder getRequestForwarder(); - - public boolean isHostSide(); - - public boolean isHost(JID jid); - - public void setHost(JID jid); - - public IActivity activityCreated(IActivity activity); - - public IActivity exec(IActivity activity); - - /** - * reset jupter state vector an init with [0,0] - * - * @param path - * of document under jupiter control. - */ - public void resetJupiterDocument(IPath path); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverDocumentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverDocumentManager.java deleted file mode 100644 index 963d6818fcb4f039a807324d6aad75b33a258ea9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverDocumentManager.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import java.util.List; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -public interface IDriverDocumentManager extends IDriverManager, - ISharedProjectListener { - - public void receiveActivity(IActivity activity); - - public void addDriverToDocument(IPath path, JID jid); - - /** - * get driver for the appropriate document. - * - * @param path - * to document - * @return list of active driver on document. - */ - public List<JID> getDriverForDocument(IPath path); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverManager.java deleted file mode 100644 index af2dba3d5cd0df10ee5c9182aab867bac8b06a12..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IDriverManager.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import java.util.List; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * This interface handles the driver event and the appropriate documents. - * - * @author orieger - * - */ -public interface IDriverManager { - - public void addDriver(JID jid); - - public void removeDriver(JID jid); - - public boolean isDriver(JID jid); - - /** - * only one active driver exists in the system. - * - * @return - */ - public boolean exclusiveDriver(); - - /** - * get all active driver - * - * @return list of active driver. - */ - public List<JID> getActiveDriver(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IRequestManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IRequestManager.java deleted file mode 100644 index 2c0e3d95bbc7d3fc6601599fd6375fc8c607f03c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/IRequestManager.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; - -/** - * received request from other clients over network. - * - * @author orieger - * - */ -public interface IRequestManager { - - public void receiveRequest(Request request); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Algorithm.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Algorithm.java deleted file mode 100644 index f4cf2be49f78c97725a8520bfb4f709fc03b84fb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Algorithm.java +++ /dev/null @@ -1,74 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -public interface Algorithm { - - /** - * Gets the site id of this algorithm. - * - * @return the site id - */ - int getSiteId(); - - /** - * Gets the current timestamp at the local site. - * - * @return the current timestamp - */ - Timestamp getTimestamp(); - - /** - * Generates a request for the given operation. The operation is a locally - * generated operation. The returned request must be sent to the other - * sites. - * - * @param op - * the operation for which a request should be generated - * @return the generated request - * @see Request - */ - Request generateRequest(Operation op); - - /** - * Receives a request from a remote site. The request must be transformed - * and the resulting operation is returned. - * - * @param req - * the request to transform and apply - * @return the transformed Operation - */ - Operation receiveRequest(Request req) throws TransformationException; - - /** - * Notifies the algorithm that the site specified by the site id has - * processed the number of messages in the timestamp. - * - * @param siteId - * the site id of the sending site - * @param timestamp - * the timestamp at the other site - * @throws TransformationException - */ - void acknowledge(int siteId, Timestamp timestamp) - throws TransformationException; - - /** - * Transform the array of indices from the state indicated by the timestamp - * to the current timestamp at the local site. The transformed indices are - * returned to the client. - * - * @param timestamp - * the timestamp at which the indices are valid - * @param indices - * the array of integer indices - * @return the transformed array of indices - */ - int[] transformIndices(Timestamp timestamp, int[] indices) - throws TransformationException; - - /** - * - * @param timestamp - * @throws TransformationException - */ - void updateVectorTime(Timestamp timestamp) throws TransformationException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/InclusionTransformation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/InclusionTransformation.java deleted file mode 100644 index b3e06a5f9b090c3abe2247777a388d73cd13ba4a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/InclusionTransformation.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * $Id: InclusionTransformation.java 2430 2005-12-11 15:17:11Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * Interface for inclusion transformation functions. - */ -public interface InclusionTransformation { - - /** - * Include operation <var>op2</var> into the context of operation - * <var>op1</var>. The transformed operation <var>op1'</var> is returned. - * - * @param op1 - * the operation into which another is to be contextually - * included. - * @param op2 - * the operation to be included. - * @param param - * an additional parameter depending on the implementation. - * @return the transformed operation <var>op1'</var> - */ - public Operation transform(Operation op1, Operation op2, Object param); - - /** - * Transforms an index against the given operation. - * - * @param index - * the index to be transformed - * @param op - * the Operation to be transformed - * @param param - * an additional implementation dependent parameter - * @return the transformed index - */ - public int transformIndex(int index, Operation op, Object param); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterClient.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterClient.java deleted file mode 100644 index b3cbc4d98eb17c71bec6d2311971e78e58eca1e3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterClient.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import de.fu_berlin.inf.dpp.net.JID; - -public interface JupiterClient extends JupiterEditor { - - public Request generateRequest(Operation op); - - public Operation receiveRequest(Request req) throws TransformationException; - - /** - * get the jid of the appropriate client. - * - * @return - */ - public JID getJID(); - - /** - * get the current vector time. - * - * @return - */ - public Timestamp getTimestamp(); - - public void updateVectorTime(Timestamp timestamp) - throws TransformationException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterEditor.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterEditor.java deleted file mode 100644 index 2865968a10882663361a221f635fe7d096e681c9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterEditor.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import org.eclipse.core.runtime.IPath; - -/** - * interface for jupiter editor settings. - * - * @author orieger - * - */ -public interface JupiterEditor { - - public void setEditor(IPath path); - - public IPath getEditor(); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterServer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterServer.java deleted file mode 100644 index 13b03a1095ef6b8c966c520d0bd9c7d2708d4107..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/JupiterServer.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.util.HashMap; - -import de.fu_berlin.inf.dpp.net.JID; - -public interface JupiterServer extends SynchronizedQueue, RequestForwarder, - JupiterEditor { - - public void addProxyClient(JID jid); - - public void removeProxyClient(JID jid); - - /** - * get current document proxies. - * - * @return - * @throws InterruptedException - */ - public HashMap<JID, JupiterClient> getProxies() throws InterruptedException; - - /** - * get exist state of proxy client for given jid. - * - * @param jid - * @return - */ - public boolean isExist(JID jid); - - public void updateVectorTime(JID source, JID dest); - - public void transformationErrorOccured(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Operation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Operation.java deleted file mode 100644 index 1ded37f968c5c7113d0db3e6a2c5b3f5494dcedc..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Operation.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.io.Serializable; - -/** - * This interface must be implemented by all operations. An operation is - * application dependent and therefore this interface does not contain any - * specific methods at all. - */ -public interface Operation extends Serializable { - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/OperationSerializer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/OperationSerializer.java deleted file mode 100644 index 2dba025d0758aa9c4a7fd80c5d7fcea8cd118bb5..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/OperationSerializer.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * - * @author rieger - * - */ -public interface OperationSerializer { - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Request.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Request.java deleted file mode 100644 index 87b7c32a3cd259ba20bea7ba2994431e768ebd52..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Request.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * $Id: Request.java 2430 2005-12-11 15:17:11Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.io.Serializable; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * This interface represents a request. Requests are typically sent over the - * network to other sites. A request consists at least of the identifier of the - * sending site, an operation and a timestamp that specifies the definition - * context of the operation. - * - */ -public interface Request extends Serializable { - - /** - * Gets the identifier of the sending site. - * - * @return the identifier of the sending site - */ - public int getSiteId(); - - /** - * Gets the operation to be propagated. - * - * @return the operation - */ - public Operation getOperation(); - - /** - * Gets the timestamp that specifies the definition context of the enclosed - * operation. - * - * @return the timestamp of the definition context - */ - public Timestamp getTimestamp(); - - /** - * Gets the jid of the appropriate client site. - * - * @return the jid of the client - */ - public JID getJID(); - - public void setJID(JID jid); - - public IPath getEditorPath(); - - public void setEditorPath(IPath editor); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/RequestForwarder.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/RequestForwarder.java deleted file mode 100644 index 66793977e04f951a358486933070686d680f17a3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/RequestForwarder.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -public interface RequestForwarder { - - /** - * Add generate request for transfering via network. - * - * @param req - */ - public void forwardOutgoingRequest(Request req); - - /** - * get next request for transfer. - * - * @return - * @throws InterruptedException - */ - public Request getNextOutgoingRequest() throws InterruptedException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/SynchronizedQueue.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/SynchronizedQueue.java deleted file mode 100644 index e3d6743f7594fa44bc8f97408dec0502ad29be14..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/SynchronizedQueue.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -public interface SynchronizedQueue { - - /** - * add request to synchronized queue. - * - * @param request - * the new request. - */ - public void addRequest(Request request); - - /** - * Gets first request in queue. - * - * @return - * @throws InterruptedException - */ - public Request getNextRequestInSynchronizedQueue() - throws InterruptedException; -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Timestamp.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Timestamp.java deleted file mode 100644 index 6813fb2bc9a4dd083cbc643a851dc0aab3be080d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/Timestamp.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * $Id: Timestamp.java 747 2005-10-21 13:31:38Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -import java.io.Serializable; - -/** - * This interface represents the concept of a timestamp. Timestamps is a general - * concept, so this interface remains empty. - * - * @see ch.iserver.ace.algorithm.VectorTime - */ -public interface Timestamp extends Serializable { - - /** - * Retrieves the components of the timestamp as an int array. The exact - * representation is up to the concrete Timestamp implementation. - * - * @return the components of the Timestamp implementation - */ - int[] getComponents(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TimestampFactory.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TimestampFactory.java deleted file mode 100644 index fd5aab1bd64752ef059ec74dd618bc60420227e2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TimestampFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * $Id: TimestampFactory.java 749 2005-10-21 13:51:56Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * TimestampFactory is a factory that can create Timestamp objects from an - * external representation of timestamps in the form of an int array. - */ -public interface TimestampFactory { - - /** - * Creates a Timestamp from the components in the int array. - * - * @param components - * the components of the timestamp as an int array - * @return a Timestamp instance created from the component array - * @throws IllegalArgumentException - * if the component array does not satisfy the expectations of - * the TimestampFactory - */ - Timestamp createTimestamp(int[] components); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TransformationException.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TransformationException.java deleted file mode 100644 index 1e29c6d9ebe37c8f0705574c53d296306278b481..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/TransformationException.java +++ /dev/null @@ -1,48 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * Exception thrown by algorithm instances whenever transforming operations - * fails. - */ -public class TransformationException extends Exception { - - /** - * Creates a new TransformationException. - */ - public TransformationException() { - super(); - } - - /** - * Creates a new TransformationException. - * - * @param message - * the detail message - */ - public TransformationException(String message) { - super(message); - } - - /** - * Creates a new TransformationException. - * - * @param cause - * the cause of this exception - */ - public TransformationException(Throwable cause) { - super(cause); - } - - /** - * Creates a new TransformationException. - * - * @param message - * the detail message - * @param cause - * the cause of this exception - */ - public TransformationException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/VectorTime.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/VectorTime.java deleted file mode 100644 index 256242487b5ca2ac69211ac65e5813a3501c7159..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/VectorTime.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter; - -/** - * Vector time is a concept used in almost all OT algorithms to determine - * causality relations of operations. - */ -public interface VectorTime extends Timestamp { - - /** - * Gets the length of the vector. - * - * @return the length of the vector time - */ - int getLength(); - - /** - * Gets the value at the given index. - * - * @param index - * the index into the vector - * @return the value at the given index - * @throws IndexOutOfBoundsException - * if index is invalid - */ - int getAt(int index); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Jupiter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Jupiter.java deleted file mode 100644 index 876ace2508e3c3c4c2f9a4b2ed24240b4c7b6cae..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Jupiter.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * $Id: Jupiter.java 2859 2006-04-01 09:39:19Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.swing.undo.CannotRedoException; -import javax.swing.undo.CannotUndoException; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm; -import de.fu_berlin.inf.dpp.concurrent.jupiter.InclusionTransformation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.GOTOInclusionTransformation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; - -/** - * This class implements the client-side core of the Jupiter control algorithm. - */ -public class Jupiter implements Algorithm { - - /** - * The inclusion transformation function used to transform operations. - */ - private InclusionTransformation inclusion; - - /** - * The vector time, representing the number of processed requests, of this - * algorithm. - */ - private JupiterVectorTime vectorTime; - - /** - * Flag indicating whether this algorithm is used on the client-side. In - * some situations, the requests from the server-side have a higher priority - * in transformations. - */ - private final boolean isClientSide; - - /** - * A list that contains the requests sent to the server which are to be - * acknowledged by the server before they can be removed. This list - * corresponds to the 'outgoing' list in the Jupiter pseudo code - * description. - */ - private final List<OperationWrapper> ackRequestList; - - /** - * Class constructor that creates a new Jupiter algorithm. - * - * @param isClientSide - * true if the algorithm resides on the client side - */ - public Jupiter(boolean isClientSide) { - this.inclusion = new GOTOInclusionTransformation(); - this.vectorTime = new JupiterVectorTime(0, 0); - this.isClientSide = isClientSide; - this.ackRequestList = new ArrayList<OperationWrapper>(); - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#generateRequest(de.fu_berlin.inf.dpp.concurrent.jupiter.Operation) - */ - public Request generateRequest(Operation op) { - // send(op, myMsgs, otherMsgs); - Request req = new RequestImpl(getSiteId(), (Timestamp) this.vectorTime - .clone(), op); - - // add(op, myMsgs) to outgoing; - if (op instanceof SplitOperation) { - SplitOperation split = (SplitOperation) op; - this.ackRequestList.add(new OperationWrapper(split.getFirst(), - this.vectorTime.getLocalOperationCount())); - this.ackRequestList.add(new OperationWrapper(split.getSecond(), - this.vectorTime.getLocalOperationCount())); - } else { - this.ackRequestList.add(new OperationWrapper(op, this.vectorTime - .getLocalOperationCount())); - } - - // myMsgs = myMsgs + 1; - this.vectorTime.incrementLocalOperationCount(); - - return req; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#receiveRequest(de.fu_berlin.inf.dpp.concurrent.jupiter.Request) - */ - public Operation receiveRequest(Request req) throws TransformationException { - Timestamp timestamp = req.getTimestamp(); - if (!(timestamp instanceof JupiterVectorTime)) { - throw new IllegalArgumentException( - "Jupiter expects timestamps of type JupiterVectorTime"); - } - // TODO: check preconditions - // try{ - checkPreconditions((JupiterVectorTime) timestamp); - // }catch(TransformationException e){ - // logger.warn(e); - // } - discardAcknowledgedOperations((JupiterVectorTime) timestamp); - - Operation newOp = transform(req.getOperation()); - this.vectorTime.incrementRemoteRequestCount(); - - return newOp; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#acknowledge(int, - * de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp) - */ - public void acknowledge(int siteId, Timestamp timestamp) - throws TransformationException { - discardAcknowledgedOperations((JupiterVectorTime) timestamp); - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#transformIndices(de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp, - * int[]) - */ - public int[] transformIndices(Timestamp timestamp, int[] indices) - throws TransformationException { - checkPreconditions((JupiterVectorTime) timestamp); - discardAcknowledgedOperations((JupiterVectorTime) timestamp); - int[] result = new int[indices.length]; - System.arraycopy(indices, 0, result, 0, indices.length); - for (int i = 0; i < this.ackRequestList.size(); i++) { - OperationWrapper wrap = this.ackRequestList.get(i); - Operation ack = wrap.getOperation(); - for (int k = 0; k < indices.length; k++) { - result[k] = transformIndex(result[k], ack); - } - } - return result; - } - - /** - * Transforms the given index against the operation. - * - * @param index - * the index to be transformed - * @param op - * the operation to be transformed - * @return the transformed index - */ - private int transformIndex(int index, Operation op) { - if (isClientSide()) { - return this.inclusion.transformIndex(index, op, Boolean.TRUE); - } else { - return this.inclusion.transformIndex(index, op, Boolean.FALSE); - } - } - - /** - * Discard from the other site (client/server) acknowledged operations. - * - * @param time - * the request to the remote operation count from - */ - private void discardAcknowledgedOperations(JupiterVectorTime time) { - Iterator<OperationWrapper> iter = this.ackRequestList.iterator(); - while (iter.hasNext()) { - OperationWrapper wrap = iter.next(); - if (wrap.getLocalOperationCount() < time.getRemoteOperationCount()) { - iter.remove(); - } - } - // ASSERT msg.myMsgs == otherMsgs - assert time.getLocalOperationCount() == this.vectorTime - .getRemoteOperationCount() : "msg.myMsgs != otherMsgs !!"; - } - - /** - * Transforms an operation with the operations in the outgoing queue - * {@link #ackRequestList}. - * - * @param newOp - * the operation to be transformed - * @return the transformed operation - * @see #ackRequestList - */ - private Operation transform(Operation newOp) { - for (int ackRequestListCnt = 0; ackRequestListCnt < this.ackRequestList - .size(); ackRequestListCnt++) { - OperationWrapper wrap = this.ackRequestList.get(ackRequestListCnt); - Operation existingOp = wrap.getOperation(); - - Operation transformedOp; - if (newOp instanceof SplitOperation) { - SplitOperation split = (SplitOperation) newOp; - if (isClientSide()) { - split.setFirst(this.inclusion.transform(split.getFirst(), - existingOp, Boolean.TRUE)); - split.setSecond(this.inclusion.transform(split.getSecond(), - existingOp, Boolean.TRUE)); - existingOp = this.inclusion.transform(existingOp, split - .getFirst(), Boolean.FALSE); - existingOp = this.inclusion.transform(existingOp, split - .getSecond(), Boolean.FALSE); - } else { - split.setFirst(this.inclusion.transform(split.getFirst(), - existingOp, Boolean.FALSE)); - split.setSecond(this.inclusion.transform(split.getSecond(), - existingOp, Boolean.FALSE)); - existingOp = this.inclusion.transform(existingOp, split - .getFirst(), Boolean.TRUE); - existingOp = this.inclusion.transform(existingOp, split - .getSecond(), Boolean.TRUE); - } - transformedOp = split; - } else { - if (isClientSide()) { - transformedOp = this.inclusion.transform(newOp, existingOp, - Boolean.TRUE); - existingOp = this.inclusion.transform(existingOp, newOp, - Boolean.FALSE); - } else { - transformedOp = this.inclusion.transform(newOp, existingOp, - Boolean.FALSE); - existingOp = this.inclusion.transform(existingOp, newOp, - Boolean.TRUE); - } - } - this.ackRequestList.set(ackRequestListCnt, new OperationWrapper( - existingOp, wrap.getLocalOperationCount())); - - newOp = transformedOp; - } - return newOp; - } - - /** - * Test 3 preconditions that must be fulfilled before transforming. They are - * taken from the Jupiter paper. - * - * @param time - * the request to be tested. - */ - private void checkPreconditions(JupiterVectorTime time) - throws TransformationException { - if (!this.ackRequestList.isEmpty() - && (time.getRemoteOperationCount() < this.ackRequestList.get(0) - .getLocalOperationCount())) { - throw new TransformationException("precondition #1 violated."); - } else if (time.getRemoteOperationCount() > this.vectorTime - .getLocalOperationCount()) { - throw new TransformationException("precondition #2 violated."); - } else if (time.getLocalOperationCount() != this.vectorTime - .getRemoteOperationCount()) { - throw new TransformationException("precondition #3 violated: " - + time + " , " + this.vectorTime); - } - } - - /** - * This is a simple helper class used in the implementation of the Jupiter - * algorithm. A OperationWrapper instance is created with an operation and - * the current local operation count and inserted into the outgoing queue - * (see {@link Jupiter#ackRequestList}). - * - * @see Jupiter#generateRequest(Operation) - * @see Jupiter#receiveRequest(Request) - */ - private static class OperationWrapper { - - private final Operation op; - - private final int count; - - OperationWrapper(Operation op, int count) { - this.op = op; - this.count = count; - } - - Operation getOperation() { - return this.op; - } - - int getLocalOperationCount() { - return this.count; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return ("OperationWrapper(" + this.op + ", " + this.count + ")"); - } - } - - /** - * Throws a CannotUndoException because undo is not supported by this - * implementation. - * - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#undo() - */ - public Request undo() { - throw new CannotUndoException(); - } - - /** - * Throws a CannotRedoException because undo is not supported by this - * implementation. - * - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#redo() - */ - public Request redo() { - throw new CannotRedoException(); - } - - /** - * Set an inclusion transformation function. - * - * @param it - * the inclusion transformation function to set. - */ - public void setInclusionTransformation(InclusionTransformation it) { - this.inclusion = it; - } - - /** - * @return the algorithms inclusion transformation - */ - public InclusionTransformation getInclusionTransformation() { - return this.inclusion; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#getSiteId() - */ - public int getSiteId() { - return isClientSide() ? 1 : 0; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm#getTimestamp() - */ - public synchronized Timestamp getTimestamp() { - return (Timestamp) this.vectorTime.clone(); - } - - /** - * Checks if this algorithm locates client side. - * - * @return true if this algorithm locates client side - */ - public boolean isClientSide() { - return this.isClientSide; - } - - public void updateVectorTime(Timestamp timestamp) - throws TransformationException { - if (this.ackRequestList.size() > 0) { - throw new TransformationException( - "ackRequestList have entries. Update Vector time failed."); - } - int local = timestamp.getComponents()[0]; - int remote = timestamp.getComponents()[1]; - this.vectorTime = new JupiterVectorTime(local, remote); - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentClient.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentClient.java deleted file mode 100644 index b507a2ffe01424e1f17f754907b5e8517970e276..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentClient.java +++ /dev/null @@ -1,89 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class JupiterDocumentClient implements JupiterClient { - - /** - * 1. Outgoing queue 2. request forwarder - * - */ - - private static Logger logger = Logger.getLogger(JupiterDocumentClient.class - .toString()); - - /** jid of remote client */ - private final JID jid; - /** jupiter sync algorithm. */ - private final Algorithm jupiter; - - private IPath editor; - - /** forwarder send request to server. */ - private final RequestForwarder forwarder; - - public JupiterDocumentClient(JID jid, RequestForwarder forwarder, - IPath editor) { - this.jid = jid; - this.jupiter = new Jupiter(true); - this.forwarder = forwarder; - this.editor = editor; - } - - public Request generateRequest(Operation op) { - Request req = null; - JupiterDocumentClient.logger.debug(this.jid.toString() - + " client generate request for " + op); - req = this.jupiter.generateRequest(op); - req.setJID(this.jid); - req.setEditorPath(this.editor); - /* send request */ - this.forwarder.forwardOutgoingRequest(req); - - return req; - } - - public Operation receiveRequest(Request req) throws TransformationException { - Operation op = null; - JupiterDocumentClient.logger.debug(this.jid.toString() - + " client receive request " + req.getOperation()); - /* receive request action */ - op = this.jupiter.receiveRequest(req); - JupiterDocumentClient.logger.debug(this.jid.toString() - + " client operation of IT: " + op); - return op; - } - - public JID getJID() { - return this.jid; - } - - public IPath getEditor() { - return this.editor; - } - - public void setEditor(IPath path) { - this.editor = path; - - } - - public Timestamp getTimestamp() { - return this.jupiter.getTimestamp(); - } - - public void updateVectorTime(Timestamp timestamp) - throws TransformationException { - this.jupiter.updateVectorTime(timestamp); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentServer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentServer.java deleted file mode 100644 index a5ec547885ee6b8b3b5aaabd2495ed700683ec0c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterDocumentServer.java +++ /dev/null @@ -1,264 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import java.util.HashMap; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class JupiterDocumentServer implements JupiterServer { - - private static Logger logger = Logger - .getLogger(JupiterDocumentServer.class); - - /** - * List of proxy clients. - */ - private final HashMap<JID, JupiterClient> proxies; - - private final List<Request> requestList; - - // /** outgoing queue to transfer request to appropriate clients. */ - private final List<Request> outgoingQueue; - - private IPath editor; - /** - * forward outgoing request to activity sequencer; - */ - private RequestTransmitter transmitter; - - /** - * this forwarder reads request form the local outgoing queue and transmit - * the requests to the global outgoing queue. - */ - class RequestTransmitter extends Thread { - - private final RequestForwarder rf; - private static final int MILLIS = 100; - - public RequestTransmitter(RequestForwarder forw) { - this.rf = forw; - } - - public Timer flushTimer = new Timer(true); - - @Override - public void run() { - this.flushTimer.schedule(new TimerTask() { - - @Override - public void run() { - /* forwarding */ - try { - JupiterDocumentServer.logger - .debug("Forwarding requests to activity sequencer. "); - RequestTransmitter.this.rf - .forwardOutgoingRequest(getNextOutgoingRequest()); - JupiterDocumentServer.logger - .debug("Forwarding is sended to activity sequencer. "); - } catch (InterruptedException e) { - JupiterDocumentServer.logger.warn( - "Exception forwarding request.", e); - } - - } - - }, 0, RequestTransmitter.MILLIS); - } - - } - - /** - * this constructor init an external request forwarder. The generate answer - * request of the proxy clients forwarding to this forwarder. - */ - public JupiterDocumentServer(RequestForwarder forwarder) { - this.proxies = new HashMap<JID, JupiterClient>(); - this.requestList = new Vector<Request>(); - this.outgoingQueue = new Vector<Request>(); - - new Serializer(this); - this.transmitter = new RequestTransmitter(forwarder); - this.transmitter.start(); - } - - /** - * default constructor. The server contains his own outgoing forwarding - * queue. - */ - public JupiterDocumentServer() { - this.proxies = new HashMap<JID, JupiterClient>(); - this.requestList = new Vector<Request>(); - this.outgoingQueue = new Vector<Request>(); - - new Serializer(this); - } - - public synchronized void addProxyClient(JID jid) { - JupiterClient proxy = new ProxyJupiterDocument(jid, this); - proxy.setEditor(this.editor); - // /* add to serializer. */ - // waitForSerializer = true; - // TODO: Sync with serializer before add action. - JupiterDocumentServer.logger.debug("add new proxy client : " + jid); - this.proxies.put(jid, proxy); - } - - public synchronized void removeProxyClient(JID jid) { - - /** - * TODO: sync with serializer. - * - * 1. save current action count 2. stop serializer after this cound and - * remove client. - */ - this.proxies.remove(jid); - notifyAll(); - } - - /** - * add request from transmitter to request queue. - */ - public synchronized void addRequest(Request request) { - - /* TODO: Sync with serializer. */ - - /** - * add request to serialized queue. - */ - JupiterDocumentServer.logger.debug("add new Request: " - + request.getJID() + " " + request.getOperation()); - this.requestList.add(request); - notify(); - } - - /** - * next message in request queue. - */ - public synchronized Request getNextRequestInSynchronizedQueue() - throws InterruptedException { - /* if queue is empty or proxy managing action is running. */ - while (!(this.requestList.size() > 0)) { - wait(); - } - JupiterDocumentServer.logger.debug("read out next request in queue! " - + this.requestList.get(0).getJID() + this.requestList.get(0)); - /* get next request. */ - return this.requestList.remove(0); - } - - public synchronized HashMap<JID, JupiterClient> getProxies() - throws InterruptedException { - /* - * Was Passiert, wenn während der Bearbeitung ein neuer proxy - * eingefügt wird - */ - - // /* Synchronistation für das Client Management.*/ - // while(waitForSerializer && requestSyncCounter == 0){ - // wait(); - // } - JupiterDocumentServer.logger.debug("Get jupiter proxies."); - return this.proxies; - } - - /* start transfer section. */ - - /** - * proxies add generated request to outgoing queue. - */ - public synchronized void forwardOutgoingRequest(Request req) { - /* add request to outgoing queue. */ - // if(outgoing == null){ - this.outgoingQueue.add(req); - // }else{ - // /* forward request.*/ - // outgoing.forwardOutgoingRequest(req); - // } - JupiterDocumentServer.logger.debug("add request to outgoing queue : " - + req.getJID() + " " + req); - notify(); - } - - /** - * transmitter interface get next request for transfer. - */ - public synchronized Request getNextOutgoingRequest() - throws InterruptedException { - Request req = null; - // if(outgoing == null){ - /* get next message and transfer to client. */ - while (!(this.outgoingQueue.size() > 0)) { - wait(200); - } - /* remove first queue element. */ - req = this.outgoingQueue.remove(0); - // } - // else{ - // req = outgoing.getNextOutgoingRequest(); - // - // } - JupiterDocumentServer.logger - .debug("read next request from outgoing queue: " + req.getJID() - + " " + req); - return req; - - // return outgoing.getNextOutgoingRequest(); - } - - public IPath getEditor() { - return this.editor; - } - - public void setEditor(IPath path) { - this.editor = path; - - } - - public boolean isExist(JID jid) { - if (this.proxies.containsKey(jid)) { - return true; - } - return false; - } - - public void updateVectorTime(JID source, JID dest) { - JupiterClient proxy = this.proxies.get(source); - if (proxy != null) { - try { - Timestamp ts = proxy.getTimestamp(); - getProxies().get(dest).updateVectorTime( - new JupiterVectorTime(ts.getComponents()[1], ts - .getComponents()[0])); - } catch (TransformationException e) { - JupiterDocumentServer.logger.error( - "Error during update vector time for " + dest, e); - } catch (InterruptedException e) { - JupiterDocumentServer.logger.error( - "Error during update vector time for " + dest, e); - } - } else { - JupiterDocumentServer.logger - .error("No proxy found for given source jid: " + source); - } - - } - - public void transformationErrorOccured() { - forwardOutgoingRequest(new RequestError(this.editor)); - } - - /* end transfer section */ - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterTimestampFactory.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterTimestampFactory.java deleted file mode 100644 index 4dfe21bf11e015abf87198667ec7191ea2edb52f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterTimestampFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TimestampFactory; - -/** - * TimestampFactory that creates Jupiter specific Timestamp objects. The - * encoding for Jupiter specific Timestamps is a component array of length 2 - * whereby the first index of the array contains the local operation count and - * the second index of the array contains the remote operation count. - */ -public class JupiterTimestampFactory implements TimestampFactory { - - /** - * - */ - public Timestamp createTimestamp(int[] components) { - if (components.length != 2) { - throw new IllegalArgumentException( - "JupiterTimestampFactory expects a component array" - + "of length 2"); - } - return new JupiterVectorTime(components[0], components[1]); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterVectorTime.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterVectorTime.java deleted file mode 100644 index f0ebf5d5dc5d9243011cc04497711881680dd58c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/JupiterVectorTime.java +++ /dev/null @@ -1,156 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.VectorTime; - -/** - * This class models the vector time for the Jupiter control algorithm. - */ -public class JupiterVectorTime implements VectorTime, Cloneable { - - /** - * Counter for the number of local operations. - */ - private int localOperationCnt; - - /** - * Counter for the number of remote operations. - */ - private int remoteOperationCnt; - - /** - * Create a new JupiterVectorTime. - * - * @param localCnt - * the local operation count. - * @param remoteCnt - * the remote operation count. - */ - public JupiterVectorTime(int localCnt, int remoteCnt) { - if (localCnt < 0) { - throw new IllegalArgumentException( - "local operation count cannot be negative"); - } - if (remoteCnt < 0) { - throw new IllegalArgumentException( - "remote operation count cannot be negative"); - } - this.localOperationCnt = localCnt; - this.remoteOperationCnt = remoteCnt; - } - - /** - * @see ch.iserver.ace.algorithm.VectorTime#getAt(int) - */ - public int getAt(int index) { - if (index == 0) { - return getLocalOperationCount(); - } else if (index == 1) { - return getRemoteOperationCount(); - } else { - throw new IndexOutOfBoundsException("" + index); - } - } - - /** - * @see ch.iserver.ace.algorithm.VectorTime#getLength() - */ - public int getLength() { - return 2; - } - - /** - * @see Timestamp#getComponents() - */ - public int[] getComponents() { - return new int[] { getLocalOperationCount(), getRemoteOperationCount() }; - } - - /** - * @return Returns the local operation count. - */ - public int getLocalOperationCount() { - return this.localOperationCnt; - } - - /** - * @return Returns the remote operation count. - */ - public int getRemoteOperationCount() { - return this.remoteOperationCnt; - } - - /** - * Increment the local operation counter. - * - * @return the counter after increment. - */ - public int incrementLocalOperationCount() { - return ++this.localOperationCnt; - } - - /** - * Increment the remote operation counter. - * - * @return the counter after increment. - */ - public int incrementRemoteRequestCount() { - return ++this.remoteOperationCnt; - } - - /** - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("["); - buffer.append(this.localOperationCnt); - buffer.append(","); - buffer.append(this.remoteOperationCnt); - buffer.append("]"); - return buffer.toString(); - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - JupiterVectorTime vector = (JupiterVectorTime) obj; - return (vector.localOperationCnt == this.localOperationCnt) - && (vector.remoteOperationCnt == this.remoteOperationCnt); - } else { - return false; - } - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - int hashcode = 17; - hashcode = 37 * hashcode + this.localOperationCnt; - hashcode = 37 * hashcode + this.remoteOperationCnt; - return hashcode; - } - - /** - * @see java.lang.Object#clone() - */ - @Override - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - // this shouldn't happen, since we are Cloneable - throw new InternalError(); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/ProxyJupiterDocument.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/ProxyJupiterDocument.java deleted file mode 100644 index 3d0fc94594ef252e31e2280f0fda1148065c3375..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/ProxyJupiterDocument.java +++ /dev/null @@ -1,89 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Algorithm; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class ProxyJupiterDocument implements JupiterClient { - - /** - * 1. Outgoing queue 2. request forwarder - * - */ - - private static Logger logger = Logger.getLogger(ProxyJupiterDocument.class); - - /** jid of remote client */ - private final JID jid; - /** jupiter sync algorithm. */ - private final Algorithm jupiter; - /** forwarder send request to client. */ - private final RequestForwarder forwarder; - - private IPath editor; - - public ProxyJupiterDocument(JID jid, RequestForwarder forwarder) { - this.jid = jid; - this.jupiter = new Jupiter(false); - this.forwarder = forwarder; - } - - public Request generateRequest(Operation op) { - Request req = null; - ProxyJupiterDocument.logger.debug(this.jid.toString() - + " proxy client generate request for " + op); - req = this.jupiter.generateRequest(op); - req.setJID(this.jid); - req.setEditorPath(this.editor); - /* send request */ - ProxyJupiterDocument.logger.debug(this.jid.toString() - + " proxy client forward request: " + req); - this.forwarder.forwardOutgoingRequest(req); - - return req; - } - - public Operation receiveRequest(Request req) throws TransformationException { - Operation op = null; - ProxyJupiterDocument.logger.debug(this.jid.toString() - + " proxy client receive request " + req.getOperation()); - /* receive request action */ - op = this.jupiter.receiveRequest(req); - ProxyJupiterDocument.logger.debug(this.jid.toString() - + " proxy client operation of IT: " + op); - return op; - } - - /** - * @see de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient#getJID() - */ - public JID getJID() { - return this.jid; - } - - public IPath getEditor() { - return this.editor; - } - - public void setEditor(IPath path) { - this.editor = path; - } - - public Timestamp getTimestamp() { - return this.jupiter.getTimestamp(); - } - - public void updateVectorTime(Timestamp timestamp) - throws TransformationException { - this.jupiter.updateVectorTime(timestamp); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestError.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestError.java deleted file mode 100644 index 6bd6a4fc155684fc13b0c963321652b289a75483..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestError.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Error object of an transformation request. - * - * @author orieger - * - */ -public class RequestError implements Request { - - private IPath path; - - public RequestError(IPath path) { - this.path = path; - } - - /** - * - */ - private static final long serialVersionUID = 3111067620344018430L; - - public IPath getEditorPath() { - return this.path; - } - - public JID getJID() { - - return null; - } - - public Operation getOperation() { - - return null; - } - - public int getSiteId() { - - return 0; - } - - public Timestamp getTimestamp() { - - return null; - } - - public void setEditorPath(IPath editor) { - this.path = editor; - } - - public void setJID(JID jid) { - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestImpl.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestImpl.java deleted file mode 100644 index c0fcaa6d6c89fdfd106105c45f9df7223a3d76ed..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/RequestImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Default implementation of the Request interface. - */ -public class RequestImpl implements Request { - - /** - * The site id of the request. - */ - private final int siteId; - - /** - * The timestamp of the request. - */ - private final Timestamp timestamp; - - /** - * The operation of the request. - */ - private final Operation operation; - - /** - * JID of appropriate client. - */ - private JID jid; - - /** - * Path of the appropriate edior. - */ - private IPath editor; - - /** - * Creates a new instance of the RequestImpl class. - * - * @param siteId - * the site id - * @param timestamp - * the timestamp - * @param operation - * the operation - */ - public RequestImpl(int siteId, Timestamp timestamp, Operation operation) { - this.siteId = siteId; - this.timestamp = timestamp; - this.operation = operation; - this.jid = null; - } - - /** - * Creates a new instance of the RequestImpl class. - * - * @param siteId - * the site id - * @param timestamp - * the timestamp - * @param operation - * the operation - */ - public RequestImpl(int siteId, Timestamp timestamp, Operation operation, - JID jid) { - this.siteId = siteId; - this.timestamp = timestamp; - this.operation = operation; - this.jid = jid; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.jupiter.Request#getSiteId() - */ - public int getSiteId() { - return this.siteId; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.jupiter.Request#getOperation() - */ - public Operation getOperation() { - return this.operation; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.jupiter.Request#getTimestamp() - */ - public Timestamp getTimestamp() { - return this.timestamp; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj instanceof Request) { - Request request = (Request) obj; - return (this.siteId == request.getSiteId()) - && nullSafeEquals(this.timestamp, request.getTimestamp()) - && nullSafeEquals(this.operation, request.getOperation()); - } else { - return false; - } - } - - private boolean nullSafeEquals(Object o1, Object o2) { - if (o1 == o2) { - return true; - } else if ((o1 == null) || (o2 == null)) { - return false; - } else { - return o1.equals(o2); - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - int hashCode = 13 * this.siteId; - hashCode += (this.timestamp != null) ? 17 * this.timestamp.hashCode() - : 0; - hashCode += (this.operation != null) ? 29 * this.operation.hashCode() - : 0; - return hashCode; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("request("); - buffer.append(this.siteId); - buffer.append(","); - buffer.append(this.timestamp); - buffer.append(","); - buffer.append(this.operation); - buffer.append(")"); - return buffer.toString(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.jupiter.Request#getJID() - */ - public JID getJID() { - return this.jid; - } - - public void setJID(JID jid) { - this.jid = jid; - } - - public IPath getEditorPath() { - return this.editor; - } - - public void setEditorPath(IPath editor) { - this.editor = editor; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Serializer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Serializer.java deleted file mode 100644 index 4071170e9d33339a569f1f541c490bb6aa5bb617..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/Serializer.java +++ /dev/null @@ -1,66 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal; - -import java.util.HashMap; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.OperationSerializer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.net.JID; - -public class Serializer extends Thread implements OperationSerializer { - - private static Logger logger = Logger.getLogger(Serializer.class); - - JupiterServer server; - - private final boolean run = true; - - public Serializer(JupiterServer server) { - this.server = server; - start(); - } - - @Override - public void run() { - Serializer.logger.debug("Start Serializer"); - - Request request = null; - HashMap<JID, JupiterClient> proxies = null; - JupiterClient proxy = null; - while (this.run) { - try { - /* get next request in queue. */ - request = this.server.getNextRequestInSynchronizedQueue(); - - proxies = this.server.getProxies(); - /* 1. execute receive action at appropriate proxy client. */ - proxy = proxies.get(request.getJID()); - Operation op = proxy.receiveRequest(request); - /* 2. execute generate action at other proxy clients. */ - for (JID j : proxies.keySet()) { - proxy = proxies.get(j); - - if (!j.toString().equals(request.getJID().toString())) { - /* - * create submit op as local proxy operation and send to - * client. - */ - proxy.generateRequest(op); - } - - } - - } catch (InterruptedException e) { - Serializer.logger.warn("Interrupt Exception", e); - } catch (TransformationException e) { - Serializer.logger.error("Transformation Exception ", e); - this.server.transformationErrorOccured(); - } - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/DeleteOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/DeleteOperation.java deleted file mode 100644 index d896746f649f22f7a0e04c728ddb0fa4998e129c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/DeleteOperation.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * $Id: DeleteOperation.java 2434 2005-12-12 07:49:51Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The DeleteOperation is used to hold a text together with its position that is - * to be deleted in the document model. - */ -public class DeleteOperation implements Operation { - - /** - * the text to be deleted. - */ - private String text; - - /** - * the position in the document where the text is to be deleted. - */ - private int position; - - /** - * Class constructor. - */ - public DeleteOperation() { - } - - /** - * Class constructor. - * - * @param position - * the position into the document - * @param text - * the text to be deleted - */ - public DeleteOperation(int position, String text) { - setPosition(position); - setText(text); - } - - /** - * Class constructor. - * - * @param position - * the position into the document - * @param text - * the text to be deleted - * @param isUndo - * flag to indicate whether this operation is an undo - */ - public DeleteOperation(int position, String text, boolean isUndo) { - setPosition(position); - setText(text); - } - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return this.position; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - if (position < 0) { - throw new IllegalArgumentException("position index must be >= 0"); - } - this.position = position; - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return this.text.length(); - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return this.text; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - if (text == null) { - throw new IllegalArgumentException("text may not be null"); - } - this.text = text; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "Delete(" + this.position + ",'" + this.text + "')"; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - DeleteOperation op = (DeleteOperation) obj; - return (op.position == this.position) && op.text.equals(this.text); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hashcode = this.position; - hashcode += 13 * this.text.hashCode(); - return hashcode; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/GOTOInclusionTransformation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/GOTOInclusionTransformation.java deleted file mode 100644 index e071ff6fe6377531a88388c0c8448402d2048d15..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/GOTOInclusionTransformation.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * $Id: GOTOInclusionTransformation.java 2434 2005-12-12 07:49:51Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import java.security.InvalidParameterException; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.InclusionTransformation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * Implementation of the GOTO operational transformation functions. The pseudo - * code can be found in the paper "Achieving Convergence, - * Causality-preservation, and Intention-preservation in Real-time cooperative - * Editing Systems" by Chengzheng Sun, Xiaohua Jia, Yanchun Zhang, Yun Yang, and - * David Chen. - */ -public class GOTOInclusionTransformation implements InclusionTransformation { - - /** - * Include operation <var>op2</var> into the context of operation - * <var>op1</var>. The transformed operation <var>op1'</var> is returned. - * - * @param op1 - * the operation into which another is to be contextually - * included. - * @param op2 - * the operation to be included. - * @param param - * a boolean flag to privilege the first operation - * <code>op1</code> (i.e. remains unchanged) when two insert - * operations are equivalent i.e. they have the same position and - * origin index. - * @return the transformed operation <var>op1'</var> - */ - public Operation transform(Operation op1, Operation op2, Object param) { - Operation transformedOp; - if (op1 instanceof SplitOperation) { - SplitOperation s = (SplitOperation) op1; - s.setFirst(transform(s.getFirst(), op2, param)); - s.setSecond(transform(s.getSecond(), op2, param)); - transformedOp = s; - } else if (op2 instanceof SplitOperation) { - SplitOperation s = (SplitOperation) op2; - op1 = transform(op1, s.getSecond(), param); - op1 = transform(op1, s.getFirst(), param); - transformedOp = op1; - } else if (op1 instanceof NoOperation) { - transformedOp = clone((NoOperation) op1); - } else if (op2 instanceof NoOperation) { - if (op1 instanceof InsertOperation) { - transformedOp = clone((InsertOperation) op1); - } else { - transformedOp = clone((DeleteOperation) op1); - } - } else if ((op1 instanceof InsertOperation) - && (op2 instanceof InsertOperation)) { - transformedOp = transform((InsertOperation) op1, - (InsertOperation) op2, ((Boolean) param).booleanValue()); - } else if ((op1 instanceof InsertOperation) - && (op2 instanceof DeleteOperation)) { - transformedOp = transform((InsertOperation) op1, - (DeleteOperation) op2); - } else if ((op1 instanceof DeleteOperation) - && (op2 instanceof InsertOperation)) { - transformedOp = transform((DeleteOperation) op1, - (InsertOperation) op2); - } else if ((op1 instanceof DeleteOperation) - && (op2 instanceof DeleteOperation)) { - transformedOp = transform((DeleteOperation) op1, - (DeleteOperation) op2); - } else { - throw new InvalidParameterException(); - } - return transformedOp; - } - - public int transformIndex(int index, Operation op, Object param) { - if (op instanceof SplitOperation) { - SplitOperation s = (SplitOperation) op; - index = transformIndex(index, s.getSecond(), param); - index = transformIndex(index, s.getFirst(), param); - return index; - } else if (op instanceof NoOperation) { - return index; - } else if (op instanceof InsertOperation) { - int pos = ((InsertOperation) op).getPosition(); - if (index < pos) { - return index; - } else { - return index + ((InsertOperation) op).getTextLength(); - } - } else if (op instanceof DeleteOperation) { - int pos = ((DeleteOperation) op).getPosition(); - if (index <= pos) { - return index; - } else { - return index - ((DeleteOperation) op).getTextLength(); - } - } else { - throw new IllegalArgumentException("Unsupported Operation type: " - + op); - } - } - - private Operation transform(InsertOperation insA, InsertOperation insB, - boolean isTransformPrivileged) { - InsertOperation transformedOperation = null; - int posA = insA.getPosition(); - int posB = insB.getPosition(); - int lenB = insB.getTextLength(); - if ((posA < posB) - || ((posA == posB) && (insA.getOrigin() < insB.getOrigin())) - || ((posA == posB) && (insA.getOrigin() == insB.getOrigin()) && isTransformPrivileged)) { - /* - * Operation A starts before operation B. (B): "ABCD" (A): "12" - * (A'): "12" - */ - transformedOperation = clone(insA); - } else { - /* - * Operation A starts in or behind operation B. Index of operation - * A' must be increased by the length of the text of operation B. - * (B): "ABCD" | "ABCD" (A): "12" | "12" (A'): " 12" | "12" - */ - transformedOperation = new InsertOperation(posA + lenB, insA - .getText(), insA.getOrigin()); - } - return transformedOperation; - } - - private Operation transform(InsertOperation insA, DeleteOperation delB) { - InsertOperation transformedOperation = null; - int posA = insA.getPosition(); - int posB = delB.getPosition(); - int lenB = delB.getTextLength(); - - if (posA <= posB) { - /* - * Operation A starts before or at the same position like operation - * B. (B): "ABCD" | "ABCD" (A): "12" | "12" (A'): "12" | "12" - */ - transformedOperation = clone(insA); - } else if (posA > (posB + lenB)) { - /* - * Operation A starts after operation B. Index of operation A' must - * be reduced by the length of the text of operation B. (B): "ABCD" - * (A): "12" (A'): "12" - */ - transformedOperation = new InsertOperation(posA - lenB, insA - .getText(), insA.getOrigin()); - } else { - /* - * Operation A starts in operation B. Index of A' must be the index - * of operation B. (B): "ABCD" (A): "12" (A'): "12" - */ - transformedOperation = new InsertOperation(posB, insA.getText(), - insA.getOrigin()); - } - return transformedOperation; - } - - private Operation transform(DeleteOperation delA, InsertOperation insB) { - Operation transformedOperation = null; - int posA = delA.getPosition(); - int lenA = delA.getTextLength(); - int posB = insB.getPosition(); - int lenB = insB.getTextLength(); - - if (posB >= (posA + lenA)) { - /* - * Operation A is completly before operation B. (B): "ABCD" (A): - * "12" (A'): "12" - */ - transformedOperation = clone(delA); - } else if (posA >= posB) { - /* - * Operation A starts before or at the same position like operation - * B. (B): "ABCD" | "ABCD" (A): "12" | "12" (A'): "12" | "12" - */ - transformedOperation = new DeleteOperation(posA + lenB, delA - .getText()); - } else { - /* - * Operation B (insert) is in the range of operation A (delete). - * Operation A' must be splitted up into two delete operations. (B): - * "ABCD" (A): "123456" (A'): "1" "23456" - */ - DeleteOperation del1 = new DeleteOperation(posA, delA.getText() - .substring(0, posB - posA)); - DeleteOperation del2 = new DeleteOperation(posA + lenB - + (posB - posA), delA.getText() - .substring(posB - posA, lenA)); - transformedOperation = new SplitOperation(del1, del2); - } - return transformedOperation; - } - - private Operation transform(DeleteOperation delA, DeleteOperation delB) { - Operation transformedOperation; - int posA = delA.getPosition(); - int lenA = delA.getTextLength(); - int posB = delB.getPosition(); - int lenB = delB.getTextLength(); - - if (posB >= (posA + lenA)) { - /* - * Operation A is completly before operation B. (B): "ABCD" (A): - * "12" (A'): "12" - */ - transformedOperation = clone(delA); - } else if (posA >= (posB + lenB)) { - /* - * Operation A starts at the end or after operation B. Index of - * operation A' must be reduced by the length of the text of - * operation B. (B): "ABCD" (A): "12" (A'): "12" - */ - transformedOperation = new DeleteOperation(posA - lenB, delA - .getText()); - } else { - /* - * Operation A and operation B are overlapping. - */ - if ((posB <= posA) && ((posA + lenA) <= (posB + lenB))) { - /* - * Operation B starts before or at the same position like - * operation A and ends after or at the same position like - * operation A. (B): "ABCD" | "ABCD (A): "12" | "12" (A'): "" | - * "" - */ - NoOperation noop = new NoOperation(); - transformedOperation = noop; - } else if ((posB <= posA) && ((posA + lenA) > (posB + lenB))) { - /* - * Operation B starts before or at the same position like - * operation A and ends before operation A. (B): "ABCD" (A): - * "12345" (A'): "345" - */ - transformedOperation = new DeleteOperation(posB, delA.getText() - .substring(posB + lenB - posA, lenA)); - } else if ((posB > posA) && ((posB + lenB) >= (posA + lenA))) { - /* - * Operation B starts after operation A and ends after or at the - * same position like operation A. (B): "ABCD" (A): "12345" - * (A'): "12" - */ - transformedOperation = new DeleteOperation(posA, delA.getText() - .substring(0, posB - posA)); - } else { - /* - * Operation B is fully in operation A. (B): "ABCD" (A): - * "123456" (A'): "16" - */ - transformedOperation = new DeleteOperation(posA, delA.getText() - .substring(0, posB - posA) - + delA.getText().substring(posB + lenB - posA, lenA)); - } - } - return transformedOperation; - } - - /** - * Clone an insert operation and update its transformation history. - * - * @param insA - * @return InsertOperation - */ - private InsertOperation clone(InsertOperation insA) { - InsertOperation cloneOp = new InsertOperation(insA.getPosition(), insA - .getText(), insA.getOrigin()); - return cloneOp; - } - - /** - * Clone a delete operation and update its transformation history. - * - * @param delA - * @return DeleteOperation - */ - private DeleteOperation clone(DeleteOperation delA) { - DeleteOperation cloneOp = new DeleteOperation(delA.getPosition(), delA - .getText()); - return cloneOp; - } - - /** - * Clones a no-operation and updates its transformation history. - * - * @param noop - * @return DeleteOperation - */ - private NoOperation clone(NoOperation noop) { - NoOperation cloneOp = new NoOperation(); - return cloneOp; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/InsertOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/InsertOperation.java deleted file mode 100644 index 0559080235f0e9ab5563cc6751b1a26dd10841c3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/InsertOperation.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * $Id: InsertOperation.java 2755 2006-03-06 09:29:34Z zbinl $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The InsertOperation is used to hold a text together with its position index. - * The text is to be inserted in the document model. - */ -public class InsertOperation implements Operation { - - /** - * the text to be inserted. - */ - private String text; - - /** - * the position index in the document model. - */ - private int position; - - /** - * the origin position index where the insert operation was originally - * intended. This concept could be extended in such a way that two origin - * positions could be compared to each other based on the same context. - * Therefore, if the two positions do not relate on the same document - * context, a least synchronization point (LSP) would have to be determined. - */ - private int origin; - - /** - * Class constructor. - * - */ - public InsertOperation() { - } - - /** - * Class constructor. - * - * @param position - * the position in the document - * @param text - * the text to be inserted - */ - public InsertOperation(int position, String text) { - setPosition(position); - setText(text); - this.origin = getPosition(); - } - - /** - * Class constructor. - * - * @param position - * the position in the document - * @param text - * the text to be inserted - * @param isUndo - * flag to indicate an undo operation - */ - public InsertOperation(int position, String text, boolean isUndo) { - this(position, text); - this.origin = getPosition(); - } - - /** - * Class constructor. - * - * @param position - * the position in the document - * @param text - * the text to be inserted - * @param origin - * the origin position of this insert operation - */ - public InsertOperation(int position, String text, int origin) { - this(position, text); - this.origin = origin; - } - - /** - * @param position - * the position in the document - * @param text - * the text to be inserted - * @param origin - * the origin position of this insert operation - * @param isUndo - * flag to indicate an undo operation - */ - public InsertOperation(int position, String text, int origin, boolean isUndo) { - this(position, text, origin); - } - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return this.position; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - if (position < 0) { - throw new IllegalArgumentException("position index must be >= 0"); - } - this.position = position; - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return this.text; - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return this.text.length(); - } - - /** - * Returns the origin position. - * - * @return the origin position - */ - public int getOrigin() { - return this.origin; - } - - /** - * Sets the origin position. - * - * @param origin - * the origin position to set - */ - public void setOrigin(int origin) { - if (origin < 0) { - throw new IllegalArgumentException("origin index must be >= 0"); - } - this.origin = origin; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - if (text == null) { - throw new IllegalArgumentException("text may not be null"); - } - this.text = text; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "Insert(" - + this.position - + ",'" - + (this.text != null ? ((this.text.length() > 20) ? this.text - .substring(0, 20) - + "..." : this.text) : "") + "'," + this.origin + ")"; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - InsertOperation op = (InsertOperation) obj; - return (op.position == this.position) && op.text.equals(this.text) - && (op.origin == this.origin); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hashcode = this.position; - hashcode += 13 * this.origin; - hashcode += 13 * this.text.hashCode(); - return hashcode; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/NoOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/NoOperation.java deleted file mode 100644 index 6b0e4c1c7a82d8753e37f67a8b7df87a097f3386..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/NoOperation.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * $Id$ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The NoOperation is used to hold a empty text together with the position zero. - */ -public class NoOperation implements Operation { - - /** - * Class constructor. - */ - public NoOperation() { - } - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return 0; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - throw new UnsupportedOperationException(); - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return 0; - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return ""; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "Noop(0,'')"; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - return true; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hashcode = 37; - return hashcode; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/SplitOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/SplitOperation.java deleted file mode 100644 index dc03516b0651ba90c461fa19530032dfe295d58c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/SplitOperation.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * $Id: SplitOperation.java 2434 2005-12-12 07:49:51Z sim $ - * - * ace - a collaborative editor - * Copyright (C) 2005 Mark Bigler, Simon Raess, Lukas Zbinden - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * The SplitOperation contains two operations. It is used when an operation - * needs to be split up under certain transformation conditions. - * - * @see ch.iserver.ace.algorithm.Operation - */ -public class SplitOperation implements Operation { - - /** - * The first operation. - */ - private Operation op1; - - /** - * The second operation. - */ - private Operation op2; - - /** - * Class constructor. - */ - public SplitOperation() { - } - - /** - * Class constructor. - * - * @param op1 - * the first operation - * @param op2 - * the second operation - */ - public SplitOperation(Operation op1, Operation op2) { - this.op1 = op1; - this.op2 = op2; - } - - /** - * Returns the first operation. - * - * @return the first operation - */ - public Operation getFirst() { - return this.op1; - } - - /** - * Sets the first operation. - * - * @param op1 - * the first operation - */ - public void setFirst(Operation op1) { - this.op1 = op1; - } - - /** - * Returns the second operation. - * - * @return the second operation - */ - public Operation getSecond() { - return this.op2; - } - - /** - * Sets the second operation. - * - * @param op2 - * the second operation - */ - public void setSecond(Operation op2) { - this.op2 = op2; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "Split(" + this.op1 + ", " + this.op2 + ")"; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - SplitOperation op = (SplitOperation) obj; - return op.getFirst().equals(this.op1) - && op.getSecond().equals(this.op2); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hashcode = this.op1.hashCode(); - hashcode += 17 * this.op2.hashCode(); - return hashcode; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/TimestampOperation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/TimestampOperation.java deleted file mode 100644 index 9b7591a5efe18f7cf900b76d90f0f7c2b0354e7c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/jupiter/internal/text/TimestampOperation.java +++ /dev/null @@ -1,98 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; - -/** - * This operation update have new vector time for the algorithm. - * - * @author orieger - * - */ - -public class TimestampOperation implements Operation { - - /** - * - */ - private static final long serialVersionUID = 2756378905499193184L; - - /** - * Returns the position. - * - * @return the position - */ - public int getPosition() { - return 0; - } - - /** - * Sets the position of this operation. - * - * @param position - * the position to set - */ - public void setPosition(int position) { - throw new UnsupportedOperationException(); - } - - /** - * Returns the text length. - * - * @return the length of the text - */ - public int getTextLength() { - return 0; - } - - /** - * Returns the text to be deleted. - * - * @return the text to be deleted - */ - public String getText() { - return ""; - } - - /** - * Sets the text to be deleted. - * - * @param text - * the text to be deleted - */ - public void setText(String text) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "Timestamp(0,'')"; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null) { - return false; - } else if (obj.getClass().equals(getClass())) { - return true; - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - int hashcode = 38; - return hashcode; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/ConcurrentDocumentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/ConcurrentDocumentManager.java deleted file mode 100644 index 543d762ea94a1214810561af4fab3a7113730a68..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/ConcurrentDocumentManager.java +++ /dev/null @@ -1,847 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -import java.util.HashMap; -import java.util.List; -import java.util.Set; -import java.util.Vector; -import java.util.concurrent.CopyOnWriteArraySet; - -import org.apache.log4j.Logger; -import org.eclipse.core.filebuffers.FileBuffers; -import org.eclipse.core.filebuffers.ITextFileBuffer; -import org.eclipse.core.filebuffers.LocationKind; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.text.IDocument; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.TextEditActivity; -import de.fu_berlin.inf.dpp.activities.EditorActivity.Type; -import de.fu_berlin.inf.dpp.concurrent.ConcurrentManager; -import de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.JupiterServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.TransformationException; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterDocumentClient; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterDocumentServer; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterVectorTime; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.RequestImpl; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.DeleteOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.InsertOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.TimestampOperation; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.VariableProxy; - -public class ConcurrentDocumentManager implements ConcurrentManager, - ISessionListener { - - private static Logger logger = Logger - .getLogger(ConcurrentDocumentManager.class); - - /** Jupiter server instance documents */ - private HashMap<IPath, JupiterDocumentServer> concurrentDocuments; - - /** current open editor at client side. */ - private final HashMap<IPath, JupiterClient> clientDocs; - - // private List<JID> drivers; - - private JID host; - - private final JID myJID; - - private final Side side; - - private RequestForwarder forwarder; - - private IActivitySequencer sequencer; - - private final IDriverDocumentManager driverManager; - - private final ISharedProject sharedProject; - - private final ConsistencyWatchdog consistencyWatchdog = new ConsistencyWatchdog( - "ConsistencyWatchdog"); - - private VariableProxy<Boolean> inconsistencyToResolve = new VariableProxy<Boolean>( - false); - - private Set<IPath> pathesWithWrongChecksums; - - /** - * This class consists of two parts. The first is a run-method which runs as - * an eclipse job on the host side. Once started with schedule() the job is - * scheduled to rerun every 5 seconds. The second part is a check method - * which checks the documents on this client side against the given - * checksums. - * - * @author chjacob - */ - private class ConsistencyWatchdog extends Job { - - private boolean executingChecksumErrorHandling; - - public ConsistencyWatchdog(String name) { - super(name); - } - - // this map holds for all jupiter controlled documents the checksums - private final HashMap<IPath, DocumentChecksum> docsChecksums = new HashMap<IPath, DocumentChecksum>(); - - @Override - protected IStatus run(IProgressMonitor monitor) { - - // if not on host side cancel the job - if (!isHostSide()) { - logger.error("This job is intended to be run on host side!"); - return Status.CANCEL_STATUS; - } - - // get the documents which are controlled by jupiter - Set<IPath> docs = clientDocs.keySet(); - - // for all documents - for (IPath docPath : docs) { - - // get document - IPath fullPath = Saros.getDefault().getSessionManager() - .getSharedProject().getProject().findMember(docPath) - .getFullPath(); - ITextFileBuffer fileBuff = FileBuffers - .getTextFileBufferManager().getTextFileBuffer(fullPath, - LocationKind.IFILE); - - // HACK - if (fileBuff == null) { - logger.error("Can't get File Buffer"); - docsChecksums.remove(docPath); - continue; - } - IDocument doc = fileBuff.getDocument(); - - // if no entry for this document exists create a new one - if (docsChecksums.get(docPath) == null) { - DocumentChecksum c = new DocumentChecksum(docPath, doc - .getLength(), doc.get().hashCode()); - docsChecksums.put(docPath, c); - logger.debug(c.getHash()); - } else { - DocumentChecksum c = docsChecksums.get(docPath); - if (c.getLength() != doc.getLength()) { - // length has changed, compute the hash new - c.setLength(doc.getLength()); - c.setHash(doc.get().hashCode()); - docsChecksums.put(docPath, c); - } - } - } - - Saros.getDefault().getSessionManager().getTransmitter() - .sendDocChecksumsToClients(docsChecksums.values()); - - // schedule the next run in 3 seconds - schedule(3000); - return Status.OK_STATUS; - } - - /** - * Checks the local documents against the given checksums. When an - * inconsistency occurs all at the concurrent document manager - * registered consistency listener are informed about the issue. When a - * previous consistency issue have resolved the listeners are also - * notified. - * - * @param checksums - * the checksums to check the documents against - */ - private void check(DocumentChecksum[] checksums) { - - for (DocumentChecksum checksum : checksums) { - - IPath path = checksum.getPath(); - - IDocument doc = EditorManager.getDefault().getDocument(path); - - // if doc == null there is no editor with this resource open - if (doc == null) - continue; - - if ((doc.getLength() != checksum.getLength()) - || (doc.get().hashCode() != checksum.getHash())) { - - logger.debug(path.toString() + ": " + doc.getLength() + "/" - + checksum.getLength() + " ; " - + doc.get().hashCode() + "/" + checksum.getHash()); - - long lastEdited = (EditorManager.getDefault() - .getLastEditTime(path)); - - long lastRemoteEdited = (EditorManager.getDefault() - .getLastRemoteEditTime(path)); - - if ((System.currentTimeMillis() - lastEdited) > 2000 - && (System.currentTimeMillis() - lastRemoteEdited > 2000)) { - logger.debug("Inconsistency detected in document " - + path.toOSString()); - ConcurrentDocumentManager.this.pathesWithWrongChecksums - .add(path); - if (!inconsistencyToResolve.getVariable()) { - ConcurrentDocumentManager.this.inconsistencyToResolve - .setVariable(true); - } - } - return; - } - logger.debug("All Inconsistencies are resolved"); - logger.debug(path.toString() + ": " + doc.getLength() + "/" - + checksum.getLength() + " ; " + doc.get().hashCode() - + "/" + checksum.getHash()); - - ConcurrentDocumentManager.this.pathesWithWrongChecksums.clear(); - - if (inconsistencyToResolve.getVariable()) { - ConcurrentDocumentManager.this.inconsistencyToResolve - .setVariable(false); - } - } - } - } - - public ConcurrentDocumentManager(Side side, User host, JID myJID, - ISharedProject sharedProject) { - this.sharedProject = sharedProject; - this.clientDocs = new HashMap<IPath, JupiterClient>(); - this.driverManager = DriverDocumentManager.getInstance(); - this.side = side; - this.host = host.getJid(); - this.myJID = myJID; - - if (side == Side.HOST_SIDE) { - this.concurrentDocuments = new HashMap<IPath, JupiterDocumentServer>(); - logger.debug("starting consistency watchdog"); - consistencyWatchdog.setSystem(true); - consistencyWatchdog.setPriority(Job.SHORT); - consistencyWatchdog.schedule(); - } - - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - public void setActivitySequencer(IActivitySequencer sequencer) { - this.sequencer = sequencer; - } - - public void setRequestForwarder(RequestForwarder f) { - this.forwarder = f; - } - - public RequestForwarder getRequestForwarder() { - return this.forwarder; - } - - /** - * - */ - public IActivity activityCreated(IActivity activity) { - - editorActivitiy(activity); - - if (createdTextEditActivity(activity)) { - /* handled by jupiter and is sended by request transmitting. */ - return null; - } - return activity; - } - - /** - * handled closed editor activity to remove the local jupiter clients. - * - * @param activity - */ - private void editorActivitiy(IActivity activity) { - if (activity instanceof EditorActivity) { - EditorActivity editor = (EditorActivity) activity; - - // if (isHostSide()) { - if (editor.getType() == Type.Saved) { - // // calculate checksum for saved file - // long checksum = FileUtil.checksum(this.sharedProject - // .getProject().getFile(editor.getPath())); - // editor.setChecksum(checksum); - // ConcurrentDocumentManager.logger - // .debug("Add checksumme to created editor save activity : " - // + checksum - // + " for path : " - // + editor.getPath().toOSString()); - } - } - } - - private void fileActivity(IActivity activity) { - if (activity instanceof FileActivity) { - - FileActivity file = (FileActivity) activity; - if (file.getType() == FileActivity.Type.Created) { - if (isHostSide()) { - - } - } - if (file.getType() == FileActivity.Type.Removed) { - if (isHostSide()) { - /* remove jupiter document server */ - if (this.concurrentDocuments.containsKey(file.getPath())) { - this.concurrentDocuments.remove(file.getPath()); - } - } - - // Client Side - if (this.clientDocs.containsKey(file.getPath())) { - this.clientDocs.remove(file.getPath()); - } - } - } - } - - /** - * handles text edit activities with jupiter. - * - * @param activity - * @return true if activity is transformed with jupiter. - */ - private boolean createdTextEditActivity(IActivity activity) { - - if (activity instanceof TextEditActivity) { - TextEditActivity textEdit = (TextEditActivity) activity; - // if (!isHostSide()) { - JupiterClient jupClient = null; - /* no jupiter client already exists for this editor text edit */ - if (!this.clientDocs.containsKey(textEdit.getEditor())) { - jupClient = new JupiterDocumentClient(this.myJID, - this.forwarder, textEdit.getEditor()); - // jupClient.setEditor(textEdit.getEditor()); - this.clientDocs.put(textEdit.getEditor(), jupClient); - } - - /* generate request. */ - jupClient = this.clientDocs.get(textEdit.getEditor()); - if (jupClient != null) { - Operation op = getOperation(textEdit); - jupClient.generateRequest(op); - - /* already set and forward inside of jup client. */ - // /* add appropriate Editor path. */ - // req.setEditorPath(textEdit.getEditor()); - // /* transmit request */ - // forwarder.forwardOutgoingRequest(req); - return true; - } - // } - } - return false; - } - - // TODO CJ: review - private void execTextEditActivity(final Request request) { - - // if (!isHostSide()) { - JupiterClient jupClient = null; - /* no jupiter client already exists for this editor text edit */ - if (!this.clientDocs.containsKey(request.getEditorPath())) { - jupClient = new JupiterDocumentClient(this.myJID, this.forwarder, - request.getEditorPath()); - // jupClient.setEditor(request.getEditorPath()); - this.clientDocs.put(request.getEditorPath(), jupClient); - } - - /* generate request. */ - jupClient = this.clientDocs.get(request.getEditorPath()); - if (jupClient != null) { - - /* operational transformation. */ - final JupiterClient jupiterClient = jupClient; - Display.getDefault().syncExec(new Runnable() { - public void run() { - Operation op; - try { - op = jupiterClient.receiveRequest(request); - } catch (TransformationException e) { - ConcurrentDocumentManager.logger.error( - "Error during transformation: ", e); - - /* create save activity. */ - IActivity activity = new EditorActivity(Type.Saved, - request.getEditorPath()); - /* execute save activity and start consistency check. */ - ConcurrentDocumentManager.this.sequencer.exec(activity); - return; - } - - for (TextEditActivity textEdit : getTextEditActivity(op)) { - textEdit.setEditor(request.getEditorPath()); - textEdit.setSource(request.getJID().toString()); - /* execute activity in activity sequencer. */ - ConcurrentDocumentManager.this.sequencer - .execTransformedActivity(textEdit); - } - } - }); - } - } - - public IActivity exec(IActivity activity) { - - if (activity instanceof EditorActivity) { - EditorActivity editorAc = (EditorActivity) activity; - - if (isHostSide()) { - JID sourceJID = new JID(editorAc.getSource()); - - /* inform driver document manager */ - this.driverManager.receiveActivity(activity); - - /* if one driver activate a new editor. */ - // if (drivers.contains(sourceJID) - if (this.driverManager.isDriver(sourceJID) - && ((editorAc.getType() == Type.Activated) || (editorAc - .getType() == Type.Closed))) { - /* start jupiter proxy for this driver. */ - if (this.concurrentDocuments - .containsKey(editorAc.getPath())) { - JupiterServer server = this.concurrentDocuments - .get(editorAc.getPath()); - - /* client has no proxy for this editor. */ - if (!server.isExist(sourceJID)) { - if (editorAc.getType() == Type.Activated) { - server.addProxyClient(sourceJID); - /* update vector time for new proxy. */ - // TODO: stop serializer and after this update - // vector time. - server.updateVectorTime(this.myJID, sourceJID); - // TODO: forward vector time method. - - /* get vector time of host for this editor path. */ - try { - - JupiterClient jupC = this.clientDocs - .get(editorAc.getPath()); - if (jupC != null) { - Timestamp ts = jupC.getTimestamp(); - - /* create update vector time request. */ - Request updateRequest = new RequestImpl( - 0, new JupiterVectorTime(ts - .getComponents()[1], ts - .getComponents()[0]), - new TimestampOperation()); - updateRequest.setEditorPath(editorAc - .getPath()); - updateRequest.setJID(sourceJID); - - this.forwarder - .forwardOutgoingRequest(updateRequest); - } - } catch (Exception e) { - - ConcurrentDocumentManager.logger.error( - "Error during get timestamp of host proxy for " - + editorAc.getPath(), e); - } - } - } else { - /* remove proxy for this jid. */ - if (editorAc.getType() == Type.Closed) { - server.removeProxyClient(sourceJID); - } - } - } else { - /* create new jupiter proxy client. */ - if (editorAc.getType() == Type.Activated) { - Request createRequest = new RequestImpl(0, - new JupiterVectorTime(0, 0), - new TimestampOperation()); - createRequest.setEditorPath(editorAc.getPath()); - createRequest.setJID(sourceJID); - - } - } - } - } - } - - if (activity instanceof TextEditActivity) { - // check for jupiter client documents - TextEditActivity text = (TextEditActivity) activity; - if (this.clientDocs.containsKey(text.getEditor())) { - /* activity have to be transformed with jupiter on this client. */ - return null; - } - } - - /* handles file activities. e.g. renamed files etc. */ - fileActivity(activity); - - return activity; - } - - public boolean isHostSide() { - if (this.side == Side.HOST_SIDE) { - return true; - } - return false; - } - - public boolean isHost(JID jid) { - if (jid != null && jid.equals(this.host)) { - return true; - } - return false; - } - - public void setHost(JID host) { - this.host = host; - } - - /** - * convert TextEditActivity to Operation op - * - * @param text - * @return - */ - public Operation getOperation(TextEditActivity text) { - - Operation op = null; - // delete activity - if ((text.replace > 0) && (text.text.length() == 0)) { - /* string placeholder in length of delete area. */ - String placeholder = ""; - for (int i = 0; i < text.replace; i++) { - placeholder += 1; - } - op = new DeleteOperation(text.offset, placeholder); - } - // insert activity - if ((text.replace == 0) && (text.text.length() > 0)) { - op = new InsertOperation(text.offset, text.text); - } - // replace operation has to split into delete and insert operation - if ((text.replace > 0) && (text.text.length() > 0)) { - /* string placeholder in length of delete area. */ - String placeholder = ""; - for (int i = 0; i < text.replace; i++) { - placeholder += 1; - } - op = new SplitOperation(new DeleteOperation(text.offset, - placeholder), new InsertOperation(text.offset, text.text)); - } - return op; - } - - /** - * Convert Operation op to text edit activity. NoOperation will ignore. - * - * @param op - * incoming transformed operation. - * @return List with executable text edit activities. - */ - public List<TextEditActivity> getTextEditActivity(Operation op) { - List<TextEditActivity> result = new Vector<TextEditActivity>(); - TextEditActivity textEdit = null; - if (op instanceof DeleteOperation) { - DeleteOperation del = (DeleteOperation) op; - textEdit = new TextEditActivity(del.getPosition(), "", del - .getTextLength()); - result.add(textEdit); - } - if (op instanceof InsertOperation) { - InsertOperation ins = (InsertOperation) op; - textEdit = new TextEditActivity(ins.getPosition(), ins.getText(), 0); - result.add(textEdit); - } - if (op instanceof SplitOperation) { - SplitOperation split = (SplitOperation) op; - TextEditActivity op1 = getTextEditActivity(split.getFirst()).get(0); - TextEditActivity op2 = getTextEditActivity(split.getSecond()) - .get(0); - - /* - * if operation one is delete operation the offset of second - * operation has to modified. - */ - if ((op1.replace > 0) && (op1.text.length() == 0) - && (op2.replace > 0) && (op2.text.length() == 0)) { - op2 = new TextEditActivity(op2.offset - op1.replace, "", - op2.replace); - } - result.add(op1); - result.add(op2); - } - - return result; - } - - private JupiterDocumentServer initDocumentServer(IPath path) { - JupiterDocumentServer docServer = null; - /* create new document server. */ - docServer = new JupiterDocumentServer(this.forwarder); - // docServer = new JupiterDocumentServer(); - docServer.setEditor(path); - /* create new local host document client. */ - docServer.addProxyClient(this.host); - return docServer; - } - - /** - * sync received request with right jupiter server document and local - * client. - * - */ - public void receiveRequest(Request request) { - - /* 1. Sync with jupiter server component. */ - if (isHostSide()) { - - /* if host side and server jupiter side of request */ - if (isHost(request.getJID()) && (request.getSiteId() == 0)) { - /* request already has transformed and have to be execute. */ - // return execTextEditActivity(request); - execTextEditActivity(request); - return; - } - - JupiterDocumentServer docServer = null; - /** - * if no jupiter document server exists. - */ - if (!this.concurrentDocuments.containsKey(request.getEditorPath())) { - // /* create new document server. */ - // docServer = new JupiterDocumentServer(forwarder); - // // docServer = new JupiterDocumentServer(); - // docServer.setEditor(request.getEditorPath()); - // /* create new local host document client. */ - // docServer.addProxyClient(host); - - docServer = initDocumentServer(request.getEditorPath()); - - if (!isHost(request.getJID())) { - // - this.driverManager.addDriverToDocument(request - .getEditorPath(), request.getJID()); - docServer.addProxyClient(request.getJID()); - } - this.concurrentDocuments - .put(request.getEditorPath(), docServer); - } - docServer = this.concurrentDocuments.get(request.getEditorPath()); - try { - /* check if sender id exists in proxy list. */ - if (!docServer.getProxies().containsKey(request.getJID())) { - docServer.addProxyClient(request.getJID()); - } - } catch (InterruptedException ie) { - ConcurrentDocumentManager.logger.error( - "Error during get proxy list of jupiter server.", ie); - } - - /* sync request with jupiter document server. */ - docServer.addRequest(request); - - return; - } else { - /* update timestamp of local jupiter client. */ - if (request.getOperation() instanceof TimestampOperation) { - if (this.clientDocs.containsKey(request.getEditorPath())) { - ConcurrentDocumentManager.logger - .info("update vector time : " - + request.getEditorPath()); - JupiterClient jupClient = this.clientDocs.get(request - .getEditorPath()); - try { - jupClient.updateVectorTime(request.getTimestamp()); - } catch (TransformationException e) { - ConcurrentDocumentManager.logger.error( - "Error during update jupiter client for " - + request.getEditorPath(), e); - } - } else { - /* if no jupiter client exists. */ - JupiterClient client = new JupiterDocumentClient( - this.myJID, this.forwarder, request.getEditorPath()); - // client.setEditor(request.getEditorPath()); - try { - client.updateVectorTime(request.getTimestamp()); - this.clientDocs.put(request.getEditorPath(), client); - } catch (TransformationException e) { - ConcurrentDocumentManager.logger.error( - "Error during update jupiter client for " - + request.getEditorPath(), e); - } - - } - } else { - - /* - * 2. receive request in local client component and return the - * transformed operation as IActivity. - */ - execTextEditActivity(request); - // return execTextEditActivity(request); - } - } - } - - public void driverChanged(JID driver, boolean replicated) { - /* - * 1. check if driver exists. 2. add new driver or remove driver. 3. - */ - // HOST - if (isHostSide()) { - /* if driver changed to observer */ - // if (drivers.contains(driver)) { - if (this.driverManager.isDriver(driver)) { - userLeft(driver); - } - // /* new driver added to project. */ - // else { - // drivers.add(driver); - // //TODO: add driver to current open document proxy ? - // } - } - // CLIENT - else { - if (driver.equals(this.myJID)) { - this.clientDocs.clear(); - } - } - - } - - public void userJoined(JID user) { - // do nothing - - } - - public void userLeft(JID user) { - if (isHostSide()) { - /* remove user from driver list */ - // drivers.remove(user); - /* remove user proxies from jupiter server. */ - for (JupiterServer server : this.concurrentDocuments.values()) { - if (server.isExist(user)) { - server.removeProxyClient(user); - - /* if only host has an proxy */ - - } - } - } - } - - /** - * reset jupiter document server component. - */ - public void resetJupiterDocument(IPath path) { - // host side - if (isHostSide()) { - if (this.concurrentDocuments.containsKey(path)) { - /* remove document server. */ - this.concurrentDocuments.remove(path); - /* init new server. */ - JupiterDocumentServer doc = initDocumentServer(path); - ConcurrentDocumentManager.logger - .debug("Reset jupiter server : "); - /* add proxy documents for active driver. */ - for (JID jid : this.driverManager.getDriverForDocument(path)) { - doc.addProxyClient(jid); - ConcurrentDocumentManager.logger - .debug("add driver proxy : " + jid); - } - - this.concurrentDocuments.put(path, doc); - - } else { - ConcurrentDocumentManager.logger - .error("No jupter document exists for " - + path.toOSString()); - } - } - - // reset client documents - if (this.clientDocs.containsKey(path)) { - this.clientDocs.remove(path); - this.clientDocs.put(path, new JupiterDocumentClient(this.myJID, - this.forwarder, path)); - ConcurrentDocumentManager.logger - .debug("Reset jupiter client doc : " + this.myJID); - } else { - ConcurrentDocumentManager.logger - .error("No jupter document exists for " + path.toOSString()); - } - - } - - public void invitationReceived(IIncomingInvitationProcess invitation) { - // TODO Auto-generated method stub - - } - - public void sessionEnded(ISharedProject session) { - this.consistencyWatchdog.cancel(); - pathesWithWrongChecksums.clear(); - } - - public void sessionStarted(ISharedProject session) { - this.pathesWithWrongChecksums = new CopyOnWriteArraySet<IPath>(); - } - - /** - * Checks the local documents against the given checksums. When an - * inconsistency occurs all at the concurrent document manager registered - * consistency listener are informed about the issue. When a previous - * consistency issue have resolved the listeners are also notified. - * - * @param checksums - * the checksums to check the documents against - */ - public void checkConsistency(DocumentChecksum[] checksums) { - consistencyWatchdog.check(checksums); - } - - /** - * Returns the variable proxy which stores the current inconsistency state - * - */ - public VariableProxy<Boolean> getConsistencyToResolve() { - return this.inconsistencyToResolve; - } - - /** - * TODO CJ: write javadoc - * - */ - public boolean getExecutingChecksumErrorHandling() { - return consistencyWatchdog.executingChecksumErrorHandling; - } - - public Set<IPath> getPathesWithWrongChecksums() { - return this.pathesWithWrongChecksums; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DocumentChecksum.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DocumentChecksum.java deleted file mode 100644 index 9fc7f8f1cc766c40e3864191dbd7ab96fa967d7f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DocumentChecksum.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -import org.eclipse.core.runtime.IPath; - -/** - * This Class represents a checksum of an document. It contains the path, the - * length and the hash code of the document. - * - * @author chjacob - */ -public class DocumentChecksum { - - // the path to the concurrent document - private IPath path; - - // the length of the document - private int length; - - // the hash code of the document - private int hash; - - public DocumentChecksum(IPath path, int length, int hash) { - this.path = path; - this.length = length; - this.hash = hash; - } - - public IPath getPath() { - return path; - } - - public void setPath(IPath path) { - this.path = path; - } - - public int getLength() { - return length; - } - - public void setLength(int length) { - this.length = length; - } - - public int getHash() { - return hash; - } - - public void setHash(int hash) { - this.hash = hash; - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocument.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocument.java deleted file mode 100644 index ee01db8f52c235bda396a0cb6457fbe880be0792..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocument.java +++ /dev/null @@ -1,79 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.concurrent.IDriverManager; -import de.fu_berlin.inf.dpp.net.JID; - -public class DriverDocument implements IDriverManager { - - private static Logger logger = Logger.getLogger(DriverDocument.class); - - private final IPath editor; - - private final List<JID> currentDriver; - - public DriverDocument(IPath editor) { - this.editor = editor; - this.currentDriver = new Vector<JID>(); - } - - public IPath getEditor() { - return this.editor; - } - - public void addDriver(JID jid) { - /* if driver not exists in list. */ - if (!isDriver(jid)) { - this.currentDriver.add(jid); - } else { - DriverDocument.logger.debug("Driver " + jid - + " is already Driver for " - + this.editor.lastSegment().toString()); - } - } - - public boolean isDriver(JID jid) { - return this.currentDriver.contains(jid); - } - - public boolean noDriver() { - return this.currentDriver.isEmpty(); - } - - public void removeDriver(JID jid) { - if (isDriver(jid)) { - this.currentDriver.remove(jid); - } else { - DriverDocument.logger.warn("JID " + jid - + " is not driver for this document " - + this.editor.lastSegment().toString()); - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#exclusiveDriver() - */ - public boolean exclusiveDriver() { - if (this.currentDriver.size() > 1) { - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#getActiveDriver() - */ - public List<JID> getActiveDriver() { - return this.currentDriver; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocumentManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocumentManager.java deleted file mode 100644 index 5be766c26f8e1a182bf9babeaa91ec360a7e10f8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/concurrent/management/DriverDocumentManager.java +++ /dev/null @@ -1,280 +0,0 @@ -package de.fu_berlin.inf.dpp.concurrent.management; - -/** - * this manager class handles driver event and the appropriate documents. - * Additional this class is managing exclusive lock for temporary single driver - * actions. - */ -import java.util.HashMap; -import java.util.List; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.RoleActivity; -import de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -/** - * - * @author orieger - * - */ -public class DriverDocumentManager implements IDriverDocumentManager, - ISessionListener { - - private static Logger logger = Logger - .getLogger(DriverDocumentManager.class); - - /* list of all active driver. */ - private final List<JID> activeDriver; - - /* list of documents with appropriate drivers. */ - private final HashMap<IPath, DriverDocument> documents; - - private static DriverDocumentManager manager; - - /** - * private constructor for singleton pattern. - */ - private DriverDocumentManager() { - this.activeDriver = new Vector<JID>(); - this.documents = new HashMap<IPath, DriverDocument>(); - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - /** - * get instance of this singleton object - * - * @return instance of DriverDocumentManager - */ - public static DriverDocumentManager getInstance() { - /* at first time, create new manager. */ - if (DriverDocumentManager.manager == null) { - DriverDocumentManager.manager = new DriverDocumentManager(); - } - return DriverDocumentManager.manager; - } - - /** - * @param jid - * JID of the driver - * @return true if driver exists in active driver list, false otherwise - */ - public boolean isDriver(JID jid) { - if (jid != null) { - return this.activeDriver.contains(jid); - } else { - System.out.println("jid null"); - } - return false; - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager#getDriverForDocument - * (org.eclipse.core.runtime.IPath) - */ - public List<JID> getDriverForDocument(IPath path) { - if (this.documents.containsKey(path)) { - List<JID> drivers = this.documents.get(path).getActiveDriver(); - return drivers; - } - return new Vector<JID>(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#getActiveDriver() - */ - public List<JID> getActiveDriver() { - return this.activeDriver; - } - - public void addDriver(JID jid) { - // if (user.getUserRole() == UserRole.OBSERVER) { - // logger.error("User " + user.getJid() + " has not driver status! "); - // } - DriverDocumentManager.logger.debug("add driver for jid: " + jid); - if (!this.activeDriver.contains(jid)) { - this.activeDriver.add(jid); - } - } - - public void addDriverToDocument(IPath path, JID jid) { - addDriver(jid); - - DriverDocumentManager.logger.debug("add activer driver " + jid - + " to document " + path.lastSegment().toString()); - /* add driver to new document. */ - DriverDocument doc = this.documents.get(path); - if ((doc == null) || !this.documents.containsKey(path)) { - DriverDocumentManager.logger.debug("New document creates for " - + path.lastSegment().toString()); - /* create new instance of this documents. */ - doc = new DriverDocument(path); - this.documents.put(path, doc); - } - if (!doc.isDriver(jid)) { - doc.addDriver(jid); - } - } - - public void removeDriver(JID jid) { - DriverDocumentManager.logger.debug("remove driver " + jid); - - /* remove driver from all documents */ - for (IPath path : this.documents.keySet()) { - removeDriverFromDocument(path, jid); - } - - this.activeDriver.remove(jid); - - } - - /** - * remove driver from document and delete empty documents. - * - * @param path - * of the document - * @param jid - * removable driver - */ - private void removeDriverFromDocument(IPath path, JID jid) { - DriverDocument doc = this.documents.get(path); - if (doc.isDriver(jid)) { - doc.removeDriver(jid); - } - /* check for other driver or delete if no other driver exists. */ - if (doc.noDriver()) { - DriverDocumentManager.logger.debug("no driver exists for document " - + path.lastSegment().toString() - + ". Document delete from driver manager."); - /* delete driver document. */ - this.documents.remove(doc.getEditor()); - } - } - - /** - * new driver activity received and has to be managed. - * - * @param activity - */ - public void receiveActivity(IActivity activity) { - JID jid = new JID(activity.getSource()); - - /* if user is an active driver */ - if (isDriver(jid)) { - - /* editor activities. */ - if (activity instanceof EditorActivity) { - EditorActivity edit = (EditorActivity) activity; - - DriverDocumentManager.logger.debug("receive activity of " + jid - + " for editor " + edit.getPath().lastSegment() - + " and action " + edit.getType()); - - /* editor has activated. */ - if (edit.getType() == EditorActivity.Type.Activated) { - /* add driver to new document. */ - addDriverToDocument(edit.getPath(), jid); - } - /* editor has closed. */ - if (edit.getType() == EditorActivity.Type.Closed) { - /* remove driver */ - if (this.documents.containsKey(edit.getPath())) { - - removeDriverFromDocument(edit.getPath(), jid); - - } else { - DriverDocumentManager.logger - .warn("No driver document exists for " - + edit.getPath()); - } - } - } - if (activity instanceof RoleActivity) { - - } - - if (activity instanceof FileActivity) { - FileActivity file = (FileActivity) activity; - /* if file has been removed, delete appropriate driver document. */ - if (file.getType() == FileActivity.Type.Removed) { - this.documents.remove(file.getPath()); - } - } - } else { - DriverDocumentManager.logger.debug("JID " + jid - + " isn't an active driver."); - } - } - - public void driverChanged(JID driver, boolean replicated) { - if (isDriver(driver)) { - removeDriver(driver); - } else { - addDriver(driver); - } - - } - - public void userJoined(JID user) { - // nothing to do - - } - - public void userLeft(JID user) { - if (isDriver(user)) { - /* remove driver status. */ - removeDriver(user); - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.concurrent.IDriverManager#exclusiveDriver() - */ - public boolean exclusiveDriver() { - boolean result = true; - if (this.activeDriver.size() > 1) { - result = false; - } - return result; - } - - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - public void sessionEnded(ISharedProject session) { - activeDriver.clear(); - } - - public void sessionStarted(ISharedProject session) { - - // when this is called the host is already active Driver, remove all - // other - if (activeDriver.size() > 1) { - for (JID participant : activeDriver) { - if (!participant.equals(session.getHost().getJid())) { - activeDriver.remove(participant); - } - } - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/EditorManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/EditorManager.java deleted file mode 100644 index 9efa5dc7513b1d76d0b2322f0cb03239278b97e8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/EditorManager.java +++ /dev/null @@ -1,1219 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.editor; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.eclipse.core.filebuffers.FileBuffers; -import org.eclipse.core.filebuffers.ITextFileBufferManager; -import org.eclipse.core.filebuffers.manipulation.ConvertLineDelimitersOperation; -import org.eclipse.core.filebuffers.manipulation.FileBufferOperationRunner; -import org.eclipse.core.filebuffers.manipulation.TextFileBufferOperation; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.Path; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IDocumentExtension4; -import org.eclipse.jface.text.IDocumentListener; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.IElementStateListener; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.TextEditActivity; -import de.fu_berlin.inf.dpp.activities.TextSelectionActivity; -import de.fu_berlin.inf.dpp.activities.ViewportActivity; -import de.fu_berlin.inf.dpp.activities.EditorActivity.Type; -import de.fu_berlin.inf.dpp.editor.annotations.AnnotationSaros; -import de.fu_berlin.inf.dpp.editor.annotations.ContributionAnnotation; -import de.fu_berlin.inf.dpp.editor.annotations.SelectionAnnotation; -import de.fu_berlin.inf.dpp.editor.annotations.ViewportAnnotation; -import de.fu_berlin.inf.dpp.editor.internal.ContributionHelper; -import de.fu_berlin.inf.dpp.editor.internal.EditorAPI; -import de.fu_berlin.inf.dpp.editor.internal.IEditorAPI; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.IActivityListener; -import de.fu_berlin.inf.dpp.project.IActivityProvider; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -/** - * The EditorManager is responsible for handling all editors in a DPP-session. - * This includes the functionality of listening for user inputs in an editor, - * locking the editors of the observer. - * - * The EditorManager contains the testable logic. All untestable logic should - * only appear in an class of the {@link IEditorAPI} type. - * - * @author rdjemili - */ -public class EditorManager implements IActivityProvider, ISharedProjectListener { - - private class ElementStateListener implements IElementStateListener { - public void elementDirtyStateChanged(Object element, boolean isDirty) { - if (!EditorManager.this.isDriver || isDirty - || !(element instanceof FileEditorInput)) { - return; - } - - FileEditorInput fileEditorInput = (FileEditorInput) element; - IFile file = fileEditorInput.getFile(); - - if (file.getProject() != EditorManager.this.sharedProject - .getProject()) { - return; - } - - IPath path = file.getProjectRelativePath(); - saveText(path, false); - } - - public void elementContentAboutToBeReplaced(Object element) { - // ignore - } - - public void elementContentReplaced(Object element) { - // ignore - } - - public void elementDeleted(Object element) { - // ignore - } - - public void elementMoved(Object originalElement, Object movedElement) { - // ignore - } - } - - /** - * @author rdjemili - * - */ - private class EditorPool { - private final Map<IPath, HashSet<IEditorPart>> editorParts = new HashMap<IPath, HashSet<IEditorPart>>(); - - public void add(IEditorPart editorPart) { - IResource resource = EditorManager.this.editorAPI - .getEditorResource(editorPart); - IPath path = resource.getProjectRelativePath(); - - if (path == null) { - return; - } - - HashSet<IEditorPart> editors = this.editorParts.get(path); - - EditorManager.this.editorAPI.addSharedEditorListener(editorPart); - EditorManager.this.editorAPI.setEditable(editorPart, - EditorManager.this.isDriver); - - IDocumentProvider documentProvider = EditorManager.this.editorAPI - .getDocumentProvider(editorPart.getEditorInput()); - - documentProvider - .addElementStateListener(EditorManager.this.elementStateListener); - - IDocument document = EditorManager.this.editorAPI - .getDocument(editorPart); - - if (editors == null) { - editors = new HashSet<IEditorPart>(); - this.editorParts.put(path, editors); - } - - // if line delimiters are not in unix style convert them - if (document instanceof IDocumentExtension4) { - if (!((IDocumentExtension4) document).getDefaultLineDelimiter() - .equals("\n")) { - convertLineDelimiters(editorPart); - } - ((IDocumentExtension4) document).setInitialLineDelimiter("\n"); - } else { - EditorManager.log - .error("Can't discover line delimiter of document"); - } - document.addDocumentListener(EditorManager.this.documentListener); - editors.add(editorPart); - lastEditTimes.put(path, System.currentTimeMillis()); - lastRemoteEditTimes.put(path, System.currentTimeMillis()); - } - - private void convertLineDelimiters(IEditorPart editorPart) { - - EditorManager.log.debug("Converting line delimiters..."); - - // get path of file - IFile file = ((FileEditorInput) editorPart.getEditorInput()) - .getFile(); - IPath[] paths = new IPath[1]; - paths[0] = file.getFullPath(); - - ITextFileBufferManager buffManager = FileBuffers - .getTextFileBufferManager(); - - // convert operation to change line delimiters - TextFileBufferOperation convertOperation = new ConvertLineDelimitersOperation( - "\n"); - - // operation runner for the convert operation - FileBufferOperationRunner runner = new FileBufferOperationRunner( - buffManager, null); - - // execute convert operation in runner - try { - runner.execute(paths, convertOperation, - new NullProgressMonitor()); - } catch (OperationCanceledException e) { - EditorManager.log.error("Can't convert line delimiters! " - + e.getMessage()); - } catch (CoreException e) { - EditorManager.log.error("Can't convert line delimiters!" - + e.getMessage()); - } - } - - public void remove(IEditorPart editorPart) { - IResource resource = EditorManager.this.editorAPI - .getEditorResource(editorPart); - IPath path = resource.getProjectRelativePath(); - - if (path == null) { - return; - } - - HashSet<IEditorPart> editors = this.editorParts.get(path); - editors.remove(editorPart); - } - - public Set<IEditorPart> getEditors(IPath path) { - HashSet<IEditorPart> set = this.editorParts.get(path); - return set == null ? new HashSet<IEditorPart>() : set; // HACK - } - - public Set<IEditorPart> getAllEditors() { - Set<IEditorPart> all = new HashSet<IEditorPart>(); - - for (Set<IEditorPart> parts : this.editorParts.values()) { - for (IEditorPart part : parts) { - all.add(part); - } - } - - return all; - } - - public void removeAllEditors() { - editorParts.clear(); - } - } - - private class DocumentListener implements IDocumentListener { - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener - */ - public void documentAboutToBeChanged(final DocumentEvent event) { - // boolean checksumErrorHandling = Saros.getDefault() - // .getSessionManager().getSharedProject() - // .getConcurrentDocumentManager() - // .getExecutingChecksumErrorHandling(); - // if (checksumErrorHandling) - // return; - String text = event.getText() == null ? "" : event.getText(); - textAboutToBeChanged(event.getOffset(), text, event.getLength(), - event.getDocument()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener - */ - public void documentChanged(final DocumentEvent event) { - } - } - - private static Logger log = Logger.getLogger(EditorManager.class.getName()); - - private static EditorManager instance; - - private IEditorAPI editorAPI; - - private ISharedProject sharedProject; - - private final List<IActivityListener> activityListeners = new LinkedList<IActivityListener>(); - - private boolean isFollowing; - - private boolean isDriver; - - private final EditorPool editorPool = new EditorPool(); - - private final ElementStateListener elementStateListener = new ElementStateListener(); - - private final DocumentListener documentListener = new DocumentListener(); - - private IPath activeDriverEditor; - - private final Set<IPath> driverEditors = new HashSet<IPath>(); - - private ITextSelection driverTextSelection; - - /** all files that have connected document providers */ - private final Set<IFile> connectedFiles = new HashSet<IFile>(); - - private final List<ISharedEditorListener> editorListeners = new ArrayList<ISharedEditorListener>(); - - /* this activity has arrived and will be execute now. */ - private IActivity currentExecuteActivity; - - public HashMap<IPath, Long> lastEditTimes; - public HashMap<IPath, Long> lastRemoteEditTimes; - - public static EditorManager getDefault() { - if (EditorManager.instance == null) { - EditorManager.instance = new EditorManager(); - } - - return EditorManager.instance; - } - - public void setEditorAPI(IEditorAPI editorAPI) { - this.editorAPI = editorAPI; - editorAPI.setEditorManager(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - this.sharedProject = session; - assert (this.editorPool.editorParts.isEmpty()); - this.isDriver = this.sharedProject.isDriver(); - this.sharedProject.addListener(this); - this.sharedProject.getActivityManager().addProvider(this); - - activateOpenEditors(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - setAllEditorsToEditable(); - removeAllAnnotations(null, null); - - this.sharedProject.removeListener(this); - this.sharedProject.getActivityManager().removeProvider(this); - this.sharedProject = null; - this.editorPool.removeAllEditors(); - this.lastEditTimes.clear(); - this.lastRemoteEditTimes.clear(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - public void addSharedEditorListener(ISharedEditorListener editorListener) { - if (!this.editorListeners.contains(editorListener)) { - this.editorListeners.add(editorListener); - } - } - - public void removeSharedEditorListener(ISharedEditorListener editorListener) { - this.editorListeners.remove(editorListener); - } - - /** - * @return the path to the resource that the driver is currently editting. - * Can be <code>null</code>. - */ - public IPath getActiveDriverEditor() { - return this.activeDriverEditor; - } - - /** - * Returns the resource paths of editors that the driver is currently using. - * - * @return all paths (in project-relative format) of files that the driver - * is currently editing by using an editor. Never returns - * <code>null</code>. A empty set is returned if there are no - * currently opened editors. - */ - public Set<IPath> getDriverEditors() { - return this.driverEditors; - } - - /** - * Return the document of the given path. - * - * @param path - * the path of the wanted document - * @return the document or null if no document exists with given path or no - * editor with this file is open - */ - public IDocument getDocument(IPath path) { - Set<IEditorPart> editors = getEditors(path); - if (editors.isEmpty()) - return null; - AbstractTextEditor editor = (AbstractTextEditor) editors.toArray()[0]; - IEditorInput input = editor.getEditorInput(); - return editor.getDocumentProvider().getDocument(input); - } - - // TODO CJ: find a better solution - public IPath getPathOfDocument(IDocument doc) { - IPath path = null; - Set<IEditorPart> editors = editorPool.getAllEditors(); - for (IEditorPart editor : editors) { - if (editorAPI.getDocument(editor) == doc) { - path = editorAPI.getEditorResource(editor) - .getProjectRelativePath(); - break; - } - } - return path; - } - - /** - * @return the text selection that the driver is currently using. - */ - public ITextSelection getDriverTextSelection() { - return this.driverTextSelection; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void viewportChanged(int top, int bottom, IPath editor) { - if (!this.sharedProject.isHost()) { - return; - } - - fireActivity(new ViewportActivity(top, bottom, editor)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void selectionChanged(ITextSelection selection, ISelectionProvider sp) { - - IDocument doc = ((ITextViewer) sp).getDocument(); - - int offset = selection.getOffset(); - int length = selection.getLength(); - IPath path = getPathOfDocument(doc); - - if (path == null) { - log.error("Couldn't get editor!"); - } else - fireActivity(new TextSelectionActivity(offset, length, path)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void textAboutToBeChanged(int offset, String text, int replace, - IDocument document) { - if (!this.isDriver) { - this.currentExecuteActivity = null; - return; - } - - IEditorPart changedEditor = null; - IPath path = null; - - // search editor which changed - Set<IEditorPart> editors = editorPool.getAllEditors(); - for (IEditorPart editor : editors) { - if (editorAPI.getDocument(editor) == document) { - changedEditor = editor; - break; - } - } - - path = editorAPI.getEditorResource(changedEditor) - .getProjectRelativePath(); - - if (path != null) { - TextEditActivity activity = new TextEditActivity(offset, text, - replace, path); - /* - * check if text edit activity is executed by other driver activity - * recently. - */ - if (activity.sameLike(this.currentExecuteActivity)) { - this.currentExecuteActivity = null; - return; - } - - EditorManager.this.lastEditTimes.put(path, System - .currentTimeMillis()); - - fireActivity(activity); - - IEditorInput input = changedEditor.getEditorInput(); - IDocumentProvider provider = this.editorAPI - .getDocumentProvider(input); - IAnnotationModel model = provider.getAnnotationModel(input); - - ContributionHelper.splitAnnotation(model, offset); - } else { - log.error("Can't get editor path"); - } - } - - /* ---------- ISharedProjectListener --------- */ - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - this.isDriver = this.sharedProject.isDriver(); - activateOpenEditors(); - - removeAllAnnotations(null, ContributionAnnotation.TYPE); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - removeAllAnnotations(user.toString(), null); - } - - /* ---------- etc --------- */ - - /** - * Opens the editor that is currently used by the driver. This method needs - * to be called from an UI thread. Is ignored if caller is already driver. - */ - public void openDriverEditor() { - if (this.isDriver) { - return; - } - - IPath path = getActiveDriverEditor(); - if (path == null) { - return; - } - - this.editorAPI - .openEditor(this.sharedProject.getProject().getFile(path)); - } - - public void setEnableFollowing(boolean enable) { - this.isFollowing = enable; - - for (ISharedEditorListener editorListener : this.editorListeners) { - editorListener.followModeChanged(enable); - } - - openDriverEditor(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void addActivityListener(IActivityListener listener) { - this.activityListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void removeActivityListener(IActivityListener listener) { - this.activityListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void exec(final IActivity activity) { - - if (activity instanceof EditorActivity) { - EditorActivity editorActivity = (EditorActivity) activity; - - if (editorActivity.getType().equals(Type.Activated)) { - setActiveDriverEditor(editorActivity.getPath(), true); - - } else if (editorActivity.getType().equals(Type.Closed)) { - removeDriverEditor(editorActivity.getPath(), true); - - } else if (editorActivity.getType().equals(Type.Saved)) { - saveText(editorActivity.getPath(), true); - } - } - - if (activity instanceof TextEditActivity) { - execTextEdit((TextEditActivity) activity); - } else if (activity instanceof TextSelectionActivity) { - execTextSelection((TextSelectionActivity) activity); - } else if (activity instanceof ViewportActivity) { - execViewport((ViewportActivity) activity); - } - } - - private void execTextEdit(TextEditActivity textEdit) { - - IPath path = textEdit.getEditor(); - IFile file = EditorManager.this.sharedProject.getProject() - .getFile(path); - - /* set current execute activity to avoid cirle executions. */ - EditorManager.this.currentExecuteActivity = textEdit; - - replaceText(file, textEdit.offset, textEdit.replace, textEdit.text, - textEdit.getSource()); - - Set<IEditorPart> editors = EditorManager.this.editorPool - .getEditors(path); - for (IEditorPart editorPart : editors) { - EditorManager.this.editorAPI.setSelection(editorPart, - new TextSelection(textEdit.offset + textEdit.text.length(), - 0), textEdit.getSource()); - } - } - - private void execTextSelection(TextSelectionActivity cursor) { - IPath path = cursor.getEditor(); - TextSelection textSelection = new TextSelection(cursor.getOffset(), - cursor.getLength()); - - setDriverTextSelection(textSelection); - - if (path == null) { - EditorManager.log - .error("Received text selection but have no driver editor"); - return; - } - - Set<IEditorPart> editors = EditorManager.this.editorPool - .getEditors(path); - for (IEditorPart editorPart : editors) { - EditorManager.this.editorAPI.setSelection(editorPart, - textSelection, cursor.getSource()); - } - } - - private void execViewport(ViewportActivity viewport) { - - int top = viewport.getTopIndex(); - int bottom = viewport.getBottomIndex(); - IPath path = viewport.getEditor(); - - Set<IEditorPart> editors = EditorManager.this.editorPool - .getEditors(path); - for (IEditorPart editorPart : editors) { - EditorManager.this.editorAPI.setViewport(editorPart, - EditorManager.this.isFollowing, top, bottom, - EditorManager.this.sharedProject.getDriver().getJid() - .toString()); - } - } - - // TODO unify partActivated and partOpened - public void partOpened(IEditorPart editorPart) { - if (!isSharedEditor(editorPart)) { - return; - } - - this.editorPool.add(editorPart); - sharedEditorActivated(editorPart); // HACK - } - - public void partActivated(IEditorPart editorPart) { - if (!isSharedEditor(editorPart)) { - return; - } - - sharedEditorActivated(editorPart); - } - - public void partClosed(IEditorPart editorPart) { - if (!isSharedEditor(editorPart)) { - return; - } - - IResource resource = this.editorAPI.getEditorResource(editorPart); - IPath path = resource.getProjectRelativePath(); - - this.editorPool.remove(editorPart); - - if (this.isDriver) { - removeDriverEditor(path, false); - } - } - - /** - * Checks wether given resource is currently opened. - * - * @param path - * the project-relative path to the resource. - * @return <code>true</code> if the given resource is opened accoring to the - * editor pool. - */ - public boolean isOpened(IPath path) { - return this.editorPool.getEditors(path).size() > 0; - } - - /** - * Gives the editors of given path. - * - * @param path - * the project-relative path to the resource. - * @return the set of editors - */ - public Set<IEditorPart> getEditors(IPath path) { - return this.editorPool.getEditors(path); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public IActivity fromXML(XmlPullParser parser) { - - try { - if (parser.getName().equals("editor")) { - return parseEditorActivity(parser); - - } else if (parser.getName().equals("edit")) { - return parseTextEditActivity(parser); - - } else if (parser.getName().equals("textSelection")) { - return parseTextSelection(parser); - - } else if (parser.getName().equals("viewport")) { - return parseViewport(parser); - } - - } catch (XmlPullParserException e) { - EditorManager.log.error("Couldn't parse message"); - } catch (IOException e) { - EditorManager.log.error("Couldn't parse message"); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public String toXML(IActivity activity) { - if (activity instanceof EditorActivity) { - EditorActivity editorActivity = (EditorActivity) activity; - // return "<editor " + "path=\"" + editorActivity.getPath() + "\" " - // + "type=\"" - // + editorActivity.getType() + "\" />"; - return "<editor " + "path=\"" + editorActivity.getPath() + "\" " - + "type=\"" + editorActivity.getType() + "\" " - + "checksum=\"" + editorActivity.getChecksum() + "\" />"; - - } else if (activity instanceof TextEditActivity) { - TextEditActivity textEditActivity = (TextEditActivity) activity; - return "<edit " + "path=\"" + textEditActivity.getEditor() + "\" " - + "offset=\"" + textEditActivity.offset + "\" " - + "replace=\"" + textEditActivity.replace + "\">" - + "<![CDATA[" + textEditActivity.text + "]]>" + "</edit>"; - - } else if (activity instanceof TextSelectionActivity) { - TextSelectionActivity textSelection = (TextSelectionActivity) activity; - assert textSelection.getEditor() != null; - return "<textSelection " + "offset=\"" + textSelection.getOffset() - + "\" " + "length=\"" + textSelection.getLength() + "\" " - + "editor=\"" - + textSelection.getEditor().toPortableString() + "\" />"; - - } else if (activity instanceof ViewportActivity) { - ViewportActivity viewportActvity = (ViewportActivity) activity; - assert viewportActvity.getEditor() != null; - return "<viewport " + "top=\"" + viewportActvity.getTopIndex() - + "\" " + "bottom=\"" + viewportActvity.getBottomIndex() - + "\" " + "editor=\"" - + viewportActvity.getEditor().toPortableString() + "\" />"; - } - - return null; - } - - private IActivity parseTextEditActivity(XmlPullParser parser) - throws XmlPullParserException, IOException { - - // extract current editor for text edit. - String pathString = parser.getAttributeValue(null, "path"); - Path path = pathString.equals("null") ? null : new Path(pathString); - - int offset = Integer.parseInt(parser.getAttributeValue(null, "offset")); - int replace = Integer.parseInt(parser - .getAttributeValue(null, "replace")); - - String text = ""; - if (parser.next() == XmlPullParser.TEXT) { - text = parser.getText(); - } - - return new TextEditActivity(offset, text, replace, path); - } - - private IActivity parseEditorActivity(XmlPullParser parser) { - String pathString = parser.getAttributeValue(null, "path"); - String checksumString = parser.getAttributeValue(null, "checksum"); - - // TODO handle cases where the file is really named "null" - Path path = pathString.equals("null") ? null : new Path(pathString); - - Type type = EditorActivity.Type.valueOf(parser.getAttributeValue(null, - "type")); - EditorActivity edit = new EditorActivity(type, path); - try { - long checksum = Long.parseLong(checksumString); - edit.setChecksum(checksum); - } catch (Exception e) { - /* exception during parse process */ - } - - return edit; - } - - private TextSelectionActivity parseTextSelection(XmlPullParser parser) { - // TODO extract constants - int offset = Integer.parseInt(parser.getAttributeValue(null, "offset")); - int length = Integer.parseInt(parser.getAttributeValue(null, "length")); - String path = parser.getAttributeValue(null, "editor"); - return new TextSelectionActivity(offset, length, Path - .fromPortableString(path)); - } - - private ViewportActivity parseViewport(XmlPullParser parser) { - int top = Integer.parseInt(parser.getAttributeValue(null, "top")); - int bottom = Integer.parseInt(parser.getAttributeValue(null, "bottom")); - String path = parser.getAttributeValue(null, "editor"); - return new ViewportActivity(top, bottom, Path.fromPortableString(path)); - } - - private boolean isSharedEditor(IEditorPart editorPart) { - IResource resource = this.editorAPI.getEditorResource(editorPart); - return ((this.sharedProject != null) && (resource.getProject() == this.sharedProject - .getProject())); - } - - private void replaceText(IFile file, int offset, int replace, String text, - String source) { - FileEditorInput input = new FileEditorInput(file); - IDocumentProvider provider = this.editorAPI.getDocumentProvider(input); - - try { - if (!this.connectedFiles.contains(file)) { - provider.connect(input); - this.connectedFiles.add(file); - } - - IDocument doc = provider.getDocument(input); - doc.replace(offset, replace, text); - EditorManager.this.lastRemoteEditTimes.put(file - .getProjectRelativePath(), System.currentTimeMillis()); - - IAnnotationModel model = provider.getAnnotationModel(input); - ContributionHelper.insertAnnotation(model, offset, text.length(), - source); - - // Don't disconnect from provider yet, because otherwise the text - // changes would be lost. We only disconnect when the document is - // reset or saved. - - } catch (BadLocationException e) { - // TODO If this happens a resend of the original text should be - // initiated. - log - .error( - "Couldn't insert driver text because of bad location.", - e); - } catch (CoreException e) { - log.error("Couldn't insert driver text.", e); - } - } - - /** - * Needs to be called from a UI thread. - */ - private void resetText(IFile file) { - if (!file.exists()) { - return; - } - - FileEditorInput input = new FileEditorInput(file); - IDocumentProvider provider = this.editorAPI.getDocumentProvider(input); - - if (this.connectedFiles.contains(file)) { - provider.disconnect(input); - this.connectedFiles.remove(file); - } - } - - /** - * Saves the driver editor. - * - * @param path - * the path to the resource that the driver was editing. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>true</code> if it is an replication of an action from - * another participant of the shared project. - */ - public void saveText(IPath path, boolean replicated) { - for (ISharedEditorListener listener : this.editorListeners) { - listener.driverEditorSaved(path, replicated); - } - - if (replicated) { - IFile file = this.sharedProject.getProject().getFile(path); - FileEditorInput input = new FileEditorInput(file); - - try { - file.setReadOnly(false); - IDocumentProvider provider = this.editorAPI - .getDocumentProvider(input); - - // save not necessary, if we have no modified document - if (!this.connectedFiles.contains(file)) { - return; - } - - IDocument doc = provider.getDocument(input); - - IAnnotationModel model = provider.getAnnotationModel(input); - model.connect(doc); - - provider.saveDocument(new NullProgressMonitor(), input, doc, - true); - EditorManager.log.debug("Saved document " + path); - - model.disconnect(doc); - - provider.disconnect(input); - this.connectedFiles.remove(file); - - } catch (CoreException e) { - EditorManager.log.error("Failed to save document.", e); - } - - } else { - IActivity activity = new EditorActivity(Type.Saved, path); - for (IActivityListener listener : this.activityListeners) { - listener.activityCreated(activity); - } - } - } - - /** - * Sends given activity to all registered activity listeners. - */ - private void fireActivity(IActivity activity) { - for (IActivityListener listener : this.activityListeners) { - listener.activityCreated(activity); - } - } - - // TODO CJ: review needed - private void activateOpenEditors() { - Display.getDefault().syncExec(new Runnable() { - public void run() { - for (IEditorPart editorPart : EditorManager.this.editorAPI - .getOpenEditors()) { - partOpened(editorPart); - } - - IEditorPart activeEditor = EditorManager.this.editorAPI - .getActiveEditor(); - if (activeEditor != null) { - sharedEditorActivated(activeEditor); - } - } - }); - } - - private void sharedEditorActivated(IEditorPart editorPart) { - if (!this.sharedProject.isHost()) { - return; - } - - IResource resource = this.editorAPI.getEditorResource(editorPart); - IPath editorPath = resource.getProjectRelativePath(); - setActiveDriverEditor(editorPath, false); - - ITextSelection selection = this.editorAPI.getSelection(editorPart); - setDriverTextSelection(selection); - - ILineRange viewport = this.editorAPI.getViewport(editorPart); - int startLine = viewport.getStartLine(); - viewportChanged(startLine, startLine + viewport.getNumberOfLines(), - editorPath); - } - - private void setAllEditorsToEditable() { - for (IEditorPart editor : this.editorPool.getAllEditors()) { - this.editorAPI.setEditable(editor, true); - } - } - - /** - * Removes all contribution and viewport annotations. - */ - - private void removeAllAnnotations(String forUserID, String typeAnnotation) { - - for (IEditorPart editor : this.editorPool.getAllEditors()) { - IEditorInput input = editor.getEditorInput(); - IDocumentProvider provider = this.editorAPI - .getDocumentProvider(input); - IAnnotationModel model = provider.getAnnotationModel(input); - - if (model == null) { - continue; - } - - for (@SuppressWarnings("unchecked") - Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - String type = annotation.getType(); - - boolean isContribution = type - .equals(ContributionAnnotation.TYPE); - boolean isViewport = type.equals(ViewportAnnotation.TYPE); - boolean isTextSelection = type - .startsWith(SelectionAnnotation.TYPE); - - if (((typeAnnotation == null) && !isContribution && !isViewport && !isTextSelection) - || ((typeAnnotation != null) && (typeAnnotation - .equals(type) == false))) { - continue; - } - - AnnotationSaros anns = (AnnotationSaros) annotation; - boolean isfromuser = (forUserID == null) - || ((forUserID != null) && anns.getSource().equals( - forUserID)); - - if (isfromuser) { - model.removeAnnotation(annotation); - } - } - } - } - - private EditorManager() { - setEditorAPI(new EditorAPI()); - if ((Saros.getDefault() != null) - && (Saros.getDefault().getSessionManager() != null)) { - Saros.getDefault().getSessionManager().addSessionListener(this); - this.lastEditTimes = new HashMap<IPath, Long>(); - this.lastRemoteEditTimes = new HashMap<IPath, Long>(); - } - } - - /** - * Sets the currently active driver editor. - * - * @param path - * the project-relative path to the resource that the editor is - * currently editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - private void setActiveDriverEditor(IPath path, boolean replicated) { - this.activeDriverEditor = path; - this.driverEditors.add(path); - - for (ISharedEditorListener listener : this.editorListeners) { - listener.activeDriverEditorChanged(this.activeDriverEditor, - replicated); - } - - if (replicated) { - if (this.isFollowing) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - openDriverEditor(); - } - }); - } - - } else { - IActivity activity = new EditorActivity(Type.Activated, path); - for (IActivityListener listener : this.activityListeners) { - listener.activityCreated(activity); - } - } - } - - /** - * Removes the given editor from the list of editors that the driver is - * currently using. - * - * @param path - * the path to the resource that the driver was editting. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>true</code> if it is an replication of an action from - * another participant of the shared project. - */ - private void removeDriverEditor(final IPath path, boolean replicated) { - if (path.equals(this.activeDriverEditor)) { - setActiveDriverEditor(null, replicated); - } - - this.driverEditors.remove(path); - - for (ISharedEditorListener listener : this.editorListeners) { - listener.driverEditorRemoved(path, replicated); - } - - if (replicated) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - IFile file = EditorManager.this.sharedProject.getProject() - .getFile(path); - resetText(file); - - if (!EditorManager.this.isFollowing) { - return; - } - - Set<IEditorPart> editors = EditorManager.this.editorPool - .getEditors(path); - for (IEditorPart part : editors) { - EditorManager.this.editorAPI.closeEditor(part); - } - } - }); - - } else { - IActivity activity = new EditorActivity(Type.Closed, path); - for (IActivityListener listener : this.activityListeners) { - listener.activityCreated(activity); - } - } - } - - /** - * @param selection - * sets the current text selection that is used by the driver. - */ - private void setDriverTextSelection(ITextSelection selection) { - this.driverTextSelection = selection; - } - - /** - * To get the java system time of the last local edit operation. - * - * @param path - * the project relative path of the resource - * @return java system time of last local edit - */ - public long getLastEditTime(IPath path) { - return this.lastEditTimes.get(path); - } - - /** - * To get the java system time of the last remote edit operation. - * - * @param path - * the project relative path of the resource - * @return java system time of last remote edit - */ - public long getLastRemoteEditTime(IPath path) { - return this.lastRemoteEditTimes.get(path); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/ISharedEditorListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/ISharedEditorListener.java deleted file mode 100644 index 8d9760635b3678a22b42f23958ced73d82615e56..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/ISharedEditorListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.fu_berlin.inf.dpp.editor; - -import org.eclipse.core.runtime.IPath; - -public interface ISharedEditorListener { - /** - * The resource that the driver is currently editing has changed. - * - * @param path - * the project-relative path of the resource that is the new - * driver resource. - * - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and only - * replicated to this client. - */ - public void activeDriverEditorChanged(IPath path, boolean replicated); - - /** - * Is fired when the given editor is removed from the list of editors that - * the driver is currently using. - * - * @param path - * the path to the resource that the driver was editing. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - public void driverEditorRemoved(IPath path, boolean replicated); - - /** - * Is fired when the driver editor is saved. - * - * @param path - * the path to the resource that the driver was editing. - * @param replicated - * <code>false</code> if this action originates on this client. - * <code>false</code> if it is an replication of an action from - * another participant of the shared project. - */ - public void driverEditorSaved(IPath path, boolean replicated); - - /** - * Is fired when the follow mode is changed. - * - * @param enabled - * <code>true</code> if follow mode is enabled. - * <code>false</code> otherwise. - */ - public void followModeChanged(boolean enabled); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/AnnotationSaros.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/AnnotationSaros.java deleted file mode 100644 index 925f02705f311f9e17342c681b5861bba1504023..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/AnnotationSaros.java +++ /dev/null @@ -1,56 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -import org.eclipse.jface.text.source.Annotation; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.net.JID; - -public class AnnotationSaros extends Annotation { - - private String source; - - AnnotationSaros(String type, boolean isPersistent, String text, - String source) { - super(type, isPersistent, text); - this.source = source; - - if ( - // type.equals(ContributionAnnotation.TYPE) - // || - type.equals(SelectionAnnotation.TYPE)) { - - // TODO: improve color assingment and dynamic handling - int colorid = getColorIdForUser(source) + 1; - String mytype = type + "." + new Integer(colorid).toString(); - - setType(mytype); - } - } - - AnnotationSaros(String type, boolean isPersistent, String text) { - super(type, isPersistent, text); - this.source = null; - } - - public String getSource() { - return this.source; - } - - public void setSource(String source) { - this.source = source; - } - - protected int getColorIdForUser(String username) { - User user = Saros.getDefault().getSessionManager().getSharedProject() - .getParticipant(new JID(username)); - - int colorid = 1; - if (user != null) { - colorid = user.getColorID(); - } - - return colorid; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ContributionAnnotation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ContributionAnnotation.java deleted file mode 100644 index bbfd0080a5128c55058926dc0824eeaf94f14848..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ContributionAnnotation.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -/** - * Marks text contributions done by the driver. - * - * @author rdjemili - */ -public class ContributionAnnotation extends AnnotationSaros { - public static final String TYPE = "de.fu_berlin.inf.dpp.annotations.contribution"; - - public ContributionAnnotation() { - this("", ""); - } - - public ContributionAnnotation(String label, String source) { - super(ContributionAnnotation.TYPE, false, label, source); - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/SelectionAnnotation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/SelectionAnnotation.java deleted file mode 100644 index 03b1a9e6c4ef5ce6e15a174ef2a34ab195d61eba..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/SelectionAnnotation.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -/** - * Marks text selected by both driver and observer. - * - * Configuration of this annotation is done in the plugin-xml - * - * @author coezbek - */ -public class SelectionAnnotation extends AnnotationSaros { - - // base TYPE name, will be extended for different remote users - public static final String TYPE = "de.fu_berlin.inf.dpp.annotations.selection"; - - public SelectionAnnotation() { - this(null, null); - } - - public SelectionAnnotation(String label, String username) { - super(SelectionAnnotation.TYPE, false, label, username); - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ViewportAnnotation.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ViewportAnnotation.java deleted file mode 100644 index b4bc756bebf5f365b3a08c5482d6537c259c601c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/annotations/ViewportAnnotation.java +++ /dev/null @@ -1,132 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.annotations; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.text.source.IAnnotationPresentation; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.texteditor.AnnotationPreference; -import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; - -/** - * The annotation that shows were the driver currently is. - * - * Preferences are set in the plug-in XML - * - * @author rdjemili - */ -public class ViewportAnnotation extends AnnotationSaros implements - IAnnotationPresentation, IPropertyChangeListener { - - public static final String TYPE = "de.fu_berlin.inf.dpp.annotations.viewport"; - - public static final int LAYER = 6; - - private static final int INSET = 2; - - private static final double STROKE_SCALE = 0.5; - - private static final double FILL_SCALE = 0.9; - - private static Color strokeColor; - - private static Color fillColor; - - public ViewportAnnotation(String label, String source) { - super(ViewportAnnotation.TYPE, false, label, source); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.IAnnotationPresentation - */ - public void paint(GC gc, Canvas canvas, Rectangle bounds) { - if (ViewportAnnotation.strokeColor == null) { - ViewportAnnotation.strokeColor = getColor(ViewportAnnotation.STROKE_SCALE); - ViewportAnnotation.fillColor = getColor(ViewportAnnotation.FILL_SCALE); - } - - Point canvasSize = canvas.getSize(); - - gc.setBackground(ViewportAnnotation.fillColor); - gc.setForeground(ViewportAnnotation.strokeColor); - gc.setLineWidth(1); - - int x = ViewportAnnotation.INSET; - int y = bounds.y; - int w = canvasSize.x - 2 * ViewportAnnotation.INSET; - int h = bounds.height; - - if (y < 0) { - h = h + y; - y = 0; - } - - if (h <= 0) { - return; - } - - gc.fillRectangle(x, y, w, h); - gc.drawRectangle(x, y, w, h); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.source.IAnnotationPresentation - */ - public int getLayer() { - return IAnnotationPresentation.DEFAULT_LAYER; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.util.IPropertyChangeListener - */ - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals( - ViewportAnnotation.getColorPreferenceKey())) { - if (ViewportAnnotation.strokeColor != null) { - ViewportAnnotation.strokeColor.dispose(); - ViewportAnnotation.strokeColor = null; - - ViewportAnnotation.fillColor.dispose(); - ViewportAnnotation.fillColor = null; - } - } - } - - public static String getColorPreferenceKey() { - AnnotationPreferenceLookup lookup = EditorsUI - .getAnnotationPreferenceLookup(); - - AnnotationPreference preference = lookup - .getAnnotationPreference(ViewportAnnotation.TYPE); - - return preference.getColorPreferenceKey(); - } - - private Color getColor(double scale) { - IPreferenceStore store = EditorsUI.getPreferenceStore(); - store.addPropertyChangeListener(this); - - RGB rgb = PreferenceConverter.getColor(store, ViewportAnnotation - .getColorPreferenceKey()); - int red = (int) ((1.0 - scale) * rgb.red + 255 * scale); - int green = (int) ((1.0 - scale) * rgb.green + 255 * scale); - int blue = (int) ((1.0 - scale) * rgb.blue + 255 * scale); - rgb = new RGB(red, green, blue); - - return new Color(Display.getDefault(), rgb); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/ContributionHelper.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/ContributionHelper.java deleted file mode 100644 index 6cf5745059c3590bba67442ac04ecd1859dcce1d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/ContributionHelper.java +++ /dev/null @@ -1,106 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import java.util.Iterator; - -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; - -import de.fu_berlin.inf.dpp.editor.annotations.AnnotationSaros; -import de.fu_berlin.inf.dpp.editor.annotations.ContributionAnnotation; - -/** - * A helper class for handling the contribution annotation. - * - * @author rdjemili - */ -public class ContributionHelper { - - /** - * Inserts a contribution annotation to given model if there is not already - * a contribution annotation at given position. This method should be called - * after the text has changed. - */ - public static void insertAnnotation(IAnnotationModel model, int offset, - int length) { - - for (@SuppressWarnings("unchecked") - Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (!annotation.getType().equals(ContributionAnnotation.TYPE)) { - continue; - } - - if (model.getPosition(annotation).includes(offset)) { - return; - } - } - - if (length > 0) { - Position position = new Position(offset, length); - AnnotationSaros annotation = new ContributionAnnotation(); - model.addAnnotation(annotation, position); - } - } - - /** - * Inserts a contribution annotation to given model if there is not already - * a contribution annotation at given position. This method should be called - * after the text has changed. - */ - public static void insertAnnotation(IAnnotationModel model, int offset, - int length, String source) { - for (@SuppressWarnings("unchecked") - Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (!annotation.getType().equals(ContributionAnnotation.TYPE)) { - continue; - } - - if (model.getPosition(annotation).includes(offset)) { - return; - } - } - - if (length > 0) { - Position position = new Position(offset, length); - AnnotationSaros annotation = new ContributionAnnotation("", source); - model.addAnnotation(annotation, position); - } - } - - /** - * Splits the contribution annotation at given position, so that the - * following text change won't expand the annotation. This needs to be - * called before the text is changed. - */ - public static void splitAnnotation(IAnnotationModel model, int offset) { - for (@SuppressWarnings("unchecked") - Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (!annotation.getType().equals(ContributionAnnotation.TYPE)) { - continue; - } - - Position pos = model.getPosition(annotation); - - if ((offset > pos.offset) && (offset < pos.offset + pos.length)) { - Position pos1 = new Position(pos.offset, offset - pos.offset); - Position pos2 = new Position(offset, pos.length - - (offset - pos.offset)); - - model.removeAnnotation(annotation); - /* get source information and create an split annotation. */ - model.addAnnotation(new ContributionAnnotation("", - ((ContributionAnnotation) annotation).getSource()), - pos1); - model.addAnnotation(new ContributionAnnotation("", - ((ContributionAnnotation) annotation).getSource()), - pos2); - } - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/EditorAPI.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/EditorAPI.java deleted file mode 100644 index 70d3030ae50d745eb82102cfcd8534f7af896135..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/EditorAPI.java +++ /dev/null @@ -1,640 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import java.awt.Toolkit; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.ITextViewerExtension; -import org.eclipse.jface.text.IViewportListener; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.LineRange; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IPathEditorInput; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.texteditor.AbstractTextEditor; -import org.eclipse.ui.texteditor.DocumentProviderRegistry; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.IEditorStatusLine; -import org.eclipse.ui.texteditor.ITextEditor; - -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.editor.annotations.AnnotationSaros; -import de.fu_berlin.inf.dpp.editor.annotations.SelectionAnnotation; -import de.fu_berlin.inf.dpp.editor.annotations.ViewportAnnotation; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * The central implementation of the IEditorAPI which basically encapsulates the - * interaction with the TextEditor. - * - * @author rdjemili - * - */ -public class EditorAPI implements IEditorAPI { - - private class SharedProjectPartListener implements IPartListener2 { - public void partActivated(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - - if ((part != null) && (part instanceof IEditorPart)) { - IEditorPart editor = (IEditorPart) part; - EditorAPI.this.editorManager.partActivated(editor); - } - } - - public void partOpened(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - - if ((part != null) && (part instanceof IEditorPart)) { - IEditorPart editor = (IEditorPart) part; - EditorAPI.this.editorManager.partOpened(editor); - } - } - - public void partClosed(IWorkbenchPartReference partRef) { - IWorkbenchPart part = partRef.getPart(false); - - if ((part != null) && (part instanceof IEditorPart)) { - IEditorPart editor = (IEditorPart) part; - EditorAPI.this.editorManager.partClosed(editor); - } - } - - public void partBroughtToTop(IWorkbenchPartReference partRef) { - } - - public void partDeactivated(IWorkbenchPartReference partRef) { - } - - public void partHidden(IWorkbenchPartReference partRef) { - } - - public void partVisible(IWorkbenchPartReference partRef) { - } - - public void partInputChanged(IWorkbenchPartReference partRef) { - } - } - - private class EditorListener implements IViewportListener, MouseListener, - KeyListener, ISelectionChangedListener { - - private final ITextViewer viewer; - - private ITextSelection lastSelection = new TextSelection(-1, -1); - - private int lastViewportTop = -1; - - private int lastViewportBottom = -1; - - public EditorListener(ITextViewer viewer) { - this.viewer = viewer; - - viewer.getTextWidget().addMouseListener(this); - viewer.getTextWidget().addKeyListener(this); - viewer.getSelectionProvider().addSelectionChangedListener(this); - viewer.addViewportListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IViewportListener - */ - public void viewportChanged(int verticalOffset) { - // TODO why doesnt this react to window resizes? - checkViewport(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener - */ - public void mouseDown(MouseEvent e) { - checkSelection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener - */ - public void mouseUp(MouseEvent e) { - checkSelection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener - */ - public void mouseDoubleClick(MouseEvent e) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.KeyListener - */ - public void keyReleased(KeyEvent e) { - checkSelection(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.KeyListener - */ - public void keyPressed(KeyEvent e) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ISelectionChangedListener - */ - public void selectionChanged(SelectionChangedEvent event) { - checkSelection(); - } - - private void checkSelection() { - ISelectionProvider sp = this.viewer.getSelectionProvider(); - ITextSelection selection = (ITextSelection) sp.getSelection(); - - if (!this.lastSelection.equals(selection)) { - EditorAPI.this.editorManager.selectionChanged(selection, sp); - this.lastSelection = selection; - } - } - - private void checkViewport() { - int top = this.viewer.getTopIndex(); - int bottom = this.viewer.getBottomIndex(); - IPath editor = EditorAPI.this.editorManager - .getPathOfDocument(this.viewer.getDocument()); - - if ((top != this.lastViewportTop) - || (bottom != this.lastViewportBottom)) { - this.lastViewportTop = top; - this.lastViewportBottom = bottom; - - EditorAPI.this.editorManager.viewportChanged(this.viewer - .getTopIndex(), this.viewer.getBottomIndex(), editor); - } - } - } - - private static Logger log = Logger.getLogger(EditorAPI.class.getName()); - - private final VerifyKeyListener keyVerifier = new VerifyKeyListener() { - public void verifyKey(VerifyEvent event) { - - log.debug(((int) event.character) + " - " + event.keyCode + " - " - + event.stateMask); - - if (event.character > 0) { - event.doit = false; - - Object adapter = getActiveEditor().getAdapter( - IEditorStatusLine.class); - if (adapter != null) { - IEditorStatusLine statusLine = (IEditorStatusLine) adapter; - statusLine - .setMessage( - false, - "You're not allowed to perform modifications while not being the driver of the session.", - null); - Toolkit.getDefaultToolkit().beep(); - } - } - } - }; - - private EditorManager editorManager; - - /** Editors where the user isn't allowed to write */ - private final List<IEditorPart> lockedEditors = new ArrayList<IEditorPart>(); - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setEditorManager(EditorManager editorManager) { - this.editorManager = editorManager; - - Display.getDefault().syncExec(new Runnable() { - public void run() { - IWorkbenchWindow window = EditorAPI.getActiveWindow(); - window.getPartService().addPartListener( - new SharedProjectPartListener()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IEditorPart openEditor(IFile file) { - IWorkbenchWindow window = EditorAPI.getActiveWindow(); - if (window != null) { - try { - IWorkbenchPage page = window.getActivePage(); - return IDE.openEditor(page, file); - - } catch (PartInitException e) { - e.printStackTrace(); - } - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void closeEditor(IEditorPart part) { - IWorkbenchWindow window = EditorAPI.getActiveWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - page.closeEditor(part, false); - } - } - - @SuppressWarnings("restriction") - public IDocumentProvider getDocumentProvider(IEditorInput input) { - Object adapter = input.getAdapter(IFile.class); - if (adapter != null) { - IFile file = (IFile) adapter; - - String fileExtension = file.getFileExtension(); - if ((fileExtension != null) && fileExtension.equals("java")) { - JavaPlugin javaPlugin = JavaPlugin.getDefault(); - return javaPlugin.getCompilationUnitDocumentProvider(); - } - } - - DocumentProviderRegistry registry = DocumentProviderRegistry - .getDefault(); - return registry.getDocumentProvider(input); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public Set<IEditorPart> getOpenEditors() { - Set<IEditorPart> editorParts = new HashSet<IEditorPart>(); - - IWorkbenchWindow[] windows = EditorAPI.getWindows(); - for (IWorkbenchWindow window : windows) { - IWorkbenchPage[] pages = window.getPages(); - - for (IWorkbenchPage page : pages) { - IEditorReference[] editorRefs = page.getEditorReferences(); - - for (IEditorReference reference : editorRefs) { - IEditorPart editorPart = reference.getEditor(true); - - if (editorPart != null) { - editorParts.add(editorPart); - } - } - } - } - - return editorParts; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IEditorPart getActiveEditor() { - IWorkbenchWindow window = EditorAPI.getActiveWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - return page.getActiveEditor(); - } - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IResource getEditorResource(IEditorPart editorPart) { - IEditorInput input = editorPart.getEditorInput(); - - if (input instanceof IPathEditorInput) { - IResource resource = (IResource) input.getAdapter(IFile.class); - - if (resource == null) { - resource = (IResource) input.getAdapter(IResource.class); - } - - return resource; - } - - return null; - } - - /* - * This implementation does not really set the selection but rather adds an - * annotation. - * - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setSelection(IEditorPart editorPart, ITextSelection selection, - String source) { - - if (!(editorPart instanceof ITextEditor)) { - return; - } - - ITextEditor textEditor = (ITextEditor) editorPart; - - IDocumentProvider docProvider = textEditor.getDocumentProvider(); - - if (docProvider != null) { - IAnnotationModel model = docProvider.getAnnotationModel(textEditor - .getEditorInput()); - - if (model != null) { - - for (@SuppressWarnings("unchecked") - Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation annotation = (Annotation) it.next(); - - if (annotation.getType().startsWith( - SelectionAnnotation.TYPE) == false) { - continue; - } - - AnnotationSaros anns = (AnnotationSaros) annotation; - if (anns.getSource().equals(source)) { - model.removeAnnotation(annotation); - } - } - - JID sourceJid = new JID(source); - String label = "Selection of " + sourceJid.getName(); - - Position position = new Position(selection.getOffset(), - selection.getLength()); - AnnotationSaros annotation = new SelectionAnnotation(label, - source); // BG:was - // source - model.addAnnotation(annotation, position); - } - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI#getSelection - */ - public ITextSelection getSelection(IEditorPart editorPart) { - if (!(editorPart instanceof ITextEditor)) { - return null; - } - - ITextEditor textEditor = (ITextEditor) editorPart; - ISelectionProvider selectionProvider = textEditor - .getSelectionProvider(); - if (selectionProvider != null) { - return (ITextSelection) selectionProvider.getSelection(); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setEditable(final IEditorPart editorPart, final boolean editable) { - EditorAPI.log.debug(editorPart + " set to editable:" + editable); - - Display.getDefault().syncExec(new Runnable() { - public void run() { - updateStatusLine(editorPart, editable); - - ITextViewerExtension textViewer = (ITextViewerExtension) EditorAPI - .getViewer(editorPart); - - if (textViewer == null) { - return; - } - - if (editable - && EditorAPI.this.lockedEditors.contains(editorPart)) { - EditorAPI.this.lockedEditors.remove(editorPart); - textViewer - .removeVerifyKeyListener(EditorAPI.this.keyVerifier); - - // enable editing and undo-manager - SourceViewer sourceViewer = (SourceViewer) textViewer; - sourceViewer.setEditable(true); - - // TODO use undoLevel from Preferences (TextEditorPlugin) - sourceViewer.getUndoManager().setMaximalUndoLevel(200); - - } else if (!editable - && !EditorAPI.this.lockedEditors.contains(editorPart)) { - EditorAPI.this.lockedEditors.add(editorPart); - textViewer - .appendVerifyKeyListener(EditorAPI.this.keyVerifier); - - // disable editing and undo-manager - SourceViewer sourceViewer = (SourceViewer) textViewer; - sourceViewer.setEditable(false); - sourceViewer.getUndoManager().setMaximalUndoLevel(0); - } - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void addSharedEditorListener(IEditorPart editorPart) { - new EditorListener(EditorAPI.getViewer(editorPart)); // HACK - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public IDocument getDocument(IEditorPart editorPart) { - AbstractTextEditor textEditor = (AbstractTextEditor) editorPart; - IEditorInput input = textEditor.getEditorInput(); - - return textEditor.getDocumentProvider().getDocument(input); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.internal.IEditorAPI - */ - public void setViewport(IEditorPart editorPart, boolean jumpTo, int top, - int bottom, String source) { - - ITextViewer viewer = EditorAPI.getViewer(editorPart); - updateViewportAnnotation(viewer, top, bottom, source); - - if (jumpTo) { - viewer.setTopIndex(top); - } - } - - public ILineRange getViewport(IEditorPart editorPart) { - ITextViewer viewer = EditorAPI.getViewer(editorPart); - - int top = viewer.getTopIndex(); - int bottom = viewer.getBottomIndex(); - - return new LineRange(top, bottom - top); - } - - private void updateViewportAnnotation(ITextViewer viewer, int top, - int bottom, String source) { - - if (!(viewer instanceof ISourceViewer)) { - return; - } - - ISourceViewer sourceViewer = (ISourceViewer) viewer; - IAnnotationModel model = sourceViewer.getAnnotationModel(); - - try { - IDocument document = viewer.getDocument(); - for (@SuppressWarnings("unchecked") - Iterator it = model.getAnnotationIterator(); it.hasNext();) { - Annotation ann = (Annotation) it.next(); - if (ann.getType().equals(ViewportAnnotation.TYPE)) { - model.removeAnnotation(ann); - } - } - - int start = document.getLineOffset(top); - int end = document.getLineOffset(bottom); - - JID jid = new JID(source); - String text = "Visible scope of " + jid.getName(); - - AnnotationSaros annotation = new ViewportAnnotation(text, source); - Position position = new Position(start, end - start); - model.addAnnotation(annotation, position); - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - /** - * Needs UI-thread. - */ - private void updateStatusLine(IEditorPart editorPart, boolean editable) { - Object adapter = editorPart.getAdapter(IEditorStatusLine.class); - if (adapter != null) { - IEditorStatusLine statusLine = (IEditorStatusLine) adapter; - statusLine.setMessage(false, editable ? "" : "Not editable", null); - } - } - - private static ITextViewer getViewer(IEditorPart editorPart) { - return (ITextViewer) editorPart.getAdapter(ITextOperationTarget.class); - } - - /** - * Returns the active workbench window. Needs to be called from UI thread. - * - * @return the active workbench window or <code>null</code> if there is no - * window or method is called from non-UI thread. - * @see IWorkbench#getActiveWorkbenchWindow() - */ - private static IWorkbenchWindow getActiveWindow() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - } - - private static IWorkbenchWindow[] getWindows() { - return PlatformUI.getWorkbench().getWorkbenchWindows(); - } - - /* - * private void makeAllProjectResourcesReadOnly(ISharedProject - * sharedProject) { - * - * try { ResourceAttributes attributes = new ResourceAttributes(); - * attributes.setReadOnly(!sharedProject.isDriver()); - * attributes.setArchive(!sharedProject.isDriver()); - * - * IResource[] resources = sharedProject.getProject().members(); for (int i - * = 0; i < resources.length; i++) { if (resources[i] instanceof IFile) { - * IFile file = (IFile) resources[i]; - * - * try { file.setResourceAttributes(attributes); } catch (CoreException e) { - * // TODO Auto-generated catch block e.printStackTrace(); } } } } catch - * (CoreException e) { e.printStackTrace(); } } - */ -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/IEditorAPI.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/IEditorAPI.java deleted file mode 100644 index 26b86ced2c68ad077801078ec53aa93be68589c2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/IEditorAPI.java +++ /dev/null @@ -1,112 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.jface.text.source.ILineRange; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.texteditor.IDocumentProvider; - -import de.fu_berlin.inf.dpp.editor.EditorManager; - -/** - * An humble interface that is responsible for editor functionality. The idea - * behind this interface is to only capsulates the least possible amount of - * functionality - the one that can't be easily tested. All higher logic can be - * found in {@link EditorManager}. - * - * @author rdjemili - */ -public interface IEditorAPI { - /** - * Sets the editor manager that uses this IEditorAPI. The given editor - * manager will receive the callbacks. - */ - public void setEditorManager(EditorManager editorManager); - - /** - * Opens the editor with given file. Needs to be called from an UI thread. - * - * @return the opened editor or <code>null</code> if the editor couldn't be - * opened. - */ - public IEditorPart openEditor(IFile file); - - /** - * Closes the given editorpart. - * - * Needs to be called from an UI thread. - */ - public void closeEditor(IEditorPart part); - - /** - * @return the editor that is currently activated. - */ - public IEditorPart getActiveEditor(); - - /** - * @return all editors that are currently opened. - */ - public Set<IEditorPart> getOpenEditors(); - - /** - * Sets the text selection in given editor. - */ - public void setSelection(IEditorPart editorPart, ITextSelection selection, - String source); - - /** - * Returns the current text selection for given editor. - * - * @param editorPart - * the editorPart for which to get the text selection. - * @return the current text selection. Returns - * {@link TextSelection#emptySelection()} if no text selection - * exists. - * - */ - public ITextSelection getSelection(IEditorPart editorPart); - - /** - * @return the file path that given editor is displaying. - */ - public IResource getEditorResource(IEditorPart editorPart); - - public void setViewport(IEditorPart editorPart, boolean jumpTo, int top, - int bottom, String source); - - /** - * Return the viewport for given editor. - * - * @param editorPart - * the editor for which to get the viewport - * @return the viewport. Never <code>null</code>. - */ - public ILineRange getViewport(IEditorPart editorPart); - - /** - * Enables/disables the ability to edit the document in given editor. - */ - public void setEditable(IEditorPart editorPart, boolean editable); - - /** - * Attaches listeners to the given editor that will fire the - * {@link IEditorListener} methods on the editor manager set with - * {@link #setEditorManager(EditorManager)}. - * - * Connecting to an editorPart multiple times, will result in multiple - * events. The caller is responsible for organizing connections. - * - * Needs to be called from a UI thread. - */ - public void addSharedEditorListener(IEditorPart editorPart); - - public IDocument getDocument(IEditorPart editorPart); - - public IDocumentProvider getDocumentProvider(IEditorInput editorInput); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/SharedDocumentProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/SharedDocumentProvider.java deleted file mode 100644 index d1a0772a731f4aff6fc76adf81002130b3d6ccaa..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/editor/internal/SharedDocumentProvider.java +++ /dev/null @@ -1,131 +0,0 @@ -package de.fu_berlin.inf.dpp.editor.internal; - -import org.eclipse.core.resources.IProject; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.editors.text.TextFileDocumentProvider; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -public class SharedDocumentProvider extends TextFileDocumentProvider implements - ISessionListener, ISharedProjectListener { - - private ISharedProject sharedProject; - - private boolean isDriver; - - public SharedDocumentProvider() { - ISessionManager sm = Saros.getDefault().getSessionManager(); - if (sm.getSharedProject() != null) { - sessionStarted(sm.getSharedProject()); - } - - sm.addSessionListener(this); - } - - @Override - public boolean isReadOnly(Object element) { - if ((this.sharedProject == null) || !isInSharedProject(element)) { - return super.isReadOnly(element); - } - - return !this.isDriver || super.isReadOnly(element); - } - - @Override - public boolean isModifiable(Object element) { - if ((this.sharedProject == null) || !isInSharedProject(element)) { - return super.isModifiable(element); - } - - return this.isDriver && super.isModifiable(element); - } - - @Override - public boolean canSaveDocument(Object element) { - if ((this.sharedProject == null) || !isInSharedProject(element)) { - return super.canSaveDocument(element); - } - - return this.isDriver && super.canSaveDocument(element); - } - - @Override - public boolean mustSaveDocument(Object element) { - if ((this.sharedProject == null) || !isInSharedProject(element)) { - return super.mustSaveDocument(element); - } - - return this.isDriver && super.mustSaveDocument(element); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - this.sharedProject = session; - this.isDriver = this.sharedProject.isDriver(); - - this.sharedProject.addListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - this.sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - if (this.sharedProject != null) { - this.isDriver = this.sharedProject.isDriver(); // HACK - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private boolean isInSharedProject(Object element) { - IFileEditorInput fileEditorInput = (IFileEditorInput) element; - IProject project = fileEditorInput.getFile().getProject(); - - return project.equals(this.sharedProject.getProject()); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IIncomingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IIncomingInvitationProcess.java deleted file mode 100644 index 709a38b2ab1f9000dc099d069fafce50aa032a25..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IIncomingInvitationProcess.java +++ /dev/null @@ -1,58 +0,0 @@ -package de.fu_berlin.inf.dpp.invitation; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; - -import de.fu_berlin.inf.dpp.FileList; - -/** - * An incoming invitation process. Is created when we receive an invitation to a - * shared project on a remote system. - * - * @author rdjemili - */ -public interface IIncomingInvitationProcess extends IInvitationProcess { - - /** - * Requests the file list of the remotly shared project. This methods blocks - * until the file list is retrieved. - * - * This method can be called while in INVITATION_SENT state. - */ - public FileList requestRemoteFileList(IProgressMonitor monitor); - - /** - * @return the file list of the remotly shared project or <code>null</code> - * if it hasn't been requested and retrieved yet. Make a call to - * {@link #requestRemoteFileList(IProgressMonitor)} before using - * this method. - */ - public FileList getRemoteFileList(); - - /** - * Accepts the incoming invitation and creates the shared project. This - * method blocks until the synchronization is done. - * - * This method can be called by the user while in HOST_FILELIST_SENT state. - * - * @param baseProject - * the local project that is used as file base for the following - * replication. If this is <code>null</code> no project will be - * used as file base. - * @param newProjectName - * the project name of the new project that is to be generated. - * If this is <code>null</code> the <code>baseProject</code> will - * be overwritten. - * @param monitor - * a progressmonitor that monitors the whole process. Can not be - * <code>null</code>. - * - * @throws InvitationException - * - - */ - public void accept(IProject baseProject, String newProjectName, - IProgressMonitor monitor); - - public void setInvitationUI(IInvitationUI inviteUI); - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IInvitationProcess.java deleted file mode 100644 index 297be56157098e7e87ea305793bab33dd6116e32..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IInvitationProcess.java +++ /dev/null @@ -1,119 +0,0 @@ -package de.fu_berlin.inf.dpp.invitation; - -import java.io.InputStream; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.net.IFileTransferCallback; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * By contract calls to this invitiation process that are not expected, will - * throw a IllegalStateException. Use {@link #getPeer()} to decide wether a - * incoming message is destined for this process. - * - * TODO add special invitation process ID which can be used to specificly - * address certain invitations - * - * @author rdjemili - */ -public interface IInvitationProcess extends IFileTransferCallback { - - /** - * This class contains UI code which is needed by the invitation process. - * - * Both the outgoing and incoming invitation UIs need to implement this. - */ - public interface IInvitationUI { - - /** - * - * @param errorMsg - * Is null if the cancelation was due to a user action. - * @param replicated - * Is true if this message originated on the remote side or - * false if the message originated on the local side. - */ - public void cancel(String errorMsg, boolean replicated); - - public void updateInvitationProgress(final JID jid); - - public void runGUIAsynch(final Runnable runnable); - } - - /** - * All states that an invitiation process can possibly have. - */ - public static enum State { - INITIALIZED, INVITATION_SENT, HOST_FILELIST_REQUESTED, HOST_FILELIST_SENT, GUEST_FILELIST_SENT, SYNCHRONIZING, SYNCHRONIZING_DONE, DONE, CANCELED - } - - public static enum TransferMode { - JINGLE, IBB, DEFAULT - } - - /** - * @return the exception that occured while executing the process or - * <code>null</code> if no exception was thrown. - */ - public Exception getException(); - - /** - * @return the current state of the process. - */ - public State getState(); - - /** - * @return the current transfer mode. - */ - public TransferMode getTransferMode(); - - /** - * @return the peer that is participating with us in this process. For an - * incoming invitation this is the inviter. For an outgoing - * invitation this is the invitee. - */ - public JID getPeer(); - - /** - * @return the user-provided informal description that can be provided with - * an invitiation. - */ - public String getDescription(); - - /** - * - * @return the name of the project that is shared by the peer. - */ - public String getProjectName(); - - /** - * Cancels the invitation process. Is ignored if invitation was already - * cancelled. - * - * @param errorMsg - * the error that caused the cancellation. This should be some - * user-friendly text as it might be presented to the user. - * <code>null</code> if the cancellation was caused by the users - * request and not by some error. - * @param replicated - * <code>true</code> if this cancellation is caused by an remote - * system. <code>false</code> if it originates on our system. If - * <code>false</code> we send an cancellation message to our - * peer. - */ - public void cancel(String errorMsg, boolean replicated); - - /** - * @return <code>true</code> if this invitation process has consumed the - * input stream. <code>false</code> otherwise. - */ - public void resourceReceived(JID from, IPath path, InputStream input); - - public void fileListReceived(JID from, FileList fileList); - - public void invitationAccepted(JID from); - - public void joinReceived(JID from); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IOutgoingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IOutgoingInvitationProcess.java deleted file mode 100644 index 717d38ceddab1a06591426368fe4e4598a503943..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/IOutgoingInvitationProcess.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.fu_berlin.inf.dpp.invitation; - -/** - * An outgoing invitation process, which is used to invite new users to the - * shared project. - * - * @author rdjemili - */ -public interface IOutgoingInvitationProcess extends IInvitationProcess { - /** - * Synchronizing is the state right before completing the invitation - * process, where the files of the shared project are - * replicated/synchronized with the local project of the invitee. - */ - public void startSynchronization(); - - public int getProgressCurrent(); - - public int getProgressMax(); - - public String getProgressInfo(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/IncomingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/IncomingInvitationProcess.java deleted file mode 100644 index 8a2b3edb50af8e0317c5a082c52178a51e003630..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/IncomingInvitationProcess.java +++ /dev/null @@ -1,530 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.invitation.internal; - -import java.io.File; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.ErrorMessageDialog; - -/** - * An incoming invitation process. - * - * @author rdjemili - */ -public class IncomingInvitationProcess extends InvitationProcess implements - IIncomingInvitationProcess { - - private static Logger logger = Logger - .getLogger(IncomingInvitationProcess.class); - - private FileList remoteFileList; - - private IProject localProject; - - private int filesLeftToSynchronize; - - /** size of current transfered part of archive file. */ - private int transferedFileSize = 0; - - private IProgressMonitor progressMonitor; - - protected String projectName; - - public IncomingInvitationProcess(ITransmitter transmitter, JID from, - String projectName, String description) { - - super(transmitter, from, description); - - this.projectName = projectName; - setState(State.INVITATION_SENT); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public void fileListReceived(JID from, FileList fileList) { - assertState(State.HOST_FILELIST_REQUESTED); - - if (fileList == null) { - cancel("Failed to receive remote file list.", false); - } else { - this.remoteFileList = fileList; - setState(State.HOST_FILELIST_SENT); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IIncomingInvitationProcess - */ - public FileList requestRemoteFileList(IProgressMonitor monitor) { - assertState(State.INVITATION_SENT); - - monitor.beginTask("Requesting remote file list", - IProgressMonitor.UNKNOWN); - - this.transmitter.sendRequestForFileListMessage(this.peer); - setState(State.HOST_FILELIST_REQUESTED); - - while ((this.remoteFileList == null) && (this.state != State.CANCELED)) { - if (monitor.isCanceled()) { - cancel(null, false); - } - - try { - Thread.sleep(500); - monitor.worked(1); - } catch (InterruptedException e) { - } - } - - monitor.done(); - - // TODO: for testing - // tmode = TransferMode.IBB; - - return this.remoteFileList; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IIncomingInvitationProcess - */ - public void accept(IProject baseProject, String newProjectName, - IProgressMonitor monitor) { - - if ((newProjectName == null) && (baseProject == null)) { - throw new IllegalArgumentException( - "At least newProjectName or baseProject have to be not null."); - } - - try { - assertState(State.HOST_FILELIST_SENT); - - if (newProjectName != null) { - this.localProject = createNewProject(newProjectName, - baseProject); - } else { - this.localProject = baseProject; - } - - this.filesLeftToSynchronize = handleDiff(this.localProject, - this.remoteFileList); - - this.progressMonitor = monitor; - if (this.tmode == TransferMode.IBB) { - this.progressMonitor - .beginTask("Transfer archive file ...", 100); - } else { - this.progressMonitor.beginTask("Synchronizing...", - this.filesLeftToSynchronize); - } - setState(State.SYNCHRONIZING); - - this.transmitter.sendFileList(this.peer, new FileList( - this.localProject)); - - if (blockUntilAllFilesSynchronized(monitor)) { - done(); - } else { - cancel(null, false); - } - - } catch (Exception e) { - ErrorMessageDialog.showErrorMessage(new Exception( - "Exception during create project.")); - failed(e); - - } finally { - monitor.done(); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void invitationAccepted(JID from) { - failState(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void joinReceived(JID from) { - failState(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void resourceReceived(JID from, IPath path, InputStream in) { - IncomingInvitationProcess.logger.debug("new file received: " + path); - if (this.localProject == null) { - return; // we dont have started the new project yet, so received - // ressources are not welcomed - } - - try { - IFile file = this.localProject.getFile(path); - if (file.exists()) { - file.setReadOnly(false); - file - .setContents(in, IResource.FORCE, - new NullProgressMonitor()); - } else { - file.create(in, true, new NullProgressMonitor()); - IncomingInvitationProcess.logger.debug("New File created: " - + file.getName()); - } - } catch (Exception e) { - failed(e); - } - - /* - * archive file for transfering data finished. Unzip separate files. - */ - if (this.tmode == TransferMode.IBB) { - this.tmode = TransferMode.DEFAULT; - this.progressMonitor.beginTask("Files left: ", - this.filesLeftToSynchronize); - } - - this.progressMonitor.worked(1); - this.progressMonitor.subTask("Files left: " - + this.filesLeftToSynchronize); - - this.filesLeftToSynchronize--; - IncomingInvitationProcess.logger.debug("file counter: " - + this.filesLeftToSynchronize); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IIncomingInvitationProcess - */ - public FileList getRemoteFileList() { - return this.remoteFileList; - } - - /** - * Blocks until all files have been synchronized or cancel has been - * selected. - * - * @return <code>true</code> if all files were synchronized. - * <code>false</code> if operation was canceled by user. - */ - private boolean blockUntilAllFilesSynchronized(IProgressMonitor monitor) { - // TODO: deadlock abfangen. - while (this.filesLeftToSynchronize > 0) { - if (monitor.isCanceled() || (getState() == State.CANCELED)) { - return false; - } - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - } - - return true; - } - - /** - * Creates a new project. - * - * @param newProjectName - * the project name of the new project. - * @param baseProject - * if not <code>null</code> all files of the baseProject will be - * copied into the new project after having created it. - * @return the new project. - * @throws CoreException - * if something goes wrong while creating the new project. - */ - private IProject createNewProject(String newProjectName, - final IProject baseProject) throws CoreException { - - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - final IProject project = workspaceRoot.getProject(newProjectName); - - final File projectDir = new File(workspaceRoot.getLocation().toString() - + File.separator + newProjectName); - if (projectDir.exists()) { - projectDir.delete(); - } - - /* run project read only settings in progress monitor thread. */ - Display.getDefault().syncExec(new Runnable() { - public void run() { - ProgressMonitorDialog dialog = new ProgressMonitorDialog( - Display.getDefault().getActiveShell()); - try { - dialog.run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - - try { - - monitor.beginTask("Copy local resources ... ", - IProgressMonitor.UNKNOWN); - - project.clearHistory(null); - project.refreshLocal(IResource.DEPTH_INFINITE, - null); - - if (baseProject == null) { - project.create(new NullProgressMonitor()); - project.open(new NullProgressMonitor()); - } else { - baseProject.copy(project.getFullPath(), - true, new NullProgressMonitor()); - } - - } catch (CoreException e) { - IncomingInvitationProcess.logger - .warn( - "Exception during copy local ressources", - e); - monitor.done(); - } - - monitor.done(); - - } - - }); - } catch (InvocationTargetException e) { - IncomingInvitationProcess.logger.warn("", e); - e.printStackTrace(); - } catch (InterruptedException e) { - IncomingInvitationProcess.logger.warn("", e); - e.printStackTrace(); - } - - } - }); - - // TODO CO: What is this??? - // project.clearHistory(null); - // project.refreshLocal(IProject.DEPTH_INFINITE, null); - - return project; - } - - /** - * Prepares for receiving the missing resources. - * - * @param localProject - * the project that is used for the base of the replication. - * @param remoteFileList - * the file list of the remote project. - * @return the number of files that we need to receive to end the - * synchronization. - * @throws CoreException - * is thrown when getting all files of the local project. - */ - private int handleDiff(IProject localProject, FileList remoteFileList) - throws CoreException { - - // TODO: Thread - FileList diff = new FileList(localProject).diff(remoteFileList); - - removeUnneededResources(localProject, diff); - int addedPaths = addAllFolders(localProject, diff); - - return diff.getAddedPaths().size() - addedPaths - + diff.getAlteredPaths().size(); - } - - /** - * Removes all local resources that aren't part of the shared project we're - * currently joining. This includes files and folders. - * - * @param localProject - * the local project were the shared project will be replicated. - * @param diff - * the fileList which contains the diff information. - * @throws CoreException - */ - private void removeUnneededResources(IProject localProject, FileList diff) - throws CoreException { - - // TODO dont throw CoreException - // TODO check if this triggers the resource listener - for (IPath path : diff.getRemovedPaths()) { - if (path.hasTrailingSeparator()) { - IFolder folder = localProject.getFolder(path); - - if (folder.exists()) { - folder.delete(true, new NullProgressMonitor()); - } - - } else { - IFile file = localProject.getFile(path); - - // check if file exists because it might have already been - // deleted when deleting its folder - if (file.exists()) { - file.delete(true, new NullProgressMonitor()); - } - } - } - } - - private int addAllFolders(IProject localProject, FileList diff) - throws CoreException { - - int addedFolders = 0; - - for (IPath path : diff.getAddedPaths()) { - if (path.hasTrailingSeparator()) { - IFolder folder = localProject.getFolder(path); - if (!folder.exists()) { - folder.create(true, true, new NullProgressMonitor()); - } - - addedFolders++; - } - } - - return addedFolders; - } - - /** - * Ends the incoming invitiation process. - */ - private void done() { - JID host = this.peer; - JID driver = this.peer; - - // TODO: HACK - List<JID> users = new ArrayList<JID>(); - users.add(host); - users.add(Saros.getDefault().getMyJID()); - - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - ISharedProject sharedProject = sessionManager.joinSession( - this.localProject, host, driver, users); - - this.transmitter.sendJoinMessage(sharedProject); - this.transmitter.removeInvitationProcess(this); // HACK - - sharedProject.setProjectReadonly(true); - - setState(State.DONE); - } - - public String getProjectName() { - return this.projectName; - } - - public void updateInvitationProgress(JID jid) { - // ignored, not needed atm - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess#getTransferMode() - */ - public TransferMode getTransferMode() { - return this.tmode; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess#jingleFallback() - */ - public void jingleFallback() { - IncomingInvitationProcess.logger.warn("jingle fallback"); - this.tmode = TransferMode.IBB; - /* if send file list failed. */ - if (getState() == State.SYNCHRONIZING) { - IncomingInvitationProcess.logger - .debug("send file list another one."); - try { - this.transmitter.sendFileList(this.peer, new FileList( - this.localProject)); - } catch (Exception e) { - ErrorMessageDialog.showErrorMessage(new Exception( - "Exception during create project.")); - failed(e); - } - } - } - - public void fileSent(IPath path) { - // do nothing - - } - - public void fileTransferFailed(IPath path, Exception e) { - failed(e); - - } - - public void transferProgress(int transfered) { - this.progressMonitor.worked(transfered - this.transferedFileSize); - this.transferedFileSize = transfered; - } - - public void setTransferMode(TransferMode mode) { - this.tmode = mode; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/InvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/InvitationProcess.java deleted file mode 100644 index bafc8f86423e6984ae5a04c8df49e8319bb05397..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/InvitationProcess.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.invitation.internal; - -import org.apache.log4j.Logger; - -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * @author rdjemili - */ -public abstract class InvitationProcess implements IInvitationProcess { - - private static Logger logger = Logger.getLogger(InvitationProcess.class); - - protected final ITransmitter transmitter; - - protected State state; - - /** mode of file transfer. */ - protected TransferMode tmode; - - private Exception exception; - - protected JID peer; - - protected IInvitationUI invitationUI = null; - - protected String description; - - public InvitationProcess(ITransmitter transmitter, JID peer, - String description) { - this.transmitter = transmitter; - this.peer = peer; - this.description = description; - - this.tmode = TransferMode.JINGLE; - - transmitter.addInvitationProcess(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public Exception getException() { - return this.exception; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public State getState() { - return this.state; - } - - public void setState(State newstate) { - this.state = newstate; - - if (this.invitationUI != null) { - this.invitationUI.updateInvitationProgress(this.peer); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public JID getPeer() { - return this.peer; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IInvitationProcess - */ - public String getDescription() { - return this.description; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess - */ - public void cancel(String errorMsg, boolean replicated) { - if (this.state == State.CANCELED) { - return; - } - - setState(State.CANCELED); - - InvitationProcess.logger.error("Invitation was canceled. " + errorMsg); - - if (!replicated) { - this.transmitter.sendCancelInvitationMessage(this.peer, errorMsg); - } - - this.invitationUI.cancel(errorMsg, replicated); - - this.transmitter.removeInvitationProcess(this); - } - - @Override - public String toString() { - return "InvitationProcess(peer:" + this.peer + ", state:" + this.state - + ")"; - } - - /** - * Should be called if an exception occured. This saves the exception and - * sets the invitation to cancelled. - */ - protected void failed(Exception e) { - this.exception = e; - e.printStackTrace(); // HACK - cancel(e.getMessage(), false); - } - - /** - * Asssert that the process is in given state or throw an exception - * otherwise. - * - * @param expected - * the state that the process should currently have. - */ - protected void assertState(State expected) { - if (this.state != expected) { - cancel("Unexpected state(" + this.state + ")", false); - } - } - - protected void failState() { - throw new IllegalStateException("Bad input while in state " - + this.state); - } - - public void setInvitationUI(IInvitationUI inviteUI) { - this.invitationUI = inviteUI; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/OutgoingInvitationProcess.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/OutgoingInvitationProcess.java deleted file mode 100644 index f7bf2f1595dcdb6fcf420066402af21fca795f63..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/invitation/internal/OutgoingInvitationProcess.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.invitation.internal; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.FileZipper; - -/** - * An outgoing invitation process. - * - * @author rdjemili - */ -public class OutgoingInvitationProcess extends InvitationProcess implements - IOutgoingInvitationProcess { - - private static Logger logger = Logger - .getLogger(OutgoingInvitationProcess.class); - - private final ISharedProject sharedProject; - - private int progress_done; - private int progress_max; - private String progress_info; - - private FileList remoteFileList; - - private List<IPath> toSend; - - /** size of project archive file */ - private final long fileSize = 100; - private File archive; - /** size of current transfered part of archive file. */ - private long transferedFileSize = 0; - - public int getProgressCurrent() { - // TODO CJ: Jingle File Transfer progrss information - if (this.tmode == TransferMode.IBB) { - return (int) (this.transferedFileSize); - } else { - return this.progress_done + 1; - } - } - - public int getProgressMax() { - if (this.tmode == TransferMode.IBB) { - return (int) (this.fileSize); - } else { - return this.progress_max; - } - - } - - public String getProgressInfo() { - return this.progress_info; - } - - /** - * A simple runnable that calls - * {@link IOutgoingInvitationProcess#startSynchronization(IProgressMonitor)} - */ - private class SynchronizationRunnable implements Runnable { - private final OutgoingInvitationProcess process; - - public SynchronizationRunnable(OutgoingInvitationProcess process) { - this.process = process; - } - - public void run() { - this.process.startSynchronization(); - } - } - - public OutgoingInvitationProcess(ITransmitter transmitter, JID to, - ISharedProject sharedProject, String description, boolean startNow, - IInvitationUI inviteUI) { - - super(transmitter, to, description); - - this.invitationUI = inviteUI; - this.sharedProject = sharedProject; - - if (startNow) { - transmitter.sendInviteMessage(sharedProject, to, description); - setState(State.INVITATION_SENT); - } else { - setState(State.INITIALIZED); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IOutgoingInvitationProcess - */ - public void startSynchronization() { - assertState(State.GUEST_FILELIST_SENT); - - setState(State.SYNCHRONIZING); - - if ((this.tmode == TransferMode.JINGLE) - || (this.tmode == TransferMode.DEFAULT) - || (this.tmode == TransferMode.IBB)) { - try { - FileList local = new FileList(this.sharedProject.getProject()); - FileList diff = this.remoteFileList.diff(local); - - List<IPath> added = diff.getAddedPaths(); - List<IPath> altered = diff.getAlteredPaths(); - this.toSend = new ArrayList<IPath>(added.size() - + altered.size()); - this.toSend.addAll(added); - this.toSend.addAll(altered); - - this.progress_max = this.toSend.size(); - this.progress_done = 0; - - /* transfer all data with archive. */ - if (tmode == TransferMode.IBB) { - sendArchive(); - } else { - /* send separate files. */ - sendNext(); - } - - if (!blockUntilFilesSent() || !blockUntilJoinReceived()) { - cancel(null, false); - } - - } catch (CoreException e) { - failed(e); - - } - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void invitationAccepted(JID from) { - assertState(State.INVITATION_SENT); - - // HACK add resource specifier to jid - if (this.peer.equals(from)) { - this.peer = from; - } - - try { - this.transmitter.sendFileList(this.peer, this.sharedProject - .getFileList()); - setState(State.HOST_FILELIST_SENT); - } catch (Exception e) { - failed(e); - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void fileListReceived(JID from, FileList fileList) { - assertState(State.HOST_FILELIST_SENT); - - this.remoteFileList = fileList; - setState(State.GUEST_FILELIST_SENT); - - this.invitationUI.runGUIAsynch(new SynchronizationRunnable(this)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void joinReceived(JID from) { - assertState(State.SYNCHRONIZING_DONE); - - this.sharedProject.addUser(new User(from)); - setState(State.DONE); - - sendDriverEditors(); - - this.transmitter.removeInvitationProcess(this); // HACK - - this.transmitter.sendUserListTo(from, this.sharedProject - .getParticipants()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.InvitationProcess - */ - public void resourceReceived(JID from, IPath path, InputStream in) { - failState(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTransferCallback - */ - public void fileTransferFailed(IPath path, Exception e) { - failed(e); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTrafnsferCallback - */ - public void fileSent(IPath path) { - - if (this.tmode == TransferMode.IBB) { - setState(State.SYNCHRONIZING_DONE); - } else { - this.progress_done++; - sendNext(); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IFileTransferCallback#transferProgress(int) - */ - public void transferProgress(int transfered) { - this.transferedFileSize = transfered; - /* update ui */ - this.invitationUI.updateInvitationProgress(this.peer); - } - - private void sendNext() { - - if (getState() == State.CANCELED) { - this.toSend.clear(); - return; - } - - if (this.toSend.size() == 0) { - setState(State.SYNCHRONIZING_DONE); - return; - } - - IPath path = this.toSend.remove(0); - this.progress_info = path.toFile().getName(); - - this.invitationUI.updateInvitationProgress(this.peer); - - this.transmitter.sendFile(this.peer, this.sharedProject.getProject(), - path, this); - } - - /** - * send all project data with archive file. - */ - private void sendArchive() { - if (getState() == State.CANCELED) { - this.toSend.clear(); - return; - } - - if (this.toSend.size() == 0) { - setState(State.SYNCHRONIZING_DONE); - return; - } - - this.archive = new File("./" + getPeer().getName() + "_Project.zip"); - OutgoingInvitationProcess.logger - .debug("Project archive file has to be send. " - + this.archive.getAbsolutePath() + " length: " - + this.archive.length()); - try { - /* create project zip archive. */ - FileZipper.createProjectZipArchive(this.toSend, this.archive - .getAbsolutePath(), this.sharedProject.getProject()); - /* send data. */ - this.transmitter.sendProjectArchive(this.peer, this.sharedProject - .getProject(), this.archive, this); - } catch (Exception e) { - failed(e); - } - - this.progress_info = "Transfer project tar file"; - - // fileSize = archive.length(); - } - - /** - * Blocks until all files have been sent or the operation was canceled by - * the user. - * - * @param monitor - * the progress monitor for the file synchronization. - * @return <code>true</code> if all files have been synchronized. - * <code>false</code> if the user chose to cancel. - */ - private boolean blockUntilFilesSent() { - while ((this.state != State.SYNCHRONIZING_DONE) - && (this.state != State.DONE)) { - if (getState() == State.CANCELED) { - return false; - } - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - } - - return true; - } - - /** - * Blocks until the join message has been received or the user cancelled. - * - * @return <code>true</code> if the join message has been received. - * <code>false</code> if the user chose to cancel. - */ - private boolean blockUntilJoinReceived() { - this.progress_info = "Waiting for confirmation"; - - while (this.state != State.DONE) { - if (getState() == State.CANCELED) { - return false; - } - - try { - Thread.sleep(500); - } catch (InterruptedException e) { - } - } - this.progress_info = ""; - - return true; - } - - /** - * Send activities which set the active editors. - */ - private void sendDriverEditors() { - EditorManager editorManager = EditorManager.getDefault(); - Set<IPath> driverEditors = editorManager.getDriverEditors(); - IPath activeDriverEditor = editorManager.getActiveDriverEditor(); - driverEditors.remove(activeDriverEditor); - - FileList filelist; - try { - filelist = this.sharedProject.getFileList(); - } catch (CoreException e) { - filelist = null; - } - // HACK - for (IPath path : driverEditors) { - if ((filelist != null) - && (filelist.getPaths().contains(path) == false)) { - continue; - } - - this.sharedProject.getSequencer().activityCreated( - new EditorActivity(EditorActivity.Type.Activated, path)); - } - - if ((filelist != null) - && (filelist.getPaths().contains(activeDriverEditor) == true)) { - this.sharedProject.getSequencer().activityCreated( - new EditorActivity(EditorActivity.Type.Activated, - activeDriverEditor)); - } - } - - public String getProjectName() { - return this.sharedProject.getProject().getName(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.invitation.IInvitationProcess#getTransferMode() - */ - public TransferMode getTransferMode() { - return this.tmode; - } - - public void setTransferMode(TransferMode mode) { - this.tmode = mode; - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IActivitySequencer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IActivitySequencer.java deleted file mode 100644 index 8b4573e362e936e6a4e5449070efa703b1457ec2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IActivitySequencer.java +++ /dev/null @@ -1,58 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import java.util.List; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.concurrent.IRequestManager; -import de.fu_berlin.inf.dpp.project.IActivityListener; -import de.fu_berlin.inf.dpp.project.IActivityManager; - -/** - * The IActivitySequencer is responsible for making sure that activities are - * sent and received in the right order. - * - * @author rdjemili - * - */ -public interface IActivitySequencer extends IActivityListener, IRequestManager, - IActivityManager { - /** - * Gets all activities since last flush. - * - * @return the activities that have accumulated since the last flush or - * <code>null</code> if no activities are are available. - */ - public List<TimedActivity> flushTimed(); - - /** - * Executes the list of timed activities in the right order. - * - * @param activities - */ - public void exec(List<TimedActivity> activities); - - /** - * Executes given timed activity. - * - * @param activity - */ - public void exec(TimedActivity activity); - - public void execTransformedActivity(IActivity activity); - - /** - * @return the log of flushed activities. - */ - public List<IActivity> getLog(); - - /** - * @return the current timestamp. - */ - public int getTimestamp(); - - public List<TimedActivity> getActivityHistory(); - - public int getQueuedActivities(); - - // public IActivity receiveRequest(Request request); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IChatManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IChatManager.java deleted file mode 100644 index 1494079bc74155cbc34dc310202e6d9fed1124ff..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IChatManager.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; - -/** - * The IChatManager contains the logic for appropriate chat transfer. - * - * @author orieger - * - */ -public interface IChatManager extends PacketListener { - - public void setConnection(XMPPConnection connection, IReceiver receiver); - - public void setReceiver(IReceiver receiver); - - /** - * status of chat connection. - * - * @return - */ - public boolean isConnected(); - - public void sendRequest(Request request); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IConnectionListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IConnectionListener.java deleted file mode 100644 index 08069070eeae216c3362441a11dca1425ef2631b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IConnectionListener.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net; - -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; - -/** - * A listener for changes to the current connection state. Use - * {@link Saros#addListener(IConnectionListener)} to attach it. - * - * @author rdjemili - */ -public interface IConnectionListener { - - /** - * Is fired when the state of the connection changes. - * - * @param connection - * The affected XMPP-connection tht changed its state - * @param newState - * the new state of the connection. If the new state is - * <code>ERROR</code>, you can use - * {@link Saros#getConnectionError()} to get the error message. - */ - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IFileTransferCallback.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IFileTransferCallback.java deleted file mode 100644 index 990348515432235edbd0efdd6d4ed35cfa6b87ee..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IFileTransferCallback.java +++ /dev/null @@ -1,47 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import org.eclipse.core.runtime.IPath; - -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.TransferMode; - -/** - * This is an simple callback listener for non-blocking file transfers. - * - * @author rdjemili - */ -public interface IFileTransferCallback { - - /** - * Is fired when the file was successfully transfered. - * - * @param path - * the project-relative path to the file. - */ - public void fileSent(IPath path); - - /** - * Is fired when the file transfer failed. - * - * @param path - * the project-relative path to the file. - * @param e - * the exception that caused the fail or <code>null</code>. - */ - public void fileTransferFailed(IPath path, Exception e); - - /** - * Is fired part of file has transfered.. - * - * @param transfered - * current transfered size. - */ - public void transferProgress(int transfered); - - /** - * set transfer mode. TransferMode.Jingle for Jingle transfer or - * TransferMode.IBB for XMPP transfer. - * - * @param mode - */ - public void setTransferMode(TransferMode mode); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IOptimizer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IOptimizer.java deleted file mode 100644 index 1f729b0f737294d8f4109548cf896076e09b47f7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IOptimizer.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import java.util.List; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -public interface IOptimizer { - public List<IActivity> optimze(List<IActivity> activities); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IReceiver.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IReceiver.java deleted file mode 100644 index 2e3b8661698deec4a33cb7c9fa357b3a7b185ce3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/IReceiver.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.packet.Packet; - -/** - * The IReceiver contains methods to process incoming packets. - * - * @author orieger - * - */ -public interface IReceiver extends PacketListener { - - /** - * process jupiter request. - * - * @param packet - */ - public void processRequest(Packet packet); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/ITransmitter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/ITransmitter.java deleted file mode 100644 index fc0a00c2390ae296e2bf20713ac010dbc47e6930..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/ITransmitter.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming (c) Freie Universitaet Berlin - - * Fachbereich Mathematik und Informatik - 2006 (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 1, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 675 Mass - * Ave, Cambridge, MA 02139, USA. - */ - -package de.fu_berlin.inf.dpp.net; - -import java.io.File; -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IPath; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.management.DocumentChecksum; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -/** - * An humble interface that is responsible for network functionality. The idea - * behind this interface is to only capsulates the least possible amount of - * functionality - the one that can't be easily tested. - * - * @author rdjemili - */ -public interface ITransmitter { - - /* ---------- invitations --------- */ - - // TODO move aggregation of pending invitation to sessionManager - /** - * Adds given invitation to the list of pending invitations. - * - * @param invitation - * the invitation that to be added. - */ - public void addInvitationProcess(IInvitationProcess invitation); - - /** - * Removes given invitation from the list of pending invitations. - * - * @param invitation - * the invitation that is to be removed. - */ - public void removeInvitationProcess(IInvitationProcess invitation); - - /** - * Sends an invitation message for given shared project to given user. - * - * @param sharedProject - * the shared project to which the user should be invitited to. - * @param jid - * the Jabber ID of the user that is to be invited. - * @param description - * a informal description text that can be provided with the - * invitation. Can not be <code>null</code>. - */ - public void sendInviteMessage(ISharedProject sharedProject, JID jid, - String description); - - /** - * Sends an cancellation message that tells the receiver that the invitation - * is canceled. - * - * @param jid - * the Jabber ID of the receipient. - * @param errorMsg - * the reason why the invitation was canceled or - * <code>null</code>. - */ - public void sendCancelInvitationMessage(JID jid, String errorMsg); - - /* ---------- files --------- */ - - /** - * Sends given file list to given Jabber user. This methods blocks until the - * file transfer is done or failed. - * - * @param jid - * the Jabber ID of the user to which the file list is to be - * sent. - * @param fileList - * the file list that is to be sent. - * @throws XMPPException - * is thrown if there is some problem with the XMPP file - * transfer. - */ - public void sendFileList(JID jid, FileList fileList) throws XMPPException; - - /** - * Sends a request-for-file-list-message to given user. - * - * @param recipient - * the Jabber ID of the recipient. - */ - public void sendRequestForFileListMessage(JID recipient); - - /** - * Sends given file to given recipient. - * - * @param recipient - * the Jabber ID of the recipient. - * @param project - * TODO - * @param path - * the project-relative path of the resource that is to be sent. - * @param callback - * an callback for the file transfer state. Can be - * <code>null</code>. - */ - public void sendFile(JID recipient, IProject project, IPath path, - IFileTransferCallback callback); - - /** - * Sends given file to given recipient with given timestamp. - * - * @param recipient - * the Jabber ID of the recipient. - * @param project - * TODO - * @param path - * the project-relative path of the resource that is to be sent. - * @param timestamp - * the time that will be associated with this activity. - * @param callback - * an callback for the file transfer state. Can be - * <code>null</code>. - */ - public void sendFile(JID recipient, IProject project, IPath path, - int timestamp, IFileTransferCallback callback); - - /** - * Sends given archive file to given recipient. (Fallback of jingle file - * transfer to achieve better transfer with IBB.) - * - * @param recipient - * the Jabber ID of the recipient. - * @param project - * TODO - * @param archive - * the project-relative path of the resource that is to be sent. - * @param callback - * an callback for the file transfer state. Can be - * <code>null</code>. - */ - public void sendProjectArchive(JID recipient, IProject project, - File archive, IFileTransferCallback callback); - - /** - * Sends queued file transfers. - */ - public void sendRemainingFiles(); - - /** - * Sends queued messages. - */ - public void sendRemainingMessages(); - - /** - * Sends a list of users to given recipient - * - * @param to - * Receipient of this list - * @param participants - * List of Users, of current shared project participants - */ - public void sendUserListTo(JID to, List<User> participants); - - /** - * Sets my XMPP connection to the given connection - for changing the - * current connection (like after reconnect). - * - * @param connection - * the new XMPPConnection - */ - public void setXMPPConnection(XMPPConnection connection); - - /** - * Sends a request for activities to all users. - * - * @param sharedProject - * the shared project - * @param timestamp - * the timestamp of the requested activity - * @param andup - * boolean, if all activities after the requested one are - * requested too - */ - public void sendRequestForActivity(ISharedProject sharedProject, - int timestamp, boolean andup); - - /* ---------- etc --------- */ - - /** - * Sends a join message to the participants of given shared project. See - * {@link IInvitationProcess} for more information when this is supposed be - * sent. - * - * @param sharedProject - * the shared project that this join message refers to. - */ - public void sendJoinMessage(ISharedProject sharedProject); - - /** - * Sends a leave message to the participants of given shared project. See - * {@link IInvitationProcess} for more information when this is supposed be - * sent. - * - * @param sharedProject - * the shared project that this join message refers to. - */ - public void sendLeaveMessage(ISharedProject sharedProject); - - /** - * Sends given list of activities with given timestamp to the participants - * of given shared project. - * - * @param sharedProject - * the shared project the activities refer to. - * @param activities - * a list of timed activities. - */ - public void sendActivities(ISharedProject sharedProject, - List<TimedActivity> activities); - - /** - * Sends given list of activities with given timestamp to given participant - * of given shared project. - * - * @param sharedProject - * the shared project the activities refer to. - * @param activity - * activity. - * @param jid - * the recipient - */ - public void sendJupiterRequest(ISharedProject sharedProject, - Request request, JID jid); - - /** - * Sends error message of checksum error to all clients. - * - * @param path - * appropriate file for checksum error - * @param resolved - * if true then the inconsistency is resolved - */ - public void sendFileChecksumErrorMessage(IPath path, boolean resolved); - - /** - * Sends the checksum of all concurrent documents to all clients. - * - * @param to - * the recipient - * @param collection - * the checksums - */ - public void sendDocChecksumsToClients( - Collection<DocumentChecksum> collection); - - /** - * Sends error messge of transformation error. - * - * @param to - * the recipient - * @param path - * appropriate file for jupiter transformtion error - */ - public void sendJupiterTransformationError(JID to, IPath path); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/JID.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/JID.java deleted file mode 100644 index 9c1753c1da9a5f953ff8122d528c34fce63472c5..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/JID.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net; - -import java.io.Serializable; - -import org.jivesoftware.smack.util.StringUtils; - -/** - * A Jabber ID which is used to identify the users of the Jabber network. - * - * @author rdjemili - */ -public class JID implements Serializable { - private final String jid; - - /** - * Construct a new Jabber-ID - * - * @param jid - * the Jabber ID in the format of user@host[/resource]. Resource - * is optional. - */ - public JID(String jid) { - // TODO check for malformated string - this.jid = jid; - } - - /** - * @return the name segment of this Jabber ID. - * @see StringUtils#parseName(String)) - */ - public String getName() { - return StringUtils.parseName(this.jid); - } - - /** - * @return the Jabber ID without resource qualifier. - * @see StringUtils#parseBareAddress(String) - */ - public String getBase() { - return StringUtils.parseBareAddress(this.jid); - } - - /** - * @return the domain segment of this Jabber ID. - * @see StringUtils#parseServer(String) - */ - public String getDomain() { - return StringUtils.parseServer(this.jid); - } - - /** - * @return the resource segment of this Jabber ID or the empty string if - * there is none. - * @see StringUtils#parseResource(String) - */ - public String getResource() { - return StringUtils.parseResource(this.jid); - } - - /** - * @return <code>true</code> if the IDs have the same user and domain. - * Resource is ignored. - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof JID) { - JID other = (JID) obj; - return getBase().equals(other.getBase()); - } - - return false; - } - - @Override - public int hashCode() { - return getBase().hashCode(); - } - - /** - * @return the complete string that was used to construct this object. - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return this.jid; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/TimedActivity.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/TimedActivity.java deleted file mode 100644 index 4dddb48ed76bb1dd5d5fc1eec49302085f9c45a4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/TimedActivity.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.fu_berlin.inf.dpp.net; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -/** - * A simple {@link IActivity} wrapper that add an time stamp. - * - * @author rdjemili - */ -public class TimedActivity { - private final IActivity activity; - - private final int timestamp; - - /** - * Constructs a new TimedActivity. - * - * @param activity - * the activity. - * @param timestamp - * the timestamp that belongs to the activity. - */ - public TimedActivity(IActivity activity, int timestamp) { - this.activity = activity; - this.timestamp = timestamp; - } - - /** - * @return the activity. - */ - public IActivity getActivity() { - return this.activity; - } - - /** - * @return the timestamp of the activiy. - */ - public int getTimestamp() { - return this.timestamp; - } - - @Override - public String toString() { - return "[" + this.timestamp + ":" + this.activity + "]"; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof TimedActivity)) { - return false; - } - - TimedActivity other = (TimedActivity) obj; - return other.activity.equals(this.activity) - && (other.timestamp == this.timestamp); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesPacketExtension.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesPacketExtension.java deleted file mode 100644 index a98dee5d130b03ed68149e21a3d8877f553a9a46..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesPacketExtension.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.text.MessageFormat; -import java.util.List; - -import org.jivesoftware.smack.packet.PacketExtension; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.ActivityRegistry; - -public class ActivitiesPacketExtension implements PacketExtension { - public static final String NAMESPACE = "de.fu_berlin.inf.dpp"; - - public static final String SESSION_ID = "sessionID"; - - public static final String ELEMENT = "activities"; - - public static final String TEXT_CHANGE_TAG = "edit"; - - private List<TimedActivity> activities; - - MessageFormat textChangeFormat = new MessageFormat( - "<{0} offset=\"{1}\" replace=\"{2}\">{3}</{4}>"); // TODO extract - - private String sessionID; - - // into - - // consts - - public ActivitiesPacketExtension() { - } - - public ActivitiesPacketExtension(String sessionID, - List<TimedActivity> activities) { - this.sessionID = sessionID; - setActivities(activities); - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.packet.PacketExtension#getElementName() - */ - public String getElementName() { - return ActivitiesPacketExtension.ELEMENT; - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.packet.PacketExtension#getNamespace() - */ - public String getNamespace() { - return ActivitiesPacketExtension.NAMESPACE; - } - - public void setActivities(List<TimedActivity> activities) { - this.activities = activities; - } - - public List<TimedActivity> getActivities() { - return this.activities; - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.packet.PacketExtension#toXML() - */ - public String toXML() { - if (this.activities.size() == 0) { - return ""; - } - - StringBuffer buf = new StringBuffer(); - buf.append("<").append(getElementName()); - buf.append(" xmlns=\"").append(getNamespace()).append("\">"); - - buf.append(sessionIdToXML()); - - int firstTimestamp = this.activities.get(0).getTimestamp(); - buf.append("<timestamp>").append(firstTimestamp).append("</timestamp>"); - - ActivityRegistry activityRegistry = ActivityRegistry.getDefault(); - for (TimedActivity timedActivity : this.activities) { - IActivity activity = timedActivity.getActivity(); - buf.append(activityRegistry.toXML(activity)); - } - - buf.append("</").append(getElementName()).append(">"); - return buf.toString(); - } - - private String sessionIdToXML() { - return "<" + ActivitiesPacketExtension.SESSION_ID + ">" + sessionID - + "</" + ActivitiesPacketExtension.SESSION_ID + ">"; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof ActivitiesPacketExtension) { - ActivitiesPacketExtension other = (ActivitiesPacketExtension) obj; - - return this.activities.equals(other.getActivities()); - } - - return false; - } - - public String getSessionID() { - return sessionID; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesProvider.java deleted file mode 100644 index 9c9b8d78ec7c9a3cb7db84e3b4691dbdc777580a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitiesProvider.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.ActivityRegistry; - -// TODO rename to ActivitiesExtensionProvider -public class ActivitiesProvider implements PacketExtensionProvider { - - public ActivitiesPacketExtension parseExtension(XmlPullParser parser) - throws XmlPullParserException, IOException { - - List<TimedActivity> timedActivities = new ArrayList<TimedActivity>(); - int time = -1; - String sessionID = null; - - boolean done = false; - while (!done) { - int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { - - if (parser.getName().equals( - ActivitiesPacketExtension.SESSION_ID)) { - sessionID = parseSessionId(parser); - } - if (parser.getName().equals("timestamp")) { - time = parseTime(parser); - } - - ActivityRegistry activityRegistry = ActivityRegistry - .getDefault(); - IActivity activity = activityRegistry.parseActivity(parser); - if (activity != null) { - timedActivities.add(new TimedActivity(activity, time)); - time++; - } - - } else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals("activities")) { - done = true; - } - } - } - - return new ActivitiesPacketExtension(sessionID, timedActivities); - } - - private String parseSessionId(XmlPullParser parser) - throws XmlPullParserException, IOException { - parser.next(); // read text - String sessionID = parser.getText(); - parser.next(); // read end tag - - return sessionID; - } - - private int parseTime(XmlPullParser parser) throws XmlPullParserException, - IOException { - parser.next(); // read text - int time = Integer.parseInt(parser.getText()); - parser.next(); // read end tag - - return time; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitySequencer.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitySequencer.java deleted file mode 100644 index bd544026ecadaa58b086bdc01f2dbeb1533b8406..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/ActivitySequencer.java +++ /dev/null @@ -1,654 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Vector; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.text.ITextSelection; -import org.eclipse.jface.text.TextSelection; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.activities.EditorActivity; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.FolderActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.TextEditActivity; -import de.fu_berlin.inf.dpp.activities.TextSelectionActivity; -import de.fu_berlin.inf.dpp.activities.ViewportActivity; -import de.fu_berlin.inf.dpp.activities.EditorActivity.Type; -import de.fu_berlin.inf.dpp.concurrent.ConcurrentManager; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.RequestForwarder; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.RequestError; -import de.fu_berlin.inf.dpp.concurrent.management.ConcurrentDocumentManager; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.IActivityManager; -import de.fu_berlin.inf.dpp.project.IActivityProvider; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -/** - * Implements {@link IActivitySequencer} and {@link IActivityManager}. - * - * @author rdjemili - */ -public class ActivitySequencer implements RequestForwarder, IActivitySequencer { - - private static Logger logger = Logger.getLogger(ActivitySequencer.class - .getName()); - - /**/ - public class ExecuterQueue { - - /** Queue with IActivity Elements */ - private final List<TextEditActivity> executerQueue; - - private TextEditActivity currentExecutedActivity; - - private boolean executed = true; - - public ExecuterQueue() { - this.executerQueue = new Vector<TextEditActivity>(); - } - - /** - * check status of created activity. After execution in - * ActivitySequencer activity has created new call of activityCreated. - * - * @param activity - */ - public synchronized boolean checkCreatedActivity(IActivity activity) { - if (this.currentExecutedActivity != null) { - if ((activity instanceof TextEditActivity) - && this.currentExecutedActivity.sameLike(activity)) { - logger.debug("TextEditActivity " + activity - + " is executed."); - this.executed = true; - notify(); - } - } - return this.executed; - } - - public synchronized void addActivity(IActivity activity) { - if (activity instanceof TextEditActivity) { - logger.debug("Add new Activity " + activity - + " to executer queue."); - this.executerQueue.add((TextEditActivity) activity); - notify(); - } - } - - public synchronized IActivity getNextActivity() { - try { - while ((this.executerQueue.size() < 1) && !this.executed) { - wait(); - } - this.currentExecutedActivity = this.executerQueue.remove(0); - this.executed = false; - logger.debug("Remove " + this.currentExecutedActivity - + " form executer queue."); - /* get next activity in queue. */ - return this.currentExecutedActivity; - } catch (InterruptedException e) { - e.printStackTrace(); - return null; - } - - } - } - - private static final int UNDEFINED_TIME = -1; - - private final List<IActivity> activities = new LinkedList<IActivity>(); - - private final List<IActivity> flushedLog = new LinkedList<IActivity>(); - - private final List<IActivityProvider> providers = new LinkedList<IActivityProvider>(); - - private final List<TimedActivity> queue = new CopyOnWriteArrayList<TimedActivity>(); - - private final List<TimedActivity> activityHistory = new LinkedList<TimedActivity>(); - - private int timestamp = ActivitySequencer.UNDEFINED_TIME; - - private ConcurrentManager concurrentManager; - - /** outgoing queue for direct client sync messages for all driver. */ - private final List<Request> outgoingSyncActivities = new Vector<Request>(); - - private IActivity executedJupiterActivity; - - private final ExecuterQueue executer; - - private ISharedProject sharedProject; - - public ActivitySequencer() { - this.executer = new ExecuterQueue(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityManager - */ - public void exec(final IActivity activity) { - try { - - if (activity instanceof EditorActivity) { - this.concurrentManager.exec(activity); - } - if (activity instanceof FileActivity) { - this.concurrentManager.exec(activity); - } - if (activity instanceof FolderActivity) { - - } - Display.getDefault().syncExec(new Runnable() { - public void run() { - if (activity instanceof TextEditActivity) { - - /* - * check if document is already managed by jupiter - * mechanism. - */ - if (!ActivitySequencer.this.concurrentManager - .isHostSide() - && (ActivitySequencer.this.concurrentManager - .exec(activity) != null)) { - // CLIENT SIDE - logger - .debug("Execute received activity (without jupiter): " - + activity); - for (IActivityProvider executor : ActivitySequencer.this.providers) { - executor.exec(activity); - } - } - } else { - - // Execute all other activities - for (IActivityProvider executor : ActivitySequencer.this.providers) { - executor.exec(activity); - } - - // Check for file checksum after incoming save file - // activity. - if ((activity instanceof EditorActivity) - && (((EditorActivity) activity).getType() == EditorActivity.Type.Saved)) { - checkSavedFile((EditorActivity) activity); - } - - } - } - }); - - } catch (Exception e) { - logger.error("Error while executing activity.", e); - } - } - - /** - * this class check the match of local and remote file checksum. - * - * @param editor - * incoming editor activity with type saved - */ - private void checkSavedFile(EditorActivity editor) { - // /* 1. reset appropriate jupiter document. */ - // if (isHostSide() || this.sharedProject.isDriver()) { - // ActivitySequencer.logger.debug("reset jupiter server for " - // + editor.getPath()); - // this.concurrentManager.resetJupiterDocument(editor.getPath()); - // } - // - // /* check match of file checksums. */ - // - // if (!isHostSide() && (editor.getType() == Type.Saved)) { - // long checksum = FileUtil.checksum(this.sharedProject.getProject() - // .getFile(editor.getPath())); - // ActivitySequencer.logger - // .debug("Checksumme on client side : " + checksum - // + " for path : " + editor.getPath().toOSString()); - // if (checksum != editor.getChecksum()) { - // ActivitySequencer.logger.error("Checksum error of file " - // + editor.getPath()); - // } - // } - // if (isHostSide()) { - // /* create local checksum. */ - // long checksum = FileUtil.checksum(this.sharedProject.getProject() - // .getFile(editor.getPath())); - // - // if (checksum != editor.getChecksum()) { - // /* send checksum error */ - // ActivitySequencer.logger.error("Checksum error for file " - // + editor.getPath() + " of " + editor.getSource() - // + " ( " + checksum + " != " + editor.getChecksum() - // + " )"); - // - // /* send checksum error */ - // FileActivity fileError = new FileActivity( - // FileActivity.Type.Error, editor.getPath(), new JID( - // editor.getSource())); - // activityCreated(fileError); - // /* send sync file. */ - // FileActivity file = new FileActivity(FileActivity.Type.Created, - // editor.getPath(), new JID(editor.getSource())); - // activityCreated(file); - // } - // } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IActivitySequencer - */ - public void exec(TimedActivity timedActivity) { - this.queue.add(timedActivity); - execQueue(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivitySequencer - */ - public void exec(List<TimedActivity> activities) { - this.queue.addAll(activities); - execQueue(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityManager - */ - public List<IActivity> flush() { - List<IActivity> out = new ArrayList<IActivity>(this.activities); - this.activities.clear(); - out = optimize(out); - this.flushedLog.addAll(out); - return out.size() > 0 ? out : null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IActivitySequencer - */ - public List<TimedActivity> flushTimed() { - List<IActivity> activities = flush(); - - if (activities == null) { - return null; - } - - if (this.timestamp == ActivitySequencer.UNDEFINED_TIME) { - this.timestamp = 0; - } - - List<TimedActivity> timedActivities = new ArrayList<TimedActivity>(); - for (IActivity activity : activities) { - timedActivities.add(new TimedActivity(activity, this.timestamp++)); - } - - return timedActivities; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityManager - */ - public void addProvider(IActivityProvider provider) { - this.providers.add(provider); - provider.addActivityListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityManager - */ - public void removeProvider(IActivityProvider provider) { - this.providers.remove(provider); - provider.removeActivityListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivitySequencer - */ - public List<IActivity> getLog() { - return this.flushedLog; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityListener - */ - public void activityCreated(IActivity activity) { - - if ((activity instanceof EditorActivity) - || (activity instanceof FileActivity)) { - /* - * Host: start and stop jupiter server process depending on editor - * activities of remote clients. Client: start and stop local - * jupiter clients depending on editor activities. - */ - this.concurrentManager.activityCreated(activity); - } - - if (activity instanceof TextEditActivity) { - - /* check for execute next activity in queue. */ - logger.debug("activity created : " + activity); - this.executer.checkCreatedActivity(activity); - - /* - * new text edit activity has created and has to sync with jupiter - * logic. - */ - IActivity resultAC = this.concurrentManager - .activityCreated(activity); - /** - * host activity: put into outgoing queue and send to all if - * activity is generated by host. otherwise: send request to host. - */ - if ((resultAC != null) || this.concurrentManager.isHostSide()) { - this.activities.add(activity); - } - - } else { - - this.activities.add(activity); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IActivitySequencer - */ - public int getTimestamp() { - return this.timestamp; - } - - public int getQueuedActivities() { - return this.queue.size(); - } - - public List<TimedActivity> getActivityHistory() { - return this.activityHistory; - } - - /** - * Executes as much activities as possible from the current queue regarding - * to their individual time stamps. - */ - private void execQueue() { - boolean executed; - - do { - executed = false; - - for (TimedActivity timedActivity : this.queue) { - if (this.timestamp == ActivitySequencer.UNDEFINED_TIME) { - this.timestamp = timedActivity.getTimestamp(); - } - - if (timedActivity.getTimestamp() <= this.timestamp) { - this.queue.remove(timedActivity); - - this.timestamp++; - exec(timedActivity.getActivity()); - executed = true; - } - } - - } while (executed); - - } - - // TODO extract this into the activities themselves - // TODO CJ: review needed - private List<IActivity> optimize(List<IActivity> activities) { - List<IActivity> result = new ArrayList<IActivity>(activities.size()); - - ITextSelection selection = null; - String source = null; - IPath path = null; - - for (IActivity activity : activities) { - source = null; - path = null; - if (activity instanceof TextEditActivity) { - TextEditActivity textEdit = (TextEditActivity) activity; - - textEdit = joinTextEdits(result, textEdit); - - selection = new TextSelection(textEdit.offset - + textEdit.text.length(), 0); - source = textEdit.getSource(); - path = textEdit.getEditor(); - result.add(textEdit); - - } else if (activity instanceof TextSelectionActivity) { - TextSelectionActivity textSelection = (TextSelectionActivity) activity; - - selection = new TextSelection(textSelection.getOffset(), - textSelection.getLength()); - source = textSelection.getSource(); - path = textSelection.getEditor(); - - } else if (activity instanceof ViewportActivity) { - ViewportActivity viewport = (ViewportActivity) activity; - path = viewport.getEditor(); - source = viewport.getSource(); - selection = addSelection(result, selection, source, path); - result.add(activity); - } else { - selection = addSelection(result, selection, source, path); - result.add(activity); - } - - selection = addSelection(result, selection, source, path); - } - - return result; - } - - private TextEditActivity joinTextEdits(List<IActivity> result, - TextEditActivity textEdit) { - if (result.size() == 0) { - return textEdit; - } - - IActivity lastActivity = result.get(result.size() - 1); - if (lastActivity instanceof TextEditActivity) { - TextEditActivity lastTextEdit = (TextEditActivity) lastActivity; - - if (((lastTextEdit.getSource() == null) || lastTextEdit.getSource() - .equals(textEdit.getSource())) - && (textEdit.offset == lastTextEdit.offset - + lastTextEdit.text.length())) { - result.remove(lastTextEdit); - textEdit = new TextEditActivity(lastTextEdit.offset, - lastTextEdit.text + textEdit.text, lastTextEdit.replace - + textEdit.replace); - textEdit.setSource(lastTextEdit.getSource()); - textEdit.setEditor(lastTextEdit.getEditor()); - } - } - - return textEdit; - } - - private ITextSelection addSelection(List<IActivity> result, - ITextSelection selection, String source, IPath path) { - if (selection == null) { - return null; - } - - if (result.size() > 0) { - IActivity lastActivity = result.get(result.size() - 1); - if (lastActivity instanceof TextEditActivity) { - TextEditActivity lastTextEdit = (TextEditActivity) lastActivity; - - if ((selection.getOffset() == lastTextEdit.offset - + lastTextEdit.text.length()) - && (selection.getLength() == 0)) { - - return selection; - } - } - } - - // HACK TODO CJ: review - if (path != null) { - TextSelectionActivity newSel = new TextSelectionActivity(selection - .getOffset(), selection.getLength(), path); - newSel.setSource(source); - result.add(newSel); - } - - selection = null; - return selection; - } - - public void initConcurrentManager( - de.fu_berlin.inf.dpp.concurrent.ConcurrentManager.Side side, - de.fu_berlin.inf.dpp.User host, JID myJID, - ISharedProject sharedProject) { - this.concurrentManager = new ConcurrentDocumentManager(side, host, - myJID, sharedProject); - this.sharedProject = sharedProject; - sharedProject.addListener(this.concurrentManager); - this.concurrentManager.setRequestForwarder(this); - this.concurrentManager.setActivitySequencer(this); - } - - public ConcurrentManager getConcurrentManager() { - return this.concurrentManager; - } - - public synchronized void forwardOutgoingRequest(Request req) { - - /* check for errors. */ - if (req instanceof RequestError) { - /* create save activity. */ - IActivity activity = new EditorActivity(Type.Saved, req - .getEditorPath()); - /* execute save activity and start consistency check. */ - exec(activity); - return; - } - - /* put request into outgoing queue. */ - this.outgoingSyncActivities.add(req); - - notify(); - } - - public synchronized Request getNextOutgoingRequest() - throws InterruptedException { - Request request = null; - /* get next message and transfer to client. */ - while (!(this.outgoingSyncActivities.size() > 0)) { - wait(); - } - /* remove first queue element. */ - request = this.outgoingSyncActivities.remove(0); - - return request; - } - - /** - * Receive request from ITransmitter and transfer to concurrent control. - */ - public void receiveRequest(Request request) { - /* - * sync with jupiter server on host side and transform operation with - * jupiter client side. - */ - logger.debug("Receive request : " + request + " from " - + request.getJID()); - this.concurrentManager.receiveRequest(request); - - // return null; - // IActivity activity = concurrentManager.receiveRequest(request); - // if (activity != null) { - // /* execute transformed activity */ - // execTransformedActivity(activity); - // } - // return activity; - } - - private boolean isHostSide() { - return this.concurrentManager.isHostSide(); - } - - /** - * Execute activity after jupiter transforming process. - * - * @param activity - */ - public void execTransformedActivity(IActivity activity) { - try { - logger.debug("execute transformed activity: " + activity); - - // /* add new activity to executer queue. */ - // this.executer.addActivity(activity); - // - // /* - // * get next activity from queue or waiting for finishing of - // current - // * execute activity. - // */ - // IActivity queueActivity = this.executer.getNextActivity(); - - // mark current execute activity - // executedJupiterActivity = activity; - // this.executedJupiterActivity = queueActivity; - this.executedJupiterActivity = activity; - - for (IActivityProvider exec : this.providers) { - exec.exec(activity); - } - /* send activity to all observer. */ - if (this.concurrentManager.isHostSide()) { - logger.debug("send transformed activity: " + activity); - this.activities.add(activity); - } - } catch (Exception e) { - logger.error("Error while executing activity.", e); - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/FileTransferProcessMonitor.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/FileTransferProcessMonitor.java deleted file mode 100644 index 89de547e1edc103bea9b5be143144d8e025e8ca1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/FileTransferProcessMonitor.java +++ /dev/null @@ -1,90 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.filetransfer.FileTransfer; - -import de.fu_berlin.inf.dpp.net.IFileTransferCallback; - -/** - * for information on monitoring the process of a file tranfer - * - * @author troll - * - */ -public class FileTransferProcessMonitor extends Thread { - - private static Logger logger = Logger - .getLogger(FileTransferProcessMonitor.class); - - FileTransfer transfer; - private final int TIMEOUT = 10000; - - private boolean running = true; - - private boolean closeMonitor = false; - - private IFileTransferCallback callback; - - public FileTransferProcessMonitor(FileTransfer transfer) { - this.transfer = transfer; - start(); - } - - public FileTransferProcessMonitor(FileTransfer transfer, - IFileTransferCallback callback) { - this.transfer = transfer; - this.callback = callback; - start(); - } - - public boolean isRunning() throws XMPPException { - return this.running; - } - - public String getException() { - return null; - } - - public void closeMonitor(boolean close) { - this.closeMonitor = close; - } - - @Override - public void run() { - int time = 0; - - while (!this.closeMonitor) { - try { - while (!this.transfer.isDone() - && (this.transfer.getProgress() < 1.0)) { - - /* check negotiator process */ - FileTransferProcessMonitor.logger.debug("Status: " - + this.transfer.getStatus() + " Progress : " - + this.transfer.getProgress()); - if (this.callback != null) { - this.callback.transferProgress((int) (this.transfer - .getProgress() * 100)); - } - if (this.closeMonitor) { - return; - } - Thread.sleep(500); - } - this.running = false; - time = time + 500; - - if (time > this.TIMEOUT) { - this.closeMonitor = true; - return; - } - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/MultiUserChatManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/MultiUserChatManager.java deleted file mode 100644 index 7da5a6a97ab257be1d478dfbb2487decb2c81a94..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/MultiUserChatManager.java +++ /dev/null @@ -1,173 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.Iterator; -import java.util.List; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smackx.Form; -import org.jivesoftware.smackx.FormField; -import org.jivesoftware.smackx.muc.MultiUserChat; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.net.IReceiver; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.PacketProtokollLogger; - -public class MultiUserChatManager implements PacketListener { - - private static Logger log = Logger.getLogger(MultiUserChatManager.class - .getName()); - - // TODO: Room name should be configured by settings. - /* name of multi user chat room */ - private String room = "saros"; - - /* host name of jabber-server on which the muc room is created */ - private final String server = "conference.jabber.org"; - - // TODO really needed as field? - private static String JID_PROPERTY = "jid"; - - /* current muc connection. */ - private MultiUserChat muc; - - public MultiUserChatManager(String roomName) { - this.room = roomName; - } - - public MultiUserChatManager() { - // TODO Auto-generated constructor stub - } - - public void initMUC(XMPPConnection connection, String user, String room) - throws XMPPException { - this.room = room; - initMUC(connection, user); - } - - public void initMUC(XMPPConnection connection, String user) - throws XMPPException { - - /* create room domain of current connection. */ - // JID(connection.getUser()).getDomain(); - String host = this.room + "@" + this.server; - - // Create a MultiUserChat using an XMPPConnection for a room - MultiUserChat muc = new MultiUserChat(connection, host); - - // try to join to room - try { - muc.join(user); - } catch (XMPPException e) { - MultiUserChatManager.log.debug(e); - if (e.getMessage().contains("404")) { - // room doesn't exist - - try { - - // Create the room - muc.create("testbot"); - - // Get the the room's configuration form - Form form = muc.getConfigurationForm(); - - // Create a new form to submit based on the original form - Form submitForm = form.createAnswerForm(); - - // Add default answers to the form to submit - for (Iterator<FormField> fields = form.getFields(); fields - .hasNext();) { - FormField field = fields.next(); - if (!FormField.TYPE_HIDDEN.equals(field.getType()) - && (field.getVariable() != null)) { - // Sets the default value as the answer - submitForm.setDefaultAnswer(field.getVariable()); - } - } - - // set configuration, see XMPP Specs - submitForm.setAnswer("muc#roomconfig_moderatedroom", true); - submitForm.setAnswer("muc#roomconfig_allowinvites", true); - submitForm - .setAnswer("muc#roomconfig_persistentroom", false); - - // Send the completed form (with default values) to the - // server to configure the room - muc.sendConfigurationForm(submitForm); - - } catch (XMPPException ee) { - MultiUserChatManager.log.debug(e.getLocalizedMessage(), ee); - throw ee; - } - } else { - MultiUserChatManager.log.debug(e.getLocalizedMessage(), e); - throw e; - } - } - this.muc = muc; - } - - /** - * this method returns current muc or null no muc exists. - * - * @return - */ - public MultiUserChat getMUC() { - return this.muc; - } - - public void sendActivities(ISharedProject sharedProject, - List<TimedActivity> activities) { - - // log.info("Sent muc activities: " + activities); - try { - /* create new message for multi chat. */ - Message newMessage = this.muc.createMessage(); - /* add packet extension. */ - newMessage.addExtension(new ActivitiesPacketExtension(Saros - .getDefault().getSessionManager().getSessionID(), - activities)); - /* add jid property */ - newMessage.setProperty(MultiUserChatManager.JID_PROPERTY, Saros - .getDefault().getMyJID().toString()); - - // newMessage.setBody("test"); - this.muc.sendMessage(newMessage); - PacketProtokollLogger.getInstance().sendPacket(newMessage); - - } catch (XMPPException e) { - - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not send message, message queued", e)); - } - - } - - public void processPacket(Packet packet) { - // TODO should processing here instead of MessagingManager? - } - - public void setReceiver(IReceiver receiver) { - - } - - public String getRoomName() { - return this.room; - } - - public boolean isConnected() { - if ((this.muc != null) && this.muc.isJoined()) { - return true; - } - return false; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PacketExtensions.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PacketExtensions.java deleted file mode 100644 index a987d715e892d3fce0f5bf1110202537caf701c9..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PacketExtensions.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.Collection; -import java.util.List; - -import org.eclipse.core.runtime.IPath; -import org.jivesoftware.smack.packet.DefaultPacketExtension; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.ProviderManager; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.concurrent.management.DocumentChecksum; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Holds various simple helper methods to create and parse simple Smack packet - * extensions. - * - * @author rdjemili - */ -public class PacketExtensions { - public static final String NAMESPACE = "de.fu_berlin.inf.dpp"; - - // elements - - private static final String INVITATION = "invite"; - - private static final String CANCEL_INVITATION = "cancelInvite"; - - private static final String JOIN = "join"; - - private static final String LEAVE = "leave"; - - private static final String REQUEST_FOR_LIST = "requestList"; - - private static final String REQUEST_FOR_ACTIVITY = "requestActivity"; - - private static final String USER_LIST = "userList"; - - private static final String DATATRANSFER = "DataTransfer"; - - private static final String JINGLEERROR = "JingleError"; - - private static final String FILE_CHECKSUM_ERROR = "FileChecksumError"; - - private static final String JUPITER_TRANSFORMATION_ERROR = "JupiterTransformationError"; - - // attributes - public static final String SESSION_ID = "sessionID"; - - public static final String DESCRIPTION = "description"; - - public static final String PROJECTNAME = "description"; - - public static final String ERROR = "error"; - - public static final String DT_NAME = "DTNAME"; - - public static final String DT_DESC = "DTDESC"; - - public static final String DT_SPLIT = "DTSPLIT"; - - public static final String DT_DATA = "DATA_BASE64"; - - public static final String FILE_PATH = "filename"; - - private static final String DOC_CHECKSUM = "DocChecksum"; - - public static void hookExtensionProviders() { - - ProviderManager providermanager = ProviderManager.getInstance(); - providermanager.addExtensionProvider(ActivitiesPacketExtension.ELEMENT, - PacketExtensions.NAMESPACE, new ActivitiesProvider()); - providermanager.addExtensionProvider(RequestPacketExtension.ELEMENT, - RequestPacketExtension.NAMESPACE, - new RequestExtensionProvider()); - } - - private static String getSessionID() { - return Saros.getDefault().getSessionManager().getSessionID(); - } - - /** - * Creates the packet extension for new invitations. - * - * @param description - * an informal text that will be shown with the invitation. - * @return the packet extension. - */ - public static PacketExtension createInviteExtension(String projectName, - String description) { - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.INVITATION, PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - extension.setValue(PacketExtensions.PROJECTNAME, projectName); - extension.setValue(PacketExtensions.DESCRIPTION, description); - - return extension; - } - - /** - * Creates the packet extension for canceling invitations. - * - * @param error - * an user-readable text that contains the reason for the - * cancellation. Can be <code>null</code>. - * @return the packet extension. - */ - public static PacketExtension createCancelInviteExtension(String error) { - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.CANCEL_INVITATION, PacketExtensions.NAMESPACE); - - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - - if ((error != null) && (error.length() > 0)) { - extension.setValue(PacketExtensions.ERROR, error); - } - return extension; - } - - public static PacketExtension createRequestForActivityExtension( - int timestamp, boolean andup) { - - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.REQUEST_FOR_ACTIVITY, - PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - extension.setValue("ID", (new Integer(timestamp)).toString()); - - if (andup) { - extension.setValue("ANDUP", "true"); - } - - return extension; - } - - public static PacketExtension createDataTransferExtension(String name, - String desc, int index, int count, String data) { - - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.DATATRANSFER, PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - extension.setValue(PacketExtensions.DT_NAME, name); - extension.setValue(PacketExtensions.DT_DESC, desc); - extension.setValue(PacketExtensions.DT_DATA, data); - - String split = index + "/" + count; - extension.setValue(PacketExtensions.DT_SPLIT, split); - - return extension; - } - - public static PacketExtension createRequestForFileListExtension() { - return PacketExtensions - .createExtension(PacketExtensions.REQUEST_FOR_LIST); - } - - public static PacketExtension createJoinExtension() { - return PacketExtensions.createExtension(PacketExtensions.JOIN); - } - - public static PacketExtension createLeaveExtension() { - return PacketExtensions.createExtension(PacketExtensions.LEAVE); - } - - public static PacketExtension createChecksumErrorExtension(IPath path, - boolean resolved) { - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.FILE_CHECKSUM_ERROR, - PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - extension.setValue(PacketExtensions.FILE_PATH, path.toOSString()); - extension.setValue("resolved", resolved ? "true" : "false"); - - return extension; - } - - public static PacketExtension createChecksumsExtension( - Collection<DocumentChecksum> checksums) { - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.DOC_CHECKSUM, PacketExtensions.NAMESPACE); - - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - extension.setValue("quantity", Integer.toString(checksums.size())); - - int i = 1; - for (DocumentChecksum checksum : checksums) { - extension.setValue("path" + Integer.toString(i), checksum.getPath() - .toPortableString()); - extension.setValue("length" + Integer.toString(i), Integer - .toString(checksum.getLength())); - extension.setValue("hash" + Integer.toString(i), Integer - .toString(checksum.getHash())); - i++; - } - - return extension; - } - - public static PacketExtension createJupiterErrorExtension(IPath path) { - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.JUPITER_TRANSFORMATION_ERROR, - PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - extension.setValue(PacketExtensions.FILE_PATH, path.toOSString()); - - return extension; - } - - public static PacketExtension createUserListExtension(List<User> list) { - DefaultPacketExtension extension = new DefaultPacketExtension( - PacketExtensions.USER_LIST, PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - - int count = 0; - for (User participant : list) { - JID jid = participant.getJid(); - String id = "User" + count; - String role = "UserRole" + count; - String color = "UserColor" + count; - extension.setValue(id, jid.toString()); - extension.setValue(role, participant.getUserRole().toString()); - extension.setValue(color, participant.getColorID() + ""); - count++; - } - - return extension; - } - - /** - * Tries to create an default packet extension from given message. The - * invite extension has a description field. - */ - public static DefaultPacketExtension getInviteExtension(Message message) { - return PacketExtensions.getExtension(PacketExtensions.INVITATION, - message); - } - - /** - * Tries to create an default packet extension from given message. The - * cancel extension can have a error field. - */ - public static DefaultPacketExtension getCancelInviteExtension( - Message message) { - return PacketExtensions.getExtension( - PacketExtensions.CANCEL_INVITATION, message); - } - - public static DefaultPacketExtension getJoinExtension(Message message) { - return PacketExtensions.getExtension(PacketExtensions.JOIN, message); - } - - public static DefaultPacketExtension getLeaveExtension(Message message) { - return PacketExtensions.getExtension(PacketExtensions.LEAVE, message); - } - - public static DefaultPacketExtension getJupiterErrorExtension( - Message message) { - return PacketExtensions.getExtension( - PacketExtensions.JUPITER_TRANSFORMATION_ERROR, message); - } - - public static DefaultPacketExtension getChecksumErrorExtension( - Message message) { - return PacketExtensions.getExtension( - PacketExtensions.FILE_CHECKSUM_ERROR, message); - } - - public static DefaultPacketExtension getChecksumExtension(Message message) { - return PacketExtensions.getExtension(PacketExtensions.DOC_CHECKSUM, - message); - } - - public static DefaultPacketExtension getUserlistExtension(Message message) { - return PacketExtensions.getExtension(PacketExtensions.USER_LIST, - message); - } - - public static DefaultPacketExtension getRequestActivityExtension( - Message message) { - return PacketExtensions.getExtension( - PacketExtensions.REQUEST_FOR_ACTIVITY, message); - } - - public static DefaultPacketExtension getRequestExtension(Message message) { - return PacketExtensions.getExtension(PacketExtensions.REQUEST_FOR_LIST, - message); - } - - public static DefaultPacketExtension getDataTransferExtension( - Message message) { - return PacketExtensions.getExtension(PacketExtensions.DATATRANSFER, - message); - } - - public static ActivitiesPacketExtension getActvitiesExtension( - Message message) { - return (ActivitiesPacketExtension) message.getExtension( - ActivitiesPacketExtension.ELEMENT, PacketExtensions.NAMESPACE); - } - - public static RequestPacketExtension getJupiterRequestExtension( - Message message) { - return (RequestPacketExtension) message.getExtension( - RequestPacketExtension.ELEMENT, PacketExtensions.NAMESPACE); - } - - private static DefaultPacketExtension createExtension(String element) { - DefaultPacketExtension extension = new DefaultPacketExtension(element, - PacketExtensions.NAMESPACE); - extension.setValue(PacketExtensions.SESSION_ID, getSessionID()); - return extension; - } - - private static DefaultPacketExtension getExtension(String element, - Message message) { - return (DefaultPacketExtension) message.getExtension(element, - PacketExtensions.NAMESPACE); - } - - /** - * TODO CJ: write javadoc - * - * @param message - * @return - */ - public static String getSessionID(Message message) { - PacketExtension extension = message.getExtension( - ActivitiesPacketExtension.ELEMENT, PacketExtensions.NAMESPACE); - if (extension != null) { - return ((ActivitiesPacketExtension) extension).getSessionID(); - } - extension = message.getExtension(RequestPacketExtension.ELEMENT, - PacketExtensions.NAMESPACE); - if (extension != null) { - return ((RequestPacketExtension) extension).getSessionID(); - } - extension = message.getExtension(PacketExtensions.NAMESPACE); - return ((DefaultPacketExtension) extension).getValue(SESSION_ID); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PrivateChatManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PrivateChatManager.java deleted file mode 100644 index 16cdbf497cb1f177edf8972750038d032b957548..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/PrivateChatManager.java +++ /dev/null @@ -1,107 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.filter.MessageTypeFilter; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.net.IChatManager; -import de.fu_berlin.inf.dpp.net.IReceiver; - -public class PrivateChatManager implements IChatManager { - - private static Logger log = Logger.getLogger(PrivateChatManager.class - .getName()); - - private XMPPConnection connection; - - private IReceiver receiver; - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.IChatManager#setConnection(org.jivesoftware. - * smack.XMPPConnection, de.fu_berlin.inf.dpp.net.IReceiver) - */ - public void setConnection(XMPPConnection connection, IReceiver receiver) { - this.connection = connection; - this.connection.addPacketListener(this, new MessageTypeFilter( - Message.Type.chat)); - setReceiver(receiver); - - } - - /* - * (non-Javadoc) - * - * @see - * org.jivesoftware.smack.PacketListener#processPacket(org.jivesoftware. - * smack.packet.Packet) - */ - public void processPacket(Packet packet) { - PrivateChatManager.log.debug("incoming packet"); - Message message = (Message) packet; - - RequestPacketExtension packetExtension = PacketExtensions - .getJupiterRequestExtension(message); - - if (packetExtension != null) { - this.receiver.processRequest(packet); - } else { - this.receiver.processPacket(packet); - } - - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.IChatManager#setReceiver(de.fu_berlin.inf.dpp - * .net.IReceiver) - */ - public void setReceiver(IReceiver receiver) { - this.receiver = receiver; - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.IChatManager#isConnected() - */ - public boolean isConnected() { - if (this.connection.isConnected() && (this.receiver != null)) { - return true; - } - return false; - } - - public void sendRequest(Request request) { - // TODO Auto-generated method stub - // log.info("Sent request: " + request); - // try { - // /* create new message for multi chat. */ - // Message newMessage = muc.createMessage(); - // /* add packet extension. */ - // newMessage.addExtension(new ActivitiesPacketExtension(activities)); - // /* add jid property */ - // newMessage.setProperty(JID_PROPERTY, Saros.getDefault().getMyJID() - // .toString()); - // - // // newMessage.setBody("test"); - // muc.sendMessage(newMessage); - // PacketProtokollLogger.getInstance().sendPacket(newMessage); - // - // } catch (XMPPException e) { - // - // Saros.getDefault().getLog().log( - // new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - // "Could not send message, message queued", e)); - // } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestExtensionProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestExtensionProvider.java deleted file mode 100644 index 4b5362dcdbe8db476adafd911b9336a516403447..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestExtensionProvider.java +++ /dev/null @@ -1,233 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.IOException; - -import org.eclipse.core.runtime.Path; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smack.provider.PacketExtensionProvider; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.JupiterVectorTime; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.RequestImpl; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.DeleteOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.InsertOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.NoOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.TimestampOperation; -import de.fu_berlin.inf.dpp.net.JID; - -public class RequestExtensionProvider implements PacketExtensionProvider { - - public PacketExtension parseExtension(XmlPullParser parser) - throws XmlPullParserException, IOException { - - Request request = null; - String sessionID = null; - String path = null; - String jid = null; - try { - boolean done = false; - while (!done) { - int eventType = parser.next(); - if (eventType == XmlPullParser.START_TAG) { - - if (parser.getName().equals(RequestPacketExtension.ELEMENT)) { - parser.next(); - } - - if (parser.getName().equals( - RequestPacketExtension.SESSION_ID)) { - sessionID = parseSessionId(parser); - parser.next(); - } - - if (parser.getName().equals(RequestPacketExtension.PATH)) { - path = parsePath(parser); - parser.next(); - } - - if (parser.getName().equals(RequestPacketExtension.JID)) { - jid = parseJID(parser); - parser.next(); - } - - request = parseRequest(parser); - - request.setEditorPath(new Path(path)); - request.setJID(new JID(jid)); - - } else if (eventType == XmlPullParser.END_TAG) { - if (parser.getName().equals(RequestPacketExtension.ELEMENT)) { - done = true; - } - } - } - } catch (Exception e) { - // System.out.println("Mist"); - e.printStackTrace(); - } - - return new RequestPacketExtension(sessionID, request); - // return null; - } - - private String parseSessionId(XmlPullParser parser) - throws XmlPullParserException, IOException { - parser.next(); // read text - String sessionID = parser.getText(); - parser.next(); // read end tag - - return sessionID; - } - - private String parsePath(XmlPullParser parser) - throws XmlPullParserException, IOException { - parser.next(); // read text - String path = parser.getText(); - parser.next(); // read end tag - - return path; - } - - private String parseJID(XmlPullParser parser) - throws XmlPullParserException, IOException { - parser.next(); // read text - String jid = parser.getText(); - parser.next(); // read end tag - - return jid; - } - - private int parseSideID(XmlPullParser parser) - throws XmlPullParserException, IOException { - parser.next(); // read text - int id = Integer.parseInt(parser.getText()); - parser.next(); // read end tag - - return id; - } - - private Request parseRequest(XmlPullParser parser) - throws XmlPullParserException, IOException { - // // extract current editor for text edit. - int id = 0; - Timestamp timestamp = null; - Operation op = null; - if (parser.getName().equals(RequestPacketExtension.SIDE_ID)) { - id = parseSideID(parser); - parser.next(); - } - - if (parser.getName().equals(RequestPacketExtension.VECTOR_TIME)) { - int local = Integer.parseInt(parser - .getAttributeValue(null, "local")); - int remote = Integer.parseInt(parser.getAttributeValue(null, - "remote")); - timestamp = new JupiterVectorTime(local, remote); - parser.next(); - parser.next(); - } - - // if(parser.getName().equals(RequestPacketExtension.INSERT_OP)){ - // op = parseInsertOperation(parser); - // return new RequestImpl(id,timestamp,op); - // } - // - // if(parser.getName().equals(RequestPacketExtension.DELETE_OP)){ - // op = parseDeleteOperation(parser); - // return new RequestImpl(id,timestamp,op); - // } - // if(parser.getName().equals(RequestPacketExtension.NO_OP)){ - // op = new NoOperation(); - // return new RequestImpl(id,timestamp,op); - // } - if (parser.getName().equals(RequestPacketExtension.SPLIT_OP)) { - parser.next(); - Operation op1 = parseSingleOperation(parser); - parser.next(); - parser.next(); - Operation op2 = parseSingleOperation(parser); - op = new SplitOperation(op1, op2); - return new RequestImpl(id, timestamp, op); - } else { - op = parseSingleOperation(parser); - } - - Request req = new RequestImpl(id, timestamp, op); - // - return req; - } - - private Operation parseSingleOperation(XmlPullParser parser) - throws XmlPullParserException, IOException { - Operation op = null; - if (parser.getName().equals(RequestPacketExtension.INSERT_OP)) { - return parseInsertOperation(parser); - } - if (parser.getName().equals(RequestPacketExtension.DELETE_OP)) { - return parseDeleteOperation(parser); - - } - if (parser.getName().equals(RequestPacketExtension.NO_OP)) { - return new NoOperation(); - } - if (parser.getName().equals(RequestPacketExtension.TIMESTAMP_OP)) { - return new TimestampOperation(); - } - return op; - } - - private Operation parseInsertOperation(XmlPullParser parser) - throws XmlPullParserException, IOException { - Operation op = null; - int pos = Integer.parseInt(parser.getAttributeValue(null, - RequestPacketExtension.POSITION)); - int origin = Integer.parseInt(parser.getAttributeValue(null, - RequestPacketExtension.ORIGIN)); - - String text = ""; - if (parser.next() == XmlPullParser.TEXT) { - text = parser.getText(); - } - op = new InsertOperation(pos, text, origin); - return op; - } - - private Operation parseDeleteOperation(XmlPullParser parser) - throws XmlPullParserException, IOException { - Operation op = null; - int pos = Integer.parseInt(parser.getAttributeValue(null, - RequestPacketExtension.POSITION)); - - String text = ""; - if (parser.next() == XmlPullParser.TEXT) { - text = parser.getText(); - } - op = new DeleteOperation(pos, text); - return op; - } - // - // private IActivity parseTextEditActivity(XmlPullParser parser) throws - // XmlPullParserException, - // IOException { - // - // // extract current editor for text edit. - // String pathString = parser.getAttributeValue(null, "path"); - // Path path = pathString.equals("null") ? null : new Path(pathString); - // - // int offset = Integer.parseInt(parser.getAttributeValue(null, "offset")); - // int replace = Integer.parseInt(parser.getAttributeValue(null, - // "replace")); - // - // String text = ""; - // if (parser.next() == XmlPullParser.TEXT) { - // text = parser.getText(); - // } - // - // return new TextEditActivity(offset, text, replace,path); - // } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestPacketExtension.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestPacketExtension.java deleted file mode 100644 index 73166c23893f57fb3c1827ab501f29fc7289665d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/RequestPacketExtension.java +++ /dev/null @@ -1,204 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.List; -import java.util.Vector; - -import org.jivesoftware.smack.packet.PacketExtension; - -import de.fu_berlin.inf.dpp.concurrent.jupiter.Operation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Timestamp; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.DeleteOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.InsertOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.NoOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.SplitOperation; -import de.fu_berlin.inf.dpp.concurrent.jupiter.internal.text.TimestampOperation; - -public class RequestPacketExtension implements PacketExtension { - public static final String NAMESPACE = "de.fu_berlin.inf.dpp"; - - public static final String ELEMENT = "request"; - - public static final String SESSION_ID = "sessionID"; - - public static final String PATH = "path"; - - public static final String JID = "jid"; - - public static final String SIDE_ID = "sideID"; - - public static final String VECTOR_TIME = "vectortime"; - - public static final String INSERT_OP = "insert"; - - public static final String DELETE_OP = "delete"; - - public static final String NO_OP = "no_op"; - - public static final String SPLIT_OP = "split"; - - public static final String TIMESTAMP_OP = "time"; - - public static final String LOCAL_TIME = "localtime"; - - public static final String REMOTE_TIME = "remotetime"; - - public static final String POSITION = "position"; - - public static final String ORIGIN = "origin"; - - public static final String TEXT = "text"; - - public static final String LENGTH = "length"; - - private Request request; - - private String sessionID; - - public RequestPacketExtension(String sessionID, Request request) { - this.sessionID = sessionID; - this.request = request; - } - - public void setRequest(Request request) { - this.request = request; - } - - public Request getRequest() { - return this.request; - } - - public String getElementName() { - return RequestPacketExtension.ELEMENT; - } - - public String getNamespace() { - return RequestPacketExtension.NAMESPACE; - } - - public String toXML() { - if (this.request == null) { - return ""; - } - - StringBuffer buf = new StringBuffer(); - buf.append("<").append(getElementName()); - buf.append(" xmlns=\"").append(getNamespace() + "\""); - - // buf.append(" xmlns=\"").append(getNamespace()).append("\">"); - - buf.append(">"); - - buf.append(sessionIdToXML()); - buf.append(pathToXML()); - buf.append(jidToXML()); - buf.append(sideIDToXML()); - buf.append(vectorTimeToXML()); - buf.append(operationToXML()); - - // buf.append(requestToXML()); - - buf.append("</").append(getElementName()).append(">"); - return buf.toString(); - // return "<request></request>"; - } - - private String sessionIdToXML() { - return "<" + RequestPacketExtension.SESSION_ID + ">" + sessionID + "</" - + RequestPacketExtension.SESSION_ID + ">"; - } - - private String pathToXML() { - return "<" + RequestPacketExtension.PATH + ">" - + this.request.getEditorPath() + "</" - + RequestPacketExtension.PATH + ">"; - } - - private String jidToXML() { - return "<" + RequestPacketExtension.JID + ">" + this.request.getJID() - + "</" + RequestPacketExtension.JID + ">"; - } - - private String sideIDToXML() { - return "<" + RequestPacketExtension.SIDE_ID + ">" - + this.request.getSiteId() + "</" - + RequestPacketExtension.SIDE_ID + ">"; - } - - private String vectorTimeToXML() { - String xml = ""; - Timestamp timestamp = this.request.getTimestamp(); - xml += "<" + RequestPacketExtension.VECTOR_TIME + " local=\"" - + timestamp.getComponents()[0] + "\" remote=\"" - + timestamp.getComponents()[1] + "\"" + "/>"; - return xml; - } - - private String operationToXML() { - Operation op = this.request.getOperation(); - String xml = ""; - if (op instanceof InsertOperation) { - xml += insertOp(op); - } - if (op instanceof DeleteOperation) { - xml += deleteOp(op); - } - if (op instanceof NoOperation) { - // NoOperation no = (NoOperation) op; - xml += "<" + RequestPacketExtension.NO_OP + "/>"; - } - if (op instanceof TimestampOperation) { - xml += "<" + RequestPacketExtension.TIMESTAMP_OP + "/>"; - } - if (op instanceof SplitOperation) { - SplitOperation split = (SplitOperation) op; - - List<Operation> ops = new Vector<Operation>(); - ops.add(split.getFirst()); - ops.add(split.getSecond()); - - xml += "<" + RequestPacketExtension.SPLIT_OP + ">"; - for (Operation o : ops) { - if (o instanceof InsertOperation) { - xml += insertOp(o); - } - if (o instanceof DeleteOperation) { - xml += deleteOp(o); - } - if (o instanceof NoOperation) { - xml += "<" + RequestPacketExtension.NO_OP + "/>"; - } - } - xml += "</" + RequestPacketExtension.SPLIT_OP + ">"; - } - return xml; - } - - private String insertOp(Operation op) { - String xml = ""; - InsertOperation ins = (InsertOperation) op; - xml += "<" + RequestPacketExtension.INSERT_OP + " " - + RequestPacketExtension.POSITION + "=\"" + ins.getPosition() - + "\"" + " " + RequestPacketExtension.ORIGIN + "=\"" - + ins.getOrigin() + "\"" + ">"; - xml += "<![CDATA[" + ins.getText() + "]]>"; - xml += "</" + RequestPacketExtension.INSERT_OP + ">"; - return xml; - } - - private String deleteOp(Operation op) { - String xml = ""; - DeleteOperation del = (DeleteOperation) op; - xml += "<" + RequestPacketExtension.DELETE_OP + " " - + RequestPacketExtension.POSITION + "=\"" + del.getPosition() - + "\"" + ">"; - xml += "<![CDATA[" + del.getText() + "]]>"; - xml += "</" + RequestPacketExtension.DELETE_OP + ">"; - return xml; - } - - public String getSessionID() { - return sessionID; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SkypeIQ.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SkypeIQ.java deleted file mode 100644 index 81d91349d9206b43674906f60d917cd768d9ba9c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SkypeIQ.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import org.jivesoftware.smack.packet.IQ; - -public class SkypeIQ extends IQ { - private String name; - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - @Override - public String getChildElementXML() { - StringBuffer buf = new StringBuffer(); - buf.append("<query xmlns=\"jabber:iq:skype\">"); - - if (this.name != null) { - buf.append("<name>").append(this.name).append("</name>"); - } - - buf.append("</query>"); - return buf.toString(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SubscriptionListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SubscriptionListener.java deleted file mode 100644 index f1aa996d66d243a8dd1dac074cca4595b5a7037c..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/SubscriptionListener.java +++ /dev/null @@ -1,148 +0,0 @@ -package de.fu_berlin.inf.dpp.net.internal; - -import java.util.concurrent.atomic.AtomicReference; - -import org.apache.log4j.Logger; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.Presence; - -import de.fu_berlin.inf.dpp.ui.IRosterTree; - -/** - * This Class implements a manual subscription. If a request for subscription is - * received (when a remote user added the local user) the user is asked about - * confirmation. If he accepts the request a new entry in the roster will be - * created and a subscribed-message sent. If a request of removal are received - * (when a remote user deleted the local user from his roster or rejected a - * request of subscription) the appropriate entry are removed from the roster. - * - * @author chjacob - * - */ -public class SubscriptionListener implements PacketListener { - - private static Logger logger = Logger.getLogger(SubscriptionListener.class); - - private final XMPPConnection connection; - - private final IRosterTree rtree; - - public SubscriptionListener(XMPPConnection conn, IRosterTree rtree) { - this.connection = conn; - this.rtree = rtree; - } - - public void processPacket(final Packet packet) { - - SubscriptionListener.logger.debug("Packet called. " + packet.getFrom()); - - if (!packet.getFrom().equals(this.connection.getUser())) { - - if (packet instanceof Presence) { - final Presence p = (Presence) packet; - - // subscribed - if (p.getType() == Presence.Type.subscribed) { - SubscriptionListener.logger.debug("subcribed from " - + p.getFrom()); - } - - // unsubscribed - if (p.getType() == Presence.Type.unsubscribed) { - SubscriptionListener.logger.debug("unsubcribed from " - + p.getFrom()); - } - - // Request of removal of subscription - else if (p.getType() == Presence.Type.unsubscribe) { - SubscriptionListener.logger.debug("unsubcribe from " - + p.getFrom()); - - // if appropriate entry exists remove that - RosterEntry e = connection.getRoster().getEntry( - packet.getFrom()); - if (e != null) { - try { - connection.getRoster().removeEntry(e); - } catch (XMPPException e1) { - logger.error(e1); - } - } - sendPresence(Presence.Type.unsubscribed, packet.getFrom()); - informUserAboutUnsubscription(packet.getFrom()); - } - - // request of subscription - else if (p.getType().equals(Presence.Type.subscribe)) { - logger.debug("subscribe from " + p.getFrom()); - - // ask user for confirmation of subscription - if (askUserForSubscriptionConfirmation(packet.getFrom())) { - - // send subscribed presence packet - sendPresence(Presence.Type.subscribed, packet.getFrom()); - - // if no appropriate entry for request exists - // create one - RosterEntry e = connection.getRoster().getEntry( - packet.getFrom()); - if (e == null) { - try { - connection.getRoster().createEntry( - packet.getFrom(), packet.getFrom(), - null); - } catch (XMPPException e1) { - logger.error(e1); - } - } - } else { - // user has rejected request - sendPresence(Presence.Type.unsubscribe, packet - .getFrom()); - } - } - } - connection.getRoster().reload(); - this.rtree.refreshRosterTree(true); - } - } - - private void sendPresence(Presence.Type type, String to) { - Presence presence = new Presence(type); - presence.setTo(to); - presence.setFrom(connection.getUser()); - connection.sendPacket(presence); - } - - private static boolean askUserForSubscriptionConfirmation(final String from) { - final AtomicReference<Boolean> result = new AtomicReference<Boolean>(); - Display.getDefault().syncExec(new Runnable() { - public void run() { - result.set(MessageDialog.openConfirm(Display.getDefault() - .getActiveShell(), "Request of subscription received", - "The User " + from + " has requested subscription.")); - } - }); - return result.get(); - } - - private static void informUserAboutUnsubscription(final String from) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog - .openInformation( - Display.getDefault().getActiveShell(), - "Removal of subscription", - "User " - + from - + " has rejected your request of subsription or has removed you from his roster."); - } - }); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/XMPPChatTransmitter.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/XMPPChatTransmitter.java deleted file mode 100644 index 217b126151819a8129e3c2d4155bb6ee17ba3641..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/internal/XMPPChatTransmitter.java +++ /dev/null @@ -1,1918 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.net.internal; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.ui.IEditorPart; -import org.jivesoftware.smack.Chat; -import org.jivesoftware.smack.ChatManager; -import org.jivesoftware.smack.MessageListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.DefaultPacketExtension; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; -import org.jivesoftware.smack.packet.PacketExtension; -import org.jivesoftware.smackx.filetransfer.FileTransferListener; -import org.jivesoftware.smackx.filetransfer.FileTransferManager; -import org.jivesoftware.smackx.filetransfer.FileTransferRequest; -import org.jivesoftware.smackx.filetransfer.IncomingFileTransfer; -import org.jivesoftware.smackx.filetransfer.OutgoingFileTransfer; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.management.DocumentChecksum; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.TransferMode; -import de.fu_berlin.inf.dpp.net.IFileTransferCallback; -import de.fu_berlin.inf.dpp.net.IReceiver; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.net.jingle.IJingleFileTransferListener; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferData; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferManager; -import de.fu_berlin.inf.dpp.net.jingle.JingleSessionException; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferData.FileTransferType; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferManager.JingleConnectionState; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.ErrorMessageDialog; - -/** - * The one ITransmitter implementation which uses Smack Chat objects. - * - * @author rdjemili - */ -public class XMPPChatTransmitter implements ITransmitter, IReceiver, - MessageListener, FileTransferListener, IJingleFileTransferListener { - private static Logger log = Logger.getLogger(XMPPChatTransmitter.class - .getName()); - - private static final int MAX_PARALLEL_SENDS = 10; - private static final int MAX_TRANSFER_RETRIES = 5; - private static final int FORCEDPART_OFFLINEUSER_AFTERSECS = 60; - - /* - * the following string descriptions are used to differentiate between - * transfers that are for invitations and transfers that are an activity for - * the current project. - */ - private static final String RESOURCE_TRANSFER_DESCRIPTION = "resourceAddActivity"; - - private static final String FILELIST_TRANSFER_DESCRIPTION = "filelist"; - - private static final String PROJECT_ARCHIVE_DESCRIPTION = "projectArchiveFile"; - - private XMPPConnection connection; - - /* - * old version of chatmanager. TODO: exchange this with private manager. - */ - private ChatManager chatmanager; - - private MultiUserChatManager mucmanager; - - private PrivateChatManager privatechatmanager; - - private final Map<JID, Chat> chats = new HashMap<JID, Chat>(); - - private FileTransferManager fileTransferManager; - - // TODO use ListenerList instead - private final List<IInvitationProcess> processes = new CopyOnWriteArrayList<IInvitationProcess>(); - - private final List<FileTransferData> fileTransferQueue = new LinkedList<FileTransferData>(); - private final List<MessageTransfer> messageTransferQueue = new LinkedList<MessageTransfer>(); - private final Map<String, IncomingFile> incomingFiles = new HashMap<String, IncomingFile>(); - private int runningFileTransfers = 0; - - private boolean m_bFileTransferByChat = false; // to switch to - - private JingleFileTransferManager jingleManager; - - public JingleFileTransferManager getJingleManager() { - try { - startingJingleThread.join(); - } catch (InterruptedException e) { - // do nothing - } - return jingleManager; - } - - private Thread startingJingleThread; - - protected long lastReceivedActivityTime; - - /** - * A simple struct that is used to queue file transfers. - */ - public class FileTransferData { - public JID recipient; - public IPath path; - public int timestamp; - public IFileTransferCallback callback; - public int retries = 0; - public byte[] content; - public long filesize; - public IProject project; - } - - /** - * A simple struct that is used to manage incoming chunked files via - * chat-file transfer - */ - private class IncomingFile { - String name; - int receivedChunks; - int chunkCount; - List<String> messageBuffer; - - IncomingFile() { - this.messageBuffer = new LinkedList<String>(); - } - - boolean isComplete() { - return (this.receivedChunks == this.chunkCount); - } - } - - /** - * A simple struct that is used to queue message transfers. - */ - private class MessageTransfer { - public JID receipient; - public PacketExtension packetextension; - } - - public XMPPChatTransmitter(XMPPConnection connection) { - setXMPPConnection(connection); - } - - public void setXMPPConnection(final XMPPConnection connection) { - this.connection = connection; - this.chatmanager = connection.getChatManager(); - this.fileTransferManager = new FileTransferManager(connection); - this.fileTransferManager.addFileTransferListener(this); - - this.chats.clear(); - - this.privatechatmanager = new PrivateChatManager(); - this.privatechatmanager.setConnection(connection, this); - - // Start Jingle Manager asynchronous - this.startingJingleThread = new Thread(new Runnable() { - public void run() { - XMPPChatTransmitter.this.jingleManager = new JingleFileTransferManager( - connection, XMPPChatTransmitter.this); - log.debug("Jingle Manager started"); - } - }); - startingJingleThread.start(); - } - - public void addInvitationProcess(IInvitationProcess process) { - this.processes.add(process); - } - - public void removeInvitationProcess(IInvitationProcess process) { - this.processes.remove(process); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.ITransmitter - */ - public void sendCancelInvitationMessage(JID user, String errorMsg) { - sendMessage(user, PacketExtensions - .createCancelInviteExtension(errorMsg)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendRequestForFileListMessage(JID user) { - - // wait of jingle manager - try { - startingJingleThread.join(); - } catch (InterruptedException e) { - log.debug("Interrupted while waiting of jingleManager"); - } - - sendMessage(user, PacketExtensions.createRequestForFileListExtension()); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendRequestForActivity(ISharedProject sharedProject, - int timestamp, boolean andup) { - - // log.info("Requesting old activity (timestamp=" + timestamp + ", " - // + andup + ") from all..."); - // - // sendMessageToAll(sharedProject, PacketExtensions - // .createRequestForActivityExtension(timestamp, andup)); - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendInviteMessage(ISharedProject sharedProject, JID guest, - String description) { - sendMessage(guest, PacketExtensions.createInviteExtension(sharedProject - .getProject().getName(), description)); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendJoinMessage(ISharedProject sharedProject) { - try { - /* sleep process for 500 millis to ensure invitation state process. */ - Thread.sleep(1000); - } catch (InterruptedException e) { - XMPPChatTransmitter.log.error(e); - } - sendMessageToAll(sharedProject, PacketExtensions.createJoinExtension()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendLeaveMessage(ISharedProject sharedProject) { - sendMessageToAll(sharedProject, PacketExtensions.createLeaveExtension()); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendActivities(ISharedProject sharedProject, - List<TimedActivity> timedActivities) { - - // timer that calls sendActivities is called before setting chat - - for (TimedActivity timedActivity : timedActivities) { - IActivity activity = timedActivity.getActivity(); - - if (activity instanceof FileActivity) { - FileActivity fileAdd = (FileActivity) activity; - - // /* send file checksum error message to exclusive recipient */ - // if (fileAdd.getType().equals(FileActivity.Type.Error)) { - // sendFileChecksumErrorMessage(fileAdd.getPath(), false); - // } - /* send file to solve checksum error to single recipient */ - // if (fileAdd.getType().equals(FileActivity.Type.Created) - // && (fileAdd.getRecipient() != null)) { - // int time = timedActivity.getTimestamp(); - // sendFile(fileAdd.getRecipient(), - // sharedProject.getProject(), fileAdd.getPath(), - // time, null); - // return; - // } - if (fileAdd.getType().equals(FileActivity.Type.Created)) { - JID myJID = Saros.getDefault().getMyJID(); - - for (User participant : sharedProject.getParticipants()) { - JID jid = participant.getJid(); - if (jid.equals(myJID)) { - continue; - } - - // TODO use callback - int time = timedActivity.getTimestamp(); - /* send file with other send method. */ - sendFile(jid, sharedProject.getProject(), fileAdd - .getPath(), time, null); - } - - // TODO remove activity and let this be handled by - // ActivitiesProvider instead - - // don't remove file activity so that it still bumps the - // time stamp when being received - } - } else { - sharedProject.getSequencer().getActivityHistory().add( - timedActivity); - - // TODO: removed very old entries - } - } - - XMPPChatTransmitter.log.info("Sent activities: " + timedActivities); - - if (timedActivities != null) { - sendMessageToAll(sharedProject, new ActivitiesPacketExtension(Saros - .getDefault().getSessionManager().getSessionID(), - timedActivities)); - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ITransmitter - */ - public void sendFileList(JID recipient, FileList fileList) - throws XMPPException { - - String xml = fileList.toXML(); - - if (getFileTransferModeViaChat()) { - - /* send file with IBB File Transfer */ - sendFileListWithIBB(xml, recipient); - - } else { // transfer file list with jingle - - // wait of jingle manager - try { - startingJingleThread.join(); - } catch (InterruptedException e) { - log.debug("Interrupted while waiting of jingleManager"); - } - - JingleFileTransferData data = new JingleFileTransferData(); - data.file_list_content = xml; - data.type = FileTransferType.FILELIST_TRANSFER; - data.recipient = recipient; - data.sender = new JID(connection.getUser()); - data.file_project_path = FileTransferType.FILELIST_TRANSFER - .toString(); - - if (jingleManager.getState(recipient) != JingleConnectionState.ERROR - && jingleManager.getState(recipient) != JingleConnectionState.CLOSED) { - try { - jingleManager.createOutgoingJingleFileTransfer(recipient, - new JingleFileTransferData[] { data }); - return; - } catch (JingleSessionException e) { - log - .info("Failed to send file list with jingle, fall back to IBB"); - } - } - // failed to send with jingle (otherwise had returned) - // failedToSendFileListWithJingle(recipient, data); - sendFileListWithIBB(xml, recipient); - } - } - - private void sendFileListWithIBB(String xml, JID recipient) - throws XMPPException { - try { - - /* Write xml datas to temp file for transfering. */ - File newfile = new File( - XMPPChatTransmitter.FILELIST_TRANSFER_DESCRIPTION + "." - + new JID(this.connection.getUser()).getName()); - if (newfile.exists()) { - newfile.delete(); - } - XMPPChatTransmitter.log - .debug("file : " + newfile.getAbsolutePath()); - - FileWriter writer = new FileWriter( - XMPPChatTransmitter.FILELIST_TRANSFER_DESCRIPTION + "." - + new JID(this.connection.getUser()).getName()); - writer.append(xml); - writer.close(); - - OutgoingFileTransfer - .setResponseTimeout(XMPPChatTransmitter.MAX_TRANSFER_RETRIES * 1000); - OutgoingFileTransfer transfer = this.fileTransferManager - .createOutgoingFileTransfer(recipient.toString()); - - XMPPChatTransmitter.log.info("Sending file list"); - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer); - transfer.sendFile(newfile, - XMPPChatTransmitter.FILELIST_TRANSFER_DESCRIPTION); - - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - monitor.closeMonitor(true); - - if (newfile.exists()) { - newfile.delete(); - } - XMPPChatTransmitter.log.info("File list sent via IBB"); - } catch (IOException e) { - - // fall back to ChatTransfer - sendChatTransfer(XMPPChatTransmitter.FILELIST_TRANSFER_DESCRIPTION, - "", xml.getBytes(), recipient); - - log.info("File list sent via ChatTransfer."); - } - } - - /** - * Sends a data buffer to a recipient using chat messages. The buffer is - * transmitted Base64 encoded and split into blocks of size MAX_MSG_LENGTH. - * - * @param name - * name of the data buffer. e.g. the filename of the transmitted - * file - * @param desc - * description String of the transfer. e.g. encoded timestamp for - * file activity - * @param data - * a byte buffer to be transmitted. it will be base64 encoded - * @param recipient - * JID of the user to send this data to - * - * @return <code>true</code> if the message was send successfully - */ - boolean sendChatTransfer(String name, String desc, byte[] data, - JID recipient) { - - final int maxMsgLen = Saros.getDefault().getPreferenceStore().getInt( - PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE); - - // Convert byte array to base64 string - String data64 = new sun.misc.BASE64Encoder().encode(data); - - // send large data sets in several messages - int tosend = data64.length(); - int pcount = (tosend / maxMsgLen) + ((tosend % maxMsgLen == 0) ? 0 : 1); - int start = 0; - try { - for (int i = 1; i <= pcount; i++) { - int psize = Math.min(tosend, maxMsgLen); - int end = start + psize; - - PacketExtension extension = PacketExtensions - .createDataTransferExtension(name, desc, i, pcount, - data64.substring(start, end)); - - sendMessage(recipient, extension); - - start = end; - tosend -= psize; - - } - } catch (Exception e) { - e.printStackTrace(); - return false; - } - return true; - } - - /** - * Receives a data buffer sent by a chat message. The data will be decoded - * from base64 encoding. Splitted transfer will be buffered until all chunks - * are received. Then the file will be reconstructed and processed as a - * whole. - * - * @param message - * Message containing the data as extension. - * - * @return <code>true</code> if the message was handled successfully. - */ - boolean receiveChatTransfer(Message message) { - DefaultPacketExtension dt = PacketExtensions - .getDataTransferExtension(message); - String sName = dt.getValue(PacketExtensions.DT_NAME); - String sData = dt.getValue(PacketExtensions.DT_DATA); - - String sSplit = dt.getValue(PacketExtensions.DT_SPLIT); - try { - // is this a multipart transfer? - if ((sSplit != null) && (sSplit.equals("1/1") == false)) { - // parse split information (index and chunk count) - int i = sSplit.indexOf('/'); - int cur = Integer.parseInt(sSplit.substring(0, i)); - int max = Integer.parseInt(sSplit.substring(i + 1)); - - XMPPChatTransmitter.log.debug("Received chunk " + cur + " of " - + max + " of file " + sName); - - // check for previous chunks - IncomingFile ifile = this.incomingFiles.get(sName); - if (ifile == null) { - // this is the first received chunk->create incoming file - // object - ifile = new IncomingFile(); - ifile.receivedChunks++; - ifile.chunkCount = max; - ifile.name = sName; - for (i = 0; i < max; i++) { - ifile.messageBuffer.add(null); - } - ifile.messageBuffer.set(cur - 1, sData); - this.incomingFiles.put(sName, ifile); - return true; - } else { - // this is a following chunk - ifile.receivedChunks++; - ifile.messageBuffer.set(cur - 1, sData); - - if (ifile.isComplete() == false) { - return true; - } - - // join the buffers to restore the file from chunks - sData = ""; - for (i = 0; i < max; i++) { - sData += ifile.messageBuffer.get(i); - } - this.incomingFiles.remove(ifile); - } - } - } catch (Exception e) { - e.printStackTrace(); - return false; - - } - - byte[] dataOrg = null; - try { - dataOrg = new sun.misc.BASE64Decoder().decodeBuffer(sData); - } catch (IOException e) { - e.printStackTrace(); - return false; - } - - // File list received - if (sName.equals(XMPPChatTransmitter.FILELIST_TRANSFER_DESCRIPTION)) { - FileList fileList = null; - IInvitationProcess myProcess = null; - try { - JID fromJID = new JID(message.getFrom()); - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(fromJID)) { - myProcess = process; - fileList = new FileList(new String(dataOrg)); - process.fileListReceived(fromJID, fileList); - } - } - XMPPChatTransmitter.log - .info("Received file list via ChatTransfer"); - } catch (Exception e) { - if (myProcess != null) { - myProcess.cancel("Error receiving file list", false); - } - } - - } else { - // receiving file (resource) - - try { - - JID from = new JID(message.getFrom()); - Path path = new Path(sName); - - ByteArrayInputStream in = new ByteArrayInputStream(dataOrg); - - XMPPChatTransmitter.log.debug("Receiving resource from " - + from.toString() + ": " + sName + " (ChatTransfer)"); - - boolean handledByInvitation = false; - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(from)) { - process.resourceReceived(from, path, in); - handledByInvitation = true; - } - } - - if (!handledByInvitation) { - - if (Saros.getDefault().getSessionManager() - .getSharedProject() == null) { - // receiving resource without a running session? not - // accepted - return false; - } - - FileActivity activity = new FileActivity( - FileActivity.Type.Created, path, in); - - int time; - String description = dt.getValue(PacketExtensions.DT_DESC); - try { - time = Integer - .parseInt(description - .substring(XMPPChatTransmitter.RESOURCE_TRANSFER_DESCRIPTION - .length() + 1)); - } catch (Exception e) { - Saros.log("Could not parse time from description: " - + description, e); - time = 0; // HACK - } - - TimedActivity timedActivity = new TimedActivity(activity, - time); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.getSharedProject().getSequencer().exec(timedActivity); - } - - XMPPChatTransmitter.log.info("Received resource " + sName); - - } catch (Exception e) { - XMPPChatTransmitter.log.warn("Failed to receive " + sName, e); - } - } - - return true; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.ITransmitter - */ - public void sendFile(JID to, IProject project, IPath path, - IFileTransferCallback callback) { - sendFile(to, project, path, -1, callback); - } - - /** - * Reads a files content into a buffer. - * - * @param transfer - * Object containing file path and a buffer (among other) to read - * from and to. - * - * @return <code>true</code> if the file was read successfully - */ - boolean readFile(FileTransferData transfer) { - // SessionManager sm = Saros.getDefault().getSessionManager(); - // IProject project = sm.getSharedProject().getProject(); - - File f = new File(transfer.project.getFile(transfer.path).getLocation() - .toOSString()); - transfer.filesize = f.length(); - transfer.content = new byte[(int) transfer.filesize]; - - try { - InputStream in = transfer.project.getFile(transfer.path) - .getContents(); - in.read(transfer.content, 0, (int) transfer.filesize); - } catch (Exception e) { - e.printStackTrace(); - transfer.content = null; - return false; - } - return true; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.net.ITransmitter - */ - public void sendFile(JID to, IProject project, IPath path, int timestamp, - IFileTransferCallback callback) { - - FileTransferData transfer = new FileTransferData(); - transfer.recipient = to; - transfer.path = path; - transfer.timestamp = timestamp; - transfer.callback = callback; - transfer.project = project; - transfer.filesize = project.getFile(path).getLocation().toFile() - .length(); - - // if transfer will be delayed, we need to buffer the file - // to not send modified versions later - if (!this.connection.isConnected()) { - readFile(transfer); - } else { - transfer.content = null; - } - - this.fileTransferQueue.add(transfer); - sendNextFile(); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendProjectArchive(de.fu_berlin - * .inf.dpp.net.JID, org.eclipse.core.resources.IProject, java.io.File, - * de.fu_berlin.inf.dpp.net.IFileTransferCallback) - */ - public void sendProjectArchive(JID recipient, IProject project, - File archive, IFileTransferCallback callback) { - OutgoingFileTransfer - .setResponseTimeout(XMPPChatTransmitter.MAX_TRANSFER_RETRIES * 1000); - OutgoingFileTransfer transfer = this.fileTransferManager - .createOutgoingFileTransfer(recipient.toString()); - - try { - transfer.sendFile(archive, - XMPPChatTransmitter.PROJECT_ARCHIVE_DESCRIPTION); - - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer, callback); - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - monitor.closeMonitor(true); - - if (transfer - .getStatus() - .equals( - org.jivesoftware.smackx.filetransfer.FileTransfer.Status.complete)) { - XMPPChatTransmitter.log.debug("transfer complete"); - callback.fileSent(new Path(archive.getName())); - } - - /* delete temp archive file. */ - archive.delete(); - - } catch (Exception e) { - - XMPPChatTransmitter.log.warn("Failed to send archive file", e); - if (callback != null) { - callback.fileTransferFailed(null, e); - } - } - } - - private void sendNextFile() { - if ((this.fileTransferQueue.size() == 0) - || (this.runningFileTransfers > XMPPChatTransmitter.MAX_PARALLEL_SENDS) - // || Saros.getDefault().getConnectionState() != - // Saros.ConnectionState.CONNECTED - ) { - XMPPChatTransmitter.log.debug("non file to send in queue."); - return; - } - - final FileTransferData transfer = this.fileTransferQueue.remove(0); - - new Thread(new Runnable() { - - /* - * (non-Javadoc) - * - * @see java.lang.Runnable#run() - */ - public void run() { - try { - XMPPChatTransmitter.this.runningFileTransfers++; - XMPPChatTransmitter.log.debug("try to send file " - + transfer.path); - transferFile(transfer); - - } catch (Exception e) { - if (transfer.retries >= XMPPChatTransmitter.MAX_TRANSFER_RETRIES) { - XMPPChatTransmitter.log.warn("Failed to send " - + transfer.path, e); - if (transfer.callback != null) { - transfer.callback.fileTransferFailed(transfer.path, - e); - } - - } else { - transfer.retries++; - XMPPChatTransmitter.this.fileTransferQueue - .add(transfer); - } - - } finally { - XMPPChatTransmitter.this.runningFileTransfers--; - sendNextFile(); - } - } - - }).start(); - } - - public void sendUserListTo(JID to, List<User> participants) { - XMPPChatTransmitter.log.debug("Sending user list to " + to.toString()); - - sendMessage(to, PacketExtensions.createUserListExtension(participants)); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendFileChecksumErrorMessage(org - * .eclipse .core.runtime.IPath) - */ - public void sendFileChecksumErrorMessage(IPath path, boolean resolved) { - - List<User> participants = Saros.getDefault().getSessionManager() - .getSharedProject().getParticipants(); - - XMPPChatTransmitter.log.debug("Sending checksum error message of file " - + path.lastSegment() + " to all"); - for (User user : participants) { - sendMessage(user.getJid(), PacketExtensions - .createChecksumErrorExtension(path, resolved)); - } - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendDocChecksumsToClients(org.eclipse - * .core.runtime.IPath) - */ - public void sendDocChecksumsToClients(Collection<DocumentChecksum> checksums) { - // send checksums to all clients - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - if (project != null) { - List<User> participants = project.getParticipants(); - if (participants != null) { - for (User participant : participants) { - if (!Saros.getDefault().getSessionManager() - .getSharedProject().getHost().getJid().equals( - participant.getJid())) { - JID jid = participant.getJid(); - XMPPChatTransmitter.log.debug("Sending checksums to " - + jid); - Message m = new Message(); - m.addExtension(PacketExtensions - .createChecksumsExtension(checksums)); - try { - getChat(jid).sendMessage(m); - } catch (XMPPException e) { - log.error("Can't send checksums to " + jid); - } - } - } - } - } - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendJupiterTransformationError( - * de.fu_berlin.inf.dpp.net.JID, org.eclipse.core.runtime.IPath) - */ - public void sendJupiterTransformationError(JID to, IPath path) { - XMPPChatTransmitter.log - .debug("Sending jupiter transformation error message to " + to - + " of file " + path.lastSegment()); - sendMessage(to, PacketExtensions.createJupiterErrorExtension(path)); - } - - public void sendRemainingFiles() { - - if (this.fileTransferQueue.size() > 0) { - sendNextFile(); - } - } - - public void sendRemainingMessages() { - - try { - while (this.messageTransferQueue.size() > 0) { - final MessageTransfer pex = this.messageTransferQueue.remove(0); - - Chat chat = getChat(pex.receipient); - Message message; - // TODO: Änderung für Smack 3 - message = new Message(); - // message = chat.createMessage(); - message.addExtension(pex.packetextension); - chat.sendMessage(message); - XMPPChatTransmitter.log.info("Resending message"); - } - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not send message", e)); - } - } - - public boolean resendActivity(JID jid, int timestamp, boolean andup) { - - boolean sent = false; - - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - - try { - List<TimedActivity> tempActivities = new LinkedList<TimedActivity>(); - for (TimedActivity tact : project.getSequencer() - .getActivityHistory()) { - - if (((andup == false) && (tact.getTimestamp() != timestamp)) - || ((andup == true) && (tact.getTimestamp() < timestamp))) { - continue; - } - - tempActivities.add(tact); - sent = true; - - if (andup == false) { - break; - } - } - - if (sent) { - PacketExtension extension = new ActivitiesPacketExtension(Saros - .getDefault().getSessionManager().getSessionID(), - tempActivities); - sendMessage(jid, extension); - } - - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not resend message", e)); - } - - return sent; - } - - public void processMessage(Chat chat, Message message) { - // TODO: new method für smack 3 - // log.debug("incomming message : " + message.getBody()); - // processPacket(message); - - } - - public void processPacket(Chat chat, Packet packet) { - - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.net.ITransmitter#sendActivitiyTo(de.fu_berlin.inf - * .dpp.project.ISharedProject, java.util.List, - * de.fu_berlin.inf.dpp.net.JID) - */ - public void sendJupiterRequest(ISharedProject sharedProject, - Request request, JID jid) { - XMPPChatTransmitter.log.info("send request to : " + jid + " request: " - + request); - sendMessage(jid, new RequestPacketExtension(Saros.getDefault() - .getSessionManager().getSessionID(), request)); - } - - public void processRequest(Packet packet) { - Message message = (Message) packet; - - RequestPacketExtension packetExtension = PacketExtensions - .getJupiterRequestExtension(message); - - if (packetExtension != null) { - this.lastReceivedActivityTime = System.currentTimeMillis(); - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - XMPPChatTransmitter.log.info("Received request : " - + packetExtension.getRequest().toString()); - project.getSequencer().receiveRequest(packetExtension.getRequest()); - - } else { - XMPPChatTransmitter.log - .error("Failure in request packet extension."); - } - - } - - // TODO replace dependencies by more generic listener interfaces - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.PacketListener - */ - public void processPacket(Packet packet) { - final Message message = (Message) packet; - - JID fromJID = new JID(message.getFrom()); - - if (PacketExtensions.getInviteExtension(message) != null) { - DefaultPacketExtension inviteExtension = PacketExtensions - .getInviteExtension(message); - String desc = inviteExtension - .getValue(PacketExtensions.DESCRIPTION); - String pName = inviteExtension - .getValue(PacketExtensions.PROJECTNAME); - String sessionID = inviteExtension - .getValue(PacketExtensions.SESSION_ID); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - log.debug("Received invitation with session id " - + inviteExtension.getValue(PacketExtensions.SESSION_ID)); - sm.invitationReceived(fromJID, sessionID, pName, desc); - return; - } - - if (!Saros.getDefault().getSessionManager().getSessionID().equals( - PacketExtensions.getSessionID(message))) { - log.debug("received message with wrong session id (" - + PacketExtensions.getSessionID(message) + "), drop it.."); - return; - } - - // Change the input method to get the right chats - putIncomingChat(fromJID, message.getThread()); - final ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - - ActivitiesPacketExtension activitiesPacket = PacketExtensions - .getActvitiesExtension(message); - - boolean isProjectParticipant = false; - if (project != null) { - isProjectParticipant = (project.getParticipant(fromJID) != null); - } - - if (activitiesPacket != null) { - List<TimedActivity> timedActivities = activitiesPacket - .getActivities(); - - XMPPChatTransmitter.log.debug("Received activities from " - + fromJID.toString() + ": " + timedActivities); - - if (!isProjectParticipant) { - XMPPChatTransmitter.log.info("user not member!"); - return; - } - - for (TimedActivity timedActivity : timedActivities) { - - IActivity activity = timedActivity.getActivity(); - activity.setSource(fromJID.toString()); - - /* - * incoming fileActivities that add files are only used as - * placeholder to bump the timestamp. the real fileActivity will - * be processed by using a file transfer. - */ - if (!(activity instanceof FileActivity) - || !((FileActivity) activity).getType().equals( - FileActivity.Type.Created)) { - - project.getSequencer().exec(timedActivity); - - } - } - } - - if (PacketExtensions.getChecksumExtension(message) != null) { - final DefaultPacketExtension ext = PacketExtensions - .getChecksumExtension(message); - log.debug("Received checksums"); - - new Thread() { - public void run() { - int count = Integer.parseInt(ext.getValue("quantity")); - DocumentChecksum[] checksums = new DocumentChecksum[count]; - - for (int i = 1; i <= count; i++) { - IPath path = Path.fromPortableString(ext - .getValue("path" + i)); - int length = Integer.parseInt(ext - .getValue("length" + i)); - int hash = Integer.parseInt(ext.getValue("hash" + i)); - checksums[i - 1] = new DocumentChecksum(path, length, - hash); - } - project.getConcurrentDocumentManager().checkConsistency( - checksums); - } - }.start(); - } - - if (PacketExtensions.getJoinExtension(message) != null) { - - boolean iAmInviter = false; - - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(fromJID)) { - process.joinReceived(fromJID); - iAmInviter = true; - } - } - if (!iAmInviter && (project != null)) { - project.addUser(new User(fromJID)); // a new user joined this - // session - - } - - } - - // TODO CJ: Leave Project Message must be handled better - else if (PacketExtensions.getLeaveExtension(message) != null) { - if (project != null) { - project.removeUser(new User(fromJID)); // HACK - } - } - - else if ((PacketExtensions.getRequestActivityExtension(message) != null) - && isProjectParticipant) { - DefaultPacketExtension rae = PacketExtensions - .getRequestActivityExtension(message); - String sID = rae.getValue("ID"); - String sIDandup = rae.getValue("ANDUP"); - - int ts = -1; - if (sID != null) { - ts = (new Integer(sID)).intValue(); - // get that activity from history (if it was mine) and send it - boolean sent = resendActivity(fromJID, ts, (sIDandup != null)); - - String info = "Received Activity request for timestamp=" + ts - + "."; - if (sIDandup != null) { - info += " (andup) "; - } - if (sent) { - info += " I sent response."; - } else { - info += " (not for me)"; - } - - XMPPChatTransmitter.log.info(info); - } - } - - else if (PacketExtensions.getDataTransferExtension(message) != null) { - receiveChatTransfer(message); - } - - /* invitee request for project file list (state.INVITATION_SEND */ - else if (PacketExtensions.getRequestExtension(message) != null) { - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(fromJID)) { - process.invitationAccepted(fromJID); - } - } - } - - else if (PacketExtensions.getUserlistExtension(message) != null) { - DefaultPacketExtension userlistExtension = PacketExtensions - .getUserlistExtension(message); - - // My inviter sent a list of all session participants - // I need to adapt the order for later case of driver leaving the - // session - XMPPChatTransmitter.log.debug("Received user list from " + fromJID); - - int count = 0; - while (true) { - String jidS = userlistExtension.getValue("User" + count); - if (jidS == null) { - break; - } - XMPPChatTransmitter.log.debug(" *:" + jidS); - - JID jid = new JID(jidS); - User user = new User(jid); - - String userRole = userlistExtension - .getValue("UserRole" + count); - user.setUserRole(de.fu_berlin.inf.dpp.User.UserRole - .valueOf(userRole)); - - String color = userlistExtension.getValue("UserColor" + count); - try { - user.setColorID(Integer.parseInt(color)); - } catch (NumberFormatException nfe) { - XMPPChatTransmitter.log - .warn("Exception during convert user color form userlist for user : " - + user.getJid()); - } - - if (project.getParticipant(jid) == null) { - sendMessage(jid, PacketExtensions.createJoinExtension()); - } - - project.addUser(user, count - 1); // add user to internal user - // list, maintaining the - // received order - count++; - } - } - - else if (PacketExtensions.getCancelInviteExtension(message) != null) { - DefaultPacketExtension cancelInviteExtension = PacketExtensions - .getCancelInviteExtension(message); - - String errorMsg = cancelInviteExtension - .getValue(PacketExtensions.ERROR); - - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(fromJID)) { - process.cancel(errorMsg, true); - } - } - - } - /** - * Checksum Error Message - */ - else if (PacketExtensions.getChecksumErrorExtension(message) != null) { - DefaultPacketExtension checksumErrorExtension = PacketExtensions - .getChecksumErrorExtension(message); - - final String path = checksumErrorExtension - .getValue(PacketExtensions.FILE_PATH); - - final boolean resolved = Boolean - .parseBoolean(checksumErrorExtension.getValue("resolved")); - - if (resolved) { - log.debug("synchronisation completed, inconsistency resolved"); - ErrorMessageDialog.closeChecksumErrorMessage(); - return; - } - - ErrorMessageDialog.showChecksumErrorMessage(path); - - // Host - if (Saros.getDefault().getSessionManager().getSharedProject() - .isHost()) { - log.warn("Checksum Error for " + path); - - IEditorPart editor = (IEditorPart) EditorManager.getDefault() - .getEditors(new Path(path)).toArray()[0]; - - new Thread() { - - public void run() { - // wait until no more activities are received - while (System.currentTimeMillis() - - XMPPChatTransmitter.this.lastReceivedActivityTime < 1500) { - try { - Thread.sleep(200); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - EditorManager.getDefault().saveText(new Path(path), - true); - - // IPath fullPath = - // Saros.getDefault().getSessionManager() - // .getSharedProject().getProject().findMember( - // path).getFullPath(); - // ITextFileBuffer fileBuff = FileBuffers - // .getTextFileBufferManager().getTextFileBuffer( - // fullPath, LocationKind.IFILE); - // - // if (fileBuff == null) { - // log.error("Can't get File Buffer"); - // } - // if (fileBuff.isDirty()) - // try { - // fileBuff - // .commit(new NullProgressMonitor(), true); - // } catch (CoreException e) { - // // TODO Auto-generated catch block - // e.printStackTrace(); - // } - - // TODO CJ: thinking about a better solution with - // activity sequencer and jupiter - - // Saros.getDefault().getSessionManager() - // .getSharedProject() - // .getConcurrentDocumentManager() - // .resetJupiterDocument(new Path(path)); - - log.debug("Sending file to clients"); - sendFile(new JID(message.getFrom()), Saros.getDefault() - .getSessionManager().getSharedProject() - .getProject(), new Path(path), null); - } - }.start(); - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smackx.filetransfer.FileTransferListener - */ - public void fileTransferRequest(FileTransferRequest incommingRequest) { - - final FileTransferRequest request = incommingRequest; - - new Thread(new Runnable() { - - public void run() { - try { - String fileDescription = request.getDescription(); - XMPPChatTransmitter.log.debug("1. incomming file transfer " - + request.getFileName()); - if (fileDescription - .equals(XMPPChatTransmitter.PROJECT_ARCHIVE_DESCRIPTION)) { - XMPPChatTransmitter.log - .debug(" incoming project archive file."); - receiveArchiveFile(request); - } - if (fileDescription - .equals(XMPPChatTransmitter.FILELIST_TRANSFER_DESCRIPTION)) { - FileList fileList = receiveFileListBufferByteArray(request); - JID fromJID = new JID(request.getRequestor()); - - XMPPChatTransmitter.log - .debug("2. inform invitation process..."); - for (IInvitationProcess process : XMPPChatTransmitter.this.processes) { - if (process.getPeer().equals(fromJID)) { - process.fileListReceived(fromJID, fileList); - /* - * incoming IBB transfer. cancel jingle transfer - * mode. - */ - process.setTransferMode(TransferMode.IBB); - } - } - - } else if (fileDescription.startsWith( - XMPPChatTransmitter.RESOURCE_TRANSFER_DESCRIPTION, - 0)) { - receiveResource(request); - } - } catch (Exception e) { - XMPPChatTransmitter.log.error( - "Incoming File Transfer Thread: ", e); - for (IInvitationProcess process : XMPPChatTransmitter.this.processes) { - if (process.getPeer().equals( - new JID(request.getRequestor()))) { - process.cancel(e.getMessage(), false); - } - } - } - - } - - }).start(); - - } - - /** - * read incoming file and open inputstream to IInvitationProcess. - * - * @param request - * @throws Exception - */ - private void receiveArchiveFile(FileTransferRequest request) - throws Exception { - // try{ - File archive = receiveFile(request); - - ZipFile zip = new ZipFile(archive); - Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - XMPPChatTransmitter.log.debug(entry.getName()); - JID fromJID = new JID(request.getRequestor()); - - XMPPChatTransmitter.log.debug("2. inform invitation process..."); - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(fromJID)) { - process.resourceReceived(fromJID, - new Path(entry.getName()), zip - .getInputStream(entry)); - } - } - } - archive.delete(); - } - - private void sendMessageToAll(ISharedProject sharedProject, - PacketExtension extension) { // HACK - - JID myJID = Saros.getDefault().getMyJID(); - - for (User participant : sharedProject.getParticipants()) { - if (participant.getJid().equals(myJID)) { - continue; - } - - // if user is known to be offline, dont send but queue - if (sharedProject != null) { - - User user = sharedProject.getParticipant(participant.getJid()); - if ((user != null) - && (user.getPresence() == User.UserConnectionState.OFFLINE)) { - - // offline for too long - if (user.getOfflineSecs() > XMPPChatTransmitter.FORCEDPART_OFFLINEUSER_AFTERSECS) { - XMPPChatTransmitter.log - .info("Removing offline user from session..."); - sharedProject.removeUser(user); - } else { - queueMessage(participant.getJid(), extension); - XMPPChatTransmitter.log - .info("User known as offline - Message queued!"); - } - - continue; - } - } - - sendMessage(participant.getJid(), extension); - } - } - - private void queueMessage(JID jid, PacketExtension extension) { - MessageTransfer msg = new MessageTransfer(); - msg.receipient = jid; - msg.packetextension = extension; - this.messageTransferQueue.add(msg); - } - - private void sendMessage(JID jid, PacketExtension extension) { - - if (!this.connection.isConnected()) { - queueMessage(jid, extension); - return; - } - - try { - - Chat chat = getChat(jid); - Message message = new Message(); - message.addExtension(extension); - chat.sendMessage(message); - - } catch (Exception e) { - queueMessage(jid, extension); - - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not send message, message queued", e)); - } - } - - /** - * receive resource with file transfer. - * - * @param request - */ - private void receiveResource(FileTransferRequest request) { - try { - - JID from = new JID(request.getRequestor()); - /* file path exists in description. */ - Path path = new Path(request.getDescription() - .substring( - XMPPChatTransmitter.RESOURCE_TRANSFER_DESCRIPTION - .length() + 1)); - - XMPPChatTransmitter.log.debug("Receiving resource from" - + from.toString() + ": " + request.getFileName()); - - // InputStream in = request.accept().recieveFile(); - - IncomingFileTransfer transfer = request.accept(); - - // FileTransferProcessMonitor monitor = new - // FileTransferProcessMonitor( - // transfer); - - InputStream in = transfer.recieveFile(); - - // TODO CJ: move this to business logic - boolean handledByInvitation = false; - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(from)) { - process.resourceReceived(from, path, in); - handledByInvitation = true; - break; - } - } - - if (!handledByInvitation) { - FileActivity activity = new FileActivity( - FileActivity.Type.Created, path, in); - - int time; - String description = request.getDescription(); - try { - time = Integer - .parseInt(description - .substring(XMPPChatTransmitter.RESOURCE_TRANSFER_DESCRIPTION - .length() + 1)); - } catch (NumberFormatException e) { - Saros.log("Could not parse time from description: " - + description, e); - time = 0; // HACK - } - - TimedActivity timedActivity = new TimedActivity(activity, time); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.getSharedProject().getSequencer().exec(timedActivity); - } - - // /* wait for complete transfer. */ - // while (monitor.isAlive() && monitor.isRunning()) { - // Thread.sleep(500); - // } - // monitor.closeMonitor(true); - - XMPPChatTransmitter.log.info("Received resource " - + request.getFileName()); - - } catch (Exception e) { - XMPPChatTransmitter.log.warn("Failed to receive " - + request.getFileName(), e); - } - } - - private void transferFile(FileTransferData transferData) - throws CoreException, XMPPException, IOException { - - XMPPChatTransmitter.log.info("Sending file " + transferData.path); - - JID recipient = transferData.recipient; - - String description = XMPPChatTransmitter.RESOURCE_TRANSFER_DESCRIPTION; - if (transferData.timestamp >= 0) { - description = description + ':' + transferData.timestamp; - } - - if (getFileTransferModeViaChat()) { - sendSingleFileWithIBB(transferData); - } else { - - if (jingleManager.getState(recipient) != JingleConnectionState.ERROR) { - log.info("Send file " + transferData.path + " (with Jingle)"); - - /* create file transfer. */ - JingleFileTransferData data = new JingleFileTransferData(); - - data.file_project_path = transferData.path.toString(); - data.project_name = transferData.project.getName(); - data.type = FileTransferType.RESOURCE_TRANSFER; - data.recipient = recipient; - data.sender = new JID(connection.getUser()); - - /* read content data. */ - File f = new File(transferData.project.getFile( - transferData.path).getLocation().toOSString()); - data.filesize = f.length(); - data.content = new byte[(int) data.filesize]; - - try { - InputStream in = transferData.project.getFile( - transferData.path).getContents(); - in.read(data.content, 0, (int) data.filesize); - } catch (Exception e) { - e.printStackTrace(); - data.content = null; - log.error("Error during read file content for transfer!"); - } - - try { - // transfer files with jingle - jingleManager.createOutgoingJingleFileTransfer(recipient, - new JingleFileTransferData[] { data }); - - /* inform callback. */ - if (transferData.callback != null) - transferData.callback.fileSent(transferData.path); - - return; - - } catch (JingleSessionException e) { - log - .info("Failed to send file with jingle, fall back to IBB"); - } - } - // failed to send file with jingle (otherwise had returned) - int attempt = 0; - while (attempt < 5) { - try { - sendSingleFileWithIBB(transferData); - return; - } catch (XMPPException ee) { - log.error("Failed to send file with IBB"); - attempt++; - } - } - ErrorMessageDialog.showErrorMessage("Failed to send file " - + transferData.path + "."); - } - } - - /** - * send single file from queue with xmpp message. - * - * @param transferData - * @throws CoreException - * @throws XMPPException - * @throws IOException - */ - private void sendSingleFileWithIBB(FileTransferData transferData) - throws CoreException, XMPPException, IOException { - - JID recipient = transferData.recipient; - - String description = RESOURCE_TRANSFER_DESCRIPTION; - - OutgoingFileTransfer.setResponseTimeout(MAX_TRANSFER_RETRIES * 1000); - OutgoingFileTransfer transfer = fileTransferManager - .createOutgoingFileTransfer(recipient.toString()); - - IFile f = transferData.project.getFile(transferData.path); - - if (f.exists()) { - log.debug("file exists and will be send :" + f.getName() + " " - + f.getLocation()); - /* set path in description */ - description = description + ":" + transferData.path; - /* send file */ - transfer - .sendFile(new File(f.getLocation().toString()), description); - } else { - log.warn("file NOT exists. " + f.getLocation()); - throw new IOException("File not exists."); - } - - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer); - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - monitor.closeMonitor(true); - - if (transfer - .getStatus() - .equals( - org.jivesoftware.smackx.filetransfer.FileTransfer.Status.complete)) { - log.debug("transfer complete"); - } - - if (transferData.callback != null) - transferData.callback.fileSent(transferData.path); - } - - /** - * Receive file and save temporary. - * - * @param request - * transfer request of incoming file. - * @return File object of received file - */ - private File receiveFile(FileTransferRequest request) { - File archiveFile = new File("./incoming_archive.zip"); - XMPPChatTransmitter.log.debug("Archive file: " - + archiveFile.getAbsolutePath()); - try { - final IncomingFileTransfer transfer = request.accept(); - - IFileTransferCallback callback = null; - - /* get IInvitationprocess for monitoring. */ - JID fromJID = new JID(request.getRequestor()); - for (IInvitationProcess process : this.processes) { - if (process.getPeer().equals(fromJID)) { - /* set callback. */ - callback = process; - } - } - - /* monitoring of transfer process */ - FileTransferProcessMonitor monitor = new FileTransferProcessMonitor( - transfer, callback); - - /* receive file. */ - transfer.recieveFile(archiveFile); - - /* wait for complete transfer. */ - while (monitor.isAlive() && monitor.isRunning()) { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - monitor.closeMonitor(true); - - } catch (Exception e) { - XMPPChatTransmitter.log.error("Error in Incoming File: ", e); - return null; - } - - return archiveFile; - } - - private FileList receiveFileListBufferByteArray(FileTransferRequest request) { - FileList fileList = null; - try { - final IncomingFileTransfer transfer = request.accept(); - - InputStream in = transfer.recieveFile(); - - byte[] buffer = new byte[1024]; - int bytesRead; - String sb = new String(); - while ((bytesRead = in.read(buffer, 0, 1024)) != -1) { - sb += new String(buffer, 0, bytesRead).toString(); - } - in.close(); - XMPPChatTransmitter.log.debug("Close input stream"); - fileList = new FileList(sb.toString()); - - } catch (Exception e) { - XMPPChatTransmitter.log.error("Error in Incoming File List: ", e); - return null; - } - - return fileList; - } - - private void putIncomingChat(JID jid, String thread) { - if (!this.chats.containsKey(jid)) { - Chat chat = this.chatmanager.getThreadChat(thread); - this.chats.put(jid, chat); - } - - } - - private Chat getChat(JID jid) { - if (this.connection == null) { - throw new NullPointerException("Connection can't be null."); - } - - Chat chat = this.chats.get(jid); - - if (chat == null) { - chat = this.chatmanager.createChat(jid.toString(), this); - this.chats.put(jid, chat); - } - - return chat; - } - - private boolean getFileTransferModeViaChat() { - return this.m_bFileTransferByChat - || Saros.getDefault().getPreferenceStore().getBoolean( - PreferenceConstants.FORCE_FILETRANSFER_BY_CHAT); - - } - - public void exceptionOccured(JingleSessionException exception) { - // TODO Auto-generated method stub - - } - - /** - * File received with jingle. - */ - public void incomingResourceFile(JingleFileTransferData data, - InputStream input) { - log.info("incoming resource " + data.file_project_path); - - JID from = data.sender; - Path path = new Path(data.file_project_path); - int time = data.timestamp; - - // TODO CJ: move this to business logic - boolean handledByInvitation = false; - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(from)) { - process.resourceReceived(from, path, input); - handledByInvitation = true; - break; - } - } - - if (!handledByInvitation) { - FileActivity activity = new FileActivity(FileActivity.Type.Created, - path, input); - - TimedActivity timedActivity = new TimedActivity(activity, time); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.getSharedProject().getSequencer().exec(timedActivity); - } - } - - public void incomingFileList(String fileList_content, JID recipient) { - FileList fileList = null; - log.info("incoming file list"); - try { - fileList = new FileList(fileList_content); - } catch (XmlPullParserException e) { - - e.printStackTrace(); - } catch (IOException e) { - - e.printStackTrace(); - } - for (IInvitationProcess process : processes) { - if (process.getPeer().equals(recipient)) - process.fileListReceived(recipient, fileList); - } - - } - - public void failedToSendFileListWithJingle(JID jid, - JingleFileTransferData transferList) { - int attempt = 0; - while (attempt < 5) { - try { - sendFileListWithIBB(transferList.file_list_content, jid); - return; - } catch (XMPPException e) { - log.error("Failed to send file list with IBB"); - attempt++; - } - } - ErrorMessageDialog.showErrorMessage("Failed to send file list"); - } - - public void connected(String protocol, String remote) { - // TODO Auto-generated method stub - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferListener.java deleted file mode 100644 index 279c5779bfb6073883881a219ce38694acf6f341..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/IJingleFileTransferListener.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.io.InputStream; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * this class contains method for jingle file transfer action - * - * @author orieger - * - */ -public interface IJingleFileTransferListener { - - public void incomingFileList(String fileList_content, JID sender); - - public void incomingResourceFile(JingleFileTransferData data, - InputStream input); - - public void exceptionOccured(JingleSessionException exception); - - public void failedToSendFileListWithJingle(JID jid, - JingleFileTransferData transferList); - - public void connected(String protocol, String remote); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferData.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferData.java deleted file mode 100644 index 6b6a8d9ab9f0e7e2615376750f06ba89c24a94ac..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferData.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * - */ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.io.File; -import java.io.Serializable; - -import de.fu_berlin.inf.dpp.net.JID; - -public class JingleFileTransferData implements Serializable { - private static final long serialVersionUID = -4063208452619555716L; - - public static enum FileTransferType { - /* file list information is transfer. */ - FILELIST_TRANSFER, - /* single resource is transfer. */ - RESOURCE_TRANSFER, - } - - public FileTransferType type; - - public String file_list_content; - public JID recipient; - public JID sender; - public String project_name; - public String file_project_path; - public int timestamp; - public long filesize; - public byte[] content; - - /* for testing only */ - public File file; - public String filePath; -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferManager.java deleted file mode 100644 index e08a15873ce60ecdb37866a01109446c48a0f109..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferManager.java +++ /dev/null @@ -1,461 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Vector; - -import org.apache.log4j.Logger; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.jingle.JingleManager; -import org.jivesoftware.smackx.jingle.JingleNegotiatorState; -import org.jivesoftware.smackx.jingle.JingleSession; -import org.jivesoftware.smackx.jingle.JingleSessionRequest; -import org.jivesoftware.smackx.jingle.listeners.JingleMediaListener; -import org.jivesoftware.smackx.jingle.listeners.JingleSessionListener; -import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener; -import org.jivesoftware.smackx.jingle.listeners.JingleTransportListener; -import org.jivesoftware.smackx.jingle.media.JingleMediaManager; -import org.jivesoftware.smackx.jingle.media.JingleMediaSession; -import org.jivesoftware.smackx.jingle.media.PayloadType; -import org.jivesoftware.smackx.jingle.nat.ICETransportManager; -import org.jivesoftware.smackx.jingle.nat.JingleTransportManager; -import org.jivesoftware.smackx.jingle.nat.STUNTransportManager; -import org.jivesoftware.smackx.jingle.nat.TransportCandidate; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * This class manages all Jingle Peer to Peer Sessions. Jingle is a - * XMPP-extension with id XEP-0166. Documentation can be found at - * http://xmpp.org/extensions/xep-0166.html . - * - * The main method is createOutgoingJingleFileTransfer which creates a Jingle - * Session. To support file transfer even a user is behind a NAT, it uses a STUN - * server to resolve the IP-addresses. - * - * @author orieger - * @author chjacob - */ -public class JingleFileTransferManager { - - private static Logger logger = Logger - .getLogger(JingleFileTransferManager.class); - - /** - * The FileMediaManager manages all FileTransferSessions. When a Jingle - * Session is established the SMACK API calls the createMediaSessions method - * and a new JingleFileTransferSession is created. To send a file with an - * existing session use the transferFiles method. - */ - private class FileMediaManager extends JingleMediaManager { - - private JingleFileTransferData[] transferData = new JingleFileTransferData[0]; - private HashMap<JID, JingleFileTransferSession> sessions; - private JingleFileTransferSession session; - - public FileMediaManager(JingleTransportManager transportManager) { - super(transportManager); - sessions = new HashMap<JID, JingleFileTransferSession>(); - } - - @Override - public JingleMediaSession createMediaSession(PayloadType payload, - TransportCandidate tc1, TransportCandidate tc2, - JingleSession jingleSession) { - - // get JID from other side - JID jid = Saros.getDefault().getMyJID().toString().equals( - jingleSession.getInitiator()) ? new JID(jingleSession - .getResponder()) : new JID(jingleSession.getInitiator()); - - JingleFileTransferSession newSession = new JingleFileTransferSession( - payload, tc1, tc2, null, jingleSession, transferData, jid, - listeners); - - sessions.put(jid, newSession); - return newSession; - } - - @Override - public List<PayloadType> getPayloads() { - List<PayloadType> result = new ArrayList<PayloadType>(); - result.add(new PayloadType.Audio(333, "fileshare")); - return result; - } - - public void setTransferFile(JingleFileTransferData[] transferData) { - this.transferData = transferData; - } - - public void transferFiles(JingleFileTransferData[] transferData, JID jid) - throws JingleSessionException { - JingleFileTransferSession session = sessions.get(jid); - if (session != null) { - session.sendFiles(transferData); - transferData = null; - } - } - - public void removeJingleSession(JID jid) { - if (sessions.containsKey(jid)) - sessions.remove(jid); - } - } - - private XMPPConnection xmppConnection; - private JingleManager jm; - - private HashMap<JID, JingleSession> incomingSessions = null; - private HashMap<JID, JingleSession> outgoingSessions = null; - - public static int JINGLE_TIME_OUT = 10000; - - /** - * this map contains for all incoming and outgoing jingle sessions the - * appropriate connection states. If an error occur the connection state - * stay in list for call back setting. - */ - private HashMap<JID, JingleConnectionState> connectionStates = null; - private FileMediaManager mediaManager = null; - private Set<IJingleFileTransferListener> listeners; - - public enum JingleConnectionState { - INIT, ESTABLISHED, CLOSED, ERROR, DEFAULT - } - - public JingleFileTransferManager(XMPPConnection connection, - IJingleFileTransferListener listener) { - this.xmppConnection = connection; - incomingSessions = new HashMap<JID, JingleSession>(); - outgoingSessions = new HashMap<JID, JingleSession>(); - connectionStates = new HashMap<JID, JingleConnectionState>(); - this.listeners = new HashSet<IJingleFileTransferListener>(); - this.listeners.add(listener); - logger.debug("initialized jingle file transfer manager."); - initialize(); - } - - public void initialize() { - - // get STUN Server from Preferences - // IPreferenceStore prefStore = Saros.getDefault().getPreferenceStore(); - // final String stunServer = - // prefStore.getString(PreferenceConstants.STUN); - // final int stunServerPort = Integer.parseInt(prefStore - // .getString(PreferenceConstants.STUN_PORT)); - - // ICETransportManager icetm0 = new ICETransportManager(xmppConnection, - // stunServer, stunServerPort); - - // ICETransportManager icetm0 = new ICETransportManager(xmppConnection, - // "10.47.47.53", 3478); - - STUNTransportManager stun = new STUNTransportManager(); - mediaManager = new FileMediaManager(stun); - - List<JingleMediaManager> medias = new Vector<JingleMediaManager>(); - medias.add(mediaManager); - - jm = new JingleManager(xmppConnection, medias); - JingleManager.setJingleServiceEnabled(); - - jm.addJingleSessionRequestListener(new JingleSessionRequestListener() { - public void sessionRequested(JingleSessionRequest request) { - - JID jid = new JID(request.getFrom()); - JingleSession incoming = incomingSessions.get(jid); - - if (incoming != null) - return; - - try { - // Accept the call - incoming = request.accept(); - - initJingleListener(incoming, new JID(incoming - .getInitiator())); - /* put to current session list. */ - incomingSessions.put(jid, incoming); - // Start the call - incoming.startIncoming(); - } catch (XMPPException e) { - e.printStackTrace(); - } - } - }); - - } - - private void initJingleListener(JingleSession js, final JID jid) { - - connectionStates.put(jid, JingleConnectionState.INIT); - - /* add media listener. */ - js.addMediaListener(new JingleMediaListener() { - - public void mediaClosed(PayloadType cand) { - logger.debug("media closed : " + jid.toString()); - } - - public void mediaEstablished(PayloadType pt) { - logger.debug("media established : " + jid.toString()); - } - }); - - /** - * Jingle Session Listener - */ - js.addListener(new JingleSessionListener() { - - public void sessionClosed(String arg0, JingleSession session) { - logger.info("session closed : " + jid.toString()); - - /* - * if session closed during pending process, fallback to - * XEP-0096 transfer - */ - if (session.getNegotiatorState() == JingleNegotiatorState.PENDING - && (connectionStates.get(jid) == JingleConnectionState.INIT)) { - logger.error("Session closed during pending process : " - + jid + " with current state : " + getState(jid)); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - for (IJingleFileTransferListener listener : listeners) { - if (session.getInitiator().equals( - session.getConnection().getUser())) { - listener.failedToSendFileListWithJingle(jid, - mediaManager.transferData[0]); - } - } - - } - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.CLOSED); - } - - public void sessionClosedOnError(XMPPException arg0, - JingleSession arg1) { - logger.error("session closed on error : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - } - - public void sessionDeclined(String arg0, JingleSession arg1) { - logger.error("session declined : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - } - - public void sessionEstablished(PayloadType arg0, - TransportCandidate arg1, TransportCandidate arg2, - JingleSession arg3) { - logger.debug("session established : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ESTABLISHED); - } - - public void sessionMediaReceived(JingleSession arg0, String arg1) { - // do nothing - } - - public void sessionRedirected(String arg0, JingleSession arg1) { - // do nothing - } - }); - - /** - * Transport Listener - */ - js.addTransportListener(new JingleTransportListener() { - - public void transportClosed(TransportCandidate cand) { - logger.debug("transport closed: " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.CLOSED); - } - - public void transportClosedOnError(XMPPException e) { - logger.error("transport closed on error : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - } - - public void transportEstablished(TransportCandidate local, - TransportCandidate remote) { - logger.debug("transport established : " + jid.toString()); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ESTABLISHED); - } - }); - } - - /** - * initiate a jingle session - * - * @param jid - * @param transferData - * @param monitor - * @throws XMPPException - */ - public void createOutgoingJingleFileTransfer(JID jid, - JingleFileTransferData[] transferData) - throws JingleSessionException { - - JingleSession outgoing = outgoingSessions.get(jid); - JingleSession incoming = incomingSessions.get(jid); - - if (outgoing != null) { - /* send new data with current connection. */ - mediaManager.transferFiles(transferData, jid); - return; - } - if (incoming != null) { - /* send new data with current connection. */ - mediaManager.transferFiles(transferData, jid); - return; - } - - mediaManager.setTransferFile(transferData); - - try { - outgoing = jm.createOutgoingJingleSession(jid.toString()); - - initJingleListener(outgoing, jid); - - /* add to outgoing session list. */ - outgoingSessions.put(jid, outgoing); - - outgoing.startOutgoing(); - } catch (XMPPException e) { - throw new JingleSessionException("Can't connect with Jingle"); - } - - } - - /** - * remove all jingle sessions. - */ - public void terminateAllJingleSessions() { - - logger.debug("Terminate all jingle sessions."); - - JingleSession outgoing = null; - for (JID jid : outgoingSessions.keySet()) { - outgoing = outgoingSessions.get(jid); - if (outgoing != null) { - try { - outgoing.terminate(); - } catch (XMPPException e1) { - e1.printStackTrace(); - } finally { - mediaManager.removeJingleSession(jid); - outgoingSessions.remove(jid); - } - } - } - - JingleSession incoming = null; - for (JID jid : incomingSessions.keySet()) { - incoming = incomingSessions.get(jid); - if (incoming != null) { - try { - incoming.terminate(); - } catch (XMPPException e1) { - e1.printStackTrace(); - } finally { - mediaManager.removeJingleSession(jid); - incomingSessions.remove(jid); - } - } - } - - /* reset connection state list */ - // connectionStates.clear(); - } - - /** - * terminate and remove jingle session for jid. - * - * @param jid - */ - public void terminateJingleSession(JID jid) { - JingleSession outgoing = outgoingSessions.get(jid); - if (outgoing != null) { - try { - outgoing.terminate(); - } catch (XMPPException e1) { - // e1.printStackTrace(); - logger.error( - "Error during terminate outgoing jingle session with JID : " - + jid, e1); - } finally { - mediaManager.removeJingleSession(jid); - outgoingSessions.remove(jid); - logger.debug("Terminate outgoing jingle session with JID : " - + jid); - } - } - - JingleSession incoming = incomingSessions.get(jid); - if (incoming != null) { - try { - incoming.terminate(); - } catch (XMPPException e1) { - // e1.printStackTrace(); - logger.error( - "Error during terminate incoming jingle session with JID : " - + jid, e1); - } finally { - mediaManager.removeJingleSession(jid); - incomingSessions.remove(jid); - logger.debug("Terminate incoming jingle session with JID : " - + jid); - } - } - } - - /** - * this method returns the appropriate connection state of active jingle - * session. - * - * @param jid - * identify the jingle session - * @return JingleConnectionState for given jabber id, or null if non jingle - * session has found. - */ - public JingleConnectionState getState(JID jid) { - JingleConnectionState state = connectionStates.get(jid); - return state; - } - - /** - * Terminate Jingle connection and set error state for given peer. - * - * @param jid - */ - public void setJingleErrorState(JID jid) { - if (jid != null) { - logger.debug("Terminate Jingle Session for " + jid); - terminateJingleSession(jid); - connectionStates.remove(jid); - connectionStates.put(jid, JingleConnectionState.ERROR); - } else { - logger.warn("JID is null. Jingle error state couldn't be set."); - } - } - - /** - * to add a JingleFileTransferListener - * - * @param listener - */ - public void addJingleFileTransferListener( - IJingleFileTransferListener listener) { - listeners.add(listener); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferSession.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferSession.java deleted file mode 100644 index cd7222b9241d8b71ff78830ef3032cc91576aa58..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleFileTransferSession.java +++ /dev/null @@ -1,484 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.ServerSocket; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.Set; - -import org.apache.log4j.Logger; -import org.jivesoftware.smackx.jingle.JingleSession; -import org.jivesoftware.smackx.jingle.media.JingleMediaSession; -import org.jivesoftware.smackx.jingle.media.PayloadType; -import org.jivesoftware.smackx.jingle.nat.TransportCandidate; -import org.limewire.nio.NIODispatcher; -import org.limewire.rudp.DefaultRUDPContext; -import org.limewire.rudp.DefaultRUDPSettings; -import org.limewire.rudp.DefaultUDPService; -import org.limewire.rudp.RudpMessageDispatcher; -import org.limewire.rudp.UDPMultiplexor; -import org.limewire.rudp.UDPSelectorProvider; -import org.limewire.rudp.messages.RUDPMessageFactory; -import org.limewire.rudp.messages.impl.DefaultMessageFactory; - -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferData.FileTransferType; - -/** - * This class implements a file transfer session with jingle. - * - * Jingle is a XMPP-extension with id XEP-0166. Documentation can be found at - * http://xmpp.org/extensions/xep-0166.html . - * - * This implementation uses TCP as transport protocol which fall back to UDP - * when a TCP connection failed. To ensure no data loss when transmitting with - * UDP the RUDP implementation from the Limewire project are used. - * - * Documentation for the RUDP component from limewire can be found at: - * http://wiki.limewire.org/index.php?title=Javadocs . - * - * @author chjacob - * - */ -public class JingleFileTransferSession extends JingleMediaSession { - - private class Receive extends Thread { - - private ObjectInputStream input; - - public Receive(ObjectInputStream ii) { - this.input = ii; - } - - public void run() { - try { - - while (true) { - logger.debug("waiting on port " + localPort); - - /* get number of file to be transfer. */ - int fileNumber; - - fileNumber = input.readInt(); - logger.debug("incoming file number: " + fileNumber); - - for (int i = 0; i < fileNumber; i++) { - - /* receive file data */ - JingleFileTransferData data = (JingleFileTransferData) input - .readObject(); - - if (data.type == FileTransferType.FILELIST_TRANSFER) { - logger.debug("received file List"); - logger.debug(data.file_list_content); - /* inform listener. */ - for (IJingleFileTransferListener listener : listeners) { - listener.incomingFileList( - data.file_list_content, data.sender); - } - - } else if (data.type == FileTransferType.RESOURCE_TRANSFER) { - logger.debug("received resource " - + data.file_project_path); - for (IJingleFileTransferListener listener : listeners) { - listener.incomingResourceFile(data, - new ByteArrayInputStream(data.content)); - } - } - } - } - } catch (IOException e) { - logger.info("receive-thread interrupted"); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - - } - } - - private static Logger logger = Logger - .getLogger(JingleFileTransferSession.class); - - private Receive tcpReceiveThread; - private Receive udpReceiveThread; - private JingleFileTransferData[] transferList; - private Set<IJingleFileTransferListener> listeners; - private UDPSelectorProvider udpSelectorProvider; - private Socket udpSocket; - private Socket tcpSocket; - private ObjectOutputStream tcpObjectOutputStream; - private ObjectOutputStream udpObjectOutputStream; - private ObjectInputStream tcpObjectInputStream; - private ObjectInputStream udpObjectInputStream; - private JID remoteJid; - private String ip; - private String localIp; - private int localPort; - private int remotePort; - - /** - * TODO CJ: write javadoc - * - * @param payloadType - * @param remote - * @param local - * @param mediaLocator - * @param jingleSession - * @param transferData - * @param listeners - */ - public JingleFileTransferSession(PayloadType payloadType, - TransportCandidate remote, TransportCandidate local, - String mediaLocator, JingleSession jingleSession, - JingleFileTransferData[] transferData, JID remoteJid, - Set<IJingleFileTransferListener> listeners) { - super(payloadType, remote, local, mediaLocator, jingleSession); - - this.remoteJid = remoteJid; - this.transferList = transferData; - this.listeners = listeners; - logger.debug("JingleFileTransferSesseion created " + local.getIp() - + ":" + local.getPort() + " <-> " + remote.getIp() + ":" - + remote.getPort()); - initialize(); - } - - /** - * Initialization of the session. It tries to create sockets for both, TCP - * and UDP. The UDP Socket is a reliable implementation from the Limewire - * project. Documentation can be found at http://wiki.limewire.org. - */ - @Override - public void initialize() { - - if (this.getLocal().getSymmetric() != null) { - ip = this.getLocal().getIp(); - localIp = this.getLocal().getLocalIp(); - localPort = getFreePort(); - remotePort = this.getLocal().getSymmetric().getPort(); - - logger.debug(this.getLocal().getConnection() + " " + ip + ": " - + localPort + "->" + remotePort); - - } else { - ip = this.getRemote().getIp(); - localIp = this.getLocal().getLocalIp(); - localPort = this.getLocal().getPort(); - remotePort = this.getRemote().getPort(); - } - - // create RUDP service - RudpMessageDispatcher dispatcher = new RudpMessageDispatcher(); - DefaultUDPService service = new DefaultUDPService(dispatcher); - RUDPMessageFactory factory = new DefaultMessageFactory(); - udpSelectorProvider = new UDPSelectorProvider(new DefaultRUDPContext( - factory, NIODispatcher.instance().getTransportListener(), - service, new DefaultRUDPSettings())); - UDPMultiplexor udpMultiplexor = udpSelectorProvider.openSelector(); - dispatcher.setUDPMultiplexor(udpMultiplexor); - NIODispatcher.instance().registerSelector(udpMultiplexor, - udpSelectorProvider.getUDPSocketChannelClass()); - try { - service.start(localPort); - } catch (IOException e) { - logger.debug("Failed to create RUDP service"); - } - - // server side - if (getJingleSession().getInitiator().equals( - getJingleSession().getConnection().getUser())) { - - // create TCP Socket and listen - Thread createTcpSocket = new Thread(new Runnable() { - public void run() { - try { - ServerSocket serverSocket = new ServerSocket(localPort); - // serverSocket.setSoTimeout(2000); - JingleFileTransferSession.this.tcpSocket = serverSocket - .accept(); - JingleFileTransferSession.this.tcpObjectOutputStream = new ObjectOutputStream( - tcpSocket.getOutputStream()); - JingleFileTransferSession.this.tcpObjectInputStream = new ObjectInputStream( - tcpSocket.getInputStream()); - informListenersAboutConnection("TCP"); - } catch (IOException e) { - logger.debug("Failed to listen with TCP"); - } - } - }); - createTcpSocket.start(); - - Thread createUdpSocket = new Thread(new Runnable() { - public void run() { - try { - Socket usock = udpSelectorProvider - .openAcceptorSocketChannel().socket(); - usock.setSoTimeout(0); - usock.connect(new InetSocketAddress(InetAddress - .getByName(ip), remotePort)); - usock.setKeepAlive(true); - JingleFileTransferSession.this.udpSocket = usock; - JingleFileTransferSession.this.udpObjectOutputStream = new ObjectOutputStream( - udpSocket.getOutputStream()); - JingleFileTransferSession.this.udpObjectInputStream = new ObjectInputStream( - udpSocket.getInputStream()); - informListenersAboutConnection("UDP"); - } catch (IOException e) { - logger.debug("Failed to listen with UDP"); - } - } - }); - createUdpSocket.start(); - - try { // give client a little time to connect - Thread.sleep(2000); - } catch (InterruptedException e) { - // do nothing - } - - } else { // client side - try { // give server a little time to come up - Thread.sleep(500); - } catch (InterruptedException e) { - // do nothing - } - try { // to create a tcp socket - this.tcpSocket = new Socket(ip, remotePort); - this.tcpObjectOutputStream = new ObjectOutputStream(tcpSocket - .getOutputStream()); - this.tcpObjectInputStream = new ObjectInputStream(tcpSocket - .getInputStream()); - logger.debug("successfully connected with TCP"); - informListenersAboutConnection("TCP"); - logger.debug("JingleFileTransferSesseion initialized"); - return; - - } catch (UnknownHostException e) { - logger.debug("Invalid IP-address of jingle remote (TCP)"); - } catch (IOException e) { - logger.debug("Failed to connect with TCP"); - } - - try { // to create a udp socket - - Socket usock = udpSelectorProvider.openSocketChannel().socket(); - usock.setSoTimeout(0); - usock.setKeepAlive(true); - usock.connect(new InetSocketAddress(InetAddress.getByName(ip), - remotePort)); - this.udpSocket = usock; - this.udpObjectOutputStream = new ObjectOutputStream(udpSocket - .getOutputStream()); - this.udpObjectInputStream = new ObjectInputStream(udpSocket - .getInputStream()); - logger.debug("successfully connected with UDP"); - informListenersAboutConnection("UDP"); - logger.debug("JingleFileTransferSesseion initialized"); - } catch (UnknownHostException e1) { - logger.debug("Invalid IP-address of jingle remote (UDP)"); - } catch (IOException e1) { - logger.debug("Failed to connect with UDP"); - } - } - } - - private void informListenersAboutConnection(String protocol) { - for (IJingleFileTransferListener listener : listeners) { - listener.connected(protocol, ip); - } - } - - /** - * This method is called from the JingleFileTransferManager to send files - * with this session. This method tries to transmit the files with TCP. When - * this fails it tries to send the files with UDP/RUDP. - * - * @throws JingleSessionException - */ - public void sendFiles(JingleFileTransferData[] transferData) - throws JingleSessionException { - - this.transferList = transferData; - - if (tcpSocket != null) { - logger.debug("sending with TCP to " + ip + ":" + remotePort); - try { - logger.debug("sending with TCP.."); - transmit(tcpObjectOutputStream); - return; - } catch (IOException e) { - logger.debug("sending with TCP failed, use UDP instead..", e); - } - } - if (udpSocket != null) { - logger.debug("sending with UDP to " + ip + ":" + remotePort); - try { - logger.debug("sending with UDP.."); - transmit(udpObjectOutputStream); - return; - } catch (IOException e) { - logger.debug("sending with UDP failed, use IBB instead..", e); - } - } - throw new JingleSessionException("Failed to send files with Jingle"); - } - - /** - * This method is called from Jingle when a jingle session is established. - * Two threads are started, one for receiving with TCP, the other for - * receiving with UDP/RUDP. - */ - @Override - public void startReceive() { - - logger.debug("start receiving"); - - if (tcpSocket != null && tcpObjectInputStream != null) { - this.tcpReceiveThread = new Receive(tcpObjectInputStream); - this.tcpReceiveThread.start(); - } - - if (udpSocket != null && udpObjectInputStream != null) { - this.udpReceiveThread = new Receive(udpObjectInputStream); - this.udpReceiveThread.start(); - } - } - - /** - * This method is called from Jingle when a jingle session is established. - * This method tries to transmit the files with TCP. When this fails it - * tries to send the files with UDP/RUDP. - */ - @Override - public void startTrasmit() { - if (transferList == null) - return; - - logger.debug("JingleFileTransferSesseion: start transmitting"); - - if (tcpSocket != null) { - try { - logger.debug("sending with TCP.."); - transmit(tcpObjectOutputStream); - return; - } catch (IOException e) { - logger.debug("sending with TCP failed, use UDP instead..", e); - } - } - if (udpSocket != null) { - try { - logger.debug("sending with UDP.."); - transmit(udpObjectOutputStream); - return; - } catch (IOException e) { - logger.warn("sending with UDP failed, use UDP instead..", e); - } - } - if (transferList.length > 0) { - for (IJingleFileTransferListener listener : listeners) { - listener.failedToSendFileListWithJingle(remoteJid, - transferList[0]); - } - } - } - - private synchronized void transmit(ObjectOutputStream oo) - throws IOException { - assert (oo != null); - - oo.writeInt(transferList.length); - oo.flush(); - logger.debug("sent transfer number : " + transferList.length); - - for (JingleFileTransferData data : transferList) { - - /* send data */ - oo.writeObject(data); - oo.flush(); - logger.debug("sent data for : " + data.file_project_path); - - } - transferList = null; - } - - @Override - public void stopReceive() { - logger.debug("JingleFileTransferSesseion: stop receiving"); - if (tcpReceiveThread != null) - tcpReceiveThread.interrupt(); - if (udpReceiveThread != null) - udpReceiveThread.interrupt(); - } - - @Override - public void stopTrasmit() { - logger.debug("JingleFileTransferSesseion: stop transmitting"); - try { - - if (tcpSocket != null) { - try { - tcpReceiveThread.join(); - } catch (InterruptedException e) { - } finally { - tcpObjectOutputStream.close(); - tcpObjectInputStream.close(); - tcpSocket.close(); - } - } - if (udpSocket != null) { - try { - udpReceiveThread.join(); - } catch (InterruptedException e) { - } finally { - udpObjectOutputStream.close(); - udpObjectInputStream.close(); - udpSocket.close(); - } - } - } catch (IOException e) { - logger.debug("Failed to close all sockets"); - } - } - - @Override - public void setTrasmit(boolean active) { - logger.debug("JingleFileTransferSesseion: set transmit to " + active); - // TODO CJ: What have to do here? - } - - /** - * Obtain a free port we can use. - * - * @return A free port number. - */ - protected int getFreePort() { - ServerSocket ss; - int freePort = 0; - - for (int i = 0; i < 10; i++) { - freePort = (int) (10000 + Math.round(Math.random() * 10000)); - freePort = freePort % 2 == 0 ? freePort : freePort + 1; - try { - ss = new ServerSocket(freePort); - freePort = ss.getLocalPort(); - ss.close(); - return freePort; - } catch (IOException e) { - e.printStackTrace(); - } - } - try { - ss = new ServerSocket(0); - freePort = ss.getLocalPort(); - ss.close(); - } catch (IOException e) { - e.printStackTrace(); - } - return freePort; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleSessionException.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleSessionException.java deleted file mode 100644 index b343a0f01d0ef3a57c6f3b79ae6a61a200d46ef1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/net/jingle/JingleSessionException.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.fu_berlin.inf.dpp.net.jingle; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * this exception is throw if jingle session request is failed. - * - * @author orieger - * - */ -public class JingleSessionException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 4395402562918748941L; - - private String message; - private JID jid; - private String errorName = "Jingle Tranfer Error"; - - public JingleSessionException(String message) { - super(); - this.message = message; - } - - public JingleSessionException(String message, JID jid) { - super(); - this.message = message; - this.jid = jid; - } - - public JingleSessionException(String message, Throwable cause) { - super(); - this.message = message; - } - - public JID getJID() { - return jid; - } - - public String getMessage() { - return message; - } - - public String toString() { - return errorName; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ActivityRegistry.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ActivityRegistry.java deleted file mode 100644 index 1f9806e2066690c3e26a76767fbab3d840468cbf..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ActivityRegistry.java +++ /dev/null @@ -1,89 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import java.util.ArrayList; -import java.util.List; - -import org.xmlpull.v1.XmlPullParser; - -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.project.internal.RoleManager; - -/** - * The activity registry holds references to all active activity providers and - * their activities. - * - * @author rdjemili - */ -public class ActivityRegistry { - private final List<IActivityProvider> activityProviders = new ArrayList<IActivityProvider>(); - - private static ActivityRegistry instance; - - /** - * @return the singleton instance of this registry.. - */ - public static ActivityRegistry getDefault() { - if (ActivityRegistry.instance == null) { - ActivityRegistry.instance = new ActivityRegistry(); - } - - return ActivityRegistry.instance; - } - - public void addProvider(IActivityProvider provider) { - if (!this.activityProviders.contains(provider)) { - this.activityProviders.add(provider); - } - } - - /** - * Converts given XML data into an activity. - */ - public IActivity parseActivity(XmlPullParser parser) { - IActivity activity = null; - for (IActivityProvider provider : this.activityProviders) { - activity = provider.fromXML(parser); - - if (activity != null) { - return activity; - } - } - - return null; - } - - /** - * Converts given activity into a XML format. - */ - public String toXML(IActivity activity) { - String xml; - for (IActivityProvider provider : this.activityProviders) { - xml = provider.toXML(activity); - - if (xml != null) { - return xml; - } - } - - return null; - } - - /** - * Singleton constructor - */ - private ActivityRegistry() { - loadDefaultActivityProviders(); - loadExtensionPoints(); - } - - private void loadDefaultActivityProviders() { - addProvider(EditorManager.getDefault()); - addProvider(new SharedResourcesManager()); - addProvider(new RoleManager()); - } - - private void loadExtensionPoints() { - // TODO load activity providers from the extension-point for Saros - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityListener.java deleted file mode 100644 index b5f19bb18fdcc4a691498d42e4b6f5fa00bca91f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -public interface IActivityListener { - public void activityCreated(IActivity activity); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityManager.java deleted file mode 100644 index fa2e352feb32a9d94390c306e24e9385ed1b4b2b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityManager.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import java.util.List; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -public interface IActivityManager { - public void addProvider(IActivityProvider provider); - - public void removeProvider(IActivityProvider provider); - - public List<IActivity> flush(); - - public void exec(IActivity activity); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityProvider.java deleted file mode 100644 index b76158b9c7e34d5fbf7ddd8b9874d239b456dba3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/IActivityProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import org.xmlpull.v1.XmlPullParser; - -import de.fu_berlin.inf.dpp.activities.IActivity; - -/** - * Every activity provider is responsible for one or more activities. It handles - * creating and executing the activity. - * - * @author rdjemili - */ -public interface IActivityProvider extends ISessionListener { - public void exec(IActivity activity); - - public void addActivityListener(IActivityListener listener); - - public void removeActivityListener(IActivityListener listener); - - /** - * Converts the XML doc to an activity. - */ - public IActivity fromXML(XmlPullParser parser); - - /** - * Converts the given activity to a XML format. - */ - public String toXML(IActivity activity); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionListener.java deleted file mode 100644 index 4c2aaa86ae0d205fc5b67672a23d7ca36a8e3c83..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionListener.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * A listener for SharedProject life-cycle related events. - * - * @author rdjemili - */ -public interface ISessionListener { - - /** - * Is fired when a new session started. - * - * @param session - * the shared project that has been created. Is never - * <code>null</code>. - * - */ - public void sessionStarted(ISharedProject session); - - /** - * Is fired when a session ended. Reasons for this can be that the session - * was closed or that the user left by himself. - * - * @param session - * the shared project that has just been left. Is never - * <code>null</code>. - */ - public void sessionEnded(ISharedProject session); - - /** - * Is fired when the local user is invited to a session. Use - * {@link SessionManager#acceptSessionInvitation(JID, String, org.eclipse.core.resources.IProject)} - * to accept the invitation. - * - * @param process - * the invitation process which represents the invitation. - */ - public void invitationReceived(IIncomingInvitationProcess invitation); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionManager.java deleted file mode 100644 index 96bdcc92813a355e2abc5e21332d2c0ec309f047..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISessionManager.java +++ /dev/null @@ -1,115 +0,0 @@ -package de.fu_berlin.inf.dpp.project; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; - -public interface ISessionManager { - - /** - * Starts a new shared project with the local user as only participant. - * - * @param project - * the local Eclipse project which should become shared. - * @throws XMPPException - * if this method is called with no established XMPP-connection. - */ - public abstract void startSession(IProject project) throws XMPPException; - - /** - * Every Session is identified by an int as identifier. - * - * @return the session id of this session - */ - public String getSessionID(); - - /** - * Joins an remotly already running shared project. - * - * @param project - * the local Eclipse project which should be used to replicate - * the remote shared project. - * @param host - * the host of the remotly shared project. - * @param driver - * the driver of the shared project. - * @param users - * the participants of the shared project. - * @return the shared project. - */ - public abstract ISharedProject joinSession(IProject project, JID host, - JID driver, List<JID> users); - - /** - * Leaves the currently active session. If the local user is the host, this - * will close the session for everybody. - * - * Has no effect if there is no currently shared project. - */ - public abstract void leaveSession(); - - /** - * @return the active SharedProject object or <code>null</code> if there is - * no active project. - */ - public abstract ISharedProject getSharedProject(); - - /** - * Add the given session listener. Is ignored if the listener is already - * listening. - * - * @param listener - * the listener that is to be added. - */ - public abstract void addSessionListener(ISessionListener listener); - - /** - * Removes the given session listener. Is ignored if the given listener - * wasn't listening. - * - * @param listener - * the listener that is to be removed. - */ - public abstract void removeSessionListener(ISessionListener listener); - - /** - * Is fired when an incoming invitation is received. - * - * @param from - * the sender of this invitation. - * @param description - * the informal description text that can be given with - * invitations. - * @param sessionID - * the id of the session - * @return the process that represents the invitation and which handles the - * further interaction with the invitation. - */ - public abstract IIncomingInvitationProcess invitationReceived(JID from, - String sessionID, String projectName, String description); - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public abstract void connectionStateChanged(XMPPConnection connection, - ConnectionState newState); - - public abstract void OnReconnect(int oldtimestamp); - - /** - * Get the transmitter of the session. - * - * @return the transmitter of the session - */ - public abstract ITransmitter getTransmitter(); - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProject.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProject.java deleted file mode 100644 index ac081399d503a3fef8f600b39af5efdd71cf6237..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProject.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.concurrent.management.ConcurrentDocumentManager; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Shared projects are the central concept of this plugin. They are associated - * with usual Eclipse projects and make them available for synchronous/real-time - * collaboration. - * - * @author rdjemili - */ -public interface ISharedProject { - - /** - * @return a list of all participants of the shared project. This list - * includes yourself. - */ - public List<User> getParticipants(); - - /** - * Sets the new driver. If given driver is already driver the call is - * ignored. - * - * @param driver - * the new driver. - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and only - * replicated to this client. - */ - public void setDriver(User driver, boolean replicated); - - /** - * Remove driver role for given User. - * - * @param driver - * one current driver. - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and only - * replicated to this client. - */ - public void removeDriver(User driver, boolean replicated); - - /** - * The driver is the person that is currently allowed to edit the resources. - * - * @return the driver. - */ - public User getDriver(); - - /** - * @return <code>true</code> if the local client is the current driver of - * this shared project. <code>false</code> otherwise. - */ - public boolean isDriver(); - - /** - * @return <code>true</code> if the given user is one of the current driver - * of this shared project. <code>false</code> otherwise. - */ - public boolean isDriver(User user); - - /** - * The host is the person that initiated this SharedProject and holds all - * original files. - * - * @return the host. - */ - public User getHost(); - - /** - * @return <code>true</code> if the local client is the host of this shared - * project. <code>false</code> otherwise. - */ - public boolean isHost(); - - /** - * Adds the user. - * - * @param user - * the user that is to be added. - */ - public void addUser(User user); - - public void addUser(User user, int index); - - /** - * Removes the user. - * - * @param user - * the user that is to be removed. - */ - public void removeUser(User user); - - /** - * Invites a user to the shared project. - * - * @param jid - * the JID of the user that is to be invited. - * @param description - * a description that will be shown to the invited user before he - * makes the decision to accept or decline the invitation. - * @param inviteUI - * user interface of the invitation for feedback calls. - * @return the outgoing invitation process. - */ - public IOutgoingInvitationProcess invite(JID jid, String description, - boolean inactive, IInvitationUI inviteUI); - - /** - * Adds the given shared project listener. This call is ignored if the - * listener is all a listener of this shared project. - * - * @param listener - * The listener that is to be added. - */ - public void addListener(ISharedProjectListener listener); - - /** - * Removes the given shared project listener. This call is ignored if the - * listener doesn't belongs to the current listeners of this shared project. - * - * @param listener - * the listener that is to be removed. - */ - public void removeListener(ISharedProjectListener listener); - - /** - * @return the Eclipse project associtated with this shared project. This - * never returns <code>null</code>. - */ - public IProject getProject(); - - /** - * @return the file list representation of the Eclipse project that is - * associated with this shared project. - * @throws CoreException - * if there are problems while reading file tree of the Eclipse - * project. - */ - public FileList getFileList() throws CoreException; - - // TODO remove direct uses of FileList - - /** - * @return the sequencer that is responsible for sending and receiving - * activities. - */ - public IActivitySequencer getSequencer(); - - /** - * @return the activity manager that is responsible for all activity - * providers. - */ - public IActivityManager getActivityManager(); - - /** - * Starts the invitation wizard to invite users. - * - * @param jid - * the JID of a user to invite without manual selection - */ - public void startInvitation(JID jid); - - /** - * Activates sending of activities. The reason that this isn't done - * automatically are unit tests. - */ - public void start(); - - /** - * Deactivates sending of activities. - */ - public void stop(); - - public User getParticipant(JID jid); - - /** - * Sets all resources of the project to a readonly state on the local file - * system. - * - * @param The - * readonly state to set the file to. - */ - public void setProjectReadonly(boolean readonly); - - /** - * true, if single driver is active, false otherwise. - * - * @return - */ - public boolean exclusiveDriver(); - - /** - * the concurrent document manager is responsible for all jupiter controlled - * documents - * - * @return the concurrent document manager - */ - public ConcurrentDocumentManager getConcurrentDocumentManager(); -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProjectListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProjectListener.java deleted file mode 100644 index 8b87c852d0e6f7159a9ec20426ee0a9f15fba430..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/ISharedProjectListener.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import de.fu_berlin.inf.dpp.net.JID; - -/** - * Listens for events that can happen inside a SharedProject session. For - * life-cycle events like starts and ends of shared projects use the - * {@link ISessionListener}. - * - * @author rdjemili - */ -public interface ISharedProjectListener { - // TODO add some easy way to check if given driver is the client (you) - - /** - * The driver role of one participant has changed. - * - * @param driver - * the new driver. - * - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and only - * replicated to this client. - */ - public void driverChanged(JID driver, boolean replicated); - - /** - * The driver role of one participant has changed. - * - * @param driver - * the new driver. - * - * @param replicated - * <code>false</code> if this event was created by this client. - * <code>true</code> if it was created by another client and only - * replicated to this client. - */ - // public void driverAdded(JID driver, boolean replicated); - /** - * Is fired when an user joins the shared project. - * - * @param user - * the user that has joined. - */ - public void userJoined(JID user); - - /** - * Is fired when an user leaves the shared project. - * - * @param user - * the user that has left. - */ - public void userLeft(JID user); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SessionManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SessionManager.java deleted file mode 100644 index 1bb1c585b857b579d387e88c11abbd0406470872..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SessionManager.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import java.util.Collection; -import java.util.List; -import java.util.Random; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IProject; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Presence; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.internal.IncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.XMPPChatTransmitter; -import de.fu_berlin.inf.dpp.project.internal.SharedProject; - -/** - * The SessionManager is responsible for initiating new Saros sessions and for - * reacting to invitiations. The user can be only part of one session at most. - * - * @author rdjemili - */ -public class SessionManager implements IConnectionListener, ISessionManager { - private static Logger log = Logger - .getLogger(SessionManager.class.getName()); - - private SharedProject sharedProject; - - // TODO use ListenerList instead - private final List<ISessionListener> listeners = new CopyOnWriteArrayList<ISessionListener>(); - - private ITransmitter transmitter; - - private String sessionID; - - public ITransmitter getTransmitter() { - return transmitter; - } - - public SessionManager() { - Saros.getDefault().addListener(this); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISessionManager#startSession(org.eclipse - * .core.resources.IProject) - */ - public void startSession(IProject project) throws XMPPException { - if (!Saros.getDefault().isConnected()) { - throw new XMPPException("No connection"); - } - - JID myJID = Saros.getDefault().getMyJID(); - this.sessionID = String.valueOf(new Random(System.currentTimeMillis()) - .nextInt()); - this.sharedProject = new SharedProject(this.transmitter, project, myJID); - this.sharedProject.start(); - - for (ISessionListener listener : this.listeners) { - listener.sessionStarted(this.sharedProject); - } - - this.sharedProject.startInvitation(null); - - SessionManager.log.info("Session started"); - } - - /** - * Every Session is identified by an int as identifier. - * - * @return the session id of this session - */ - public String getSessionID() { - return sessionID; - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISessionManager#joinSession(org.eclipse. - * core.resources.IProject, de.fu_berlin.inf.dpp.net.JID, - * de.fu_berlin.inf.dpp.net.JID, java.util.List) - */ - public ISharedProject joinSession(IProject project, JID host, JID driver, - List<JID> users) { - - this.sharedProject = new SharedProject(this.transmitter, project, Saros - .getDefault().getMyJID(), host, driver, users); - this.sharedProject.start(); - - for (ISessionListener listener : this.listeners) { - listener.sessionStarted(this.sharedProject); - } - - SessionManager.log.info("Session joined"); - - return this.sharedProject; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionManager#leaveSession() - */ - public void leaveSession() { - if (this.sharedProject == null) { - return; - } - - this.transmitter.sendLeaveMessage(this.sharedProject); - this.sharedProject.setProjectReadonly(false); // set ressources - // writeable again - - this.sharedProject.stop(); - - ISharedProject closedProject = this.sharedProject; - this.sharedProject = null; - - for (ISessionListener listener : this.listeners) { - listener.sessionEnded(closedProject); - } - - SessionManager.log.info("Session left"); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionManager#getSharedProject() - */ - public ISharedProject getSharedProject() { - return this.sharedProject; - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISessionManager#addSessionListener(de.fu_berlin - * .inf.dpp.project.ISessionListener) - */ - public void addSessionListener(ISessionListener listener) { - if (!this.listeners.contains(listener)) { - this.listeners.add(listener); - } - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISessionManager#removeSessionListener(de - * .fu_berlin.inf.dpp.project.ISessionListener) - */ - public void removeSessionListener(ISessionListener listener) { - this.listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISessionManager#invitationReceived(de.fu_berlin - * .inf.dpp.net.JID, java.lang.String, java.lang.String) - */ - public IIncomingInvitationProcess invitationReceived(JID from, - String sessionID, String projectName, String description) { - - this.sessionID = sessionID; - - IIncomingInvitationProcess process = new IncomingInvitationProcess( - this.transmitter, from, projectName, description); - - for (ISessionListener listener : this.listeners) { - listener.invitationReceived(process); - } - - SessionManager.log.info("Received invitation"); - - return process; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISessionManager#connectionStateChanged(org - * .jivesoftware.smack.XMPPConnection, - * de.fu_berlin.inf.dpp.Saros.ConnectionState) - */ - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - - if (newState == Saros.ConnectionState.CONNECTED) { - if (this.transmitter == null) { - this.transmitter = new XMPPChatTransmitter(connection); - attachRosterListener(); - } else { - // TODO: Does this ever happen? - this.transmitter.setXMPPConnection(connection); - } - - } else if (newState == Saros.ConnectionState.NOT_CONNECTED) { - if (this.sharedProject != null) { - leaveSession(); - } - - this.transmitter = null; - } - } - - private void attachRosterListener() { - Roster roster = Saros.getDefault().getRoster(); - roster.addRosterListener(new RosterListener() { - public void entriesAdded(Collection<String> addresses) { - } - - public void entriesUpdated(Collection<String> addresses) { - } - - public void entriesDeleted(Collection<String> addresses) { - } - - public void presenceChanged(String XMPPAddress) { - - if (SessionManager.this.sharedProject == null) { - return; - } - - Roster roster = Saros.getDefault().getRoster(); - Presence presence = roster.getPresence(XMPPAddress); - - JID jid = new JID(XMPPAddress); - User user = SessionManager.this.sharedProject - .getParticipant(jid); - if (user != null) { - if (presence == null) { - user.setPresence(User.UserConnectionState.OFFLINE); - - } else { - user.setPresence(User.UserConnectionState.ONLINE); - } - } - } - - public void presenceChanged(Presence presence) { - // TODO: new Method for Smack 3 - presenceChanged(presence.getFrom()); - - } - - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionManager#OnReconnect(int) - */ - public void OnReconnect(int oldtimestamp) { - - if (this.sharedProject == null) { - return; - } - - this.transmitter.sendRemainingFiles(); - this.transmitter.sendRemainingMessages(); - - // ask for next expected timestamp activities (in case I missed - // something while being not available) - this.transmitter.sendRequestForActivity(this.sharedProject, - oldtimestamp, true); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SharedResourcesManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SharedResourcesManager.java deleted file mode 100644 index c4fe330c2f7848c1b80da1e9e3dde88867b0c471..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/SharedResourcesManager.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project; - -import java.io.IOException; -import java.io.InputStream; -import java.util.LinkedList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.activities.FileActivity; -import de.fu_berlin.inf.dpp.activities.FolderActivity; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; - -/** - * This manager is responsible for handling all resource changes that aren't - * handled by the EditorManager, that is for changes that aren't done by - * entering text in an text editor. It creates and executes file activities and - * folder activities. - * - * @author rdjemili - */ -public class SharedResourcesManager implements IResourceChangeListener, - IActivityProvider { - - private static Logger log = Logger.getLogger(SharedResourcesManager.class - .getName()); - - /** - * Should be set to <code>true</code> while executing resource changes to - * avoid an infinite resource event loop. - */ - private boolean replicationInProgess = false; - - private ISharedProject sharedProject; - - private final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - - private final List<IActivityListener> listeners = new LinkedList<IActivityListener>(); - - /** - * Listens for resource changes in shared project and fires activities. - */ - private class ResourceDeltaVisitor implements IResourceDeltaVisitor { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceDeltaVisitor - */ - public boolean visit(IResourceDelta delta) { - assert SharedResourcesManager.this.sharedProject != null; - - if (SharedResourcesManager.this.replicationInProgess - || !SharedResourcesManager.this.sharedProject.isDriver()) { - return false; - } - - IResource resource = delta.getResource(); - if (resource.getProject() == null) { - return true; - } - - if (resource.getProject() != SharedResourcesManager.this.sharedProject - .getProject()) { - return false; - } - - if (resource.isDerived()) { - return false; - } - - IPath path = delta.getProjectRelativePath(); - int kind = delta.getKind(); - - IActivity activity = null; - if (resource instanceof IFile) { - activity = handleFileDelta(path, kind); - - } else if (resource instanceof IFolder) { - activity = handleFolderDelta(path, kind); - } - - fireActivity(activity); - closeRemovedEditors(); - - return delta.getKind() > 0; - } - - private IActivity handleFolderDelta(IPath path, int kind) { - switch (kind) { - case IResourceDelta.ADDED: - return new FolderActivity(FolderActivity.Type.Created, path); - - case IResourceDelta.REMOVED: - return new FolderActivity(FolderActivity.Type.Removed, path); - - default: - return null; - } - } - - private IActivity handleFileDelta(IPath path, int kind) { - switch (kind) { - case IResourceDelta.CHANGED: - case IResourceDelta.ADDED: - // ignore opened files because otherwise we might send CHANGED - // events for files that are also handled by the editor manager. - if (EditorManager.getDefault().isOpened(path)) { - return null; - } - - // fall through - - return new FileActivity(FileActivity.Type.Created, path); - - case IResourceDelta.REMOVED: - return new FileActivity(FileActivity.Type.Removed, path); - - default: - return null; - } - } - - private void fireActivity(IActivity activity) { - if (activity == null) { - return; - } - - for (IActivityListener listener : SharedResourcesManager.this.listeners) { - listener.activityCreated(activity); - } - } - } - - public SharedResourcesManager() { - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - this.sharedProject = session; - this.sharedProject.getActivityManager().addProvider(this); - ResourcesPlugin.getWorkspace().addResourceChangeListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); - this.sharedProject.getActivityManager().removeProvider(this); - this.sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void addActivityListener(IActivityListener listener) { - if (!this.listeners.contains(listener)) { - this.listeners.add(listener); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void removeActivityListener(IActivityListener listener) { - this.listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceChangeListener - */ - public void resourceChanged(IResourceChangeEvent event) { - try { - event.getDelta().accept(this.visitor); - } catch (CoreException e) { - SharedResourcesManager.log.log(Level.SEVERE, - "Couldn't handle resource change.", e); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void exec(IActivity activity) { - try { - this.replicationInProgess = true; - - if (activity instanceof FileActivity) { - exec((FileActivity) activity); - } else if (activity instanceof FolderActivity) { - exec((FolderActivity) activity); - } - - } catch (CoreException e) { - SharedResourcesManager.log.log(Level.SEVERE, - "Failed to execute resource activity.", e); - - } finally { - this.replicationInProgess = false; - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public IActivity fromXML(XmlPullParser parser) { - try { - if (parser.getName().equals("file")) { - return parseFile(parser); - - } else if (parser.getName().equals("folder")) { - return parseFolder(parser); - } - - } catch (IOException e) { - SharedResourcesManager.log.severe("Couldn't parse message"); - } catch (XmlPullParserException e) { - SharedResourcesManager.log.severe("Couldn't parse message"); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public String toXML(IActivity activity) { - if (activity instanceof FileActivity) { - FileActivity fileActivity = (FileActivity) activity; - return "<file " + "path=\"" + fileActivity.getPath() + "\" " - + "type=\"" + fileActivity.getType() + "\" />"; - - } else if (activity instanceof FolderActivity) { - FolderActivity folderActivity = (FolderActivity) activity; - return "<folder " + "path=\"" + folderActivity.getPath() + "\" " - + "type=\"" + folderActivity.getType() + "\" />"; - } - - return null; - } - - private void exec(FileActivity activity) throws CoreException { - IProject project = this.sharedProject.getProject(); - IFile file = project.getFile(activity.getPath()); - - if (activity.getType() == FileActivity.Type.Created) { - InputStream in = activity.getContents(); - if (file.exists()) { - file.setContents(in, IResource.FORCE, null); - } else { - file.create(in, true, new NullProgressMonitor()); - } - - } else if (activity.getType() == FileActivity.Type.Removed) { - file.delete(false, new NullProgressMonitor()); - } - - closeRemovedEditors(); - } - - private void exec(FolderActivity activity) throws CoreException { - IProject project = this.sharedProject.getProject(); - IFolder folder = project.getFolder(activity.getPath()); - - if (activity.getType() == FolderActivity.Type.Created) { - folder.create(true, true, new NullProgressMonitor()); - } else if (activity.getType() == FolderActivity.Type.Removed) { - folder.delete(true, new NullProgressMonitor()); - } - } - - private FileActivity parseFile(XmlPullParser parser) - throws XmlPullParserException, IOException { - - IPath path = new Path(parser.getAttributeValue(null, "path")); - return new FileActivity(FileActivity.Type.valueOf(parser - .getAttributeValue(null, "type")), path); - } - - private FolderActivity parseFolder(XmlPullParser parser) { - Path path = new Path(parser.getAttributeValue(null, "path")); - - return new FolderActivity(FolderActivity.Type.valueOf(parser - .getAttributeValue(null, "type")), path); - } - - private void closeRemovedEditors() { - // TODO - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/RoleManager.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/RoleManager.java deleted file mode 100644 index f3955104162cc089e67cb03ef9768ff827e1fda8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/RoleManager.java +++ /dev/null @@ -1,155 +0,0 @@ -package de.fu_berlin.inf.dpp.project.internal; - -import java.util.LinkedList; -import java.util.List; - -import org.xmlpull.v1.XmlPullParser; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.activities.IActivity; -import de.fu_berlin.inf.dpp.activities.RoleActivity; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.IActivityListener; -import de.fu_berlin.inf.dpp.project.IActivityProvider; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; - -/** - * This manager is responsible for handling driver changes. - * - * @author rdjemili - */ -public class RoleManager implements IActivityProvider, ISharedProjectListener { - private final List<IActivityListener> activityListeners = new LinkedList<IActivityListener>(); - - private ISharedProject sharedProject; - - public RoleManager() { - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - this.sharedProject = session; - this.sharedProject.addListener(this); - this.sharedProject.getActivityManager().addProvider(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - this.sharedProject.removeListener(this); - this.sharedProject.getActivityManager().removeProvider(this); - this.sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void addActivityListener(IActivityListener listener) { - this.activityListeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void removeActivityListener(IActivityListener listener) { - this.activityListeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.IActivityProvider - */ - public void exec(IActivity activity) { - if (activity instanceof RoleActivity) { - RoleActivity roleActivity = (RoleActivity) activity; - User user = this.sharedProject.getParticipant(roleActivity - .getDriver()); - this.sharedProject.setDriver(user, true); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - if (!replicated) { - IActivity activity = new RoleActivity(driver); - for (IActivityListener listener : this.activityListeners) { - listener.activityCreated(activity); - } - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public IActivity fromXML(XmlPullParser parser) { - if (parser.getName().equals("driver")) { - JID user = new JID(parser.getAttributeValue(null, "id")); - return new RoleActivity(user); - } - - return null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.IActivityProvider - */ - public String toXML(IActivity activity) { - if (activity instanceof RoleActivity) { - RoleActivity roleActivity = (RoleActivity) activity; - return "<driver id=\"" + roleActivity.getDriver() + "\" />"; - } - - return null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedModelProvider.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedModelProvider.java deleted file mode 100644 index 84b2d4098aefd081cc5c3ee1b60c98a491058e34..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedModelProvider.java +++ /dev/null @@ -1,143 +0,0 @@ -package de.fu_berlin.inf.dpp.project.internal; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.mapping.ModelProvider; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -/** - * This model provider is responsible for keeping an session observer from - * modifying the file tree of a shared project on his own. - * - * @author rdjemili - */ -public class SharedModelProvider extends ModelProvider implements - ISessionListener { - - private static final String ERROR_TEXT = "Only the driver should edit the resources of this shared project."; - private static final String EXCLUSIVE_ERROR_TEXT = "The project host should be the exclusive driver to edit resources of this shared project."; - - private static final IStatus ERROR_STATUS = new Status(IStatus.ERROR, - "de.fu_berlin.inf.dpp", 2, SharedModelProvider.ERROR_TEXT, null); - - private static final IStatus EXCLUSIVE_ERROR_STATUS = new Status( - IStatus.ERROR, "de.fu_berlin.inf.dpp", 2, - SharedModelProvider.EXCLUSIVE_ERROR_TEXT, null); - - /** the currently running shared project */ - private ISharedProject sharedProject; - - public SharedModelProvider() { - - } - - /** - * Validates the resource delta. - */ - private class ResourceDeltaVisitor implements IResourceDeltaVisitor { - private boolean isAllowed = true; - private boolean isExclusive = true; - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.resources.IResourceDeltaVisitor - */ - public boolean visit(IResourceDelta delta) throws CoreException { - if ((SharedModelProvider.this.sharedProject == null) - || SharedModelProvider.this.sharedProject.isDriver()) { - /* check driver status */ - if (!(SharedModelProvider.this.sharedProject.isHost() && SharedModelProvider.this.sharedProject - .exclusiveDriver())) { - this.isExclusive = false; - } - return false; - } - - IResource resource = delta.getResource(); - if (resource.getProject() == null) { - return true; - } - - if (resource.getProject() != SharedModelProvider.this.sharedProject - .getProject()) { - return false; - } - - if ((resource instanceof IFile) || (resource instanceof IFolder)) { - this.isAllowed = false; - return false; - } - - return delta.getKind() > 0; - } - } - - @Override - protected void initialize() { - ISessionManager sm = Saros.getDefault().getSessionManager(); - - sm.addSessionListener(this); - this.sharedProject = sm.getSharedProject(); - } - - @Override - public IStatus validateChange(IResourceDelta delta, IProgressMonitor pm) { - ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); - - try { - delta.accept(visitor); - } catch (CoreException e) { - e.printStackTrace(); - } - - IStatus result = Status.OK_STATUS; - if (!visitor.isAllowed) { - result = SharedModelProvider.ERROR_STATUS; - } - if (!visitor.isExclusive) { - result = SharedModelProvider.EXCLUSIVE_ERROR_STATUS; - } - return result; - // return visitor.isAllowed ? Status.OK_STATUS : ERROR_STATUS; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - this.sharedProject = session; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - this.sharedProject = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedProject.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedProject.java deleted file mode 100644 index a6dd928b5bb6b8b70d70d6e29db203aa597dd625..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/project/internal/SharedProject.java +++ /dev/null @@ -1,764 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.project.internal; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; -import java.util.concurrent.CopyOnWriteArrayList; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourceAttributes; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.User.UserRole; -import de.fu_berlin.inf.dpp.concurrent.ConcurrentManager; -import de.fu_berlin.inf.dpp.concurrent.IDriverDocumentManager; -import de.fu_berlin.inf.dpp.concurrent.jupiter.Request; -import de.fu_berlin.inf.dpp.concurrent.management.ConcurrentDocumentManager; -import de.fu_berlin.inf.dpp.concurrent.management.DriverDocumentManager; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.invitation.internal.OutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IActivitySequencer; -import de.fu_berlin.inf.dpp.net.ITransmitter; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.TimedActivity; -import de.fu_berlin.inf.dpp.net.internal.ActivitySequencer; -import de.fu_berlin.inf.dpp.project.IActivityManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.InvitationDialog; - -public class SharedProject implements ISharedProject { - private static Logger log = Logger.getLogger(SharedProject.class.getName()); - - private static final int REQUEST_ACTIVITY_ON_AGE = 5; - protected static final int MILLIS_UPDATE = 1000; - - protected JID myID; - - protected CopyOnWriteArrayList<User> participants = new CopyOnWriteArrayList<User>(); - - private final IProject project; - - private final List<ISharedProjectListener> listeners = new ArrayList<ISharedProjectListener>(); - - private User driver; - - private User host; - - private final ITransmitter transmitter; - - private IDriverDocumentManager driverManager; - - private final ActivitySequencer activitySequencer = new ActivitySequencer(); - - private static final int MAX_USERCOLORS = 5; - private final int colorlist[] = new int[SharedProject.MAX_USERCOLORS + 1]; - - // private ConcurrentManager concurrentManager; - - public SharedProject(ITransmitter transmitter, IProject project, JID myID) { // host - assert (transmitter != null && myID != null); - - this.transmitter = transmitter; - - // concurrentManager = new ConcurrentDocumentManager(); - - this.myID = myID; - User u = new User(myID); - u.setUserRole(UserRole.DRIVER); - this.driver = this.host = u; - - this.participants.add(this.host); - - /* add host to driver list. */ - this.activitySequencer.initConcurrentManager( - ConcurrentManager.Side.HOST_SIDE, this.host, myID, this); - - /* init driver manager */ - this.driverManager = DriverDocumentManager.getInstance(); - addListener(this.driverManager); - this.driverManager.addDriver(this.host.getJid()); - - // activitySequencer.getConcurrentManager().addDriver(host.getJid()); - - this.project = project; - setProjectReadonly(false); - } - - public SharedProject(ITransmitter transmitter, IProject project, JID myID, // guest - JID host, JID driver, List<JID> allParticipants) { - - this.transmitter = transmitter; - - this.myID = myID; - - this.host = new User(host); - this.driver = new User(driver); - - this.activitySequencer.initConcurrentManager( - ConcurrentManager.Side.CLIENT_SIDE, this.host, myID, this); - - for (JID jid : allParticipants) { // HACK - User user = new User(jid); - this.participants.add(user); - assignColorId(user); - } - - this.project = project; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public List<User> getParticipants() { - return this.participants; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public IActivitySequencer getSequencer() { - return this.activitySequencer; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public IActivityManager getActivityManager() { - return this.activitySequencer; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public void setDriver(User driver, boolean replicated) { - assert driver != null; - - /* if user has current role observer */ - if (getParticipant(driver.getJid()).getUserRole() == UserRole.OBSERVER) { - - /* set new driver status in participant list of sharedProject. */ - getParticipant(driver.getJid()).setUserRole(UserRole.DRIVER); - - /* - * TODO: 1. actual the host never lost the driver status and added - * new driver to driverlist - */ - - // host - if ((this.activitySequencer.getConcurrentManager() != null) - && this.activitySequencer.getConcurrentManager() - .isHostSide()) { - // if replicated=false check for privileges - if (driver.equals(this.driver)) { - return; - } - - /* add new driver to list. */ - // TODO: durch hinzufügen von isharedprojectlistener zum - // concurrentmanager - // könnte dieser punkt ausgelagert werden. - // activitySequencer.getConcurrentManager().addDriver(driver.getJid()); - } - // client - else { - // if replicated=false check for privileges - if (driver.equals(this.driver)) { - return; - } - - /* - * set driver in client to observer driver actions or to set the - * local driver status. - */ - - /* currently, no other driver than host can be followed. */ - // this.driver = driver; - } - - // // TODO if replicated=false check for privileges - // if (driver.equals(this.driver)) - // return; - // - // this.driver = driver; - - /* set local file settings. */ - if (driver.getJid().equals(this.myID)) { - setProjectReadonly(!isDriver()); - } - - } else { - /* changed state form observer to driver */ - if (getParticipant(driver.getJid()).getUserRole() == UserRole.DRIVER) { - - /* set the local driver state to observer */ - if (driver.getJid().equals(this.myID) - && isDriver(new User(this.myID))) { - setProjectReadonly(true); - this.driver = this.host; - } - - /* set observer state. */ - getParticipant(driver.getJid()).setUserRole(UserRole.OBSERVER); - - } - } - - /* inform observer. */ - JID jid = driver.getJid(); - for (ISharedProjectListener listener : this.listeners) { - listener.driverChanged(jid, replicated); - } - } - - public void removeDriver(User driver, boolean replicated) { - /* set new observer status in participant list of sharedProject. */ - getParticipant(driver.getJid()).setUserRole(UserRole.OBSERVER); - - this.driver = this.host; - /** - * communicate driver role change to listener. - */ - JID jid = driver.getJid(); - for (ISharedProjectListener listener : this.listeners) { - listener.driverChanged(jid, replicated); - } - - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public User getDriver() { - return this.driver; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public boolean isDriver() { - // TODO: change driver status request to userrole request of - // participient list. - - // HOST - /* TODO: change to driver document manager. */ - // if (activitySequencer.getConcurrentManager() != null - // && activitySequencer.getConcurrentManager().isHostSide()) { - // return - // activitySequencer.getConcurrentManager().isDriver(driver.getJid()); - // } - // CLIENT - return (getParticipant(this.myID).getUserRole() == UserRole.DRIVER); - // return driver.getJid().equals(myID); - - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.project.ISharedProject#isDriver(de.fu_berlin.inf - * .dpp.User) - */ - public boolean isDriver(User user) { - // HOST - if (this.driverManager != null) { - return this.driverManager.isDriver(user.getJid()); - } - // CLIENT - if (getParticipant(user.getJid()).getUserRole() == UserRole.DRIVER) { - return true; - } - return false; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ISharedProject - */ - public User getHost() { - return this.host; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public boolean isHost() { - return this.host.getJid().equals(this.myID); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject#exclusiveDriver() - */ - public boolean exclusiveDriver() { - return this.driverManager.exclusiveDriver(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void addUser(User user) { - addUser(user, -1); - } - - public void addUser(User user, int index) { - if (this.participants.contains(user)) { - if ((index >= 0) && (this.participants.indexOf(user) != index)) { - this.participants.remove(user); - this.participants.add(index, user); - } - /* update exists user. */ - this.participants.remove(user); - this.participants.add(user); - for (ISharedProjectListener listener : this.listeners) { - listener.userJoined(user.getJid()); - } - return; - } - - this.participants.add(user); - - // find free color and assign it to user - assignColorId(user); - - for (ISharedProjectListener listener : this.listeners) { - listener.userJoined(user.getJid()); - } - - SharedProject.log.info("User " + user.getJid() + " joined session"); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void removeUser(User user) { - this.participants.remove(user); - - // free colorid - this.colorlist[user.getColorID()] = 0; - - if (this.driver.equals(user)) { - setDriver(this.participants.get(0), true); - } - - for (ISharedProjectListener listener : this.listeners) { - listener.userLeft(user.getJid()); - } - - SharedProject.log.info("User " + user.getJid() + " left session"); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public IOutgoingInvitationProcess invite(JID jid, String description, - boolean inactive, IInvitationUI inviteUI) { - return new OutgoingInvitationProcess(this.transmitter, jid, this, - description, inactive, inviteUI); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void addListener(ISharedProjectListener listener) { - if (!this.listeners.contains(listener)) { - this.listeners.add(listener); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void removeListener(ISharedProjectListener listener) { - this.listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public IProject getProject() { - return this.project; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public FileList getFileList() throws CoreException { - return new FileList(this.project); - } - - public Timer flushTimer = new Timer(true); - public Thread requestTransmitter = null; - private static int queuedsince = 0; - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void start() { - - this.flushTimer.schedule(new TimerTask() { - @Override - public void run() { - if (SharedProject.this.participants.size() <= 1) { - SharedProject.this.activitySequencer.flush(); - - } else { - List<TimedActivity> activities = SharedProject.this.activitySequencer - .flushTimed(); - - if (activities != null) { - SharedProject.this.transmitter.sendActivities( - SharedProject.this, activities); - } - } - - // missing activities? (cant execute all) - if (SharedProject.this.activitySequencer.getQueuedActivities() > 0) { - SharedProject.queuedsince++; - - // if i am missing activities for REQUEST_ACTIVITY_ON_AGE - // seconds, ask all (because I dont know the origin) - // to send it to me again. - if (SharedProject.queuedsince >= SharedProject.REQUEST_ACTIVITY_ON_AGE) { - - SharedProject.this.transmitter.sendRequestForActivity( - SharedProject.this, - SharedProject.this.activitySequencer - .getTimestamp(), false); - - SharedProject.queuedsince = 0; - - // TODO: forever? - } - - } else { - SharedProject.queuedsince = 0; - } - } - }, 0, SharedProject.MILLIS_UPDATE); - - /* 2. start thread for sending jupiter requests. */ - this.requestTransmitter = new Thread(new Runnable() { - - public void run() { - while (true) { - sendRequest(); - } - - } - - }); - this.requestTransmitter.start(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public void stop() { - this.flushTimer.cancel(); - this.requestTransmitter = null; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProject - */ - public User getParticipant(JID jid) { - if (participants != null) { - for (User participant : this.participants) { - if (participant.getJid().equals(jid)) { - return participant; - } - } - } - - return null; - } - - boolean assignColorId(User user) { - - // already has a color assigned - if (user.getColorID() == -1) { - return true; - } - - for (int i = 0; i < SharedProject.MAX_USERCOLORS; i++) { - if (this.colorlist[i] == 0) { - user.setColorID(i); - this.colorlist[user.getColorID()] = 1; - return true; - } - } - - return false; - } - - public void startInvitation(final JID jid) { - - Shell shell = Display.getDefault().getActiveShell(); - - if (searchUnsavedChangesInProject(false)) { - if (MessageDialog - .openQuestion( - shell, - "Unsaved file modifications", - "Before inviting users and therefore synchronizing files, " - + "this project needs to be saved to disk. " - + "Do you want to save all unsaved files of this project now?")) { - - // save - // PlatformUI.getWorkbench().saveAllEditors(false); // saves all - // editors - searchUnsavedChangesInProject(true); - - } else { - return; - } - } - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault().getActiveShell(); - Window iw = new InvitationDialog(shell, jid); - iw.open(); - } catch (Exception e) { - Saros - .getDefault() - .getLog() - .log( - new Status( - IStatus.ERROR, - Saros.SAROS, - IStatus.ERROR, - "Error while running invitation helper", - e)); - } - } - }); - - } - - boolean searchUnsavedChangesInProject(boolean save) { - FileList flist = null; - - try { - flist = new FileList(getProject()); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } - - try { - IWorkbenchWindow[] wbWindows = PlatformUI.getWorkbench() - .getWorkbenchWindows(); - for (IWorkbenchWindow window : wbWindows) { - IWorkbenchPage activePage = window.getActivePage(); - IEditorReference[] editorRefs = activePage - .getEditorReferences(); - for (IEditorReference editorRef : editorRefs) { - if (editorRef.isDirty() - && (editorRef.getEditorInput() instanceof IFileEditorInput)) { - - IPath fp = ((IFileEditorInput) editorRef - .getEditorInput()).getFile() - .getProjectRelativePath(); - - // is that dirty file in my project? - if (flist.getPaths().contains(fp)) { - if (save) { - editorRef.getEditor(false).doSave(null); - } else { - return true; - } - } - } - } - } - } catch (CoreException e1) { - System.out.println(e1.getMessage()); - } - - return false; - } - - public void setProjectReadonly(final boolean readonly) { - - /* run project read only settings in progress monitor thread. */ - Display.getDefault().syncExec(new Runnable() { - public void run() { - ProgressMonitorDialog dialog = new ProgressMonitorDialog( - Display.getDefault().getActiveShell()); - try { - dialog.run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - - FileList flist; - try { - flist = new FileList(SharedProject.this.project); - - monitor.beginTask("Project settings ... ", - flist.getPaths().size()); - - ResourceAttributes attributes = new ResourceAttributes(); - attributes.setReadOnly(readonly); - attributes.setArchive(readonly); - - for (int i = 0; i < flist.getPaths().size(); i++) { - IPath path = flist.getPaths().get(i); - path = path.makeAbsolute(); - IFile file = getProject().getFile(path); - if ((file != null) && file.exists()) { - file.setResourceAttributes(attributes); - } - - monitor.worked(1); - } - } catch (CoreException e) { - // log.log(Level.WARNING, "",e); - SharedProject.log.warn("", e); - monitor.done(); - } - - monitor.done(); - - } - - }); - } catch (InvocationTargetException e) { - // log.log(Level.WARNING, "",e); - SharedProject.log.warn("", e); - e.printStackTrace(); - } catch (InterruptedException e) { - // log.log(Level.WARNING, "",e); - SharedProject.log.warn("", e); - e.printStackTrace(); - } - - } - }); - - } - - public void sendRequest() { - try { - // Request request = outgoing.getNextOutgoingRequest(); - Request request = this.activitySequencer.getNextOutgoingRequest(); - - if (isHost()) { - - /* - * if jupiter server request to has to execute locally on host - * side. - */ - if (request.getJID().equals(this.host.getJid())) { - SharedProject.log - .debug("Send host request back for local execution: " - + request); - this.activitySequencer.receiveRequest(request); - } else { - /* send operation to client. */ - SharedProject.log.debug("Send request to client: " - + request + request.getJID()); - this.transmitter.sendJupiterRequest(this, request, request - .getJID()); - } - } else { - SharedProject.log.debug("Send request to host : " + request); - this.transmitter.sendJupiterRequest(this, request, this.host - .getJid()); - } - // connection.sendOperation(new - // NetworkRequest(this.jid,request.getJID(),request), 0); - } catch (InterruptedException e) { - - e.printStackTrace(); - } - } - - public ConcurrentDocumentManager getConcurrentDocumentManager() { - return (ConcurrentDocumentManager) this.activitySequencer - .getConcurrentManager(); - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/AdvancedPreferencePage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/AdvancedPreferencePage.java deleted file mode 100644 index 20ba91675388253302a7dbb543f19c3ebd62e307..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/AdvancedPreferencePage.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -/** - * Contains the advanced preferences - consisting of preferences that are geared - * towards developers and power users and that are not necessary for normal use. - * - * @author rdjemili - */ -public class AdvancedPreferencePage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - - public AdvancedPreferencePage() { - super(FieldEditorPreferencePage.GRID); - setPreferenceStore(Saros.getDefault().getPreferenceStore()); - setDescription("Advanced settings geared toward developers and power users."); - } - - @Override - protected void createFieldEditors() { - addField(new StringFieldEditor(PreferenceConstants.SKYPE_USERNAME, - "Skype name:", getFieldEditorParent())); - - addField(new IntegerFieldEditor(PreferenceConstants.FILE_TRANSFER_PORT, - "File transfer port (needs reconnect):", getFieldEditorParent())); - - addField(new BooleanFieldEditor(PreferenceConstants.DEBUG, - "Show Jabber debug window (needs restart).", - getFieldEditorParent())); - - addField(new BooleanFieldEditor( - PreferenceConstants.FORCE_FILETRANSFER_BY_CHAT, - "Avoid direct file transfer connection", getFieldEditorParent())); - - addField(new IntegerFieldEditor( - PreferenceConstants.CHATFILETRANSFER_CHUNKSIZE, - "Chunk size for chat data transfer", getFieldEditorParent())); - - // addField(new StringFieldEditor(PreferenceConstants.STUN, - // "STUN Server:", getFieldEditorParent())); - // - // addField(new IntegerFieldEditor(PreferenceConstants.STUN_PORT, - // "STUN server port", getFieldEditorParent())); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPreferencePage - */ - public void init(IWorkbench workbench) { - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ChatView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ChatView.java deleted file mode 100644 index df1b56a3a5d60dc8a755b431ea4ff4b1088e011b..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ChatView.java +++ /dev/null @@ -1,226 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import org.apache.log4j.Logger; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.ITextListener; -import org.eclipse.jface.text.TextEvent; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; -import org.eclipse.ui.part.ViewPart; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.MessagingManager; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.MessagingManager.IChatListener; -import de.fu_berlin.inf.dpp.MessagingManager.MultiChatSession; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -public class ChatView extends ViewPart implements ISessionListener, - IConnectionListener, IChatListener { - - private static Logger log = Logger.getLogger(ChatView.class.getName()); - - private Text inputText; - - private MultiChatSession session; - - private SourceViewer viewer; - - private boolean joined = false; - - private Action connectAction; - - private static final int[] WEIGHTS = { 75, 25 }; - - @Override - public void createPartControl(Composite parent) { - Composite rootComposite = new Composite(parent, SWT.NONE); - rootComposite.setLayout(new FillLayout()); - - SashForm sash = new SashForm(rootComposite, SWT.VERTICAL); - - this.viewer = new SourceViewer(sash, null, null, true, SWT.BORDER - | SWT.WRAP | SWT.V_SCROLL | SWT.MULTI | SWT.READ_ONLY); - this.viewer.configure(new TextSourceViewerConfiguration(EditorsUI - .getPreferenceStore())); - this.viewer.setDocument(new Document()); - this.viewer.getTextWidget(); - - this.inputText = new Text(sash, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); - this.inputText - .setText("To Join the chat please use the connect button."); - this.inputText.setEditable(false); - - sash.setWeights(ChatView.WEIGHTS); - - this.inputText.addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - switch (e.keyCode) { - case SWT.CR: - case SWT.KEYPAD_CR: - if (e.stateMask == 0) { - String text = ChatView.this.inputText.getText(); - ChatView.this.inputText.setText(""); //$NON-NLS-1$ - - if (!text.equals("")) { //$NON-NLS-1$ - Saros.getDefault().getMessagingManager() - .getSession().sendMessage(text); - } - // append("ID-TODO", text); - } - break; - } - } - }); - - this.viewer.addTextListener(new ITextListener() { - - public void textChanged(TextEvent event) { - - // scrolls down, so the last line is visible - int lines = ChatView.this.viewer.getDocument() - .getNumberOfLines(); - ChatView.this.viewer.setTopIndex(lines); - } - }); - - this.connectAction = new Action("Connect/DisConnect") { - - public void run() { - MessagingManager mm = Saros.getDefault().getMessagingManager(); - Saros.getDefault().getConnection().getUser(); - if (ChatView.this.joined) { - try { - ChatView.this.session - .sendMessage("is leaving the chat.."); - ChatView.this.inputText - .setText("You have left the chat. To renter the chat please use the connect button."); - mm.disconnectMultiUserChat(); - ChatView.this.session = null; - ChatView.this.inputText.setEditable(false); - - } catch (XMPPException e) { - ChatView.this.viewer.getDocument().set( - "Error: Couldn't disconnect"); - } - ChatView.this.joined = false; - ChatView.this.connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/disconnect.png")); - } else { - try { - mm.connectMultiUserChat(); - ChatView.this.joined = true; - ChatView.this.viewer.setDocument(new Document()); - ChatView.this.inputText.setEditable(true); - ChatView.this.inputText.setText(""); - ChatView.this.connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/connect.png")); - ChatView.this.session = Saros.getDefault() - .getMessagingManager().getSession(); - ChatView.this.session - .sendMessage("have joined the chat"); - } catch (XMPPException e) { - ChatView.this.viewer.getDocument().set( - "Error: Couldn't connect"); - } - } - } - }; - - if (this.joined) { - this.connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/connect.png")); - } else { - this.connectAction.setImageDescriptor(SarosUI - .getImageDescriptor("/icons/disconnect.png")); - } - - if (Saros.getDefault().isConnected()) { - this.connectAction.setEnabled(true); - } else { - this.connectAction.setEnabled(false); - } - IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); - mgr.add(this.connectAction); - - // register ChatView as chat listener - MessagingManager mm = Saros.getDefault().getMessagingManager(); - mm.addChatListener(this); - - // register as connection listener - Saros.getDefault().addListener(this); - } - - public void setFocus() { - // TODO Auto-generated method stub - - } - - public void invitationReceived(IIncomingInvitationProcess invitation) { - // TODO Auto-generated method stub - - } - - public void sessionEnded(ISharedProject session) { - // TODO Auto-generated method stub - - } - - public void sessionStarted(ISharedProject session) { - // TODO Auto-generated method stub - - } - - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - if (newState == ConnectionState.CONNECTED) { - this.connectAction.setEnabled(true); - } else if (newState == ConnectionState.NOT_CONNECTED) { - // TODO do a little bit more here... - this.connectAction.setEnabled(false); - } - } - - public void displayMessage(String body) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - // - } - }); - - } - - public void chatMessageAdded(final String sender, final String message) { - ChatView.log.debug("Received Message from " + sender + ": " + message); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - int prefixPos = sender.indexOf('/') + 1; - String m = message.startsWith("\n") ? message.substring(1) - : message; - ChatView.this.viewer.getTextWidget().append( - sender.substring(prefixPos, sender.indexOf('/', - prefixPos)) - + ": " + m + "\n"); - } - }); - - } - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ErrorMessageDialog.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ErrorMessageDialog.java deleted file mode 100644 index ee1714fb3f1257d81750a541500ffa4cace2138d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/ErrorMessageDialog.java +++ /dev/null @@ -1,84 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.widgets.Display; - -/** - * Eclipse Dialog to show Exception Messages. - * - * @author rdjemili - * - */ -public class ErrorMessageDialog { - - /** - * show error message dialog. - * - * @param exception - */ - public static void showErrorMessage(final Exception exception) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - MessageDialog.openError(Display.getDefault().getActiveShell(), - exception.toString(), exception.getMessage()); - } - }); - } - - /** - * show error message dialog. - * - * @param exception - */ - public static void showErrorMessage(final String exceptionMessage) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - if ((exceptionMessage == null) || exceptionMessage.equals("")) { - MessageDialog.openError(Display.getDefault() - .getActiveShell(), "Exception", "Error occured."); - } else { - MessageDialog.openError(Display.getDefault() - .getActiveShell(), "Exception", exceptionMessage); - } - } - - }); - } - - protected static MessageDialog actualChecksumerrorDialog = null; - - /** - * TODO CJ: write javadoc - * - */ - public static void showChecksumErrorMessage(final String fileName) { - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - actualChecksumerrorDialog = new MessageDialog(Display - .getDefault().getActiveShell(), "Consistency Problem!", - null, "Inconsitent file state has detected. File " - + fileName - + " has to synchronized with project host", - MessageDialog.WARNING, new String[0], 0); - actualChecksumerrorDialog.open(); - } - }); - } - - /** - * TODO CJ: write javadoc - * - */ - public static void closeChecksumErrorMessage() { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - if (actualChecksumerrorDialog != null) { - actualChecksumerrorDialog.close(); - actualChecksumerrorDialog = null; - } - - } - }); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/IRosterTree.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/IRosterTree.java deleted file mode 100644 index c3eb72153eac3bf5eb0c130dc69f8ea0be454392..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/IRosterTree.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -/** - * This interface handles the event updates for roster tree. - * - * @author orieger - * - */ -public interface IRosterTree { - - /** - * Refreshes the roster tree. - * - * @param updateLabels - * <code>true</code> if item labels (might) have changed. - * <code>false</code> otherwise. - */ - public void refreshRosterTree(final boolean updateLabels); -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/InvitationDialog.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/InvitationDialog.java deleted file mode 100644 index 20b257bc2a991546ea436a97be961e2b6af57b65..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/InvitationDialog.java +++ /dev/null @@ -1,543 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.packet.Presence; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.State; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISharedProject; - -public class InvitationDialog extends Dialog implements IInvitationUI, - IConnectionListener { - - private TableViewer tableviewer; - private Table table; - private ArrayList<inviterdata> input; - private Button cancelButton; - - private Roster roster = Saros.getDefault().getRoster(); - private InvState inviteStep = InvState.SELECTION; - private JID autoinviteJID = null; - private Display display = null; - - private static enum InvState { - SELECTION, INVITING, DONE - } - - // assigned to any of the entries of the invite-tableview - private class inviterdata { - JID jid; - String name; - IOutgoingInvitationProcess outginvatationProc; - } - - // Class for providing labels of my Tableview - private class MyLabelProvider extends LabelProvider implements - ITableLabelProvider { - - public Image getColumnImage(Object element, int columnIndex) { - return null; - } - - public String getColumnText(Object element, int columnIndex) { - inviterdata item = (inviterdata) element; - - switch (columnIndex) { - case 0: - return item.name; - case 1: - if (item.outginvatationProc != null) { - return getStateDesc(item.outginvatationProc.getState()); - } else { - return ""; - } - case 2: - if (item.outginvatationProc != null) { - if (item.outginvatationProc.getState() == IInvitationProcess.State.SYNCHRONIZING) { - return "Transfering file " - + (item.outginvatationProc.getProgressCurrent()) - + " of " - + item.outginvatationProc.getProgressMax() - + ": " - + item.outginvatationProc.getProgressInfo(); - } else { - return ""; - } - } else { - return ""; - } - } - return ""; - } - } - - public InvitationDialog(Shell parentShell, JID jid) { - super(parentShell); - this.autoinviteJID = jid; - - // TODO Auto-generated constructor stub - } - - @Override - protected Control createContents(Composite parent) { - - getShell().setText("Invitation Helper"); - this.display = getShell().getDisplay(); - - Composite composite = new Composite(parent, SWT.NONE); - - GridLayout gl = new GridLayout(); - composite.setLayout(gl); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.minimumHeight = 200; - - Label usersLabel = new Label(composite, SWT.NONE); - usersLabel.setText("Select users to invite:"); - - Composite comTable = new Composite(composite, SWT.NONE); - comTable.setLayout(gl); - comTable.setLayoutData(gd); - - // avoid multi selection - this.tableviewer = new TableViewer(comTable, SWT.FULL_SELECTION); - this.table = this.tableviewer.getTable(); - this.table.setLinesVisible(true); - this.tableviewer.setContentProvider(new ArrayContentProvider()); - this.tableviewer.setLabelProvider(new MyLabelProvider()); - this.table.setHeaderVisible(true); - this.table.setLayoutData(gd); - TableColumn column = new TableColumn(this.table, SWT.NONE); - column.setText("User"); - column.setWidth(150); - column = new TableColumn(this.table, SWT.NONE); - column.setText("Status"); - column.setWidth(300); - column = new TableColumn(this.table, SWT.NONE); - column.setText("Action"); - column.setWidth(200); - - // table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - this.input = new ArrayList<inviterdata>(); - this.tableviewer.setInput(this.input); - - this.cancelButton = new Button(composite, SWT.NONE); - this.cancelButton.setText("Cancel selected invitation"); - this.cancelButton.addSelectionListener(new SelectionListener() { - - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - cancelInvite(); - Display.getDefault().syncExec(new Runnable() { - public void run() { - } - }); - } - }); - - this.table.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - if (InvitationDialog.this.inviteStep == InvState.SELECTION) { - setInviteable((InvitationDialog.this.table - .getSelectionCount() > 0)); - } else if (InvitationDialog.this.inviteStep == InvState.INVITING) { - InvitationDialog.this.cancelButton - .setEnabled(isSelectionCancelable()); - } else { - InvitationDialog.this.cancelButton.setEnabled(false); - } - } - - @Override - public void widgetDefaultSelected(SelectionEvent event) { - } - }); - - this.cancelButton.setEnabled(false); - - // get online users from roster - if (this.autoinviteJID == null) { - attachRosterListener(); - } - refreshRosterListRunASync(this.autoinviteJID); - - Control c = super.createContents(parent); - - getButton(IDialogConstants.OK_ID).setText("Invite"); - getButton(IDialogConstants.CANCEL_ID).setText("Close"); - setInviteable(false); - - // auto trigger automatic invite - if (this.autoinviteJID != null) { - performInvitation(); - } - - return c; - } - - protected void setInviteable(boolean b) { - getButton(IDialogConstants.OK_ID).setEnabled(b); - } - - @Override - protected void okPressed() { - performInvitation(); - } - - public boolean performInvitation() { - - this.inviteStep = InvState.INVITING; - this.cancelButton.setEnabled(true); - getButton(IDialogConstants.CANCEL_ID).setEnabled(false); - - try { - TableItem[] cursel = this.table.getSelection(); - - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - String name = project.getProject().getName(); - - for (TableItem ti : cursel) { - Object o = ti.getData(); - - inviterdata invdat = (inviterdata) o; - invdat.outginvatationProc = project.invite(invdat.jid, name, - true, this); - } - - return false; // we wanna wait (and block) until all invites are - // done - - } catch (Exception e) { - e.printStackTrace(); - } - - return false; - } - - // Triggers the update of the table in a GUI thread. - public void updateInvitationProgress(final JID jid) { - this.display.asyncExec(new Runnable() { - public void run() { - updateInvitationProgressRunASyn(jid); - } - }); - } - - /* - * Updates the invitation progress for all users in the table by refreshing - * the table. MyLabelProvider will then poll the current progresses. - */ - private void updateInvitationProgressRunASyn(JID jid) { - boolean alldone = true; - inviterdata invdat = null; - int index; - - for (index = 0; index < this.table.getItemCount(); index++) { - - TableItem ti = this.table.getItem(index); - Object o = ti.getData(); - invdat = (inviterdata) o; - - if ((invdat.outginvatationProc != null) - && (invdat.outginvatationProc.getState() != IInvitationProcess.State.DONE) - && (invdat.outginvatationProc.getState() != IInvitationProcess.State.CANCELED)) { - alldone = false; - } - - if ((jid != null) && invdat.jid.equals(jid)) { - this.tableviewer.refresh(o); - } - } - - // force the table to update ALL labels - if (jid == null) { - this.tableviewer.refresh(); - } - - // are all invites done? - if (alldone) { - // if(invdat.outginvatationProc.getState() == - // IInvitationProcess.State.DONE){ - // inviteStep= InvState.SELECTION; - // } - this.inviteStep = InvState.DONE; - getButton(IDialogConstants.CANCEL_ID).setEnabled(true); - setInviteable(false); - - } - this.cancelButton.setEnabled(isSelectionCancelable() - && (this.inviteStep != InvState.DONE)); - - } - - boolean isSelectionCancelable() { - - if (this.table.getSelectionCount() == 0) { - return false; - } - - TableItem[] cursel = this.table.getSelection(); - for (TableItem ti : cursel) { - Object o = ti.getData(); - inviterdata invdat = (inviterdata) o; - if ((invdat.outginvatationProc == null) - || ((invdat.outginvatationProc.getState() == State.INITIALIZED) - || (invdat.outginvatationProc.getState() == State.SYNCHRONIZING_DONE) - || (invdat.outginvatationProc.getState() == State.CANCELED) || (invdat.outginvatationProc - .getState() == State.DONE))) { - return false; - } - } - return true; - } - - void cancelInvite() { - TableItem[] cursel = this.table.getSelection(); - for (TableItem ti : cursel) { - Object o = ti.getData(); - inviterdata invdat = (inviterdata) o; - if (invdat.outginvatationProc == null) { - continue; - } - - invdat.outginvatationProc.cancel(null, false); - } - updateInvitationProgress(null); - } - - boolean isJIDinList(ArrayList<JID> items, JID jid) { - for (int i = 0; i < items.size(); i++) { - - try { - JID curJID = items.get(i); - - if (curJID.equals(jid)) { - return true; - } - - } catch (Exception e) { - System.out.println(e); - } - } - - return false; - } - - static final String[] StateNames = { "Initialized", - "Invitation sent. Waiting for acknowledgement...", - "Filelist of inviter requested", "Filelist of inviter sent", - "Filelist of invitee sent", - "Synchornizing project files. Transfering files...", - "Files sent. Waiting for invitee...", "Invitiation completed", - "Invitation canceled" }; - - private String getStateDesc(IInvitationProcess.State state) { - return InvitationDialog.StateNames[state.ordinal()]; - } - - public void showErrorMessage(String errorMessage) { - ErrorMessageDialog.showErrorMessage(errorMessage); - } - - public void cancel(String errorMsg, boolean replicated) { - updateInvitationProgress(null); - } - - /* - * (non-Javadoc) - * - * @see - * de.fu_berlin.inf.dpp.invitation.IOutgoingInvitationProcess.IInvitationUI - */ - public void runGUIAsynch(final Runnable runnable) { - - this.display.asyncExec(new Runnable() { - public void run() { - new Thread(runnable).start(); - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, - final ConnectionState newState) { - - if (newState == ConnectionState.CONNECTED) { - this.roster = Saros.getDefault().getRoster(); - attachRosterListener(); - - } else if (newState == ConnectionState.NOT_CONNECTED) { - this.roster = null; - } - - refreshRosterListRunASync(null); - - } - - private void attachRosterListener() { - this.roster.addRosterListener(new RosterListener() { - public void entriesAdded(Collection<String> addresses) { - refreshRosterList(); - } - - public void entriesUpdated(Collection<String> addresses) { - refreshRosterList(); - } - - public void entriesDeleted(Collection<String> addresses) { - refreshRosterList(); - } - - public void presenceChanged(String XMPPAddress) { - refreshRosterList(); - } - - public void presenceChanged(Presence presence) { - presenceChanged(presence.getFrom()); - - } - }); - } - - /* - * Triggers the refresh of the roster list in a GUI thread. - */ - private void refreshRosterList() { - if (this.inviteStep != InvState.SELECTION) { - return; - } - - this.display.asyncExec(new Runnable() { - public void run() { - refreshRosterListRunASync(null); - } - }); - } - - /* - * Clears and re-filles the table with all online users from my roster. - * Selections are preserved. - */ - private void refreshRosterListRunASync(JID toselect) { - ArrayList<JID> curselA = new ArrayList<JID>(); - int[] curselNew = null; - - // save selection - TableItem[] curselTIs = this.table.getSelection(); - for (TableItem curselTI : curselTIs) { - curselA.add(((inviterdata) curselTI.getData()).jid); - } - - this.input.clear(); - this.table.removeAll(); - - if (this.roster == null) { - return; - } - - Collection<RosterEntry> users = this.roster.getEntries(); - int index = -1; - for (RosterEntry entry : users) { - - String username = entry.getUser(); - Presence presence = this.roster.getPresence(username); - - User user = Saros.getDefault().getSessionManager() - .getSharedProject() - .getParticipant(new JID(entry.getUser())); - - if ((presence != null) - && presence.getType().equals(Presence.Type.available) - && (user == null)) { - inviterdata invdat = new inviterdata(); - invdat.jid = new JID(entry.getUser()); - String name = entry.getName(); - invdat.name = (name == null) ? entry.getUser() : name; - invdat.outginvatationProc = null; - - this.input.add(invdat); - index++; - - if (((this.autoinviteJID != null) && invdat.jid - .equals(this.autoinviteJID)) - || ((this.autoinviteJID == null) && isJIDinList( - curselA, invdat.jid))) { - int curselOld[] = this.table.getSelectionIndices(); - curselNew = new int[curselOld.length + 1]; - System.arraycopy(curselOld, 0, curselNew, 0, - curselOld.length); - curselNew[curselNew.length - 1] = index; - } - } - } - - this.tableviewer.refresh(); - - if (curselNew != null) { - this.table.setSelection(curselNew); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/MessagingWindow.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/MessagingWindow.java deleted file mode 100644 index f55df83661c26ac9ad1ea25a92e77a68cabdec72..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/MessagingWindow.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.TextViewer; -import org.eclipse.jface.window.ApplicationWindow; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - -import de.fu_berlin.inf.dpp.MessagingManager; -import de.fu_berlin.inf.dpp.Saros; - -/** - * TODO Very kludgy window for chat messages. Needs some work - * - * @author rdjemili - * - */ -public class MessagingWindow extends ApplicationWindow { - private final MessagingManager.SessionProvider session; - - private TextViewer historyViewer; - - private StyledText textInput; - - public MessagingWindow(MessagingManager.SessionProvider session) { - super(null); // top-level window - - this.session = session; - } - - @Override - protected Control createContents(Composite parent) { - // main composite - Composite composite = new Composite(parent, SWT.None); - FillLayout fillLayout = new FillLayout(); - // fillLayout.marginHeight = 5; - // fillLayout.marginWidth = 5; - composite.setLayout(fillLayout); - - SashForm form = new SashForm(composite, SWT.VERTICAL); - - this.historyViewer = new TextViewer(form, SWT.READ_ONLY | SWT.V_SCROLL - | SWT.BORDER); - this.historyViewer.setDocument(new Document()); - - this.textInput = new StyledText(form, SWT.MULTI | SWT.BORDER); - this.textInput.addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - if (e.character == SWT.CR) { - e.doit = false; - sendInput(); - } - } - - public void keyReleased(KeyEvent e) { - // ignore - } - }); - this.textInput.setFocus(); - - form.setWeights(new int[] { 5, 1 }); - - // fill textViewer - for (MessagingManager.ChatLine chatLine : this.session.getHistory()) { - addChatLine(chatLine); - } - - return composite; - } - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - - shell.setText("Talking to " + this.session.getName()); - shell.setSize(500, 400); - shell.setImage(SarosUI.getImage("icons/comment.png")); - } - - private void sendInput() { - String msg = this.textInput.getText().trim(); - this.textInput.setText(""); - - this.session.sendMessage(msg); - } - - /** - * Add a chat line to the text viewer. - */ - public void addChatLine(MessagingManager.ChatLine line) { - String sender = line.sender; - String text = line.text; - - IDocument document = this.historyViewer.getDocument(); - int start = document.getLength(); - - // build and append new chat line string - StringBuffer newLine = new StringBuffer(); - if (start > 0) { - newLine.append('\n'); - start++; - } - newLine.append(sender); - newLine.append(": "); - newLine.append(text); - - try { - document.replace(document.getLength(), 0, newLine.toString()); - } catch (BadLocationException e) { - Saros.log("Could not update chat window", e); - } - - // Show sender in bold - StyledText styledText = this.historyViewer.getTextWidget(); - StyleRange styleRange = new StyleRange(); - styleRange.start = start; - styleRange.length = sender.length(); - styleRange.fontStyle = SWT.BOLD; - styledText.setStyleRange(styleRange); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/NetworkView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/NetworkView.java deleted file mode 100644 index f1d73562a8f2827febf100933179704a99508ff3..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/NetworkView.java +++ /dev/null @@ -1,106 +0,0 @@ -package de.fu_berlin.inf.dpp.ui; - -import java.io.InputStream; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.part.ViewPart; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smackx.jingle.listeners.JingleTransportListener; -import org.jivesoftware.smackx.jingle.nat.TransportCandidate; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.net.internal.XMPPChatTransmitter; -import de.fu_berlin.inf.dpp.net.jingle.IJingleFileTransferListener; -import de.fu_berlin.inf.dpp.net.jingle.JingleFileTransferData; -import de.fu_berlin.inf.dpp.net.jingle.JingleSessionException; - -public class NetworkView extends ViewPart implements JingleTransportListener, - IJingleFileTransferListener, IConnectionListener { - - private Text log; - - @Override - public void createPartControl(Composite parent) { - Composite rootComposite = new Composite(parent, SWT.NONE); - rootComposite.setLayout(new FillLayout()); - SashForm sash = new SashForm(rootComposite, SWT.VERTICAL); - this.log = new Text(sash, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); - - // register as connection listener - Saros.getDefault().addListener(this); - } - - @Override - public void setFocus() { - // TODO Auto-generated method stub - - } - - public void transportClosed(TransportCandidate cand) { - // TODO Auto-generated method stub - - } - - public void transportClosedOnError(XMPPException e) { - // TODO Auto-generated method stub - - } - - public void transportEstablished(TransportCandidate local, - TransportCandidate remote) { - log.append("Jingle transport estabblished: " + local.getLocalIp() - + " <-> " + remote.getLocalIp()); - - } - - public void connected(final String protocol, final String remote) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - log.append("P2P Connected with " + protocol + " to " + remote - + "\n"); - } - }); - } - - public void exceptionOccured(JingleSessionException exception) { - // TODO Auto-generated method stub - - } - - public void failedToSendFileListWithJingle(JID jid, - JingleFileTransferData transferList) { - log.append("Failed to send File with Jingle to " + jid); - } - - public void incomingFileList(String fileList_content, JID sender) { - // TODO Auto-generated method stub - } - - public void incomingResourceFile(JingleFileTransferData data, - InputStream input) { - // TODO Auto-generated method stub - - } - - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - if (newState == ConnectionState.CONNECTED) { - ((XMPPChatTransmitter) Saros.getDefault().getSessionManager() - .getTransmitter()).getJingleManager() - .addJingleFileTransferListener(this); - - } else if (newState == ConnectionState.NOT_CONNECTED) { - } - - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/PreferencePage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/PreferencePage.java deleted file mode 100644 index f91203f77cba94896ef2ea33d545bfad5b7f311e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/PreferencePage.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -/** - * Contains the basic preferences for Saros. - * - * @author rdjemili - */ -public class PreferencePage extends FieldEditorPreferencePage implements - IWorkbenchPreferencePage { - - public PreferencePage() { - super(FieldEditorPreferencePage.GRID); - setPreferenceStore(Saros.getDefault().getPreferenceStore()); - setDescription("Your settings for Jabber."); - } - - @Override - public void createFieldEditors() { - addField(new StringFieldEditor(PreferenceConstants.SERVER, "Server:", - getFieldEditorParent())); - - addField(new StringFieldEditor(PreferenceConstants.USERNAME, - "Username:", getFieldEditorParent())); - - StringFieldEditor passwordField = new StringFieldEditor( - PreferenceConstants.PASSWORD, "Password:", - getFieldEditorParent()); - passwordField.getTextControl(getFieldEditorParent()).setEchoChar('*'); - addField(passwordField); - - addField(new BooleanFieldEditor(PreferenceConstants.AUTO_CONNECT, - "Automatically connect on startup.", getFieldEditorParent())); - - addField(new BooleanFieldEditor(PreferenceConstants.AUTO_FOLLOW_MODE, - "Start in Follow Mode.", getFieldEditorParent())); - } - - /* - * @see org.eclipse.ui.IWorkbenchPreferencePage - */ - public void init(IWorkbench workbench) { - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/RosterView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/RosterView.java deleted file mode 100644 index 1a5a138d523fbf26a571a28a82e5f3189da40abf..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/RosterView.java +++ /dev/null @@ -1,502 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import org.apache.log4j.Logger; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.part.ViewPart; -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterGroup; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.filter.PacketTypeFilter; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smack.packet.RosterPacket; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.net.internal.SubscriptionListener; -import de.fu_berlin.inf.dpp.ui.actions.ConnectDisconnectAction; -import de.fu_berlin.inf.dpp.ui.actions.DeleteContactAction; -import de.fu_berlin.inf.dpp.ui.actions.InviteAction; -import de.fu_berlin.inf.dpp.ui.actions.NewContactAction; -import de.fu_berlin.inf.dpp.ui.actions.RenameContactAction; -import de.fu_berlin.inf.dpp.ui.actions.SkypeAction; - -/** - * This view displays the roster (also known as contact list) of the local user. - * - * @author rdjemili - */ -public class RosterView extends ViewPart implements IConnectionListener, - IRosterTree { - - private static Logger logger = Logger.getLogger(RosterView.class); - - private TreeViewer viewer; - - private Roster roster; - - private XMPPConnection connection; - - // actions - // private Action messagingAction; - - private Action inviteAction; - - private RenameContactAction renameContactAction; - - private DeleteContactAction deleteContactAction; - - private SkypeAction skypeAction; - - /** - * An item of the roster tree. Can be either a group or a single contact. - * - * @author rdjemili - */ - private interface TreeItem { - - /** - * @return all child items of this tree item. - */ - Object[] getChildren(); - } - - /** - * A group item which holds a number of users. - */ - private class GroupItem implements TreeItem { - private final RosterGroup group; - - public GroupItem(RosterGroup group) { - this.group = group; - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ui.RosterView.TreeItem - */ - public Object[] getChildren() { - return this.group.getEntries().toArray(); - } - - @Override - public String toString() { - return this.group.getName(); - } - } - - /** - * A group item that holds all users that don't belong to another group. - */ - private class UnfiledGroupItem implements TreeItem { - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.ui.RosterView.TreeItem - */ - public Object[] getChildren() { - return RosterView.this.roster.getUnfiledEntries().toArray(); - } - - @Override - public String toString() { - return "Buddies"; - } - } - - /** - * Provide tree content. - */ - private class TreeContentProvider implements IStructuredContentProvider, - ITreeContentProvider { - - /* - * @see org.eclipse.jface.viewers.IContentProvider - */ - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - } - - /* - * @see org.eclipse.jface.viewers.IContentProvider - */ - public void dispose() { - } - - /* - * @see org.eclipse.jface.viewers.IStructuredContentProvider - */ - public Object[] getElements(Object parent) { - if (parent.equals(getViewSite()) - && (RosterView.this.roster != null)) { - List<TreeItem> groups = new LinkedList<TreeItem>(); - for (RosterGroup rg : RosterView.this.roster.getGroups()) { - GroupItem item = new GroupItem(rg); - groups.add(item); - } - - // for (Iterator it = roster.getGroups(); it.hasNext();) { - // GroupItem item = new GroupItem((RosterGroup) it.next()); - // groups.add(item); - // } - - groups.add(new UnfiledGroupItem()); - - return groups.toArray(); - } - - return new Object[0]; - } - - /* - * @see org.eclipse.jface.viewers.ITreeContentProvider - */ - public Object getParent(Object child) { - return null; // TODO - } - - /* - * @see org.eclipse.jface.viewers.ITreeContentProvider - */ - public Object[] getChildren(Object parent) { - if (parent instanceof TreeItem) { - return ((TreeItem) parent).getChildren(); - } - - return new Object[0]; - } - - /* - * @see org.eclipse.jface.viewers.ITreeContentProvider - */ - public boolean hasChildren(Object parent) { - if (parent instanceof TreeItem) { - Object[] children = ((TreeItem) parent).getChildren(); - return children.length > 0; - } - - return false; - } - } - - /** - * Shows user name and state in parenthesis. - */ - private class ViewLabelProvider extends LabelProvider { - private final Image groupImage = SarosUI.getImage("icons/group.png"); - - private final Image personImage = SarosUI.getImage("icons/user.png"); - - @Override - public String getText(Object obj) { - if (obj instanceof RosterEntry) { - RosterEntry entry = (RosterEntry) obj; - - String label = entry.getName(); - - // show JID if entry has no nickname - if (label == null) { - label = entry.getUser(); - } - - // append presence information if available - Presence presence = RosterView.this.roster.getPresence(entry - .getUser()); - RosterEntry e = RosterView.this.roster - .getEntry(entry.getUser()); - if (e.getStatus() == RosterPacket.ItemStatus.SUBSCRIPTION_PENDING) { - label = label + " (wait for permission)"; - } else if (presence != null) { - label = label + " (" + presence.getType() + ")"; - } - - return label; - } - - return obj.toString(); - } - - @Override - public Image getImage(Object element) { - return element instanceof RosterEntry ? this.personImage - : this.groupImage; - } - } - - /** - * A sorter that orders by presence and then by name. - */ - private class NameSorter extends ViewerSorter { - @Override - public int compare(Viewer viewer, Object elem1, Object elem2) { - - // sort by presence - if (elem1 instanceof RosterEntry) { - RosterEntry entry1 = (RosterEntry) elem1; - - if (elem2 instanceof RosterEntry) { - RosterEntry entry2 = (RosterEntry) elem2; - - String user1 = entry1.getUser(); - boolean presence1 = RosterView.this.roster - .getPresence(user1) != null; - - String user2 = entry2.getUser(); - boolean presence2 = RosterView.this.roster - .getPresence(user2) != null; - - if (presence1 && !presence2) { - return -1; - } else if (!presence1 && presence2) { - return 1; - } - } - } - - // otherwise use default order - return super.compare(viewer, elem1, elem2); - } - } - - /** - * Creates an roster view.. - */ - public RosterView() { - } - - /** - * This is a callback that will allow us to create the viewer and initialize - * it. - */ - @Override - public void createPartControl(Composite parent) { - this.viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL - | SWT.V_SCROLL); - this.viewer.setContentProvider(new TreeContentProvider()); - this.viewer.setLabelProvider(new ViewLabelProvider()); - this.viewer.setSorter(new NameSorter()); - this.viewer.setInput(getViewSite()); - this.viewer.expandAll(); - - makeActions(); - hookContextMenu(); - // hookDoubleClickAction(); - contributeToActionBars(); - updateEnablement(); - - Saros saros = Saros.getDefault(); - saros.addListener(this); - - connectionStateChanged(saros.getConnection(), saros - .getConnectionState()); - } - - /** - * Passing the focus request to the viewer's control. - */ - @Override - public void setFocus() { - this.viewer.getControl().setFocus(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, - final ConnectionState newState) { - if (newState == ConnectionState.CONNECTED) { - // roster = Saros.getDefault().getRoster(); - this.roster = connection.getRoster(); - this.connection = connection; - attachRosterListener(); - - } else if (newState == ConnectionState.NOT_CONNECTED) { - this.roster = null; - } - - refreshRosterTree(true); - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - updateStatusLine(newState); - updateEnablement(); - } - }); - } - - /** - * Needs to called from an UI thread. - */ - private void updateEnablement() { - this.viewer.getControl().setEnabled(Saros.getDefault().isConnected()); - } - - /** - * Needs to called from an UI thread. - */ - private void updateStatusLine(final ConnectionState newState) { - IStatusLineManager statusLine = getViewSite().getActionBars() - .getStatusLineManager(); - statusLine.setMessage(SarosUI.getDescription(newState)); - } - - private void attachRosterListener() { - - this.connection.addPacketListener(new SubscriptionListener( - this.connection, this), new PacketTypeFilter(Presence.class)); - - this.connection.getRoster().addRosterListener(new RosterListener() { - public void entriesAdded(Collection<String> addresses) { - } - - public void entriesUpdated(Collection<String> addresses) { - for (String address : addresses) { - logger.debug(address - + ": " - + connection.getRoster().getEntry(address) - .getType() - + ", " - + connection.getRoster().getEntry(address) - .getStatus()); - } - - refreshRosterTree(true); - } - - public void entriesDeleted(Collection<String> addresses) { - refreshRosterTree(false); - } - - public void presenceChanged(Presence presence) { - logger.debug(presence.getFrom() + ": " + presence); - refreshRosterTree(true); - } - }); - } - - /** - * Refreshes the roster tree. - * - * @param updateLabels - * <code>true</code> if item labels (might) have changed. - * <code>false</code> otherwise. - */ - public void refreshRosterTree(final boolean updateLabels) { - if (this.viewer.getControl().isDisposed()) { - return; - } - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - RosterView.this.viewer.refresh(updateLabels); - RosterView.this.viewer.expandAll(); - } - }); - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - RosterView.this.fillContextMenu(manager); - } - }); - - Menu menu = menuMgr.createContextMenu(this.viewer.getControl()); - - this.viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, this.viewer); - } - - // private void hookDoubleClickAction() { - // this.viewer.addDoubleClickListener(new IDoubleClickListener() { - // public void doubleClick(DoubleClickEvent event) { - // if (RosterView.this.messagingAction.isEnabled()) { - // RosterView.this.messagingAction.run(); - // } - // } - // }); - // } - - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - - IMenuManager menuManager = bars.getMenuManager(); - // menuManager.add(this.messagingAction); - menuManager.add(this.inviteAction); - // menuManager.add(new TestJoinWizardAction()); - menuManager.add(new Separator()); - - IToolBarManager toolBarManager = bars.getToolBarManager(); - toolBarManager.add(new ConnectDisconnectAction()); - toolBarManager.add(new NewContactAction()); - } - - private void fillContextMenu(IMenuManager manager) { - // manager.add(this.messagingAction); - manager.add(this.skypeAction); - manager.add(this.inviteAction); - manager.add(new Separator()); - manager.add(this.renameContactAction); - manager.add(this.deleteContactAction); - - // Other plug-ins can contribute there actions here - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - private void makeActions() { - // this.messagingAction = new MessagingAction(this.viewer); - this.skypeAction = new SkypeAction(this.viewer); - this.inviteAction = new InviteAction(this.viewer); - this.renameContactAction = new RenameContactAction(this.viewer); - this.deleteContactAction = new DeleteContactAction(this.viewer); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SarosUI.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SarosUI.java deleted file mode 100644 index a868ac63b92b39184762c83876f83e5fbc7e42f0..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SarosUI.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.core.filebuffers.IDocumentSetupParticipant; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.internal.ui.JavaPlugin; -import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider; -import org.eclipse.jdt.internal.ui.javaeditor.JavaDocumentSetupParticipant; -import org.eclipse.jdt.ui.text.IJavaPartitions; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.editors.text.ForwardingDocumentProvider; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.editor.internal.SharedDocumentProvider; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.wizards.JoinSessionWizard; -import de.fu_berlin.inf.dpp.ui.wizards.WizardDialogAccessable; - -public class SarosUI implements ISessionListener { - - private static final String SESSION_VIEW = "de.fu_berlin.inf.dpp.ui.SessionView"; - - private static final String ROSTER_VIEW = "de.fu_berlin.inf.dpp.ui.RosterView"; - - public SarosUI(ISessionManager sessionManager) { - setupCompilationUnitDocumentProvider(); - sessionManager.addSessionListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(final IIncomingInvitationProcess process) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault().getActiveShell(); - JoinSessionWizard jsw = new JoinSessionWizard(process); - WizardDialogAccessable wd = new WizardDialogAccessable( - shell, jsw); - jsw.setWizardDlg(wd); - process.setInvitationUI(jsw.getInvitationUI()); - wd.open(); - } catch (Exception e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, - IStatus.ERROR, - "Error while joining a session", e)); - } - } - }); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - try { - // Create Session View - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench - .getActiveWorkbenchWindow(); - window.getActivePage().showView(SarosUI.SESSION_VIEW, null, - IWorkbenchPage.VIEW_CREATE); - } catch (PartInitException e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, - IStatus.ERROR, - "Could not create Session View", e)); - } - - try { - // Open Roster so that a participant can be invited - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench - .getActiveWorkbenchWindow(); - window.getActivePage().showView(SarosUI.ROSTER_VIEW, null, - IWorkbenchPage.VIEW_ACTIVATE); - } catch (PartInitException e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, - IStatus.ERROR, - "Could not activate Roster View", e)); - } - - } - }); - } - - /** - * @param state - * @return a nice string description of the given state, which can be used - * to be shown in labels (e.g. CONNECTING becomes "Connecting.."). - */ - public static String getDescription(ConnectionState state) { - switch (state) { - case NOT_CONNECTED: - return "Not connected"; - case CONNECTING: - return "Connecting..."; - case CONNECTED: - return "Connected (as " - + Saros.getDefault().getConnection().getUser() + ")"; - case DISCONNECTING: - return "Disconnecting..."; - case ERROR: - return "Error (" + Saros.getDefault().getConnectionError() + ")"; - } - - return ""; - } - - public static Composite createLabelComposite(Composite parent, String text) { - Composite composite = new Composite(parent, SWT.NONE); - - FillLayout layout = new FillLayout(SWT.NONE); - layout.marginHeight = 20; - composite.setLayout(layout); - - Label label = new Label(composite, SWT.NONE); - label.setText(text); - - return composite; - } - - public static Image getImage(String path) { - return new Image(Display.getDefault(), SarosUI.getImageDescriptor(path) - .getImageData()); - } - - /** - * Returns an image descriptor for the image file at the given plug-in - * relative path. - * - * @param path - * the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin( - "de.fu_berlin.inf.dpp", path); - } - - @SuppressWarnings("restriction") - private void setupCompilationUnitDocumentProvider() { // UGLY HACK - CompilationUnitDocumentProvider cuProvider = (CompilationUnitDocumentProvider) JavaPlugin - .getDefault().getCompilationUnitDocumentProvider(); - - SharedDocumentProvider sharedProvider = new SharedDocumentProvider(); - - IDocumentSetupParticipant setupParticipant = new JavaDocumentSetupParticipant(); - ForwardingDocumentProvider parentProvider = new ForwardingDocumentProvider( - IJavaPartitions.JAVA_PARTITIONING, setupParticipant, - sharedProvider); - - cuProvider.setParentDocumentProvider(parentProvider); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SessionView.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SessionView.java deleted file mode 100644 index 48207bd6db5a6a9b01a4ce755be816f27cdf8322..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/SessionView.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.IColorProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableFontProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.AnnotationPreference; -import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.editor.annotations.SelectionAnnotation; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.actions.ConsistencyAction; -import de.fu_berlin.inf.dpp.ui.actions.FollowModeAction; -import de.fu_berlin.inf.dpp.ui.actions.GiveDriverRoleAction; -import de.fu_berlin.inf.dpp.ui.actions.LeaveSessionAction; -import de.fu_berlin.inf.dpp.ui.actions.OpenInviteInterface; -import de.fu_berlin.inf.dpp.ui.actions.RemoveAllDriverRoleAction; -import de.fu_berlin.inf.dpp.ui.actions.TakeDriverRoleAction; - -public class SessionView extends ViewPart implements ISessionListener, - IPropertyChangeListener { - - private TableViewer viewer; - - private ISharedProject sharedProject; - - private GiveDriverRoleAction giveDriverRoleAction; - - private TakeDriverRoleAction takeDriverRoleAction; - - private IPreferenceStore store = null; - - private FollowModeAction followModeAction; - - private class SessionContentProvider implements IStructuredContentProvider, - ISharedProjectListener { - - private TableViewer tableViewer; - - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - if (oldInput != null) { - ISharedProject oldProject = (ISharedProject) oldInput; - oldProject.removeListener(this); - } - - SessionView.this.sharedProject = (ISharedProject) newInput; - if (SessionView.this.sharedProject != null) { - SessionView.this.sharedProject.addListener(this); - } - - this.tableViewer = (TableViewer) v; - this.tableViewer.refresh(); - - updateEnablement(); - } - - public Object[] getElements(Object parent) { - if (SessionView.this.sharedProject != null) { - return SessionView.this.sharedProject.getParticipants() - .toArray(); - } - - return new Object[] {}; - } - - public void driverChanged(JID driver, boolean replicated) { - User participant = SessionView.this.sharedProject - .getParticipant(driver); - - // if the local host become driver leave follow mode - if (participant.getJid().equals(Saros.getDefault().getMyJID())) { - if (SessionView.this.sharedProject.isDriver(participant)) - followModeAction.setFollowMode(false); - } - refreshTable(); - } - - public void userJoined(JID user) { - refreshTable(); - } - - public void userLeft(JID user) { - refreshTable(); - } - - public void dispose() { - } - - private void refreshTable() { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - SessionContentProvider.this.tableViewer.refresh(); - } - }); - } - } - - private class SessionLabelProvider extends LabelProvider implements - ITableLabelProvider, IColorProvider, ITableFontProvider { - - private final Image userImage = SarosUI.getImage("icons/user.png"); - private final Image driverImage = SarosUI - .getImage("icons/user_edit.png"); - private Font boldFont = null; - - public String getColumnText(Object obj, int index) { - User participant = (User) obj; - - StringBuffer sb = new StringBuffer(participant.getJid().getName()); - // if (participant.equals(sharedProject.getDriver())) { - if (SessionView.this.sharedProject.isDriver(participant)) { - - sb.append(" (Driver)"); - } - - return sb.toString(); - } - - @Override - public Image getImage(Object obj) { - User user = (User) obj; - if (SessionView.this.sharedProject.isDriver(user)) { - return this.driverImage; - } - // return user.equals(sharedProject.getDriver()) ? driverImage : - // userImage; - return this.userImage; - } - - public Image getColumnImage(Object obj, int index) { - return getImage(obj); - } - - // TODO getting current color doesnt uses when default was changed. - public Color getBackground(Object element) { - User user = (User) element; - - if (user.getJid().equals(Saros.getDefault().getMyJID())) { - return null; - } - - int colorid = user.getColorID(); - String mytype = SelectionAnnotation.TYPE + "." - + new Integer(colorid + 1).toString(); - - AnnotationPreferenceLookup lookup = org.eclipse.ui.editors.text.EditorsUI - .getAnnotationPreferenceLookup(); - AnnotationPreference ap = lookup.getAnnotationPreference(mytype); - if (ap == null) { - return null; - } - - IPreferenceStore store = EditorsUI.getPreferenceStore(); - RGB rgb = PreferenceConverter.getColor(store, ap - .getColorPreferenceKey()); - - return new Color(Display.getDefault(), rgb); - - } - - public Color getForeground(Object element) { - return null; - } - - public Font getFont(Object element, int columnIndex) { - if (this.boldFont == null) { - Display disp = SessionView.this.viewer.getControl() - .getDisplay(); - FontData[] data = disp.getSystemFont().getFontData(); - for (FontData fontData : data) { - fontData.setStyle(SWT.BOLD); - } - this.boldFont = new Font(disp, data); - } - - User user = (User) element; - if (user.getJid().equals(Saros.getDefault().getMyJID())) { - return this.boldFont; - } - return null; - } - - @Override - public void dispose() { - if (this.boldFont != null) { - this.boldFont.dispose(); - this.boldFont = null; - } - - super.dispose(); - } - } - - /** - * The constructor. - */ - public SessionView() { - this.store = EditorsUI.getPreferenceStore(); - this.store.addPropertyChangeListener(this); - } - - @Override - protected void finalize() throws Throwable { - this.store.removePropertyChangeListener(this); - super.finalize(); - } - - public void sessionStarted(final ISharedProject session) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - SessionView.this.viewer.setInput(session); - } - }); - } - - public void sessionEnded(ISharedProject session) { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - SessionView.this.viewer.setInput(null); - } - }); - this.sharedProject = null; - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /** - * This is a callback that will allow us to create the viewer and initialize - * it. - */ - @Override - public void createPartControl(Composite parent) { - this.viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL - | SWT.V_SCROLL); - this.viewer.setContentProvider(new SessionContentProvider()); - this.viewer.setLabelProvider(new SessionLabelProvider()); - this.viewer.setInput(null); - - this.giveDriverRoleAction = new GiveDriverRoleAction(this.viewer); - this.takeDriverRoleAction = new TakeDriverRoleAction(this.viewer); - - contributeToActionBars(); - hookContextMenu(); - attachSessionListener(); - updateEnablement(); - - setPartName("Shared Project Session"); - } - - /** - * Passing the focus request to the viewer's control. - */ - @Override - public void setFocus() { - this.viewer.getControl().setFocus(); - } - - /** - * Needs to called from the UI thread. - */ - private void updateEnablement() { - this.viewer.getControl().setEnabled(this.sharedProject != null); - } - - private void attachSessionListener() { - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - - sessionManager.addSessionListener(this); - if (sessionManager.getSharedProject() != null) { - this.viewer.setInput(sessionManager.getSharedProject()); - } - } - - private void contributeToActionBars() { - IActionBars bars = getViewSite().getActionBars(); - IToolBarManager toolBar = bars.getToolBarManager(); - - this.followModeAction = new FollowModeAction(); - toolBar.add(new ConsistencyAction()); - toolBar.add(new OpenInviteInterface()); - toolBar.add(new RemoveAllDriverRoleAction()); - toolBar.add(followModeAction); - toolBar.add(new LeaveSessionAction()); - } - - private void hookContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(new IMenuListener() { - public void menuAboutToShow(IMenuManager manager) { - fillContextMenu(manager); - } - }); - - Menu menu = menuMgr.createContextMenu(this.viewer.getControl()); - - this.viewer.getControl().setMenu(menu); - getSite().registerContextMenu(menuMgr, this.viewer); - } - - private void fillContextMenu(IMenuManager manager) { - manager.add(this.giveDriverRoleAction); - manager.add(this.takeDriverRoleAction); - - // Other plug-ins can contribute there actions here - manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - public void propertyChange(PropertyChangeEvent event) { - this.viewer.refresh(); - - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConnectDisconnectAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConnectDisconnectAction.java deleted file mode 100644 index cb5a62b82614a7b7c951f3255e08d332a192cfef..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConnectDisconnectAction.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class ConnectDisconnectAction extends Action implements - IConnectionListener { - - private final IPropertyChangeListener propertyListener; - - public ConnectDisconnectAction() { - updateStatus(); - Saros.getDefault().addListener(this); - - this.propertyListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(PreferenceConstants.USERNAME)) { - updateStatus(); - } - } - }; - Saros.getDefault().getPreferenceStore().addPropertyChangeListener( - this.propertyListener); - } - - @Override - public void run() { - new Thread(new Runnable() { - public void run() { - Saros saros = Saros.getDefault(); - if (saros.isConnected()) { - saros.disconnect(null); - } else { - - // display task progress information (begin) in status line - Display.getDefault().syncExec(new Runnable() { - public void run() { - IStatusLineManager slm = getStatusmanager(); - IProgressMonitor monitor = slm.getProgressMonitor(); - monitor.beginTask("Connecting...", - IProgressMonitor.UNKNOWN); - } - }); - - saros.connect(); - - // display task progress information (end) in status line - Display.getDefault().syncExec(new Runnable() { - public void run() { - IStatusLineManager slm = getStatusmanager(); - slm.setMessage("Connecting.."); - IProgressMonitor monitor = slm.getProgressMonitor(); - monitor.done(); - } - }); - - } - } - - private IStatusLineManager getStatusmanager() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().getViewReferences()[0].getView(false) - .getViewSite().getActionBars().getStatusLineManager(); - } - }).start(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.IConnectionListener - */ - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - updateStatus(); - } - - private void updateStatus() { - ConnectionState state = Saros.getDefault().getConnectionState(); - - switch (state) { - case CONNECTED: - case CONNECTING: - setImageDescriptor(SarosUI.getImageDescriptor("/icons/connect.png")); - break; - - case ERROR: - case NOT_CONNECTED: - case DISCONNECTING: - setImageDescriptor(SarosUI - .getImageDescriptor("/icons/disconnect.png")); - break; - } - - String username = Saros.getDefault().getPreferenceStore().getString( - PreferenceConstants.USERNAME); - - setEnabled((state == ConnectionState.CONNECTED) - || (((state == ConnectionState.NOT_CONNECTED) || (state == ConnectionState.ERROR)) && ((username != null) && (username - .length() > 0)))); - updateText(); - } - - private void updateText() { - ConnectionState state = Saros.getDefault().getConnectionState(); - String text = SarosUI.getDescription(state); - - setText(text); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConsistencyAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConsistencyAction.java deleted file mode 100644 index c3bf5d7df39719d487be5deacd3a8e871f8325b7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/ConsistencyAction.java +++ /dev/null @@ -1,106 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.action.Action; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.util.VariableProxy; -import de.fu_berlin.inf.dpp.util.VariableProxyListener; - -public class ConsistencyAction extends Action implements ISessionListener { - - private static Logger logger = Logger.getLogger(ConsistencyAction.class); - - private boolean executingChecksumErrorHandling; - - private static Set<IPath> pathes; - - public ConsistencyAction() { - setImageDescriptor(PlatformUI.getWorkbench().getSharedImages() - .getImageDescriptor(ISharedImages.IMG_OBJS_WARN_TSK)); - setEnabled(false); - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - VariableProxy<Boolean> proxy; - - VariableProxyListener<Boolean> listener = new VariableProxyListener<Boolean>() { - - public void setVariable(Boolean newValue) { - - ConsistencyAction.this.setEnabled(newValue); - - if (newValue) { - setToolTipText("Inconsistency Detected!"); - } else { - setToolTipText(""); - logger.debug("All Inconsistencies are resolved"); - if (executingChecksumErrorHandling) { - for (IPath path : pathes) { - Saros.getDefault().getSessionManager().getTransmitter() - .sendFileChecksumErrorMessage(path, true); - } - pathes.clear(); - executingChecksumErrorHandling = false; - } - } - } - - }; - - @Override - public void run() { - super.run(); - - executingChecksumErrorHandling = true; - - pathes = new CopyOnWriteArraySet<IPath>(Saros.getDefault() - .getSessionManager().getSharedProject() - .getConcurrentDocumentManager().getPathesWithWrongChecksums()); - - for (IPath path : pathes) { - Saros.getDefault().getSessionManager().getTransmitter() - .sendFileChecksumErrorMessage(path, false); - } - - } - - public void sessionStarted(ISharedProject session) { - - ConsistencyAction.pathes = new CopyOnWriteArraySet<IPath>(); - if (proxy != null) { - proxy.remove(listener); - } - - proxy = Saros.getDefault().getSessionManager().getSharedProject() - .getConcurrentDocumentManager().getConsistencyToResolve(); - - proxy.add(listener); - } - - public void invitationReceived(IIncomingInvitationProcess invitation) { - // ignore - } - - public void sessionEnded(ISharedProject session) { - - if (pathes != null) { - ConsistencyAction.pathes.clear(); - } - - if (proxy != null) { - proxy.remove(listener); - proxy = null; - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/DeleteContactAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/DeleteContactAction.java deleted file mode 100644 index f36248a2e8890706cb40d77168d839cfb3757f2f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/DeleteContactAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros; - -public class DeleteContactAction extends SelectionProviderAction { - private RosterEntry rosterEntry; - - public DeleteContactAction(ISelectionProvider provider) { - super(provider, "Delete"); - selectionChanged((IStructuredSelection) provider.getSelection()); - - setToolTipText("Set the nickname of this contact."); - - IWorkbench workbench = Saros.getDefault().getWorkbench(); - setImageDescriptor(workbench.getSharedImages().getImageDescriptor( - ISharedImages.IMG_TOOL_DELETE)); - } - - @Override - public void run() { - - Shell shell = Display.getDefault().getActiveShell(); - if ((shell == null) || (this.rosterEntry == null)) { - return; - } - - if (MessageDialog.openQuestion(shell, "Confirm Delete", - "Are you sure you want to delete contact '" - + this.rosterEntry.getName() + "' ('" - + this.rosterEntry.getUser() + "')?")) { - - try { - Saros.getDefault().removeContact(this.rosterEntry); - } catch (XMPPException e) { - e.printStackTrace(); - } - } - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - Object selected = selection.getFirstElement(); - - if ((selection.size() == 1) && (selected instanceof RosterEntry)) { - this.rosterEntry = (RosterEntry) selected; - setEnabled(true); - } else { - this.rosterEntry = null; - setEnabled(false); - } - - // TODO disable if user == self - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/FollowModeAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/FollowModeAction.java deleted file mode 100644 index f077c090f1f5b39063d10eea4f352cd61ddd91cb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/FollowModeAction.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class FollowModeAction extends Action implements ISessionListener { - - private boolean isFollowMode = false; - - public FollowModeAction() { - super(); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/monitor_add.png")); - setToolTipText("Enable/disable follow mode"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - setFollowMode(!getFollowMode()); - } - - public boolean getFollowMode() { - return this.isFollowMode; - } - - public void setFollowMode(boolean isFollowMode) { - this.isFollowMode = isFollowMode; - EditorManager.getDefault().setEnableFollowing(isFollowMode); - updateEnablement(); - } - - public void sessionStarted(ISharedProject session) { - // Automatically start follow mode at the beginning of a session if - // Auto-Follow-Mode is enabled. - if (Saros.getDefault().getPreferenceStore().getBoolean( - PreferenceConstants.AUTO_FOLLOW_MODE)) { - setFollowMode(true); - } - updateEnablement(); - } - - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - setEnabled(Saros.getDefault().getSessionManager().getSharedProject() != null); - setChecked(getFollowMode()); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/GiveDriverRoleAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/GiveDriverRoleAction.java deleted file mode 100644 index d3fde4f460a6b341d8144ec998f201484b2b5f48..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/GiveDriverRoleAction.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class GiveDriverRoleAction extends SelectionProviderAction implements - ISharedProjectListener, ISessionListener { - - private User selectedUser; - - public GiveDriverRoleAction(ISelectionProvider provider) { - super(provider, "Give driver role"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/user_edit.png")); - setToolTipText("Give the driver role to this user"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablemnet(); - } - - @Override - public void run() { - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - project.setDriver(this.selectedUser, false); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - this.selectedUser = (selection.size() == 1) ? (User) selection - .getFirstElement() : null; - - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - session.addListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private void updateEnablemnet() { - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - - boolean enabled = ((project != null) && (this.selectedUser != null) - && project.isHost() && !project.isDriver(this.selectedUser)); - setEnabled(enabled); - // setEnabled(project != null && (project.isDriver() /*|| - // project.isHost()*/) - // && selectedUser != null && - // !project.getDriver().equals(selectedUser)); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/InviteAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/InviteAction.java deleted file mode 100644 index 3fcfd21c3e3d8153cad133f5136b8a16dd119c98..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/InviteAction.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * @author rdjemili - */ -public class InviteAction extends SelectionProviderAction implements - ISessionListener { - - private RosterEntry selectedEntry; - - public InviteAction(ISelectionProvider provider) { - super(provider, "Invite user to shared project.."); - selectionChanged((IStructuredSelection) provider.getSelection()); - - setToolTipText("Start a IM messaging session with this user"); - setImageDescriptor(SarosUI - .getImageDescriptor("icons/transmit_blue.png")); - - Saros.getDefault().getSessionManager().addSessionListener(this); - } - - @Override - public void run() { - JID jid = new JID(this.selectedEntry.getUser()); - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - ISharedProject project = sessionManager.getSharedProject(); - - project.startInvitation(jid); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - if ((selection.size() == 1) - && (selection.getFirstElement() instanceof RosterEntry)) { - this.selectedEntry = (RosterEntry) selection.getFirstElement(); - } else { - this.selectedEntry = null; - } - - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - JID jid = (this.selectedEntry == null) ? null : new JID( - this.selectedEntry.getUser()); - - setEnabled((getSharedProject() != null) - && (this.selectedEntry != null) - && (getSharedProject().getParticipant(jid) == null) - && (getSharedProject().isHost() || getSharedProject() - .isDriver())); - } - - private ISharedProject getSharedProject() { - return Saros.getDefault().getSessionManager().getSharedProject(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/JumpToDriverPositionAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/JumpToDriverPositionAction.java deleted file mode 100644 index 179f402ed5642cf6f0c04d1818948deb8d213f32..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/JumpToDriverPositionAction.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class JumpToDriverPositionAction extends Action implements - ISessionListener { - - public JumpToDriverPositionAction() { - setToolTipText("Jump to position of driver."); - setImageDescriptor(SarosUI.getImageDescriptor("icons/table_edit.png")); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - EditorManager.getDefault().openDriverEditor(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - setEnabled(getSharedProject() != null); - } - - private ISharedProject getSharedProject() { - return Saros.getDefault().getSessionManager().getSharedProject(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/LeaveSessionAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/LeaveSessionAction.java deleted file mode 100644 index 0bc6c86a45fa73e7f59900e339b2cdefa8b75e18..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/LeaveSessionAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * Leaves the current Saros session. Is deactivated if there is no running - * session. - * - * @author rdjemili - */ -public class LeaveSessionAction extends Action implements ISessionListener { - - public LeaveSessionAction() { - setToolTipText("Leave the session"); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/door_open.png")); - - LeaveSessionAction.getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - try { - LeaveSessionAction.getSessionManager().leaveSession(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - setEnabled(LeaveSessionAction.getSessionManager().getSharedProject() != null); - } - - private static ISessionManager getSessionManager() { - return Saros.getDefault().getSessionManager(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/MessagingAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/MessagingAction.java deleted file mode 100644 index bf77e93a99cce5fd99f94a9a7e2b069a6b452d21..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/MessagingAction.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.apache.log4j.Logger; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class MessagingAction extends SelectionProviderAction { - - private static Logger logger = Logger.getLogger(MessagingAction.class); - - public MessagingAction(ISelectionProvider provider) { - super(provider, "Send instant message.."); - selectionChanged((IStructuredSelection) provider.getSelection()); - - setToolTipText("Start a IM session with this user"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/comment.png")); - } - - @Override - public void run() { - Saros.getDefault().getMessagingManager(); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - Object selected = selection.getFirstElement(); - - if ((selection.size() == 1) && (selected instanceof RosterEntry)) { - setEnabled(true); - } else { - setEnabled(false); - } - - // TODO disable if user == self - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewAccountAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewAccountAction.java deleted file mode 100644 index a458569c13b6e8a2591bbc471f456ae7c409a98d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewAccountAction.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.ui.wizards.CreateAccountWizard; - -public class NewAccountAction implements IWorkbenchWindowActionDelegate { - private IWorkbenchWindow window; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate - */ - public void run(IAction action) { - try { - Shell shell = this.window.getShell(); - new WizardDialog(shell, new CreateAccountWizard(true, true, true)) - .open(); - } catch (Exception e) { - Saros.log("Could not create new Account.", e); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate - */ - public void init(IWorkbenchWindow window) { - this.window = window; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate - */ - public void selectionChanged(IAction action, ISelection selection) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate - */ - public void dispose() { - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewContactAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewContactAction.java deleted file mode 100644 index 155b3e00f1125a4ebbff95372b2db164ee5b0c84..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewContactAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.jivesoftware.smack.XMPPConnection; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.Saros.ConnectionState; -import de.fu_berlin.inf.dpp.net.IConnectionListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; -import de.fu_berlin.inf.dpp.ui.wizards.AddContactWizard; - -public class NewContactAction extends Action implements IConnectionListener { - - public NewContactAction() { - setToolTipText("Add a new contact"); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/user_add.png")); - - Saros.getDefault().addListener(this); - updateEnablement(); - } - - @Override - public void run() { - Shell shell = Display.getDefault().getActiveShell(); - new WizardDialog(shell, new AddContactWizard()).open(); - } - - public void connectionStateChanged(XMPPConnection connection, - ConnectionState newState) { - updateEnablement(); - } - - private void updateEnablement() { - setEnabled(Saros.getDefault().isConnected()); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewSessionAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewSessionAction.java deleted file mode 100644 index f6a69ebe13a2decd28d2d77436dd9bcfb2a36bff..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/NewSessionAction.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.project.ISessionManager; - -/** - * Start to share a project (a "session"). - * - * @author rdjemili - * - */ -public class NewSessionAction implements IObjectActionDelegate { - - private IProject selectedProject; - - /* - * (non-Javadoc) Defined in IActionDelegate - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - } - - /* - * (non-Javadoc) Defined in IActionDelegate - */ - public void run(IAction action) { - try { - ISessionManager sm = Saros.getDefault().getSessionManager(); - sm.startSession(this.selectedProject); - } catch (final XMPPException e) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - ErrorDialog.openError( - Display.getDefault().getActiveShell(), - "Error Starting Session", - "Session could not be started", new Status( - IStatus.ERROR, "de.fu_berlin.inf.dpp", - IStatus.ERROR, e.getMessage(), e)); - } - }); - } - } - - /* - * (non-Javadoc) Defined in IActionDelegate - */ - public void selectionChanged(IAction action, ISelection selection) { - this.selectedProject = getProject(selection); - - ISessionManager sm = Saros.getDefault().getSessionManager(); - boolean running = sm.getSharedProject() != null; - boolean connected = Saros.getDefault().isConnected(); - - // TODO This action should rather connect if not already connected - // instead of being disabled. - - action.setEnabled(connected && !running - && (this.selectedProject != null) - && this.selectedProject.isAccessible()); - } - - private IProject getProject(ISelection selection) { - Object element = ((IStructuredSelection) selection).getFirstElement(); - if (element instanceof IProject) { - return (IProject) element; - } else if (element instanceof IJavaProject) { - return ((IJavaProject) element).getProject(); - } - - return null; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/OpenInviteInterface.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/OpenInviteInterface.java deleted file mode 100644 index f877222976d2e5c8c6e241dfb89bcd9dbee37cec..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/OpenInviteInterface.java +++ /dev/null @@ -1,62 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class OpenInviteInterface extends Action implements - ISharedProjectListener, ISessionListener { - - public OpenInviteInterface() { - super(); - setImageDescriptor(SarosUI.getImageDescriptor("/icons/invites.png")); - setToolTipText("Open invitation interface"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - Saros.getDefault().getSessionManager().getSharedProject() - .startInvitation(null); - } - - public void sessionStarted(ISharedProject session) { - session.addListener(this); - updateEnablement(); - } - - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - updateEnablement(); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - private void updateEnablement() { - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - setEnabled((project != null) && project.isDriver()); - } - - public void driverChanged(JID driver, boolean replicated) { - updateEnablement(); - } - - public void userJoined(JID user) { - // ignore - } - - public void userLeft(JID user) { - // ignore - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RemoveAllDriverRoleAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RemoveAllDriverRoleAction.java deleted file mode 100644 index 70e069a46d0f777dadb4dd417ce2bfc2493d232a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RemoveAllDriverRoleAction.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.action.Action; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.User.UserRole; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * this action remove all remote driver from project. Only the project host has - * the driver role after this action is executed. - * - * @author orieger - * - */ -public class RemoveAllDriverRoleAction extends Action implements - ISharedProjectListener, ISessionListener { - - public RemoveAllDriverRoleAction() { - super("Take remote user driver roles"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/user_edit.png")); - setToolTipText("Take remote driver roles"); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablement(); - } - - @Override - public void run() { - // getSharedProject().setDriver(getSharedProject().getHost(), false); - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - for (User user : project.getParticipants()) { - - if ((user.getUserRole() == UserRole.DRIVER) - && !project.getHost().equals(user)) { - project.removeDriver(user, false); - } - } - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - session.addListener(this); - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - updateEnablement(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private void updateEnablement() { - ISharedProject project = getSharedProject(); - boolean enabled = ((project != null) && project.isHost()); - setEnabled(enabled); - // setEnabled(project != null && project.isHost() && - // !project.isDriver()); - } - - private ISharedProject getSharedProject() { - return Saros.getDefault().getSessionManager().getSharedProject(); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RenameContactAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RenameContactAction.java deleted file mode 100644 index bf30d7aeb75e0d8ccb9166e6c6c9e7121c1557b1..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/RenameContactAction.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.dialogs.IInputValidator; -import org.eclipse.jface.dialogs.InputDialog; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -/** - * Renames the nickname of the selected roster entry. - * - * @author rdjemili - */ -public class RenameContactAction extends SelectionProviderAction { - private class InputValidator implements IInputValidator { - public String isValid(String newText) { - return null; - } - } - - private RosterEntry rosterEntry; - - public RenameContactAction(ISelectionProvider provider) { - super(provider, "Rename..."); - selectionChanged((IStructuredSelection) provider.getSelection()); - - setToolTipText("Set the nickname of this contact."); - } - - @Override - public void run() { - Shell shell = Display.getDefault().getActiveShell(); - if ((shell == null) || (this.rosterEntry == null)) { - return; - } - - InputDialog dialog = new InputDialog(shell, "Set new nickname", - "Enter the new nickname of this contact '" - + this.rosterEntry.getName() + "' ('" - + this.rosterEntry.getUser() + "'):", this.rosterEntry - .getName(), new InputValidator()); - - if (dialog.open() == Window.OK) { - String name = (dialog.getValue().length() == 0) ? "" : dialog - .getValue(); - this.rosterEntry.setName(name); - } - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - Object selected = selection.getFirstElement(); - - if ((selection.size() == 1) && (selected instanceof RosterEntry)) { - this.rosterEntry = (RosterEntry) selected; - setEnabled(true); - } else { - this.rosterEntry = null; - setEnabled(false); - } - - // TODO disable if user == self - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/SkypeAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/SkypeAction.java deleted file mode 100644 index eb2d9242527b6f95eb9986c25fd44508cf5563a7..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/SkypeAction.java +++ /dev/null @@ -1,58 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.text.Region; -import org.eclipse.jface.text.hyperlink.URLHyperlink; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.jivesoftware.smack.RosterEntry; - -import de.fu_berlin.inf.dpp.SkypeManager; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * A action for skyping other users. - * - * @author rdjemili - */ -public class SkypeAction extends SelectionProviderAction { - private String skypeURL; - - public SkypeAction(ISelectionProvider provider) { - super(provider, "Skype this user"); - setEnabled(false); - - setToolTipText("Start a Skype-VoIP session with this user"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/telephone.png")); - } - - @Override - public void run() { - if (this.skypeURL == null) { - return; - } - - URLHyperlink link = new URLHyperlink(new Region(0, 0), this.skypeURL); - link.open(); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - final Object item = selection.getFirstElement(); - - if ((selection.size() != 1) || !(item instanceof RosterEntry)) { - setEnabled(false); - - } else { - new Thread(new Runnable() { - public void run() { - setEnabled(false); - SkypeManager sm = SkypeManager.getDefault(); - SkypeAction.this.skypeURL = sm - .getSkypeURL((RosterEntry) item); - setEnabled(SkypeAction.this.skypeURL != null); - } - }).start(); - } - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/TakeDriverRoleAction.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/TakeDriverRoleAction.java deleted file mode 100644 index f428f86e2db71d212e2536f3c66748a4fd0b517f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/actions/TakeDriverRoleAction.java +++ /dev/null @@ -1,113 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.actions; - -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.actions.SelectionProviderAction; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.User; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.net.JID; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.project.ISharedProjectListener; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -public class TakeDriverRoleAction extends SelectionProviderAction implements - ISharedProjectListener, ISessionListener { - private User selectedUser; - - public TakeDriverRoleAction(ISelectionProvider provider) { - super(provider, "Take driver role"); - setImageDescriptor(SarosUI.getImageDescriptor("icons/user.png")); - setToolTipText("Take the driver role from this user."); - - Saros.getDefault().getSessionManager().addSessionListener(this); - updateEnablemnet(); - } - - @Override - public void run() { - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - // project.setDriver(selectedUser, false); - project.removeDriver(this.selectedUser, false); - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - this.selectedUser = (selection.size() == 1) ? (User) selection - .getFirstElement() : null; - - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionStarted(ISharedProject session) { - session.addListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void sessionEnded(ISharedProject session) { - session.removeListener(this); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener - */ - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void driverChanged(JID driver, boolean replicated) { - updateEnablemnet(); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userJoined(JID user) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISharedProjectListener - */ - public void userLeft(JID user) { - // ignore - } - - private void updateEnablemnet() { - ISharedProject project = Saros.getDefault().getSessionManager() - .getSharedProject(); - - boolean enabled = ((project != null) && (this.selectedUser != null) - && project.isHost() - && !project.getHost().equals(this.selectedUser) && project - .isDriver(this.selectedUser)); - setEnabled(enabled); - // setEnabled(project != null && (project.isDriver() /*|| - // project.isHost()*/) - // && selectedUser != null && - // !project.getDriver().equals(selectedUser)); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/decorators/SharedProjectDecorator.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/decorators/SharedProjectDecorator.java deleted file mode 100644 index f280a2dc93872b2b240233eef7b46ab098a8a02a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/decorators/SharedProjectDecorator.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.decorators; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IDecoration; -import org.eclipse.jface.viewers.ILabelProviderListener; -import org.eclipse.jface.viewers.ILightweightLabelDecorator; -import org.eclipse.jface.viewers.LabelProviderChangedEvent; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.editor.EditorManager; -import de.fu_berlin.inf.dpp.editor.ISharedEditorListener; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.project.ISessionListener; -import de.fu_berlin.inf.dpp.project.ISessionManager; -import de.fu_berlin.inf.dpp.project.ISharedProject; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * Decorates Shared Project files. - * - * @see ILightweightLabelDecorator - */ -public class SharedProjectDecorator implements ILightweightLabelDecorator, - ISessionListener, ISharedEditorListener { - - private final ImageDescriptor activeDescriptor = SarosUI - .getImageDescriptor("icons/bullet_green.png"); // NON-NLS-1 - - private final ImageDescriptor passiveDescriptor = SarosUI - .getImageDescriptor("icons/bullet_yellow.png"); // NON-NLS-1 - - private ISharedProject sharedProject; - - private final List<ILabelProviderListener> listeners = new ArrayList<ILabelProviderListener>(); - - public SharedProjectDecorator() { - ISessionManager sessionManager = Saros.getDefault().getSessionManager(); - sessionManager.addSessionListener(this); - - if (sessionManager.getSharedProject() != null) { - sessionStarted(sessionManager.getSharedProject()); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate - */ - public void decorate(Object element, IDecoration decoration) { - if (this.sharedProject == null) { - return; - } - - IFile file = (IFile) element; // enablement ensures that we only get - // IFile's - if (!this.sharedProject.getProject().equals(file.getProject())) { - return; - } - - IPath path = file.getProjectRelativePath(); - if (path != null) { - EditorManager editorManager = EditorManager.getDefault(); - if (path.equals(editorManager.getActiveDriverEditor())) { - decoration.addOverlay(this.activeDescriptor, - IDecoration.TOP_LEFT); - } else if (editorManager.getDriverEditors().contains(path)) { - decoration.addOverlay(this.passiveDescriptor, - IDecoration.TOP_LEFT); - } - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener - */ - public void addListener(ILabelProviderListener listener) { - this.listeners.add(listener); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener - */ - public void removeListener(ILabelProviderListener listener) { - this.listeners.remove(listener); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener#sessionStarted - */ - public void sessionStarted(ISharedProject session) { - this.sharedProject = session; - EditorManager.getDefault().addSharedEditorListener(this); - - updateDecorators(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.listeners.ISessionListener#sessionEnded - */ - public void sessionEnded(ISharedProject session) { - if (this.sharedProject != null) { - EditorManager.getDefault().removeSharedEditorListener(this); - } - - this.sharedProject = null; - updateDecorators(null); - } - - public void invitationReceived(IIncomingInvitationProcess process) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void activeDriverEditorChanged(IPath path, boolean replicated) { - updateDecorators(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverEditorRemoved(IPath path, boolean replicated) { - updateDecorators(null); - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.project.ISharedProjectListener - */ - public void driverEditorSaved(IPath path, boolean replicated) { - // ignore - } - - /* - * (non-Javadoc) - * - * @see de.fu_berlin.inf.dpp.editor.ISharedEditorListener - */ - public void followModeChanged(boolean enabled) { - // ignore - } - - private void updateDecorators(final Object[] updateElements) { - // Set<IFile> changedFiles = new HashSet<IFile>(); - // - // if (sharedProject != null) { - // if (sharedProject.getActiveDriverEditor() != null) { - // activeFile = sharedProject.getProject().getFile( - // sharedProject.getActiveDriverEditor()); - // - // } else if (sharedProject.getDriverEditors() != null) { - // passiveFiles = - // } - // } - // - // final Object[] updateElements; - // if (activeDriverFile == null) { - // updateElements = new Object[]{activeFile}; - // } else if (activeFile == null) { - // updateElements = new Object[]{activeDriverFile}; - // } else { - // updateElements = new Object[]{activeDriverFile, activeFile}; - // } - // - // activeDriverFile = activeFile; - - Display.getDefault().asyncExec(new Runnable() { - public void run() { - LabelProviderChangedEvent event = new LabelProviderChangedEvent( - SharedProjectDecorator.this, updateElements); - - for (ILabelProviderListener listener : SharedProjectDecorator.this.listeners) { - listener.labelProviderChanged(event); - } - } - }); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/AddContactWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/AddContactWizard.java deleted file mode 100644 index e00bcefa5b6aae21f3ea454a17d4cfb0422b847f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/AddContactWizard.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.Saros; -import de.fu_berlin.inf.dpp.net.JID; - -public class AddContactWizard extends Wizard { - - private class AddContactPage extends WizardPage { - private Text idText; - - private Text nicknameText; - - protected AddContactPage() { - super("create"); - - setTitle("New Contact"); - setDescription("Add a new contact to your Jabber roster"); - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - - composite.setLayout(new GridLayout(2, false)); - - Label idLabel = new Label(composite, SWT.NONE); - idLabel.setText("Jabber ID"); - - this.idText = new Text(composite, SWT.BORDER); - this.idText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - - Label nicknameLabel = new Label(composite, SWT.NONE); - nicknameLabel.setText("Nickname"); - - this.nicknameText = new Text(composite, SWT.BORDER); - this.nicknameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, - true, false)); - - hookListeners(); - updateNextEnablement(); - - setControl(composite); - } - - public JID getJID() { - return new JID(this.idText.getText()); - } - - public String getNickname() { - return this.nicknameText.getText(); - } - - private void hookListeners() { - ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateNextEnablement(); - } - }; - - this.idText.addModifyListener(listener); - this.nicknameText.addModifyListener(listener); - } - - private void updateNextEnablement() { - boolean done = (this.idText.getText().length() > 0) - && (this.nicknameText.getText().length() > 0); - - setPageComplete(done); - } - } - - private final AddContactPage page = new AddContactPage(); - - public AddContactWizard() { - setWindowTitle("New Contact"); - setHelpAvailable(false); - } - - @Override - public void addPages() { - addPage(this.page); - } - - @Override - public boolean performFinish() { - try { - Saros.getDefault().addContact(this.page.getJID(), - this.page.getNickname(), null); - return true; - - } catch (XMPPException e) { - // contact not found - if (e.getMessage().contains("item-not-found")) - this.page.setMessage("Contact not found!", - IMessageProvider.ERROR); - else - this.page.setMessage(e.getMessage(), IMessageProvider.ERROR); - } - - return false; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ConfigurationWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ConfigurationWizard.java deleted file mode 100644 index c6707358193cd86d95f1348d6acb1cf068e81e1e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ConfigurationWizard.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.util.LinkedList; -import java.util.List; - -import org.eclipse.jface.wizard.Wizard; - -/** - * A wizard to configure Saros. - * - */ -public class ConfigurationWizard extends Wizard { - - public ConfigurationWizard() { - setWindowTitle("Saros Configuration"); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - - this.wizards.add(new RegisterAccountPage(false, false, true)); - this.wizards.add(new NetworkSettingsPage()); - } - - List<IWizardPage2> wizards = new LinkedList<IWizardPage2>(); - - @Override - public void addPages() { - for (IWizardPage2 wizard : this.wizards) { - addPage(wizard); - } - } - - @Override - public boolean performFinish() { - - for (IWizardPage2 wizard : this.wizards) { - if (!wizard.performFinish()) { - getContainer().showPage(wizard); - return false; - } - } - - return true; - } - - @Override - public boolean performCancel() { - return true; - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/CreateAccountWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/CreateAccountWizard.java deleted file mode 100644 index 43b4f89047a3723bd7fc512f68009c796b3a1772..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/CreateAccountWizard.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * (c) Christopher Oezbek - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - -import de.fu_berlin.inf.dpp.Saros; - -/** - * An wizard that is used to create Jabber accounts. - * - * @author rdjemili - * @author coezbek - */ -public class CreateAccountWizard extends Wizard { - - private final RegisterAccountPage page; - - public CreateAccountWizard(boolean createAccount, - boolean showStoreInPrefsButton, boolean storeInPrefsDefault) { - - if (createAccount) { - setWindowTitle("Create New User Account"); - } else { - setWindowTitle("Enter User Account"); - } - this.page = new RegisterAccountPage(createAccount, - showStoreInPrefsButton, storeInPrefsDefault); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - public String getServer() { - return this.server; - } - - public String getUsername() { - return this.username; - } - - public String getPassword() { - return this.password; - } - - String server, password, username; - - @Override - public void addPages() { - addPage(this.page); - } - - @Override - public boolean performFinish() { - if (this.page.performFinish()) { - this.server = this.page.getServer(); - this.username = this.page.getUsername(); - this.password = this.page.getPassword(); - - try { - // Open Roster so that a participant can be invited - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - window.getActivePage().showView( - "de.fu_berlin.inf.dpp.ui.RosterView", null, - IWorkbenchPage.VIEW_ACTIVATE); - } catch (PartInitException e) { - Saros.getDefault().getLog().log( - new Status(IStatus.ERROR, Saros.SAROS, IStatus.ERROR, - "Could not activate Roster View", e)); - } - return true; - } else { - return false; - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/EnterNamePage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/EnterNamePage.java deleted file mode 100644 index 668804bf31561883030e7cfbcf7bec77bf2f311f..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/EnterNamePage.java +++ /dev/null @@ -1,446 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ContainerSelectionDialog; - -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.State; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.TransferMode; -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * A wizard page that allows to enter the new project name or to choose to - * overwrite the project selected by the {@link ProjectSelectionPage}. - */ -class EnterNamePage extends WizardPage { - - private final JoinSessionWizard joinSessionWizard; - - private Label newProjectNameLabel; - private Button projCopy; - private Text newProjectNameText; - private Button copyCheckbox; - private Text copyToBeforeUpdateText; - - private Button projUpd; - private Text updateProjectText; - private Button browseUpdateProjectButton; - - private Label updateProjectStatusResult; - private Label updateProjectNameLabel; - private Button scanWorkspaceProjectsButton; - - /* project for update or base project for copy into new project */ - private IProject similarProject; - - protected EnterNamePage(JoinSessionWizard joinSessionWizard) { - super("namePage"); - this.joinSessionWizard = joinSessionWizard; - setPageComplete(false); - - setTitle("Select local project."); - - setConnectionStatus(); - } - - protected void setUpdateProject(IProject project) { - this.similarProject = project; - - if (project == null) { - - this.updateProjectStatusResult - .setText("No matching project found. Project download will start from scratch."); - - } else { - - this.updateProjectStatusResult.setText("Your project " - + project.getName() - + " matches with " - + JoinSessionWizardUtils.getMatch( - this.joinSessionWizard.process.getRemoteFileList(), - project) + "% accuracy.\n" - + "This fact will used to shorten the process of " - + "downloading the remote project."); - - this.updateProjectText.setText(this.similarProject.getName()); - - } - updatePageComplete(); - } - - /** - * get transfer mode and set header information of the wizard. - */ - private void setConnectionStatus() { - if (this.joinSessionWizard.process.getTransferMode() == TransferMode.IBB) { - setDescription("Attention: No direct connection avialable!" - + '\n' - + "Suggestion: Update an existing project or copy resources from another project."); - setImageDescriptor(SarosUI - .getImageDescriptor("icons/ibb_connection.png")); - } else { - setDescription("P2P Connection with Jingle available.\nThis means that sharing a project from scratch will be fast."); - setImageDescriptor(SarosUI - .getImageDescriptor("icons/jingle_connection.png")); - } - } - - /** - * create components of create new project area for enternamepage wizard. - * - * @param workArea - * composite of appropriate wizard - */ - private void createNewProjectGroup(Composite workArea) { - - Composite projectGroup = new Composite(workArea, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - projectGroup.setLayout(layout); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - - projectGroup.setLayoutData(data); - - this.newProjectNameLabel = new Label(projectGroup, SWT.NONE); - this.newProjectNameLabel.setText("Project name"); - - this.newProjectNameText = new Text(projectGroup, SWT.BORDER); - this.newProjectNameText.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - this.newProjectNameText.setFocus(); - this.newProjectNameText.setText(JoinSessionWizardUtils - .findProjectNameProposal(this.joinSessionWizard.process - .getProjectName())); - } - - /** - * create components of update area for enternamepage wizard. - * - * @param workArea - * composite of appropriate wizard - */ - private void createUpdateProjectGroup(Composite workArea) { - - Composite projectGroup = new Composite(workArea, SWT.NONE); - - GridLayout layout = new GridLayout(); - layout.numColumns = 4; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - projectGroup.setLayout(layout); - - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalIndent = 10; - projectGroup.setLayoutData(data); - - this.updateProjectNameLabel = new Label(projectGroup, SWT.NONE); - this.updateProjectNameLabel.setText("Project name"); - this.updateProjectNameLabel.setEnabled(false); - - this.updateProjectText = new Text(projectGroup, SWT.BORDER); - this.updateProjectText.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - this.updateProjectText.setFocus(); - this.updateProjectText.setEnabled(false); - this.updateProjectText.setText(""); - - this.browseUpdateProjectButton = new Button(projectGroup, SWT.PUSH); - this.browseUpdateProjectButton.setText("Browse"); - setButtonLayoutData(this.browseUpdateProjectButton); - this.browseUpdateProjectButton - .addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - IProject project = getProjectDialog("Select project for update."); - if (project != null) { - EnterNamePage.this.updateProjectText - .setText(project.getName()); - } - } - }); - - Composite optionsGroup = new Composite(workArea, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginLeft = 20; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 0; - - optionsGroup.setLayout(layout); - optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - this.copyCheckbox = new Button(optionsGroup, SWT.CHECK); - this.copyCheckbox - .setText("Create copy for working distributed. New project name:"); - this.copyCheckbox.setSelection(false); - this.copyCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateEnabled(); - } - }); - - this.copyToBeforeUpdateText = new Text(optionsGroup, SWT.BORDER); - this.copyToBeforeUpdateText.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); - this.copyToBeforeUpdateText.setFocus(); - this.copyToBeforeUpdateText.setText(JoinSessionWizardUtils - .findProjectNameProposal(this.joinSessionWizard.process - .getProjectName())); - - Composite scanGroup = new Composite(workArea, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.makeColumnsEqualWidth = false; - layout.marginWidth = 10; - scanGroup.setLayout(layout); - data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_VERTICAL); - data.verticalIndent = 10; - data.horizontalIndent = 10; - scanGroup.setLayoutData(data); - - this.scanWorkspaceProjectsButton = new Button(scanGroup, SWT.PUSH); - this.scanWorkspaceProjectsButton.setText("Scan workspace"); - this.scanWorkspaceProjectsButton - .setToolTipText("Scan workspace for similar projects."); - setButtonLayoutData(this.scanWorkspaceProjectsButton); - - this.scanWorkspaceProjectsButton - .addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - setUpdateProject(JoinSessionWizardUtils - .getBestScanMatch(EnterNamePage.this.joinSessionWizard.process)); - } - }); - - this.updateProjectStatusResult = new Label(scanGroup, SWT.NONE); - this.updateProjectStatusResult.setText("No scan results."); - this.updateProjectStatusResult.setLayoutData(new GridData( - GridData.FILL_HORIZONTAL | GridData.GRAB_VERTICAL)); - } - - /** - * browse dialog to select project for copy. - */ - public IProject getProjectDialog(String title) { - ContainerSelectionDialog dialog = new ContainerSelectionDialog( - getShell(), null, false, title); - - dialog.open(); - Object[] result = dialog.getResult(); - - if ((result == null) && (result.length == 0)) { - return null; - } - - return ((IResource) result[0]).getProject(); - } - - protected void createScanStatusProject(Composite workArea) { - - } - - protected void requestRemoteFileList() { - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - EnterNamePage.this.joinSessionWizard.process - .requestRemoteFileList(monitor); - } - }); - } catch (InvocationTargetException e) { - JoinSessionWizard.log.log(Level.WARNING, - "Exception while requesting remote file list", e); - } catch (InterruptedException e) { - JoinSessionWizard.log.log(Level.FINE, - "Request of remote file list canceled/interrupted", e); - } - } - - public void createControl(Composite parent) { - - if (this.joinSessionWizard.process.getState() == State.CANCELED) { - return; - } - - /* wait for getting project file list. */ - requestRemoteFileList(); - - if (this.joinSessionWizard.process.getRemoteFileList() == null) { - getShell().close(); - } - - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout()); - GridData gridData = new GridData(GridData.FILL_VERTICAL); - gridData.verticalIndent = 20; - composite.setLayoutData(gridData); - - this.projCopy = new Button(composite, SWT.RADIO); - this.projCopy.setText("Create new project"); - this.projCopy.setSelection(true); - - createNewProjectGroup(composite); - - this.projUpd = new Button(composite, SWT.RADIO); - this.projUpd.setText("Use existing project"); - - createUpdateProjectGroup(composite); - - attachListeners(); - setControl(composite); - - updateEnabled(); - } - - public boolean isUpdateSelected() { - return this.projUpd.getSelection(); - } - - private void attachListeners() { - - ModifyListener m = new ModifyListener() { - public void modifyText(ModifyEvent e) { - updatePageComplete(); - } - }; - - this.newProjectNameText.addModifyListener(m); - this.updateProjectText.addModifyListener(m); - this.copyToBeforeUpdateText.addModifyListener(m); - - SelectionAdapter s = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateEnabled(); - } - }; - - this.projCopy.addSelectionListener(s); - - s.widgetSelected(null); - } - - public void setPageCompleteTargetProject(String newText) { - - if (newText.length() == 0) { - setMessage(null); - setErrorMessage("Please set a project name"); - setPageComplete(false); - } else { - if (JoinSessionWizardUtils.projectIsUnique(newText)) { - setMessage(null); - setErrorMessage(null); - setPageComplete(true); - } else { - setMessage(null); - setErrorMessage("A project with this name already exists"); - setPageComplete(false); - } - } - } - - protected void updateEnabled() { - - boolean updateSelected = !this.projCopy.getSelection(); - boolean copySelected = this.copyCheckbox.getSelection(); - - this.newProjectNameText.setEnabled(!updateSelected); - this.newProjectNameLabel.setEnabled(!updateSelected); - - this.updateProjectText.setEnabled(updateSelected); - this.browseUpdateProjectButton.setEnabled(updateSelected); - this.updateProjectNameLabel.setEnabled(updateSelected); - this.copyCheckbox.setEnabled(updateSelected); - this.copyToBeforeUpdateText.setEnabled(updateSelected && copySelected); - this.scanWorkspaceProjectsButton.setEnabled(updateSelected); - this.updateProjectStatusResult.setEnabled(updateSelected); - - updatePageComplete(); - } - - protected void updatePageComplete() { - - if (!isUpdateSelected()) { - - setPageCompleteTargetProject(this.newProjectNameText.getText()); - - } else { - String newText = this.updateProjectText.getText(); - - if (newText.length() == 0) { - setMessage(null); - setErrorMessage("Please set a project name to update from or press 'Scan Workspace' to find best matching existing project"); - setPageComplete(false); - - } else { - if (!JoinSessionWizardUtils.projectIsUnique(newText)) { - - if (this.copyCheckbox.getSelection()) { - setPageCompleteTargetProject(this.copyToBeforeUpdateText - .getText()); - } else { - setMessage(null); - setErrorMessage(null); - setPageComplete(true); - } - - } else { - setMessage(null); - setErrorMessage("No project exists with this name to update from"); - setPageComplete(false); - } - } - } - } - - public String getTargetProjectName() { - if (isUpdateSelected()) { - - if (this.copyCheckbox.getSelection()) { - return this.copyToBeforeUpdateText.getText(); - } else { - return null; - } - } else { - return this.newProjectNameText.getText(); - } - } - - public IProject getSourceProject() { - - if (isUpdateSelected()) { - if (this.copyCheckbox.getSelection()) { - return ResourcesPlugin.getWorkspace().getRoot().getProject( - this.copyToBeforeUpdateText.getText()); - } else { - return ResourcesPlugin.getWorkspace().getRoot().getProject( - this.updateProjectText.getText()); - } - } else { - return null; - } - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/IWizardPage2.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/IWizardPage2.java deleted file mode 100644 index df28f766fbf3493f93695d28fea21b1953eb822d..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/IWizardPage2.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.IWizardPage; - -// TODO CJ: Review needed: Why this interface is needed??? -public interface IWizardPage2 extends IWizardPage { - - public boolean performFinish(); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizard.java deleted file mode 100644 index 04683188a75064668408b48f5f2a3695c22bf157..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizard.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * DPP - Serious Distributed Pair Programming - * (c) Freie Universitaet Berlin - Fachbereich Mathematik und Informatik - 2006 - * (c) Riad Djemili - 2006 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 1, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.IInvitationUI; -import de.fu_berlin.inf.dpp.invitation.IInvitationProcess.State; -import de.fu_berlin.inf.dpp.net.JID; - -/** - * A wizard that guides the user through an incoming invitiation process. - * - * Todo: - * - * o Automatically switch to follow mode - * - * o Suggest if the project is a CVS project that the user checks it out and - * offers an option to transfer the settings - * - * @author rdjemili - */ -public class JoinSessionWizard extends Wizard { - - static Logger log = Logger.getLogger(JoinSessionWizard.class.getName()); - - ShowDescriptionPage descriptionPage; - - EnterNamePage namePage; - - WizardDialogAccessable myWizardDlg; - - IIncomingInvitationProcess process; - - Display current; - - public JoinSessionWizard(IIncomingInvitationProcess process) { - this.process = process; - - this.current = Display.getCurrent(); - - setWindowTitle("Session Invitation"); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - public IInvitationUI getInvitationUI() { - return new IInvitationUI() { - - public void cancel(final String errorMsg, final boolean replicated) { - JoinSessionWizard.this.current.asyncExec(new Runnable() { - public void run() { - - if (errorMsg != null) { - MessageDialog.openError(getShell(), - "Invitation aborted", - "Could not complete invitation because an error occurred (" - + errorMsg + ")"); - } else { - // errorMsg == null means canceled either by us or - // peer - if (replicated) { - MessageDialog.openInformation(getShell(), - "Invitation cancelled", - "Invitation was cancelled by peer."); - } - } - JoinSessionWizard.this.myWizardDlg.close(); - } - }); - } - - public void runGUIAsynch(Runnable runnable) { - // ignored, not needed atm - } - - public void updateInvitationProgress(JID jid) { - // ignored, not needed atm - } - }; - } - - @Override - public void createPageControls(Composite pageContainer) { - this.descriptionPage.createControl(pageContainer); - // create namePage lazily - } - - @Override - public void addPages() { - this.descriptionPage = new ShowDescriptionPage(this); - this.namePage = new EnterNamePage(this); - - addPage(this.descriptionPage); - addPage(this.namePage); - } - - @Override - public boolean performFinish() { - - if (this.process.getState() == State.CANCELED) { - return true; - } - - final IProject source = this.namePage.getSourceProject(); - final String target = this.namePage.getTargetProjectName(); - - try { - getContainer().run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, InterruptedException { - - JoinSessionWizard.this.process.accept(source, target, - monitor); - } - }); - } catch (InvocationTargetException e) { - JoinSessionWizard.log.log(Level.WARNING, - "Exception while requesting remote file list", e); - } catch (InterruptedException e) { - JoinSessionWizard.log.log(Level.FINE, - "Request of remote file list canceled/interrupted", e); - } - - return true; - } - - @Override - public boolean performCancel() { - this.process.cancel(null, false); - - return super.performCancel(); - } - - public void setWizardDlg(WizardDialogAccessable wd) { - this.myWizardDlg = wd; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizardUtils.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizardUtils.java deleted file mode 100644 index 7e37661a189c6aa9767eea10e40f3ba50d1932aa..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/JoinSessionWizardUtils.java +++ /dev/null @@ -1,186 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Display; - -import de.fu_berlin.inf.dpp.FileList; -import de.fu_berlin.inf.dpp.invitation.IIncomingInvitationProcess; - -public class JoinSessionWizardUtils { - - private static Logger log = Logger.getLogger(JoinSessionWizardUtils.class - .getName()); - - public static class ScanRunner implements Runnable { - - public ScanRunner(IIncomingInvitationProcess invitationProcess) { - this.invitationProcess = invitationProcess; - } - - IIncomingInvitationProcess invitationProcess; - - boolean running; - - IProject project; - - public void run() { - this.running = true; - - ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display - .getDefault().getActiveShell()); - try { - dialog.run(true, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - - monitor.beginTask("Scanning workspace projects ... ", - IProgressMonitor.UNKNOWN); - ScanRunner.this.project = JoinSessionWizardUtils - .getLocalProject( - ScanRunner.this.invitationProcess - .getRemoteFileList(), monitor); - monitor.done(); - ScanRunner.this.running = false; - } - - }); - } catch (InvocationTargetException e) { - JoinSessionWizardUtils.log.log(Level.WARNING, "", e); - e.printStackTrace(); - } catch (InterruptedException e) { - JoinSessionWizardUtils.log.log(Level.WARNING, "", e); - e.printStackTrace(); - } - } - } - - /** - * Run the scan for the best matching project as a blocking operation. - */ - public static IProject getBestScanMatch( - IIncomingInvitationProcess invitationProcess) { - - ScanRunner runner = new ScanRunner(invitationProcess); - - Display.getDefault().syncExec(runner); - - return runner.project; - } - - public static int getMatch(FileList remoteFileList, IProject project) { - try { - return remoteFileList.match(new FileList(project)); - } catch (CoreException e) { - JoinSessionWizardUtils.log.log(Level.FINE, - "Couldn't calculate match for project " + project, e); - - return -1; - } - } - - /** - * Return the best match among all project from workspace with the given - * remote file list or null if no best match could be found. - * - * To be considered a match, projects have to match at least 80%. - */ - public static IProject getLocalProject(FileList remoteFileList, - IProgressMonitor monitor) { - - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - IProject bestMatch = null; - - // A match needs to be at least 80% for us to consider. - int bestMatchScore = 80; - - for (int i = 0; i < projects.length; i++) { - monitor.worked(1); - if (!projects[i].isOpen()) { - continue; - } - - int matchScore = JoinSessionWizardUtils.getMatch(remoteFileList, - projects[i]); - - if (matchScore > bestMatchScore) { - bestMatchScore = matchScore; - bestMatch = projects[i]; - } - } - - return bestMatch; - } - - public static boolean projectIsUnique(String name) { - - // Then check with all the projects - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - return JoinSessionWizardUtils.projectIsUnique(name, projects); - } - - public static IProject getProjectForName(String name) { - return ResourcesPlugin.getWorkspace().getRoot().getProject(name); - } - - public static boolean projectIsUnique(String name, IProject[] projects) { - - for (IProject p : projects) { - if (p.getName().equals(name)) { - return false; - } - } - return true; - } - - public static String findProjectNameProposal(String projectName) { - - // Start with the projects name - String projectProposal = projectName; - - // Then check with all the projects - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IProject[] projects = workspace.getRoot().getProjects(); - - if (JoinSessionWizardUtils.projectIsUnique(projectProposal, projects)) { - return projectProposal; - - } else { - // Name is already in use! - Pattern p = Pattern.compile("^(.*)(\\d+)$"); - Matcher m = p.matcher(projectProposal); - - int i; - // Check whether the name ends in a number or not - if (m.find()) { - projectProposal = m.group(1).trim(); - i = Integer.parseInt(m.group(2)); - } else { - i = 2; - } - - // Then find the next available number - while (!JoinSessionWizardUtils.projectIsUnique(projectProposal - + " " + i, projects)) { - i++; - } - - return projectProposal + " " + i; - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/NetworkSettingsPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/NetworkSettingsPage.java deleted file mode 100644 index 38d52020b769df9a8f5b20d9c2dddf8c885f68d2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/NetworkSettingsPage.java +++ /dev/null @@ -1,132 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -/** - * A Wizard Page for entering the Port Configuration. - * - * @author rdjemili - * - */ -public class NetworkSettingsPage extends WizardPage implements IWizardPage2 { - - protected NetworkSettingsPage() { - super("networksettings"); - } - - private Text portText, skypeText; - private Button autoText; - - public void createControl(Composite parent) { - - Composite root = new Composite(parent, SWT.NONE); - - root.setLayout(new GridLayout(2, false)); - - setTitle("Configure Network Settings"); - setDescription("Configure your network settings for use with Saros"); - - Label portDescription = new Label(root, SWT.NONE); - GridData twoColumn = new GridData(); - twoColumn.horizontalSpan = 2; - portDescription.setLayoutData(twoColumn); - portDescription - .setText("Choose your incoming port and configure your firewall to accept incoming connections over this port."); - - Label serverLabel = new Label(root, SWT.NONE); - serverLabel.setText("Port:"); - - this.portText = new Text(root, SWT.BORDER); - this.portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - - Label autoConnectDesc = new Label(root, SWT.NONE); - autoConnectDesc.setLayoutData(twoColumn); - autoConnectDesc - .setText("Should Saros automatically connect on Eclipse startup?"); - - new Label(root, SWT.NONE); - - this.autoText = new Button(root, SWT.CHECK | SWT.LEFT); - this.autoText.setText("Startup automatically."); - - Label skypeDesc = new Label(root, SWT.NONE); - skypeDesc.setLayoutData(twoColumn); - skypeDesc - .setText("Saros can send your Skype username to your peer if you provide it here"); - - Label skype = new Label(root, SWT.NONE); - skype.setText("Skype Username:"); - this.skypeText = new Text(root, SWT.BORDER); - this.skypeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - - // Set initial values - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - this.portText.setText(String.valueOf(preferences - .getInt(PreferenceConstants.FILE_TRANSFER_PORT))); - this.autoText.setSelection(preferences - .getBoolean(PreferenceConstants.AUTO_CONNECT)); - this.skypeText.setText(preferences - .getString(PreferenceConstants.SKYPE_USERNAME)); - - ModifyListener m = new ModifyListener() { - public void modifyText(ModifyEvent e) { - update(); - } - }; - - this.portText.addModifyListener(m); - - this.autoText.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - update(); - } - }); - - this.skypeText.addModifyListener(m); - - update(); - - setControl(root); - } - - private void update() { - try { - Integer.parseInt(this.portText.getText()); - setPageComplete(true); - setErrorMessage(null); - } catch (Exception e) { - setPageComplete(false); - setErrorMessage("Port should a number (for instance 7777)"); - } - } - - public boolean performFinish() { - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - preferences.setValue(PreferenceConstants.FILE_TRANSFER_PORT, - this.portText.getText()); - preferences.setValue(PreferenceConstants.AUTO_CONNECT, this.autoText - .getSelection()); - preferences.setValue(PreferenceConstants.SKYPE_USERNAME, this.skypeText - .getText()); - - return true; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PrivacyPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PrivacyPage.java deleted file mode 100644 index ca834b47969512c4f937beb3ab455e9c23af5451..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PrivacyPage.java +++ /dev/null @@ -1,40 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; - -// TODO CJ Review needed: Class never used -public class PrivacyPage extends WizardPage implements IWizardPage2 { - - protected PrivacyPage() { - super("PrivacyPage"); - } - - public void createControl(Composite parent) { - - Composite root = new Composite(parent, SWT.NONE); - - root.setLayout(new GridLayout(2, false)); - - setTitle("Configure Privacy Setting"); - setDescription("Saros is a research project and we are very interested in understanding how people use distributed pair programming."); - - // Of course we respect your privacy and give you full control over - // which information you would like to share. - Label portDescription = new Label(root, SWT.NONE); - GridData twoColumn = new GridData(); - twoColumn.horizontalSpan = 3; - portDescription.setLayoutData(twoColumn); - portDescription.setText("Share aggregated anonymous data"); - - setControl(root); - } - - public boolean performFinish() { - return true; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PropertyConfigurationWizard.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PropertyConfigurationWizard.java deleted file mode 100644 index 52c005389ae9452cb2833df9c0aa08dfeee30fe4..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/PropertyConfigurationWizard.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.Wizard; - -public class PropertyConfigurationWizard extends Wizard { - - public PropertyConfigurationWizard() { - setWindowTitle("Saros Configuration"); - setHelpAvailable(false); - setNeedsProgressMonitor(true); - } - - private NetworkSettingsPage firewallPage; - - @Override - public void addPages() { - this.firewallPage = new NetworkSettingsPage(); - addPage(this.firewallPage); - } - - @Override - public boolean performFinish() { - return this.firewallPage.performFinish(); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/RegisterAccountPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/RegisterAccountPage.java deleted file mode 100644 index 591a6f1f61cdae05830db610209bdc9fd1aad340..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/RegisterAccountPage.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * - */ -package de.fu_berlin.inf.dpp.ui.wizards; - -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.IMessageProvider; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.jivesoftware.smack.XMPPException; - -import de.fu_berlin.inf.dpp.PreferenceConstants; -import de.fu_berlin.inf.dpp.Saros; - -public class RegisterAccountPage extends WizardPage implements IWizardPage2 { - - private Text serverText; - - private Text userText; - - private Text passwordText; - - private Text repeatPasswordText; - - private Button prefButton; - - private final boolean createAccount; - - private final boolean showPrefButton; - - private final boolean storePreferences; - - public RegisterAccountPage() { - this(true, true, true); - } - - public RegisterAccountPage(boolean createAccount, boolean showPrefButton, - boolean storePreferences) { - super("create"); - this.createAccount = createAccount; - this.showPrefButton = showPrefButton; - this.storePreferences = storePreferences; - } - - public void createControl(Composite parent) { - Composite root = new Composite(parent, SWT.NONE); - - root.setLayout(new GridLayout(2, false)); - - if (this.createAccount) { - setTitle("Create New User Account"); - setDescription("Create a new user account for a Jabber server"); - } else { - setTitle("Enter User Account"); - setDescription("Enter your account information and Jabber server"); - } - - Label serverLabel = new Label(root, SWT.NONE); - serverLabel.setText("Jabber Server"); - - this.serverText = new Text(root, SWT.BORDER); - this.serverText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - this.serverText.setText("jabber.org"); - - Label userLabel = new Label(root, SWT.NONE); - userLabel.setText("Username"); - - this.userText = new Text(root, SWT.BORDER); - this.userText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, - false)); - - Label pwLabel = new Label(root, SWT.NONE); - pwLabel.setText("Password"); - - this.passwordText = new Text(root, SWT.BORDER); - this.passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, - true, false)); - this.passwordText.setEchoChar('*'); - - Label rpwLabel = new Label(root, SWT.NONE); - rpwLabel.setText("Repeat Password"); - - this.repeatPasswordText = new Text(root, SWT.BORDER); - this.repeatPasswordText.setLayoutData(new GridData(SWT.FILL, - SWT.CENTER, true, false)); - this.repeatPasswordText.setEchoChar('*'); - - if (this.showPrefButton) { - this.prefButton = new Button(root, SWT.CHECK | SWT.SEPARATOR); - this.prefButton.setSelection(this.storePreferences); - this.prefButton - .setText("Store the new configuration in your preferences."); - this.prefButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, - true, false, 2, 1)); - } - - if (!this.createAccount) { - - Button createAccountButton = new Button(root, SWT.NONE); - createAccountButton.setText("Create Account"); - createAccountButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } - - public void widgetSelected(SelectionEvent e) { - Display.getDefault().syncExec(new Runnable() { - public void run() { - try { - Shell shell = Display.getDefault() - .getActiveShell(); - - CreateAccountWizard wizard = new CreateAccountWizard( - true, false, false); - boolean success = Window.OK == new WizardDialog( - shell, wizard).open(); - - if (success) { - RegisterAccountPage.this.passwordText - .setText(wizard.getPassword()); - RegisterAccountPage.this.repeatPasswordText - .setText(wizard.getPassword()); - RegisterAccountPage.this.serverText - .setText(wizard.getServer()); - RegisterAccountPage.this.userText - .setText(wizard.getUsername()); - } - - } catch (Exception e) { - Saros - .getDefault() - .getLog() - .log( - new Status( - IStatus.ERROR, - Saros.SAROS, - IStatus.ERROR, - "Error while running enter account wizard", - e)); - } - } - }); - } - }); - } - - setInitialValues(); - - hookListeners(); - updateNextEnablement(); - - setControl(root); - } - - public String getServer() { - return this.serverText.getText(); - } - - public String getUsername() { - return this.userText.getText(); - } - - public String getPassword() { - return this.passwordText.getText(); - } - - public boolean isStoreInPreferences() { - if (this.showPrefButton) { - return this.prefButton.getSelection(); - } - return this.storePreferences; - } - - private void hookListeners() { - ModifyListener listener = new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateNextEnablement(); - } - }; - - this.serverText.addModifyListener(listener); - this.userText.addModifyListener(listener); - this.passwordText.addModifyListener(listener); - this.repeatPasswordText.addModifyListener(listener); - if (this.showPrefButton) { - this.prefButton.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - // do nothing - } - - public void widgetSelected(SelectionEvent e) { - IPreferenceStore preferences = Saros.getDefault() - .getPreferenceStore(); - if ((preferences.getString(PreferenceConstants.USERNAME) - .length() != 0) - && RegisterAccountPage.this.prefButton - .getSelection()) { - setMessage( - "Storing the configuration will override the existing settings.", - IMessageProvider.WARNING); - } else { - setMessage(null); - } - } - - }); - } - } - - private void updateNextEnablement() { - - boolean passwordsMatch = this.passwordText.getText().equals( - this.repeatPasswordText.getText()); - boolean done = (this.serverText.getText().length() > 0) - && (this.userText.getText().length() > 0) - && (this.passwordText.getText().length() > 0) && passwordsMatch; - - if (passwordsMatch) { - setErrorMessage(null); - } else { - setErrorMessage("Passwords don't match."); - } - - setPageComplete(done); - } - - public void setInitialValues() { - IPreferenceStore preferences = Saros.getDefault().getPreferenceStore(); - this.serverText.setText(preferences - .getDefaultString(PreferenceConstants.SERVER)); - if (this.showPrefButton) { - this.prefButton.setSelection(preferences.getString( - PreferenceConstants.USERNAME).length() == 0); - } - } - - public boolean performFinish() { - - if (this.createAccount) { - - final String server = getServer(); - final String username = getUsername(); - final String password = getPassword(); - final boolean storeInPreferences = isStoreInPreferences(); - - try { - getContainer().run(false, false, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) - throws InvocationTargetException, - InterruptedException { - try { - Saros.getDefault().createAccount(server, username, - password, monitor); - - if (storeInPreferences) { - IPreferenceStore preferences = Saros - .getDefault().getPreferenceStore(); - preferences.setValue( - PreferenceConstants.SERVER, server); - preferences.setValue( - PreferenceConstants.USERNAME, username); - preferences.setValue( - PreferenceConstants.PASSWORD, password); - } - - } catch (final XMPPException e) { - throw new InvocationTargetException(e); - } - } - }); - - } catch (InvocationTargetException e) { - String s = ((XMPPException) e.getCause()).getXMPPError() - .getMessage(); - - if ((s == null) - && (((XMPPException) e.getCause()).getXMPPError() - .getCode() == 409)) { - s = "Account already exists"; - } - - setMessage(e.getCause().getMessage() + ": " - + (s != null ? s : "No Explanation"), - IMessageProvider.ERROR); - return false; - - } catch (InterruptedException e) { - setMessage(e.getCause().getMessage(), IMessageProvider.ERROR); - return false; - } - - return true; - } - - else { - if (isStoreInPreferences()) { - - final String server = getServer(); - final String username = getUsername(); - final String password = getPassword(); - - IPreferenceStore preferences = Saros.getDefault() - .getPreferenceStore(); - preferences.setValue(PreferenceConstants.SERVER, server); - preferences.setValue(PreferenceConstants.USERNAME, username); - preferences.setValue(PreferenceConstants.PASSWORD, password); - } - return true; - } - } - -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ShowDescriptionPage.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ShowDescriptionPage.java deleted file mode 100644 index 72e6aa84232df4677bed55e54a766b771f9935cb..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/ShowDescriptionPage.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -import de.fu_berlin.inf.dpp.ui.SarosUI; - -/** - * A wizard page that displays the name of the inviter and the description - * provided with the invitation. - */ -class ShowDescriptionPage extends WizardPage { - - private final JoinSessionWizard joinSessionWizard; - - protected ShowDescriptionPage(JoinSessionWizard joinSessionWizard) { - super("firstPage"); - this.joinSessionWizard = joinSessionWizard; - - setTitle("Session Invitation"); - setDescription("You have been invited to join on a session for a " - + "shared project. Click next if you want to accept the invitation."); - setImageDescriptor(SarosUI - .getImageDescriptor("icons/start_invitation.png")); - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout(2, false)); - - Label inviterLabel = new Label(composite, SWT.NONE); - inviterLabel.setText("Inviter"); - - Text inviterText = new Text(composite, SWT.READ_ONLY | SWT.SINGLE - | SWT.BORDER); - - inviterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, - false)); - inviterText.setText(this.joinSessionWizard.process.getPeer().getBase()); - - Label descriptionLabel = new Label(composite, SWT.NONE); - descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, - false, false)); - descriptionLabel.setText("Project"); - - Text descriptionText = new Text(composite, SWT.READ_ONLY | SWT.BORDER); - descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, - true)); - descriptionText - .setText(this.joinSessionWizard.process.getDescription()); - - setControl(composite); - } -} \ No newline at end of file diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/WizardDialogAccessable.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/WizardDialogAccessable.java deleted file mode 100644 index 73e24e0556e1d1efc8d1a9567f35dc1123601d94..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/ui/wizards/WizardDialogAccessable.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.fu_berlin.inf.dpp.ui.wizards; - -import org.eclipse.jface.wizard.IWizard; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Shell; - -public class WizardDialogAccessable extends WizardDialog { - public WizardDialogAccessable(Shell parentShell, IWizard newWizard) { - super(parentShell, newWizard); - } - - public Button getWizardButton(int id) { - return getButton(id); - } - - public void setWizardButtonLabel(int id, String label) { - Button btn = getButton(id); - if (btn != null) { - btn.setText(label); - } - } - - public void setWizardButtonEnabled(int id, boolean enabled) { - Button btn = getButton(id); - if (btn != null) { - btn.setEnabled(enabled); - } - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/DeferredVariableProxyListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/DeferredVariableProxyListener.java deleted file mode 100644 index 0f866fc8816f41133442a62a3a32929bf13164a8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/DeferredVariableProxyListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -public class DeferredVariableProxyListener<T> implements - VariableProxyListener<T> { - - VariableProxyListener<T> wrapped; - - ScheduledExecutorService executor; - - Future<?> setFilterFuture; - - long time; - - TimeUnit timeUnit; - - public static <S> VariableProxyListener<S> defer( - VariableProxyListener<S> wrap, long time, TimeUnit timeUnit) { - return new DeferredVariableProxyListener<S>(wrap, time, timeUnit); - } - - public DeferredVariableProxyListener(VariableProxyListener<T> wrapped) { - this(wrapped, 1, TimeUnit.SECONDS); - } - - public DeferredVariableProxyListener(VariableProxyListener<T> wrapped, - long time, TimeUnit timeUnit) { - this.wrapped = wrapped; - this.time = time; - this.timeUnit = timeUnit; - } - - public void setVariable(final T newValue) { - - // Lazyly create Thread-Pool Executor - if (executor == null) - executor = Executors.newSingleThreadScheduledExecutor(); - - // Cancel previous set operations - if (setFilterFuture != null && !setFilterFuture.isCancelled()) - setFilterFuture.cancel(false); - - setFilterFuture = executor.schedule(new Runnable() { - public void run() { - wrapped.setVariable(newValue); - } - }, time, timeUnit); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileUtil.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileUtil.java deleted file mode 100644 index d33197f57d465ddb6a4cede87aa8926c85da63b8..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; - -/** - * this class get files or contents and check for identicalness. - * - * @author orieger - * - * TODO CJ: review needed - * - */ -public class FileUtil { - - /** - * calculate checksum for given file - * - * @param file - * @return checksum of file or -1 if checksum calculation has been failed. - */ - public static Long checksum(IFile file) { - InputStream contents = null; - - try { - // Adler-32 checksum - contents = file.getContents(); - CheckedInputStream cis = new CheckedInputStream(contents, - new Adler32()); - - byte[] tempBuf = new byte[128]; - while (cis.read(tempBuf) >= 0) { - } - long checksum = cis.getChecksum().getValue(); - return new Long(checksum); - - } catch (IOException e) { - e.printStackTrace(); - - } catch (CoreException e) { - e.printStackTrace(); - - } finally { - try { - if (contents != null) { - contents.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - return new Long(-1); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileZipper.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileZipper.java deleted file mode 100644 index b54985ed33b076b3ded91bb5f0c4e9e86e34e237..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/FileZipper.java +++ /dev/null @@ -1,216 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.util.Enumeration; -import java.util.List; -import java.util.zip.Adler32; -import java.util.zip.CheckedInputStream; -import java.util.zip.CheckedOutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - -import org.apache.log4j.Logger; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -/** - * This class contains method to write file into and read file out of zip - * archive. - * - * @author orieger - * - * TODO CJ: review needed - * - */ -public class FileZipper { - - private static Logger logger = Logger.getLogger(FileZipper.class); - - public static void createZipArchive() throws Exception { - - File dir = new File("/home/troll/test_archiv"); - // archive müssen rekursiv ausgelesen werden. - File[] files = (dir.listFiles()); - - CheckedOutputStream cos = new CheckedOutputStream(new FileOutputStream( - "/home/troll/archive.zip"), new Adler32()); - ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(cos)); - - File f; - // for(String path : files){ - for (File path : files) { - - FileZipper.logger.debug("compress file: " + path.toString()); - - f = new File(path.getPath()); - if (f.exists()) { - - if (f.isDirectory()) { - FileZipper.addFolder("", f, zos); - } else { - FileZipper.addFile("", f, zos); - } - - } else { - new FileNotFoundException(path.getName()); - } - - } - zos.close(); - // checksum - FileZipper.logger.debug("checksum: " + cos.getChecksum().getValue()); - } - - private static void addFile(String path, File file, ZipOutputStream zos) - throws Exception { - FileInputStream fis = null; - int i; - - /* Pfad übergeben */ - ZipEntry e = new ZipEntry(path + Path.SEPARATOR + file.getName()); - zos.putNextEntry(e); - - fis = new FileInputStream(file); - while ((i = fis.read()) != -1) { - zos.write(i); - } - - zos.closeEntry(); - } - - private static void addFolder(String path, File file, ZipOutputStream zos) - throws Exception { - - File[] files = file.listFiles(); - for (File f : files) { - if (f.isDirectory()) { - FileZipper.logger.debug("compress folder: " + file.getName()); - FileZipper.addFolder(path + Path.SEPARATOR + file.getName(), f, - zos); - } else { - FileZipper.logger.debug("compress file : " + file.getName() - + " path " + path); - FileZipper.addFile(path + Path.SEPARATOR + file.getName(), f, - zos); - } - } - - } - - public static void readZipArchive(String archive) throws Exception { - CheckedInputStream cis = new CheckedInputStream(new FileInputStream( - archive), new Adler32()); - ZipInputStream zis = new ZipInputStream(cis); - - String outputFolder = "/home/troll/test_archiv_output"; - new File(outputFolder).delete(); - - // entpacke archiv - ZipEntry entry; - int i = 0; - while ((entry = zis.getNextEntry()) != null) { - FileZipper.logger.debug("unzip file: " + entry.getName()); - // zu entpackende Datei im Zielverzeichnis anlegen - File directory = new File(entry.getName()); - directory.mkdirs(); - // FileOutputStream fos = new FileOutputStream(new File( - // "/home/troll/test_archiv_output", entry.getName())); - FileOutputStream fos = new FileOutputStream(entry.getName()); - - while ((i = zis.read()) != -1) { - fos.write(i); - } - fos.close(); - zis.closeEntry(); - } - FileZipper.logger.debug("checksum: " + cis.getChecksum().getValue()); - zis.close(); - } - - public static void createProjectZipArchive(List<IPath> files, - String descPath, IProject project) throws Exception { - CheckedOutputStream cos = new CheckedOutputStream(new FileOutputStream( - descPath), new Adler32()); - ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(cos)); - - File f; - - for (IPath path : files) { - FileZipper.logger.debug("compress file: " + path); - - f = project.getFile(path).getLocation().toFile(); - if (f.exists()) { - - /* create project path in folder structure. */ - String[] structure = path.segments(); - String path_structure = ""; - for (int j = 0; j < structure.length - 1; j++) { - - String s = structure[j]; - path_structure += s + Path.SEPARATOR; - } - - FileZipper.addFile(path_structure, f, zos); - - } else { - new FileNotFoundException(path.toString()); - } - - } - zos.close(); - // checksum - FileZipper.logger.debug("checksum: " + cos.getChecksum().getValue()); - // return cos.getChecksum().getValue(); - } - - public static void readInputStreamsProjectArchive(File file) - throws Exception { - ZipFile zip = new ZipFile(file); - Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zip.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); - System.out.println(entry.getName()); - - } - } - - public static void readProjectZipArchive() throws Exception { - - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject project = root.getProject("Projectname"); - Path p = new Path(""); - project.getFile(p); - - CheckedInputStream cis = new CheckedInputStream(new FileInputStream( - "./archive.zip"), new Adler32()); - ZipInputStream zis = new ZipInputStream(cis); - - // entpacke archiv - ZipEntry entry; - int i = 0; - while ((entry = zis.getNextEntry()) != null) { - - FileZipper.logger.debug("unzip file: " + entry.getName()); - // zu entpackende Datei im Zielverzeichnis anlegen - FileOutputStream fos = new FileOutputStream(new File( - "zielverzeichns", entry.getName())); - while ((i = zis.read()) != -1) { - fos.write(i); - } - fos.close(); - zis.closeEntry(); - } - FileZipper.logger.debug("checksum: " + cis.getChecksum().getValue()); - zis.close(); - } - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/PacketProtokollLogger.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/PacketProtokollLogger.java deleted file mode 100644 index 2a8ae59e3011d181d81ba6b3833c595cf81ef642..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/PacketProtokollLogger.java +++ /dev/null @@ -1,70 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.jivesoftware.smack.packet.Message; - -import de.fu_berlin.inf.dpp.Saros; - -// TODO CJ: review needed -public class PacketProtokollLogger { - - private static Logger logger; - - /* Singleton Pattern. */ - private static PacketProtokollLogger connectionLogger; - - private PacketProtokollLogger() { - PacketProtokollLogger.logger = Logger.getLogger("Connection Logger"); - PacketProtokollLogger.initLogger(); - } - - public static PacketProtokollLogger getInstance() { - if (PacketProtokollLogger.connectionLogger == null) { - PacketProtokollLogger.connectionLogger = new PacketProtokollLogger(); - } - return PacketProtokollLogger.connectionLogger; - } - - public static void initLogger() { - try { - PatternLayout layout = new PatternLayout("%d{ISO8601} %-5p %m%n"); - // DailyRollingFileAppender fileAppender = new - // DailyRollingFileAppender( layout, - // "ConnectionDatei"+Saros.getDefault().getMyJID().getName()+".log", - // "'.'yyyy-MM-dd_HH-mm" ); - FileAppender fileAppender = new FileAppender(layout, - "ConnectionDatei" + Saros.getDefault().getMyJID().getName() - + ".log", false); - PacketProtokollLogger.logger.addAppender(fileAppender); - PacketProtokollLogger.logger.setLevel(Level.ALL); - } catch (Exception ex) { - System.out.println(ex); - } - } - - /** - * log time in millis and message properties of outgoing message. - * - * @param msg - * sended message - */ - public void sendPacket(Message msg) { - // Date send = Calendar.getInstance().getTime(); - // logger.info(msg.getFrom()+" "+msg.getThread()+" send : "+DateFormat.getDateTimeInstance().format(send)); - // logger.info(Saros.getDefault().getMyJID().getName()+" send : "+msg.getPacketID()); - } - - /** - * log time in millis and message properties of incomming message. - * - * @param msg - * received message. - */ - public void receivePacket(Message msg) { - - // logger.info(Saros.getDefault().getMyJID().getName()+" receive : "+msg.getPacketID()); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/StateChangeListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/StateChangeListener.java deleted file mode 100644 index 23e345dd31b6d31800ad68e2ab0d42cac2f32509..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/StateChangeListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.fu_berlin.inf.dpp.util; - -/** - * The notifier complements the Listener construct. - * - * - */ -public interface StateChangeListener<T> { - - public void stateChangedNotification(T t); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/StateChangeNotifier.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/StateChangeNotifier.java deleted file mode 100644 index 902ec9ad61055e76d3211d3751beca72f0d41e92..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/StateChangeNotifier.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Created on 17.01.2005 - * - */ -package de.fu_berlin.inf.dpp.util; - -import java.util.HashSet; - -public class StateChangeNotifier<T> extends HashSet<StateChangeListener<T>> { - - public void notify(T sender) { - for (StateChangeListener<T> cl : this) { - cl.stateChangedNotification(sender); - } - } - - public void addAndNotify(StateChangeListener<T> listener, T sender) { - add(listener); - listener.stateChangedNotification(sender); - } - - /** - * Forward all notification of the sender to this notifier. - * - * @param <S> - * @param sender - * @param toSender - */ - public void chain(StateChangeNotifier<T> sender) { - sender.add(new StateChangeListener<T>() { - public void stateChangedNotification(T t) { - StateChangeNotifier.this.notify(t); - } - }); - } - - /** - * Forward all notification of the sender to this notifier. - * - * @param <S> - * @param sender - * @param toSender - */ - public <S> void chain(StateChangeNotifier<S> sender, final T toSender) { - sender.add(new StateChangeListener<S>() { - public void stateChangedNotification(S s) { - StateChangeNotifier.this.notify(toSender); - } - }); - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VariableProxy.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VariableProxy.java deleted file mode 100644 index b17b1dfb2d61d479b1bb8bd19617cf23a94da45e..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VariableProxy.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Created on 20.01.2005 - * - */ -package de.fu_berlin.inf.dpp.util; - -import java.util.HashSet; -import java.util.Set; - -/** - * @author oezbek - * - */ -public class VariableProxy<T> { - - Set<VariableProxyListener<? super T>> nonVetoables = new HashSet<VariableProxyListener<? super T>>(); - - T variable; - - public VariableProxy(T variable) { - super(); - this.variable = variable; - } - - public void addAndNotify(VariableProxyListener<? super T> listener) { - nonVetoables.add(listener); - listener.setVariable(variable); - } - - public void add(VariableProxyListener<? super T> listener) { - nonVetoables.add(listener); - } - - public void remove(VariableProxyListener<? super T> listener) { - nonVetoables.remove(listener); - } - - /** - * - * @return Returns true if the setting of the variable was successful. - * - */ - public boolean setVariable(T variable) { - return setVariable(variable, null); - } - - public boolean setVariable(T variable, - VariableProxyListener<? super T> exclude) { - this.variable = variable; - for (VariableProxyListener<? super T> vpl : nonVetoables) { - if (vpl == exclude) - continue; - vpl.setVariable(variable); - } - return true; - } - - public T getVariable() { - return variable; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VariableProxyListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VariableProxyListener.java deleted file mode 100644 index 0a92f982806948961d064f2bb99c0c3b38a2b15a..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VariableProxyListener.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Created on 20.01.2005 - * - */ -package de.fu_berlin.inf.dpp.util; - -/** - * @author oezbek - * - */ -public interface VariableProxyListener<T> { - - public void setVariable(T newValue); - -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VetoableVariableProxy.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VetoableVariableProxy.java deleted file mode 100644 index d1e6374655f0dee4857afc76b97981e1bbb09042..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VetoableVariableProxy.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Created on 20.01.2005 - * - */ -package de.fu_berlin.inf.dpp.util; - -import java.util.HashSet; -import java.util.Set; - -public class VetoableVariableProxy<T> extends VariableProxy<T> { - - Set<VetoableVariableProxyListener<? super T>> vetoables = new HashSet<VetoableVariableProxyListener<? super T>>(); - - public VetoableVariableProxy(T variable) { - super(variable); - } - - public void addAndNotify(VetoableVariableProxyListener<? super T> listener) { - vetoables.add(listener); - listener.setVariable(variable, null); - } - - public void add(VetoableVariableProxyListener<? super T> listener) { - vetoables.add(listener); - } - - public void remove(VetoableVariableProxyListener<? super T> listener) { - vetoables.remove(listener); - } - - @Override - public boolean setVariable(T variable) { - T oldValue = this.variable; - this.variable = variable; - - for (VetoableVariableProxyListener<? super T> vpl : vetoables) { - if (!vpl.setVariable(variable, oldValue)) { - this.variable = oldValue; - return false; - } - } - - for (VariableProxyListener<? super T> vpl : nonVetoables) { - vpl.setVariable(variable); - } - return true; - } -} diff --git a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VetoableVariableProxyListener.java b/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VetoableVariableProxyListener.java deleted file mode 100644 index 80a6cd6c0c6d993399340003cd4257f136335f37..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/de/fu_berlin/inf/dpp/util/VetoableVariableProxyListener.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Created on 20.01.2005 - * - */ -package de.fu_berlin.inf.dpp.util; - -/** - * @author oezbek - * - */ -public interface VetoableVariableProxyListener<T> { - - public boolean setVariable(T newValue, T oldValue); - -} diff --git a/de.fu_berlin.inf.dpp/src/org/limewire/rudp/RudpMessageDispatcher.java b/de.fu_berlin.inf.dpp/src/org/limewire/rudp/RudpMessageDispatcher.java deleted file mode 100644 index 95b6020af091e16f8e2d015fe69db5d67db711d2..0000000000000000000000000000000000000000 --- a/de.fu_berlin.inf.dpp/src/org/limewire/rudp/RudpMessageDispatcher.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.limewire.rudp; - -import java.net.InetSocketAddress; -import java.util.concurrent.Executor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.limewire.concurrent.ExecutorsHelper; -import org.limewire.rudp.messages.RUDPMessage; - -/** - * Dispatches messages. - */ -public class RudpMessageDispatcher implements MessageDispatcher { - - private static final Log LOG = LogFactory - .getLog(DefaultMessageDispatcher.class); - - private final Executor executor = ExecutorsHelper - .newProcessingQueue("RUDPDispatch"); - private volatile UDPMultiplexor multiplexor; - - public void setUDPMultiplexor(UDPMultiplexor plexor) { - if (plexor != null) - multiplexor = plexor; - } - - public void dispatch(RUDPMessage message, InetSocketAddress from) { - executor.execute(new Dispatch(multiplexor, message, from)); - } - - private static class Dispatch implements Runnable { - private final UDPMultiplexor plexor; - private final RUDPMessage msg; - private final InetSocketAddress from; - - Dispatch(UDPMultiplexor plexor, RUDPMessage msg, InetSocketAddress from) { - this.plexor = plexor; - this.msg = msg; - this.from = from; - } - - public void run() { - plexor.routeMessage(msg, from); - } - } - -} \ No newline at end of file