Issues #124, #67, #88
authordasilvj
Tue, 26 May 2009 19:56:38 +0200
changeset 212 bbc0b169cdf0
parent 211 d75cbb5937c3
child 213 9bdff6cbd120
Issues #124, #67, #88
.classpath
.settings/org.eclipse.jdt.core.prefs
.settings/org.eclipse.jdt.ui.prefs
.settings/org.eclipse.ltk.core.refactoring.prefs
AndroidManifest.xml
libs/jlibrtp-0.2.2.jar
res/drawable/background.png
res/drawable/icon.png
res/drawable/logo.png
res/layout/create_account.xml
res/layout/edit_settings.xml
res/layout/login.xml
res/menu/create_account.xml
res/menu/edit_settings.xml
res/menu/login.xml
res/values/arrays.xml
res/values/strings.xml
res/values/styles.xml
src/com/beem/project/beem/BeemApplication.java
src/com/beem/project/beem/BeemException.java
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/jingle/Caller.java
src/com/beem/project/beem/jingle/FileSender.java
src/com/beem/project/beem/jingle/RTPMediaManager.java
src/com/beem/project/beem/jingle/RTPMediaSession.java
src/com/beem/project/beem/jingle/RTPReceiver.java
src/com/beem/project/beem/jingle/RTPTransmitter.java
src/com/beem/project/beem/jingle/Receiver.java
src/com/beem/project/beem/jingle/ReceiverMediaManager.java
src/com/beem/project/beem/jingle/SenderMediaManager.java
src/com/beem/project/beem/jingle/SenderMediaSession.java
src/com/beem/project/beem/provider/Beem.java
src/com/beem/project/beem/provider/BeemDatabaseHelper.java
src/com/beem/project/beem/provider/ContactProvider.java
src/com/beem/project/beem/provider/UserProvider.java
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/service/ChatAdapter.java
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/service/Message.java
src/com/beem/project/beem/service/PresenceAdapter.java
src/com/beem/project/beem/service/RosterAdapter.java
src/com/beem/project/beem/service/XmppConnectionAdapter.java
src/com/beem/project/beem/service/XmppFacade.java
src/com/beem/project/beem/ui/AccountCreation.java
src/com/beem/project/beem/ui/AddContact.java
src/com/beem/project/beem/ui/ChangeStatus.java
src/com/beem/project/beem/ui/ContactDialog.java
src/com/beem/project/beem/ui/ContactDialogAliasDialog.java
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/ContactListSettings.java
src/com/beem/project/beem/ui/CreateAccount.java
src/com/beem/project/beem/ui/EditSettings.java
src/com/beem/project/beem/ui/Login.java
src/com/beem/project/beem/ui/SendIM.java
src/com/beem/project/beem/ui/SendIMDialogSmiley.java
src/com/beem/project/beem/ui/Subscription.java
src/com/beem/project/beem/utils/PresenceType.java
src/com/beem/project/beem/utils/Status.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.classpath	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry kind="lib" path="libs/smack.jar"/>
+	<classpathentry kind="lib" path="libs/smackx-debug.jar"/>
+	<classpathentry kind="lib" path="libs/smackx-jingle.jar"/>
+	<classpathentry kind="lib" path="libs/smackx.jar"/>
+	<classpathentry kind="lib" path="libs/jlibrtp-0.2.2.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.jdt.core.prefs	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,337 @@
+#Tue May 26 10:33:43 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.builder.cleanOutputFolder=clean
+org.eclipse.jdt.core.builder.duplicateResourceTask=warning
+org.eclipse.jdt.core.builder.invalidClasspath=abort
+org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
+org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
+org.eclipse.jdt.core.circularClasspath=error
+org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
+org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=ignore
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
+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=1
+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=true
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=true
+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=100
+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=4
+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=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=120
+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=mixed
+org.eclipse.jdt.core.formatter.tabulation.size=8
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=true
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.incompatibleJDKLevel=ignore
+org.eclipse.jdt.core.incompleteClasspath=error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.jdt.ui.prefs	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,109 @@
+#Tue May 26 10:35:42 CEST 2009
+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=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=false
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=false
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=true
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=true
+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=_beem
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_beem
+formatter_settings_version=11
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=false
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=true
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.ltk.core.refactoring.prefs	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,3 @@
+#Tue May 26 10:03:53 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
--- a/AndroidManifest.xml	Fri May 22 19:17:50 2009 +0200
+++ b/AndroidManifest.xml	Tue May 26 19:56:38 2009 +0200
@@ -3,8 +3,9 @@
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
 	<application android:label="@string/app_name" android:name="BeemApplication"
-		android:icon="@drawable/signal">
-		<activity android:name=".ui.ContactList" android:label="@string/app_name">
+		android:icon="@drawable/signal"
+		android:theme="@style/Theme.BEEM.Default">
+		<activity android:name=".ui.Login" android:label="@string/app_name">
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
 				<category android:name="android.intent.category.LAUNCHER" />
@@ -18,6 +19,12 @@
 		<activity android:name=".ui.AccountCreation" android:label="@string/app_name" />
 		<activity android:name=".ui.AddContact" android:label="@string/app_name" />
 		<activity android:name=".ui.Subscription" android:label="@string/app_name" />
+        <activity android:name=".ui.EditSettings" android:label="@string/edit_settings_name">
+        </activity>
+        <activity android:name=".ui.CreateAccount" android:label="@string/create_account_name">
+        </activity>
+        <activity android:name=".ui.ContactList" android:label="@string/app_name">
+        </activity>
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
 			<intent-filter>
@@ -32,5 +39,5 @@
 	<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
 	<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"></uses-permission>
 	<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
-	<uses-sdk android:minSdkVersion="2"></uses-sdk>
+	<uses-sdk android:minSdkVersion="3"></uses-sdk>
 </manifest> 
Binary file libs/jlibrtp-0.2.2.jar has changed
Binary file res/drawable/background.png has changed
Binary file res/drawable/icon.png has changed
Binary file res/drawable/logo.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/create_account.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+	android:orientation="vertical"
+   	android:layout_width="fill_parent"
+    android:layout_height="fill_parent">
+	<LinearLayout
+		android:layout_width="fill_parent"
+		android:layout_height="fill_parent"
+		android:orientation="vertical"
+		android:padding="10dip">
+    	<TextView android:id="@+id/create_account_label_username"
+    		android:layout_width="fill_parent"
+    		android:layout_height="wrap_content"
+  			android:text="@string/create_account_username"
+    		style="@style/Label" />
+		<EditText android:id="@+id/create_account_username"
+			android:layout_width="fill_parent"
+			android:layout_height="wrap_content" />
+    	<TextView android:id="@+id/create_account_label_password"
+    		android:layout_width="fill_parent"
+    		android:layout_height="wrap_content"
+    		android:text="@string/create_account_password"
+    		style="@style/Label" />
+		<EditText android:id="@+id/create_account_password"
+			android:layout_width="fill_parent"
+			android:layout_height="wrap_content"
+			android:password="true" />
+    	<TextView android:id="@+id/create_account_label_confirm_password"
+    		android:layout_width="fill_parent"
+    		android:layout_height="wrap_content"
+    		android:text="@string/create_account_confirm_password"
+    		style="@style/Label" />
+		<EditText android:id="@+id/create_account_confirm_password"
+			android:layout_width="fill_parent"
+			android:layout_height="wrap_content"
+			android:password="true" />
+    	<View
+    		android:layout_height="21dp"
+    		android:layout_width="fill_parent" />
+		<Button android:id="@+id/create_account_button"
+			android:layout_width="fill_parent"
+			android:layout_height="fill_parent"
+			android:text="@string/button_create_account" />
+	</LinearLayout>
+</ScrollView>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/edit_settings.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TabHost android:id="@+id/settings_tab_host" xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+	android:layout_height="fill_parent">
+	<LinearLayout 
+		android:orientation="vertical"
+    	android:layout_width="fill_parent"
+    	android:layout_height="fill_parent">
+    	<TabWidget android:id="@android:id/tabs"
+    		android:layout_width="fill_parent"
+    		android:layout_height="wrap_content" />
+    	<FrameLayout android:id="@android:id/tabcontent"
+    		android:layout_width="fill_parent"
+    		android:layout_height="fill_parent">
+    		
+    		<!--
+    			Account Tab
+    		-->
+    		<ScrollView
+    			android:orientation="vertical"
+    			android:layout_width="fill_parent"
+    			android:layout_height="fill_parent">
+    		<RelativeLayout android:id="@+id/settings_account"
+    			android:orientation="vertical"
+    			android:layout_width="fill_parent"
+    			android:layout_height="fill_parent"
+    			android:padding="10dip">
+    			<TextView android:id="@+id/settings_account_label_username"
+    				android:layout_width="fill_parent"
+    				android:layout_height="wrap_content"
+    				android:text="@string/settings_account_username"
+    				style="@style/Label" />
+				<EditText android:id="@+id/settings_account_username"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_below="@id/settings_account_label_username" />
+    			<TextView android:id="@+id/settings_account_label_password"
+    				android:layout_width="fill_parent"
+    				android:layout_height="wrap_content"
+					android:layout_below="@id/settings_account_username"
+    				android:text="@string/settings_account_password"
+    				style="@style/Label" />
+				<EditText android:id="@+id/settings_account_password"
+					android:layout_width="fill_parent"
+					android:layout_height="wrap_content"
+					android:layout_below="@id/settings_account_label_password"
+					android:password="true" />
+    			<Button android:id="@+id/settings_account_button_save"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_below="@id/settings_account_password"
+					android:layout_alignParentRight="true"
+					android:text="@string/button_save" />
+    		</RelativeLayout>
+    		</ScrollView>
+    		
+    		<!-- 
+    			XMPP Tab
+    		-->
+    		<ScrollView
+    			android:layout_width="fill_parent"
+    			android:layout_height="fill_parent"
+    			android:orientation="vertical">
+    		<RelativeLayout android:id="@+id/settings_xmpp"
+    			android:orientation="vertical"
+    			android:layout_width="fill_parent"
+    			android:layout_height="fill_parent"
+    			android:padding="10dip">
+	  			<TableLayout android:id="@+id/settings_xmpp_table_sp"
+  					android:layout_width="fill_parent"
+  					android:layout_height="wrap_content"
+  					android:stretchColumns="1">
+  					<TableRow>
+   						<TextView android:id="@+id/settings_xmpp_label_server"
+   							android:layout_column="1"
+  							android:layout_width="223dp"
+  							android:layout_height="wrap_content"
+  							android:text="@string/settings_xmpp_server"
+  							style="@style/Label" />
+  						<TextView android:id="@+id/settings_xmpp_label_port"
+  							android:layout_column="2"
+  							android:layout_width="wrap_content"
+  							android:layout_height="wrap_content"
+  							android:text="@string/settings_xmpp_port"
+  							style="@style/Label" />
+					</TableRow>
+					<TableRow>
+						<EditText android:id="@+id/settings_xmpp_server"
+							android:layout_column="1"
+							android:layout_width="wrap_content"
+							android:layout_height="wrap_content" />
+						<EditText android:id="@+id/settings_xmpp_port"
+							android:layout_column="2"
+							android:layout_width="wrap_content"
+							android:layout_height="wrap_content"
+							android:minWidth="77dp"
+							android:numeric="integer"
+							android:maxLength="5" />
+					</TableRow>
+				</TableLayout>
+    			<CheckBox android:id="@+id/settings_xmpp_use_tls"
+    				android:layout_width="wrap_content"
+    				android:layout_height="wrap_content"
+    				android:text="@string/settings_xmpp_use_tls"
+    				android:layout_below="@id/settings_xmpp_table_sp"
+    				style="@style/Label" />
+				<Button android:id="@+id/settings_xmpp_button_save"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_alignParentRight="true"
+					android:layout_below="@id/settings_xmpp_use_tls"
+					android:text="@string/button_save" />
+    		</RelativeLayout>
+    		</ScrollView>
+    		
+    		<!--
+    			Proxy Tab
+    		-->
+    		<ScrollView
+    			android:layout_width="fill_parent"
+    			android:layout_height="fill_parent"
+    			android:orientation="vertical">
+    		<RelativeLayout android:id="@+id/settings_proxy"
+    			android:orientation="vertical"
+    			android:layout_width="fill_parent"
+    			android:layout_height="fill_parent"
+    			android:padding="10dip">
+    			<CheckBox android:id="@+id/settings_proxy_use"
+    				android:layout_width="wrap_content"
+    				android:layout_height="wrap_content"
+    				android:text="@string/settings_proxy_use"
+    				style="@style/Label" />
+    			<LinearLayout android:id="@+id/settings_proxy_parameters"
+    				android:layout_width="fill_parent"
+    				android:layout_height="fill_parent"
+    				android:layout_below="@id/settings_proxy_use"
+    				android:orientation="vertical">
+    				<Spinner android:id="@+id/settings_proxy_type"
+    					android:layout_width="fill_parent"
+    					android:layout_height="wrap_content" />
+    				<TableLayout android:id="@+id/settings_proxy_table_sp"
+    					android:layout_width="fill_parent"
+    					android:layout_height="wrap_content"
+    					android:stretchColumns="1">
+    					<TableRow>
+     						<TextView android:id="@+id/settings_proxy_label_server"
+     							android:layout_column="1"
+    							android:layout_width="223dp"
+    							android:layout_height="wrap_content"
+    							android:text="@string/settings_proxy_server"
+    							style="@style/Label" />
+    						<TextView android:id="@+id/settings_proxy_label_port"
+    							android:layout_column="2"
+    							android:layout_width="wrap_content"
+    							android:layout_height="wrap_content"
+    							android:text="@string/settings_proxy_port"
+    							style="@style/Label" />
+						</TableRow>
+						<TableRow>
+							<EditText android:id="@+id/settings_proxy_server"
+								android:layout_column="1"
+								android:layout_width="wrap_content"
+								android:layout_height="wrap_content" />
+							<EditText android:id="@+id/settings_proxy_port"
+								android:layout_column="2"
+								android:layout_width="wrap_content"
+								android:layout_height="wrap_content"
+								android:minWidth="77dp"
+								android:numeric="integer"
+								android:maxLength="5" />
+						</TableRow>
+					</TableLayout>
+     				<TextView android:id="@+id/settings_proxy_label_username"
+    					android:layout_width="fill_parent"
+    					android:layout_height="wrap_content"
+    					android:text="@string/settings_proxy_username"
+    					style="@style/Label" />
+					<EditText android:id="@+id/settings_proxy_username"
+						android:layout_width="fill_parent"
+						android:layout_height="wrap_content" />
+     				<TextView android:id="@+id/settings_proxy_label_password"
+    					android:layout_width="fill_parent"
+    					android:layout_height="wrap_content"
+    					android:text="@string/settings_proxy_password"
+    					style="@style/Label" />
+					<EditText android:id="@+id/settings_proxy_password"
+						android:layout_width="fill_parent"
+						android:layout_height="wrap_content"
+    					android:password="true" />
+				</LinearLayout>
+				<Button android:id="@+id/settings_proxy_button_save"
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:layout_alignParentRight="true"
+					android:text="@string/button_save" />
+    		</RelativeLayout>
+    		</ScrollView>
+    	</FrameLayout>
+	</LinearLayout>
+</TabHost>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/login.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+	android:orientation="vertical"
+	android:layout_width="fill_parent"
+	android:layout_height="fill_parent">
+<RelativeLayout
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:padding="10dip">
+	<ImageView android:id="@+id/log_as_logo"
+		android:src="@drawable/logo"
+		android:layout_width="fill_parent"
+		android:layout_height="wrap_content"
+		android:adjustViewBounds="true"
+		android:scaleType="center"
+		android:layout_marginTop="10px" />
+</RelativeLayout>
+</ScrollView>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/menu/create_account.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,2 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+</menu>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/menu/edit_settings.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,8 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+	<item android:id="@+id/settings_menu_create_account"
+		android:visible="true"
+		android:title="@string/settings_menu_create_account" />
+	<item android:id="@+id/settings_menu_login"
+		android:visible="true"
+		android:title="@string/settings_menu_login" />
+</menu>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/menu/login.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,8 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+	<item android:id="@+id/login_menu_settings"
+		android:visible="true"
+		android:title="@string/login_menu_settings" />
+	<item android:id="@+id/login_menu_about"
+		android:visible="true"
+		android:title="@string/login_menu_about" />
+</menu>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/values/arrays.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+	<string-array name="proxy_types">
+		<item>HTTP</item>
+		<item>SOCKS4</item>
+		<item>SOCKS5</item>
+	</string-array>
+</resources>
--- a/res/values/strings.xml	Fri May 22 19:17:50 2009 +0200
+++ b/res/values/strings.xml	Tue May 26 19:56:38 2009 +0200
@@ -109,5 +109,117 @@
 
 	<!--  BeemChatManager -->
 	<string name="BeemChatManagerNewMessage">You have got a new message</string>
+	
+    <!--
+    	Services
+    -->
+    
+    <!--
+    	Activities
+    -->
+    <string name="login_tag">BEEM - Login Activity</string>
+    
+    <string name="edit_settings_name">BEEM - Settings</string>
+	<string name="edit_settings_tag">BEEM - EditSettings Activity</string>
+	
+    <string name="create_account_name">BEEM - Create an account</string>
+    <string name="create_account_tag">BEEM - CreateAccount Activity</string>
+
+    
+    <!--
+    	Buttons
+    -->
+    <string name="button_reset">Reset</string>
+    <string name="button_login">Login</string>
+    <string name="button_save">Save</string>
+    <string name="button_create_account">Create this account</string>
+    
+    
+    <!--
+    	LogAs Activity
+    -->
+	<string name="login_username">Username</string>
+	<string name="login_password">Password</string>
+	
+	<string name="login_error_dialog_title">Login - Error</string>
+	<string name="login_close_dialog_button">Close</string>
+	
+	<string name="login_menu_create_account">Create an account</string>
+	<string name="login_menu_settings">Settings</string>
+	<string name="login_menu_about">About</string>
+	
+	<string name="login_about_title">About</string>
+	<string name="login_about_msg">
+		BEEM is an EPITECH Innovative Project. Visit us at http://www.beem-project.com !
+	</string>
+	<string name="login_about_button">Close</string>
+	
+	
+	<!--
+		EditSettings Activity
+	-->
+	<string name="settings_menu_create_account">Create an account</string>
+	<string name="settings_menu_login">Login</string>
+
+	<string name="settings_saved_ok">The settings have been saved successfully.</string>
+	
+	<string name="settings_filename">beem_settings</string>
+	<string name="settings_key_account_username">beem_account_username</string>
+	<string name="settings_key_account_password">beem_account_password</string>
+	<string name="settings_key_xmpp_server">beem_xmpp_server</string>
+	<string name="settings_key_xmpp_port">beem_xmpp_port</string>
+	<string name="settings_key_xmpp_tls_use">beem_xmpp_tls_use</string>
+	<string name="settings_key_proxy_use">beem_xmpp_proxy_use</string>
+	<string name="settings_key_proxy_server">beem_xmpp_proxy_server</string>
+	<string name="settings_key_proxy_port">beem_xmpp_proxy_port</string>
+	<string name="settings_key_proxy_username">beem_xmpp_proxy_username</string>
+	<string name="settings_key_proxy_password">beem_xmpp_proxy_password</string>
+	<string name="settings_key_proxy_type">beem_xmpp_proxy_type</string>
+	
+	<!-- EditSettings Activity tabs -->
+	<string name="settings_tab_tag_account">edit_settings_tab_account</string>
+	<string name="settings_tab_label_account">Account</string>
+	
+	<string name="settings_tab_tag_xmpp">edit_settings_tab_xmpp</string>
+	<string name="settings_tab_label_xmpp">XMPP</string>
+	
+	<string name="settings_tab_tag_proxy">edit_settings_tab_proxy</string>
+	<string name="settings_tab_label_proxy">Proxy</string>
+	
+	<!-- EditSettings Activity Account tab -->
+	<string name="settings_account_username">Username</string>
+	<string name="settings_account_password">Password</string>
+	<string name="settings_account_server">Server</string>
+	<string name="settings_account_port">Port</string>
+	
+	
+	<!-- EditSettings Activity XMPP tab -->
+	<string name="settings_xmpp_server">Server</string>
+	<string name="settings_xmpp_port">Port</string>
+	<string name="settings_xmpp_use_tls">Require SSL/TLS</string>
+	
+	<!-- EditSettings Activity Proxy tab -->
+	<string name="settings_proxy_use">Connect using a proxy</string>
+	<string name="settings_proxy_type_prompt">Choose a type of proxy</string>
+	<string name="settings_proxy_server">Server</string>
+	<string name="settings_proxy_port">Port</string>
+	<string name="settings_proxy_username">Username</string>
+	<string name="settings_proxy_password">Password</string>
+	
+	<!--
+		Create an account Activity
+	-->
+	<string name="create_account_instr_dialog_title">Create an account - Instructions</string>
+	<string name="create_account_err_dialog_title">Create an account - Error</string>
+	<string name="create_account_err_dialog_settings_button">Change my settings</string>
+	<string name="create_account_close_dialog_button">Close</string>
+
+	
+	<string name="create_account_successfull_after">has been created successfully</string>
+	<string name="create_account_err_passwords">Passwords do not match.</string>
+	
+	<string name="create_account_username">Username</string>
+	<string name="create_account_password">Password</string>
+	<string name="create_account_confirm_password">Confirm password</string>
 
 </resources>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/values/styles.xml	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+	<style name="customtheme" parent="android:Theme">
+	</style>
+	<style name="customtheme.contactList">
+		<item name="android:windowBackground">@drawable/background</item>
+		<item name="android:windowNoTitle">true</item>
+		<item name="android:textColor">#000000</item>
+		<item name="android:typeface">sans</item>
+		<item name="android:textSize">18sp</item>
+
+	</style>
+	<style name="customtheme.jungle">
+		<item name="android:windowBackground">@drawable/background</item>
+		<item name="android:windowNoTitle">true</item>
+		<item name="android:textColor">#FFFFFF</item>
+		<item name="android:typeface">sans</item>
+		<item name="android:textSize">18sp</item>
+	</style>
+	<style name="customtheme.spinner">
+		<item name="android:windowBackground">@drawable/background</item>
+		<item name="android:windowNoTitle">true</item>
+		<item name="android:textColor">#FF0000</item>
+		<item name="android:typeface">sans</item>
+		<item name="android:textSize">18sp</item>
+	</style>
+	<style name="Label">
+		<item name="android:textSize">16sp</item>
+		<item name="android:textStyle">bold</item>
+		<item name="android:typeface">sans</item>
+		<item name="android:capitalize">characters</item>
+		<item name="android:textColor">#FFFFFF</item>
+	</style>
+	<style name="Theme.BEEM.Default" parent="@android:style/Theme">
+		<item name="android:windowBackground">@drawable/background</item>
+	</style>
+</resources>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemApplication.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Tue May 26 19:56:38 2009 +0200
@@ -26,183 +26,14 @@
 
 /**
  * The Beem application. This class has some methods utiliy needs by the activities.
+ * 
  * @author darisk
  */
 public class BeemApplication extends Application {
 
-    private static BeemApplication mBeemApp;
-    private Activity mActivity;
-    private static final Intent SERVICE_INTENT = new Intent();
-    public static final String TAG = "BeemApplication";
-    private IXmppFacade mFacade;
-    private Context mApplicationContext;
-    private List<Message> mQueue = new LinkedList<Message>();
-    private boolean mIsConnected;
-    private IXmppConnection mConnection;
-    private ProgressDialog mProgressDialog;
-    private ConnectionListener mConnectionListener = new ConnectionListener();
-
-    static {
-	SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
-    }
-
-    private ServiceConnection mServConn = new ServiceConnection() {
-
-	@Override
-	public void onServiceDisconnected(ComponentName name) {
-	    mFacade = null;
-	    mIsConnected = false;
-	}
-
-	@Override
-	public void onServiceConnected(ComponentName name, IBinder service) {
-	    mIsConnected = true;
-	    mFacade = IXmppFacade.Stub.asInterface(service);
-	    try {
-		mConnection = mFacade.createConnection();
-		if (!mConnection.isAuthentificated()) {
-		    mConnection.addConnectionListener(mConnectionListener);
-		    mApplicationContext.startService(BeemApplication.SERVICE_INTENT);
-		}else {
-		    mProgressDialog.dismiss();
-		    synchronized (mQueue) {
-			for (Message msg : mQueue) {
-			    msg.sendToTarget();
-			}
-			mQueue.clear();
-		    }
-		}
-	    } catch (RemoteException e) {
-		Log.e(TAG, "service connection exception", e);
-	    }
-	}
-    };
-
-    /**
-     * Constructor.
-     */
-    public BeemApplication() {
-	mIsConnected = false;
-    }
-
-    /**
-     * Get the Beem application for an activity.
-     * @param activity the activity which want the Beem application
-     * @return the Beem application
-     */
-    public static BeemApplication getApplication(Activity activity) {
-	if (mBeemApp == null) {
-	    mBeemApp = new BeemApplication();
-	}
-	mBeemApp.mActivity = activity;
-	mBeemApp.mProgressDialog = new ProgressDialog(activity);
-	mBeemApp.mProgressDialog.setTitle("Beem");
-	mBeemApp.mProgressDialog.setIcon(R.drawable.signal);
-	mBeemApp.mProgressDialog.setMessage("Connecting...");
-	mBeemApp.mProgressDialog.setCancelable(true);
-	
-	mBeemApp.mApplicationContext = activity.getApplication();
-	activity.getResources();
-	mBeemApp.onCreate();
-	//mBeemApp.mProgressDialog.show();
-	return mBeemApp;
-    }
-
-    /**
-     * Start the beem service.
-     */
-    public synchronized void startBeemService() {
-	if (!mIsConnected) {
-	    ConnectionRunnable cRun = new ConnectionRunnable("Connecting...");
-	    mBeemApp.mActivity.runOnUiThread(cRun);
-	    // the connection will be made on service connect
-	    mApplicationContext.bindService(BeemApplication.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
-	}
-    }
-
-    /**
-     * Stop the Beem service.
-     */
-    public synchronized void stopBeemService() {
-	if (mIsConnected) {
-	    Intent intent = new Intent();
-	    intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
-	    mApplicationContext.unbindService(mServConn);
-	    mApplicationContext.stopService(intent);
-	    mIsConnected = false;
-	}
-    }
-
-    public synchronized void unbindBeemService() {
-	if (mIsConnected) {
-	    mApplicationContext.unbindService(mServConn);
-	    mIsConnected = false;
-	}
-     }
-
-    /**
-     * Get the facade to use to access the Beem service.
-     * @return the facade or null if the application is not connected to the beem service.
-     */
-    public IXmppFacade getXmppFacade() {
-	return mFacade;
-    }
-
-    /**
-     * Add a methode to execute when the application is connected to the server.
-     * @param target the handler which will execute the callback
-     * @param callback the callback to execute
-     */
-    public void callWhenConnectedToServer(Handler target, Runnable callback) {
-	Message msg = Message.obtain(target, callback);
-	if (mIsConnected) {
-	    msg.sendToTarget();
-	} else {
-	    startBeemService();
-	    synchronized (mQueue) {
-		mQueue.add(msg);
-	    }
-	}
-    }
-
-    /**
-     * Tell if we are connected with the Beem Service.
-     * @return true if connected false otherwise
-     */
-    public boolean isConnected() {
-	return mIsConnected;
-    }
-
-    private class ConnectionRunnable implements Runnable {
-	private String mErrorMsg;
-
-	public ConnectionRunnable(String string) {
-	    this.mErrorMsg = string;
-	}
-
-	@Override
-	public void run() {
-	    mBeemApp.mProgressDialog.setMessage(mErrorMsg);
-	}
-
-	/**
-	 * @param mErrorMsg the mErrorMsg to set
-	 */
-	public void setMErrorMsg(String mErrorMsg) {
-	    this.mErrorMsg = mErrorMsg;
-	}
-
-	/**
-	 * @return the mErrorMsg
-	 */
-	public String getMErrorMsg() {
-	    return mErrorMsg;
-	}
-
-    }
-
     /**
      * Connection listener use to hide the progress dialog.
+     * 
      * @author darisk
      */
     private class ConnectionListener extends IBeemConnectionListener.Stub {
@@ -231,6 +62,13 @@
 	    // TODO afficher une notification et reafficher le progress dialog
 	}
 
+	@Override
+	public void connectionFailed(String errorMsg) throws RemoteException {
+	    Log.i(TAG, "Connection Failed");
+	    ConnectionRunnable cRun = new ConnectionRunnable(errorMsg);
+	    mBeemApp.mActivity.runOnUiThread(cRun);
+	}
+
 	/**
 	 * {@inheritDoc}
 	 */
@@ -269,13 +107,193 @@
 	public void reconnectionSuccessful() throws RemoteException {
 	}
 
+    }
+
+    private class ConnectionRunnable implements Runnable {
+
+	private String mErrorMsg;
+
+	public ConnectionRunnable(String string) {
+	    this.mErrorMsg = string;
+	}
+
+	/**
+	 * @return the mErrorMsg
+	 */
+	public String getMErrorMsg() {
+	    return mErrorMsg;
+	}
+
 	@Override
-	public void connectionFailed(String errorMsg) throws RemoteException {
-	    Log.i(TAG, "Connection Failed");
-	    ConnectionRunnable cRun = new ConnectionRunnable(errorMsg);
-	    mBeemApp.mActivity.runOnUiThread(cRun);
+	public void run() {
+	    mBeemApp.mProgressDialog.setMessage(mErrorMsg);
+	}
+
+	/**
+	 * @param mErrorMsg
+	 *            the mErrorMsg to set
+	 */
+	public void setMErrorMsg(String mErrorMsg) {
+	    this.mErrorMsg = mErrorMsg;
 	}
 
     }
 
+    private static final Intent    SERVICE_INTENT = new Intent();
+    private static BeemApplication mBeemApp;
+    static {
+	SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+    }
+
+    /**
+     * Get the Beem application for an activity.
+     * 
+     * @param activity
+     *            the activity which want the Beem application
+     * @return the Beem application
+     */
+    public static BeemApplication getApplication(Activity activity) {
+	if (mBeemApp == null) {
+	    mBeemApp = new BeemApplication();
+	}
+	mBeemApp.mActivity = activity;
+	mBeemApp.mProgressDialog = new ProgressDialog(activity);
+	mBeemApp.mProgressDialog.setTitle("Beem");
+	mBeemApp.mProgressDialog.setIcon(R.drawable.signal);
+	mBeemApp.mProgressDialog.setMessage("Connecting...");
+	mBeemApp.mProgressDialog.setCancelable(true);
+
+	mBeemApp.mApplicationContext = activity.getApplication();
+	activity.getResources();
+	mBeemApp.onCreate();
+	// mBeemApp.mProgressDialog.show();
+	return mBeemApp;
+    }
+
+    private Activity                 mActivity;
+    public static final String       TAG                 = "BeemApplication";
+    private IXmppFacade              mFacade;
+    private Context                  mApplicationContext;
+    private final List<Message>      mQueue              = new LinkedList<Message>();
+
+    private boolean                  mIsConnected;
+
+    private IXmppConnection          mConnection;
+
+    private ProgressDialog           mProgressDialog;
+
+    private final ConnectionListener mConnectionListener = new ConnectionListener();
+
+    private final ServiceConnection  mServConn           = new ServiceConnection() {
+
+	                                                     @Override
+	                                                     public void onServiceConnected(ComponentName name,
+	                                                             IBinder service) {
+		                                                 mIsConnected = true;
+		                                                 mFacade = IXmppFacade.Stub.asInterface(service);
+		                                                 try {
+		                                                     mConnection = mFacade.createConnection();
+		                                                     if (!mConnection.isAuthentificated()) {
+			                                                 mConnection
+			                                                         .addConnectionListener(mConnectionListener);
+			                                                 mApplicationContext
+			                                                         .startService(BeemApplication.SERVICE_INTENT);
+		                                                     } else {
+			                                                 mProgressDialog.dismiss();
+			                                                 synchronized (mQueue) {
+			                                                     for (Message msg : mQueue) {
+				                                                 msg.sendToTarget();
+			                                                     }
+			                                                     mQueue.clear();
+			                                                 }
+		                                                     }
+		                                                 } catch (RemoteException e) {
+		                                                     Log.e(TAG, "service connection exception", e);
+		                                                 }
+	                                                     }
+
+	                                                     @Override
+	                                                     public void onServiceDisconnected(ComponentName name) {
+		                                                 mFacade = null;
+		                                                 mIsConnected = false;
+	                                                     }
+	                                                 };
+
+    /**
+     * Constructor.
+     */
+    public BeemApplication() {
+	mIsConnected = false;
+    }
+
+    /**
+     * Add a methode to execute when the application is connected to the server.
+     * 
+     * @param target
+     *            the handler which will execute the callback
+     * @param callback
+     *            the callback to execute
+     */
+    public void callWhenConnectedToServer(Handler target, Runnable callback) {
+	Message msg = Message.obtain(target, callback);
+	if (mIsConnected) {
+	    msg.sendToTarget();
+	} else {
+	    startBeemService();
+	    synchronized (mQueue) {
+		mQueue.add(msg);
+	    }
+	}
+    }
+
+    /**
+     * Get the facade to use to access the Beem service.
+     * 
+     * @return the facade or null if the application is not connected to the beem service.
+     */
+    public IXmppFacade getXmppFacade() {
+	return mFacade;
+    }
+
+    /**
+     * Tell if we are connected with the Beem Service.
+     * 
+     * @return true if connected false otherwise
+     */
+    public boolean isConnected() {
+	return mIsConnected;
+    }
+
+    /**
+     * Start the beem service.
+     */
+    public synchronized void startBeemService() {
+	if (!mIsConnected) {
+	    ConnectionRunnable cRun = new ConnectionRunnable("Connecting...");
+	    mBeemApp.mActivity.runOnUiThread(cRun);
+	    // the connection will be made on service connect
+	    mApplicationContext.bindService(BeemApplication.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+	}
+    }
+
+    /**
+     * Stop the Beem service.
+     */
+    public synchronized void stopBeemService() {
+	if (mIsConnected) {
+	    Intent intent = new Intent();
+	    intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+	    mApplicationContext.unbindService(mServConn);
+	    mApplicationContext.stopService(intent);
+	    mIsConnected = false;
+	}
+    }
+
+    public synchronized void unbindBeemService() {
+	if (mIsConnected) {
+	    mApplicationContext.unbindService(mServConn);
+	    mIsConnected = false;
+	}
+    }
+
 }
--- a/src/com/beem/project/beem/BeemException.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/BeemException.java	Tue May 26 19:56:38 2009 +0200
@@ -8,53 +8,57 @@
 
 /**
  * @author darisk
- *
  */
-public class BeemException extends Exception implements Parcelable  {
+public class BeemException extends Exception implements Parcelable {
 
     /**
 	 * 
 	 */
-	private static final long serialVersionUID = -5794514989326146456L;
-	public static final Parcelable.Creator<BeemException> CREATOR = new Creator<BeemException>() {
-    
-        @Override
-        public BeemException[] newArray(int size) {
-    	// TODO Auto-generated method stub
-    	   return new BeemException[size];
-        }
-    
-        @Override
-        public BeemException createFromParcel(Parcel source) {
-    	// TODO Auto-generated method stub
-    	    return new BeemException(source);
-        }
-    };
-    
+    private static final long                             serialVersionUID = -5794514989326146456L;
+    public static final Parcelable.Creator<BeemException> CREATOR          = new Creator<BeemException>() {
+
+	                                                                       @Override
+	                                                                       public BeemException createFromParcel(
+	                                                                               Parcel source) {
+		                                                                   // TODO
+		                                                                   // Auto-generated
+		                                                                   // method stub
+		                                                                   return new BeemException(source);
+	                                                                       }
+
+	                                                                       @Override
+	                                                                       public BeemException[] newArray(int size) {
+		                                                                   // TODO
+		                                                                   // Auto-generated
+		                                                                   // method stub
+		                                                                   return new BeemException[size];
+	                                                                       }
+	                                                                   };
+
     public BeemException() {
 	super();
 	// TODO Auto-generated constructor stub
     }
 
+    private BeemException(Parcel parcel) {
+	this(parcel.readString());
+    }
+
+    public BeemException(String detailMessage) {
+	super(detailMessage);
+	// TODO Auto-generated constructor stub
+    }
+
     public BeemException(String detailMessage, Throwable throwable) {
 	super(detailMessage, throwable);
 	// TODO Auto-generated constructor stub
     }
 
-    public BeemException(String detailMessage) {
-	super(detailMessage);
-	// TODO Auto-generated constructor stub
-    }
-
     public BeemException(Throwable throwable) {
 	super(throwable);
 	// TODO Auto-generated constructor stub
     }
-    
-    private BeemException(Parcel parcel){
-	this(parcel.readString());
-    }
-     
+
     @Override
     public int describeContents() {
 	// TODO Auto-generated method stub
@@ -67,5 +71,4 @@
 	dest.writeString(getLocalizedMessage());
     }
 
-    
 }
--- a/src/com/beem/project/beem/BeemService.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Tue May 26 19:56:38 2009 +0200
@@ -10,6 +10,7 @@
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.proxy.ProxyInfo;
 import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
+
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -27,8 +28,9 @@
 import com.beem.project.beem.ui.Subscription;
 
 /**
- * This class is for the Beem service. The connection to the xmpp server will be made asynchronously when the service
- * will start.
+ * This class is for the Beem service. The connection to the xmpp server will be made asynchronously
+ * when the service will start.
+ * 
  * @author darisk
  */
 public class BeemService extends Service {
@@ -36,20 +38,20 @@
     /**
      * The id to use for status notification.
      */
-    public static final int NOTIFICATION_STATUS_ID = 100;
+    public static final int         NOTIFICATION_STATUS_ID = 100;
 
-    private NotificationManager mNotificationManager;
-    private XmppConnectionAdapter mConnection;
-    private SharedPreferences mSettings;
-    private String mLogin;
-    private String mPassword;
-    private String mHost;
-    private String mService;
-    private int mPort;
+    private NotificationManager     mNotificationManager;
+    private XmppConnectionAdapter   mConnection;
+    private SharedPreferences       mSettings;
+    private String                  mLogin;
+    private String                  mPassword;
+    private String                  mHost;
+    private String                  mService;
+    private int                     mPort;
     private ConnectionConfiguration mConnectionConfiguration;
-    private ProxyInfo mProxyInfo;
-    private boolean mUseProxy;
-    private IXmppFacade.Stub mBind;
+    private ProxyInfo               mProxyInfo;
+    private boolean                 mUseProxy;
+    private IXmppFacade.Stub        mBind;
 
     /**
      * Constructor.
@@ -58,67 +60,11 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IBinder onBind(Intent intent) {
-	return mBind;
-	// to forbid a client to bind
-	// return null;
-    }
-
-    /**
-     * {@inheritDoc}
+     * Close the connection to the xmpp server.
      */
-    @Override
-    public void onCreate() {
-
-	super.onCreate();
-	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
-	mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
-	mPassword = mSettings.getString(getString(R.string.PreferencePasswordKey), "");
-	mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
-	mPort = mSettings.getInt(getString(R.string.PreferencePortKey), 5222);
-	if (mHost.equals("talk.google.com"))
-	    mService = "gmail.com";
-	else
-	    mService = null;
-	initConnectionConfig();
-	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-	mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
-	initRosterRequestListener();
-	mBind = new XmppFacade(mConnection, this);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void onStart(Intent intent, int startId) {
-	try {
-	    mConnection.connectAsync();
-	} catch (RemoteException e) {
-	    // TODO Auto-generated catch block
-	    e.printStackTrace();
-	}
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void onDestroy() {
-	closeConnection();
-	mNotificationManager.cancel(NOTIFICATION_STATUS_ID);
-    }
-
-    /**
-     * Show a notification.
-     * @param id the id of the notification.
-     * @param notif the notification to show
-     */
-    public void sendNotification(int id, Notification notif) {
-	mNotificationManager.notify(id, notif);
+    private void closeConnection() {
+	if (mConnection != null)
+	    mConnection.disconnect();
     }
 
     /**
@@ -126,14 +72,14 @@
      */
     private void initConnectionConfig() {
 	// TODO mettre a false par defaut et remplacer les valeurs par defaut
-	mUseProxy = mSettings.getBoolean(getString(R.string.PreferenceUseProxy), false);
+	mUseProxy = mSettings.getBoolean(getString(R.string.settings_key_proxy_use), false);
 	if (mUseProxy) {
 	    String stype = mSettings.getString(getString(R.string.PreferenceProxyType),
-		getString(R.string.PreferenceProxyTypeHttp));
-	    String phost = mSettings.getString(getString(R.string.PreferenceProxyHost), "");
-	    String puser = mSettings.getString(getString(R.string.PreferenceProxyUser), "");
-	    String ppass = mSettings.getString(getString(R.string.PreferenceProxyPassword), "");
-	    int pport = mSettings.getInt(getString(R.string.PreferenceProxyPort), 1080);
+		    getString(R.string.PreferenceProxyTypeHttp));
+	    String phost = mSettings.getString(getString(R.string.settings_key_proxy_server), "");
+	    String puser = mSettings.getString(getString(R.string.settings_key_proxy_username), "");
+	    String ppass = mSettings.getString(getString(R.string.settings_key_proxy_password), "");
+	    int pport = Integer.parseInt(mSettings.getString(getString(R.string.settings_key_proxy_port), "1080"));
 	    ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
 	    mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
 	    if (mService != null)
@@ -154,10 +100,78 @@
 	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
 	final XMPPConnection con = mConnection.getAdaptee();
 	try {
-	    // l'ajout d'un packet listener ne peut etre effectuer que lorsqu'on est connecte au serveur
+	    // l'ajout d'un packet listener ne peut etre effectuer que lorsqu'on est connecte au
+	    // serveur
 	    mConnection.addConnectionListener(new IBeemConnectionListener.Stub() {
 
 		@Override
+		public void connectionClosed() throws RemoteException {
+		    // TODO Auto-generated method stub
+
+		}
+
+		@Override
+		public void connectionClosedOnError() throws RemoteException {
+		    // TODO Auto-generated method stub
+
+		}
+
+		@Override
+		public void connectionFailed(String errorMsg) throws RemoteException {
+		    // TODO Auto-generated method stub
+
+		}
+
+		@Override
+		public void onConnect() throws RemoteException {
+
+		    PacketFilter filter = new PacketFilter() {
+
+			@Override
+			public boolean accept(Packet packet) {
+			    if (packet instanceof Presence) {
+				Presence pres = (Presence) packet;
+				if (pres.getType() == Presence.Type.subscribe)
+				    return true;
+			    }
+			    return false;
+			}
+		    };
+		    con.addPacketListener(new PacketListener() {
+
+			@Override
+			public void processPacket(Packet packet) {
+			    String from = packet.getFrom();
+			    Notification notif = new Notification(com.beem.project.beem.R.drawable.signal,
+				    "Demande d'ajout", System.currentTimeMillis());
+			    notif.defaults = Notification.DEFAULT_ALL;
+			    notif.flags = Notification.FLAG_AUTO_CANCEL;
+			    Intent intent = new Intent(BeemService.this, Subscription.class);
+			    intent.putExtra("from", from);
+			    notif
+				    .setLatestEventInfo(BeemService.this, from, "demande d'ajout de " + from,
+				            PendingIntent.getActivity(BeemService.this, 0, intent,
+				                    PendingIntent.FLAG_ONE_SHOT));
+			    int id = packet.hashCode();
+			    sendNotification(id, notif);
+			}
+		    }, filter);
+
+		}
+
+		@Override
+		public void reconnectingIn(int seconds) throws RemoteException {
+		    // TODO Auto-generated method stub
+
+		}
+
+		@Override
+		public void reconnectionFailed() throws RemoteException {
+		    // TODO Auto-generated method stub
+
+		}
+
+		@Override
 		public void reconnectionSuccessful() throws RemoteException {
 		    // TODO Auto-generated method stub
 		    PacketFilter filter = new PacketFilter() {
@@ -181,71 +195,6 @@
 			}
 		    }, filter);
 		}
-
-		@Override
-		public void reconnectionFailed() throws RemoteException {
-		    // TODO Auto-generated method stub
-
-		}
-
-		@Override
-		public void reconnectingIn(int seconds) throws RemoteException {
-		    // TODO Auto-generated method stub
-
-		}
-
-		@Override
-		public void onConnect() throws RemoteException {
-
-		    PacketFilter filter = new PacketFilter() {
-
-			@Override
-			public boolean accept(Packet packet) {
-			    if (packet instanceof Presence) {
-				Presence pres = (Presence) packet;
-				if (pres.getType() == Presence.Type.subscribe)
-				    return true;
-			    }
-			    return false;
-			}
-		    };
-		    con.addPacketListener(new PacketListener() {
-
-			@Override
-			public void processPacket(Packet packet) {
-			    String from = packet.getFrom();
-			    Notification notif = new Notification(com.beem.project.beem.R.drawable.signal,
-				"Demande d'ajout", System.currentTimeMillis());
-			    notif.defaults = Notification.DEFAULT_ALL;
-			    notif.flags = Notification.FLAG_AUTO_CANCEL;
-			    Intent intent = new Intent(BeemService.this, Subscription.class);
-			    intent.putExtra("from", from);
-			    notif.setLatestEventInfo(BeemService.this, from, "demande d'ajout de " + from,
-				PendingIntent.getActivity(BeemService.this, 0, intent, PendingIntent.FLAG_ONE_SHOT));
-			    int id = packet.hashCode();
-			    sendNotification(id, notif);
-			}
-		    }, filter);
-
-		}
-
-		@Override
-		public void connectionClosedOnError() throws RemoteException {
-		    // TODO Auto-generated method stub
-
-		}
-
-		@Override
-		public void connectionClosed() throws RemoteException {
-		    // TODO Auto-generated method stub
-
-		}
-
-		@Override
-		public void connectionFailed(String errorMsg) throws RemoteException {
-		    // TODO Auto-generated method stub
-
-		}
 	    });
 	} catch (RemoteException e) {
 	    // TODO Auto-generated catch block
@@ -254,11 +203,75 @@
     }
 
     /**
-     * Close the connection to the xmpp server.
+     * {@inheritDoc}
+     */
+    @Override
+    public IBinder onBind(Intent intent) {
+	return mBind;
+	// to forbid a client to bind
+	// return null;
+    }
+
+    /**
+     * {@inheritDoc}
      */
-    private void closeConnection() {
-	if (mConnection != null)
-	    mConnection.disconnect();
+    @Override
+    public void onCreate() {
+
+	super.onCreate();
+	mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
+	mLogin = mSettings.getString(getString(R.string.settings_key_account_username), "");
+	mPassword = mSettings.getString(getString(R.string.settings_key_account_password), "");
+	mHost = mSettings.getString(getString(R.string.settings_key_xmpp_server), "");
+	mPort = Integer.parseInt(mSettings.getString(getString(R.string.settings_key_xmpp_port), "5222"));
+
+	Log.i("BEEMSERVICE", mLogin);
+	Log.i("BEEMSERVICE", mPassword);
+	Log.i("BEEMSERVICE", mHost);
+	Log.i("BEEMSERVICE", "" + mPort + "");
+	if (mHost.equals("talk.google.com"))
+	    mService = "gmail.com";
+	else
+	    mService = null;
+	initConnectionConfig();
+	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+	mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
+	initRosterRequestListener();
+	mBind = new XmppFacade(mConnection, this);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onDestroy() {
+	closeConnection();
+	mNotificationManager.cancel(NOTIFICATION_STATUS_ID);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onStart(Intent intent, int startId) {
+	try {
+	    mConnection.connectAsync();
+	} catch (RemoteException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
+	}
+    }
+
+    /**
+     * Show a notification.
+     * 
+     * @param id
+     *            the id of the notification.
+     * @param notif
+     *            the notification to show
+     */
+    public void sendNotification(int id, Notification notif) {
+	mNotificationManager.notify(id, notif);
     }
 
 }
--- a/src/com/beem/project/beem/jingle/Caller.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/Caller.java	Tue May 26 19:56:38 2009 +0200
@@ -3,6 +3,7 @@
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
+
 import org.jivesoftware.smack.ConnectionConfiguration;
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
@@ -16,146 +17,128 @@
 
 /**
  * @author darisk
- * 
  */
 public class Caller {
 
-	private XMPPConnection con;
-	private String login;
-	private String password;
-	private JingleManager jingleManager;
-	private List<JingleMediaManager> mediaManagers;
-	private JingleSession out;
+    /**
+     * @param args
+     *            Program args
+     * @throws InterruptedException
+     *             exception
+     */
+    public static void main(final String[] args) throws InterruptedException {
+	if (args.length < 3) {
+	    System.err.println("Not enough parameters");
+	    System.err.println("Usage : Caller user password server jidtocall");
+	}
+	Caller test = new Caller(args[0], args[1], args[2]);
+	test.call("test2@nikita-rack/TEST");
+	Thread.sleep(60000);
+    }
+
+    private XMPPConnection           con;
+    private String                   login;
+    private String                   password;
+    private JingleManager            jingleManager;
+    private List<JingleMediaManager> mediaManagers;
+
+    private JingleSession            out;
+
+    public Caller(final String login, final String pass, String server) {
+	if (server == null || server.equals(""))
+	    server = "localhost";
+	// XMPPConnection.DEBUG_ENABLED = true;
+	this.login = login;
+	this.password = pass;
+	ConnectionConfiguration conf = new ConnectionConfiguration(server);
+	conf.setRosterLoadedAtLogin(false);
+
+	con = new XMPPConnection(conf);
+	try {
+	    con.connect();
+	    con.login(this.login, this.password, "Caller");
+	    initialize();
+	} catch (XMPPException e) {
+	    // TODO Auto-generated catch block
+	    System.err.println("Echec de la connexion au serveru");
+	    e.printStackTrace();
+	}
+    }
+
+    public void call(final String destinataire) {
+	try {
+	    out = jingleManager.createOutgoingJingleSession(destinataire);
+	    // TODO configure out avec addMediaSession et addNegociator
+	    out.addListener(new JingleSessionListener() {
 
-	public Caller(final String login, final String pass, String server) {
-		if (server == null || server.equals(""))
-			server = "localhost";
-		//XMPPConnection.DEBUG_ENABLED = true;
-		this.login = login;
-		this.password = pass;
-		ConnectionConfiguration conf = new ConnectionConfiguration(server);
-		conf.setRosterLoadedAtLogin(false);
+		@Override
+		public void sessionClosed(final String reason, final JingleSession jingleSession) {
+		    System.out.println("Session " + jingleSession.getResponder() + "closed because " + reason);
+		}
+
+		@Override
+		public void sessionClosedOnError(final XMPPException e, final JingleSession jingleSession) {
+		    System.out.println("Session " + jingleSession.getResponder() + " closed on error");
+
+		}
+
+		@Override
+		public void sessionDeclined(final String reason, final JingleSession jingleSession) {
+		    System.out.println("Session " + jingleSession.getResponder() + "declined because " + reason);
+		}
 
-		con = new XMPPConnection(conf);
-		try {
-			con.connect();
-			con.login(this.login, this.password, "Caller");
-			initialize();
-		} catch (XMPPException e) {
-			// TODO Auto-generated catch block
-			System.err.println("Echec de la connexion au serveru");
+		@Override
+		public void sessionEstablished(final PayloadType pt, final TransportCandidate remoteCandidate,
+		        final TransportCandidate localCandidate, final JingleSession jingleSession) {
+		    System.out.println("Session established");
+		    // String name = localCandidate.getName();
+		    String ip = localCandidate.getIp();
+		    int port = localCandidate.getPort();
+		    System.out.println("Session established waiting connection on " + ip + ":" + port);
+		    try {
+			try {
+			    FileSender fs = new FileSender(ip, port, "/tmp/img.jpeg");
+			    fs.start();
+			    fs.join();
+			    System.out.println("End of transfer");
+			} finally {
+			    jingleSession.terminate();
+			}
+		    } catch (UnknownHostException e) {
+			System.err.println("Can't create server");
+		    } catch (InterruptedException e) {
+		    } catch (XMPPException e) {
+			System.err.println("Probably lost the connection");
 			e.printStackTrace();
+		    }
 		}
+
+		@Override
+		public void sessionMediaReceived(final JingleSession jingleSession, final String participant) {
+		    // TODO Auto-generated method stub
+		    System.out.println("Session Media received from " + participant);
+		}
+
+		@Override
+		public void sessionRedirected(final String redirection, final JingleSession jingleSession) {
+		    // TODO Auto-generated method stub
+		}
+	    });
+	    out.startOutgoing();
+
+	} catch (XMPPException e) {
+	    // TODO Auto-generated catch block
+	    e.printStackTrace();
 	}
 
-	public void call(final String destinataire) {
-		try {
-			out = jingleManager.createOutgoingJingleSession(destinataire);
-			// TODO configure out avec addMediaSession et addNegociator
-			out.addListener(new JingleSessionListener() {
-
-				@Override
-				public void sessionRedirected(final String redirection,
-						final JingleSession jingleSession) {
-					// TODO Auto-generated method stub
-				}
-
-				@Override
-				public void sessionMediaReceived(
-						final JingleSession jingleSession,
-						final String participant) {
-					// TODO Auto-generated method stub
-					System.out.println("Session Media received from "
-							+ participant);
-				}
-
-				@Override
-				public void sessionEstablished(final PayloadType pt,
-						final TransportCandidate remoteCandidate,
-						final TransportCandidate localCandidate,
-						final JingleSession jingleSession) {
-					System.out.println("Session established");
-					//String name = localCandidate.getName();
-					String ip = localCandidate.getIp();
-					int port = localCandidate.getPort();
-					System.out
-							.println("Session established waiting connection on "
-									+ ip + ":" + port);
-					try {
-						try {
-							FileSender fs = new FileSender(ip, port,
-									"/tmp/img.jpeg");
-							fs.start();
-							fs.join();
-							System.out.println("End of transfer");
-						} finally {
-							jingleSession.terminate();
-						}
-					} catch (UnknownHostException e) {
-						System.err.println("Can't create server");
-					} catch (InterruptedException e) {
-					} catch (XMPPException e) {
-						System.err.println("Probably lost the connection");
-						e.printStackTrace();
-					}
-				}
+    }
 
-				@Override
-				public void sessionDeclined(final String reason,
-						final JingleSession jingleSession) {
-					System.out.println("Session "
-							+ jingleSession.getResponder()
-							+ "declined because " + reason);
-				}
-
-				@Override
-				public void sessionClosedOnError(final XMPPException e,
-						final JingleSession jingleSession) {
-					System.out
-							.println("Session " + jingleSession.getResponder()
-									+ " closed on error");
-
-				}
-
-				@Override
-				public void sessionClosed(final String reason,
-						final JingleSession jingleSession) {
-					System.out.println("Session "
-							+ jingleSession.getResponder() + "closed because "
-							+ reason);
-				}
-			});
-			out.startOutgoing();
+    private void initialize() {
+	mediaManagers = new ArrayList<JingleMediaManager>();
+	mediaManagers.add(new SenderMediaManager(new BasicTransportManager()));
+	JingleManager.setJingleServiceEnabled();
+	jingleManager = new JingleManager(con, mediaManagers);
 
-		} catch (XMPPException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-
-	}
-
-	private void initialize() {
-		mediaManagers = new ArrayList<JingleMediaManager>();
-		mediaManagers.add(new SenderMediaManager(new BasicTransportManager()));
-		JingleManager.setJingleServiceEnabled();
-		jingleManager = new JingleManager(con, mediaManagers);
-
-	}
-
-	/**
-	 * @param args
-	 *            Program args
-	 * @throws InterruptedException
-	 *             exception
-	 */
-	public static void main(final String[] args) throws InterruptedException {
-		if (args.length < 3) {
-			System.err.println("Not enough parameters");
-			System.err.println("Usage : Caller user password server jidtocall");
-		}
-		Caller test = new Caller(args[0], args[1], args[2]);
-		test.call("test2@nikita-rack/TEST");
-		Thread.sleep(60000);
-	}
+    }
 
 }
--- a/src/com/beem/project/beem/jingle/FileSender.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/FileSender.java	Tue May 26 19:56:38 2009 +0200
@@ -7,25 +7,33 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-
 import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.UnknownHostException;
 
 public class FileSender extends Thread {
-    private int port;
-    private boolean started = false;
-    private String filename;
+
+    public static void main(String args[]) throws InterruptedException, UnknownHostException {
+	FileSender fs = new FileSender("127.0.0.1", 4242, "/tmp/img.jpeg");
+	fs.start();
+	fs.join();
+    }
+
+    private int         port;
+    private boolean     started = false;
+    private String      filename;
+
     private InetAddress local_addr;
 
-    public FileSender(String listenAddr,  int port, String file) throws UnknownHostException{
+    public FileSender(String listenAddr, int port, String file) throws UnknownHostException {
 	this.port = port;
 	this.filename = file;
 	this.local_addr = InetAddress.getByName(listenAddr);
     }
 
-    public void run(){
+    @Override
+    public void run() {
 	try {
 	    ServerSocket ssock = new ServerSocket(port, 50, local_addr);
 	    InputStream in = new BufferedInputStream(new FileInputStream(filename));
@@ -37,7 +45,7 @@
 		started = true;
 		byte buf[] = new byte[1024];
 		int nbbytes = 1;
-		while (started){
+		while (started) {
 		    nbbytes = in.read(buf, 0, 1024);
 		    if (nbbytes == -1)
 			break;
@@ -54,21 +62,15 @@
 		if (ssock != null)
 		    ssock.close();
 	    }
-	} catch (FileNotFoundException e){
-	    System.err.println("Impossible d'ouvrir " + filename +" " + e.getLocalizedMessage());
+	} catch (FileNotFoundException e) {
+	    System.err.println("Impossible d'ouvrir " + filename + " " + e.getLocalizedMessage());
 	} catch (IOException e) {
 	    System.err.println("I/O Error " + e.getLocalizedMessage());
 	}
     }
 
-    public void setStarted(){
+    public void setStarted() {
 	started = false;
     }
 
-    public static void main(String args[]) throws InterruptedException, UnknownHostException {
-	FileSender fs = new FileSender("127.0.0.1" ,4242, "/tmp/img.jpeg");
-	fs.start();
-	fs.join();
-    }
-
 }
--- a/src/com/beem/project/beem/jingle/RTPMediaManager.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPMediaManager.java	Tue May 26 19:56:38 2009 +0200
@@ -12,42 +12,42 @@
 import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
 
 public class RTPMediaManager extends JingleMediaManager {
-	
-	private static final SmackLogger LOGGER = SmackLogger.getLogger(RTPMediaManager.class);
+
+    private static final SmackLogger LOGGER     = SmackLogger.getLogger(RTPMediaManager.class);
 
-	public static final String MEDIA_NAME = "RTP_BIDON";
-	
-	private List<PayloadType> payloads;
+    public static final String       MEDIA_NAME = "RTP_BIDON";
+
+    private List<PayloadType>        payloads;
 
-	public RTPMediaManager(JingleTransportManager transportManager) {
-		super(transportManager);
-		// TODO Auto-generated constructor stub
-		setupPayloads();
-		LOGGER.info("A TestMedia Manager is created(Receiver)");
-	}
+    public RTPMediaManager(JingleTransportManager transportManager) {
+	super(transportManager);
+	// TODO Auto-generated constructor stub
+	setupPayloads();
+	LOGGER.info("A TestMedia Manager is created(Receiver)");
+    }
 
-	@Override
-	public JingleMediaSession createMediaSession(PayloadType payloadType,
-			TransportCandidate remote, TransportCandidate local,
-			JingleSession jingleSession) {
-		// TODO Auto-generated method stub
-		return new RTPMediaSession(payloadType, remote, local, null, jingleSession);
-	}
+    @Override
+    public JingleMediaSession createMediaSession(PayloadType payloadType, TransportCandidate remote,
+	    TransportCandidate local, JingleSession jingleSession) {
+	// TODO Auto-generated method stub
+	return new RTPMediaSession(payloadType, remote, local, null, jingleSession);
+    }
+
+    @Override
+    public String getName() {
+	return MEDIA_NAME;
+    }
 
-	@Override
-	public List<PayloadType> getPayloads() {
-		// TODO Auto-generated method stub
-		return payloads;
-	}
+    @Override
+    public List<PayloadType> getPayloads() {
+	// TODO Auto-generated method stub
+	return payloads;
+    }
 
-	private void setupPayloads() {
-		payloads = new ArrayList<PayloadType>();
-		payloads.add(new PayloadType.Audio(51, "BIDON1"));
-		payloads.add(new PayloadType.Audio(52, "BIDON2"));
-		payloads.add(new PayloadType.Audio(53, "BIDON3"));
-	}
-	
-	public String getName() {
-		return MEDIA_NAME;
-	}
+    private void setupPayloads() {
+	payloads = new ArrayList<PayloadType>();
+	payloads.add(new PayloadType.Audio(51, "BIDON1"));
+	payloads.add(new PayloadType.Audio(52, "BIDON2"));
+	payloads.add(new PayloadType.Audio(53, "BIDON3"));
+    }
 }
--- a/src/com/beem/project/beem/jingle/RTPMediaSession.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPMediaSession.java	Tue May 26 19:56:38 2009 +0200
@@ -11,66 +11,62 @@
 
 /**
  * @author darisk
- * 
  */
 public class RTPMediaSession extends JingleMediaSession {
 
-	private static final SmackLogger LOGGER = SmackLogger
-	.getLogger(RTPMediaSession.class);
-	private RTPTransmitter transmitter;
-	private RTPReceiver receiver;
+    private static final SmackLogger LOGGER = SmackLogger.getLogger(RTPMediaSession.class);
+    private RTPTransmitter           transmitter;
+    private RTPReceiver              receiver;
+
+    /**
+     * @param payloadType
+     * @param remote
+     * @param local
+     * @param mediaLocator
+     * @param jingleSession
+     */
+    public RTPMediaSession(PayloadType payloadType, TransportCandidate remote, TransportCandidate local,
+	    String mediaLocator, JingleSession jingleSession) {
+
+	super(payloadType, remote, local, mediaLocator, jingleSession);
+	initialize();
+	LOGGER.info("Demarrage d'une session avec local: " + local + " #remote: " + remote);
+
+	transmitter = new RTPTransmitter(remote.getIp(), getRemote().getPort());
+	receiver = new RTPReceiver(getLocal().getPort());
+    }
 
-	/**
-	 * @param payloadType
-	 * @param remote
-	 * @param local
-	 * @param mediaLocator
-	 * @param jingleSession
-	 */
-	public RTPMediaSession(PayloadType payloadType,
-			TransportCandidate remote, TransportCandidate local,
-			String mediaLocator, JingleSession jingleSession) {
+    @Override
+    public void initialize() {
+	// TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setTrasmit(boolean active) {
+    }
 
-		super(payloadType, remote, local, mediaLocator, jingleSession);
-		initialize();
-		LOGGER.info("Demarrage d'une session avec local: " + local
-				+ " #remote: " + remote);
+    @Override
+    public void startReceive() {
+
+    }
 
-		transmitter = new RTPTransmitter(remote.getIp(), getRemote().getPort());
-		receiver = new RTPReceiver(getLocal().getPort());
-	}
+    @Override
+    public void startTrasmit() {
+
+    }
 
-	@Override
-	public void initialize() {
-		// TODO Auto-generated method stub
-
+    @Override
+    public void stopReceive() {
+	if (receiver != null) {
+	    receiver.stop();
 	}
-
-	@Override
-	public void setTrasmit(boolean active) {	
-	}
-
-	@Override
-	public void startReceive() {
-
-	}
-
-	@Override
-	public void startTrasmit() {
-
-	}
+    }
 
-	@Override
-	public void stopReceive() {
-		if (receiver != null) {
-			receiver.stop();
-		}
+    @Override
+    public void stopTrasmit() {
+	if (transmitter != null) {
+	    transmitter.stop();
 	}
-
-	@Override
-	public void stopTrasmit() {
-		if (transmitter != null) {
-			transmitter.stop();
-		}
-	}
+    }
 }
--- a/src/com/beem/project/beem/jingle/RTPReceiver.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPReceiver.java	Tue May 26 19:56:38 2009 +0200
@@ -5,93 +5,98 @@
 import java.net.ServerSocket;
 
 import org.jivesoftware.smackx.jingle.SmackLogger;
+import org.jlibrtp.jlibrtp.core.DataFrame;
+import org.jlibrtp.jlibrtp.core.Participant;
+import org.jlibrtp.jlibrtp.core.RTPAppIntf;
+import org.jlibrtp.jlibrtp.core.RTPSession;
 
-import jlibrtp.DataFrame;
-import jlibrtp.Participant;
-import jlibrtp.RTPAppIntf;
-import jlibrtp.RTPSession;
+public class RTPReceiver implements Runnable, RTPAppIntf {
 
-public class RTPReceiver implements Runnable, RTPAppIntf{
+    RTPSession                       rtpSession = null;
+    byte[]                           abData     = null;
+    private boolean                  killme     = false;
+
+    private static final SmackLogger LOGGER     = SmackLogger.getLogger(SenderMediaManager.class);
+
+    public RTPReceiver(int rtpPort) {
+	DatagramSocket rtpSocket = null;
 
-	RTPSession rtpSession = null;
-	byte[] abData = null;
-	private boolean killme = false;
+	try {
+	    rtpSocket = new DatagramSocket(rtpPort);
+	} catch (Exception e) {
+	    System.out.println("RTPSession failed to obtain port");
+	    return;
+	}
+	rtpSession = new RTPSession(rtpSocket, null);
+	rtpSession.naivePktReception(true);
+	rtpSession.RTPSessionRegister(this, null, null);
+    }
 
-	private static final SmackLogger LOGGER = SmackLogger.getLogger(SenderMediaManager.class);
+    @Override
+    public int frameSize(int payloadType) {
+	return 1;
+    }
 
-	public RTPReceiver(int rtpPort) {
-		DatagramSocket rtpSocket = null;
+    protected int getFreePort() {
+	ServerSocket ss;
+	int freePort = 0;
 
-		try {
-			rtpSocket = new DatagramSocket(rtpPort);
-		} catch (Exception e) {
-			System.out.println("RTPSession failed to obtain port");
-			return;
-		}
-		rtpSession = new RTPSession(rtpSocket, null);
-		rtpSession.naivePktReception(true);
-		rtpSession.RTPSessionRegister(this, null, null);
+	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;
+    }
 
-	@Override
-	public void run() {
-		start();		
-	}
+    @Override
+    public void receiveData(DataFrame frame, Participant participant) {
+	// byte[] data = frame.getConcatenatedData();
+    }
 
-	private void start() {
-		LOGGER.info("Debut envoi de donnees par RTPTransmitter");
-		while (!killme) {
-			try { Thread.sleep(1000); } catch(Exception e) { }
-		}
+    @Override
+    public void run() {
+	start();
+    }
 
-		try {Thread.sleep(200);} catch (Exception e) {}
-		this.rtpSession.endSession();
-
+    private void start() {
+	LOGGER.info("Debut envoi de donnees par RTPTransmitter");
+	while (!killme) {
+	    try {
+		Thread.sleep(1000);
+	    } catch (Exception e) {
+	    }
 	}
 
-	@Override
-	public int frameSize(int payloadType) {
-		return 1;
+	try {
+	    Thread.sleep(200);
+	} catch (Exception e) {
 	}
-
-	@Override
-	public void receiveData(DataFrame frame, Participant participant) {
-		//byte[] data = frame.getConcatenatedData();		
-	}
+	this.rtpSession.endSession();
 
-	@Override
-	public void userEvent(int type, Participant[] participant) {
-		//rien
-
-	}
-
-	public void stop() {
-		this.killme  = true;
-	}
+    }
 
-	protected int getFreePort() {
-		ServerSocket ss;
-		int freePort = 0;
+    public void stop() {
+	this.killme = true;
+    }
 
-		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;
-	}
+    @Override
+    public void userEvent(int type, Participant[] participant) {
+	// rien
+
+    }
 }
--- a/src/com/beem/project/beem/jingle/RTPTransmitter.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/RTPTransmitter.java	Tue May 26 19:56:38 2009 +0200
@@ -5,96 +5,97 @@
 import java.net.ServerSocket;
 
 import org.jivesoftware.smackx.jingle.SmackLogger;
-
-import jlibrtp.DataFrame;
-import jlibrtp.Participant;
-import jlibrtp.RTPAppIntf;
-import jlibrtp.RTPSession;
+import org.jlibrtp.jlibrtp.core.DataFrame;
+import org.jlibrtp.jlibrtp.core.Participant;
+import org.jlibrtp.jlibrtp.core.RTPAppIntf;
+import org.jlibrtp.jlibrtp.core.RTPSession;
 
 public class RTPTransmitter implements Runnable, RTPAppIntf {
 
-	private static final SmackLogger LOGGER = SmackLogger
-			.getLogger(SenderMediaManager.class);
-	private RTPSession rtpSession;
-	private boolean killme = false;
+    private static final SmackLogger LOGGER     = SmackLogger.getLogger(SenderMediaManager.class);
+    private RTPSession               rtpSession = null;
+    private boolean                  killme     = false;
+
+    public RTPTransmitter(String remoteIP, int port) {
+
+	DatagramSocket rtpSocket = null;
+	int rtpPort = 0;
 
-	public RTPTransmitter(String remoteIP, int port) {
+	try {
+	    rtpPort = getFreePort();
+	    rtpSocket = new DatagramSocket(rtpPort);
+	} catch (Exception e) {
+	    System.out.println("RTPSession failed to obtain port");
+	    return;
+	}
+	rtpSession = new RTPSession(rtpSocket, null);
+	rtpSession.naivePktReception(true);
+	rtpSession.RTPSessionRegister(this, null, null);
+	rtpSession.addParticipant(new Participant(remoteIP, rtpPort, 0));
+    }
 
-		DatagramSocket rtpSocket = null;
-		int rtpPort = 0;
+    @Override
+    public int frameSize(int payloadType) {
+	return 1;
+    }
+
+    protected int getFreePort() {
+	ServerSocket ss;
+	int freePort = 0;
 
-		try {
-			rtpPort = getFreePort();
-			rtpSocket = new DatagramSocket(rtpPort);
-		} catch (Exception e) {
-			System.out.println("RTPSession failed to obtain port");
-			return;
-		}
-		rtpSession = new RTPSession(rtpSocket, null);
-		rtpSession.naivePktReception(true);
-		rtpSession.RTPSessionRegister(this, null, null);
-		rtpSession.addParticipant(new Participant(remoteIP,rtpPort, 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;
+    }
 
-	private void start() {
-		LOGGER.info("Debut envoi de donnees par RTPTransmitter");
-		while (!killme) {
-			rtpSession.sendData(null);
-		}
+    @Override
+    public void receiveData(DataFrame frame, Participant participant) {
+	// On envoie uniquement
+    }
 
-		try {Thread.sleep(200);} catch (Exception e) {}
-		this.rtpSession.endSession();
-	}
+    @Override
+    public void run() {
+	start();
+    }
 
-	@Override
-	public void run() {
-		start();
-	}
-
-	@Override
-	public int frameSize(int payloadType) {
-		return 1;
+    private void start() {
+	LOGGER.info("Debut envoi de donnees par RTPTransmitter");
+	while (!killme) {
+	    rtpSession.sendData(null);
 	}
 
-	@Override
-	public void receiveData(DataFrame frame, Participant participant) {
-		//On envoie uniquement
+	try {
+	    Thread.sleep(200);
+	} catch (Exception e) {
 	}
-
-	@Override
-	public void userEvent(int type, Participant[] participant) {
-		//je sais pas ce que c'est
-
-	}
-
-	protected int getFreePort() {
-		ServerSocket ss;
-		int freePort = 0;
+	this.rtpSession.endSession();
+    }
 
-		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;
-	}
+    public void stop() {
+	this.killme = true;
+    }
 
-	public void stop() {
-		this.killme = true;
-	}
+    @Override
+    public void userEvent(int type, Participant[] participant) {
+	// je sais pas ce que c'est
+
+    }
 
 }
--- a/src/com/beem/project/beem/jingle/Receiver.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/Receiver.java	Tue May 26 19:56:38 2009 +0200
@@ -5,6 +5,7 @@
 import java.net.Socket;
 import java.util.ArrayList;
 import java.util.List;
+
 import org.jivesoftware.smack.ConnectionConfiguration;
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
@@ -19,39 +20,54 @@
 import org.jivesoftware.smackx.jingle.nat.BasicTransportManager;
 import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
 
-
 public class Receiver {
 
-    private XMPPConnection con;
-    private JingleManager jingleManager;
+    /**
+     * @param args
+     * @throws InterruptedException
+     * @throws InterruptedException
+     */
+    public static void main(String[] args) throws InterruptedException {
+	@SuppressWarnings("unused")
+	Receiver rec = new Receiver("test2", "test2");
+	System.out.println("Receiver initialized");
+
+	Thread.sleep(60000);
+
+    }
+
+    private XMPPConnection           con;
+    private JingleManager            jingleManager;
     private List<JingleMediaManager> mediaManagers;
-    private JingleSession in;
+
+    private JingleSession            in;
 
     public Receiver(String username, String pass) {
-	//		XMPPConnection.DEBUG_ENABLED = true;
+	// XMPPConnection.DEBUG_ENABLED = true;
 	ConnectionConfiguration conf = new ConnectionConfiguration("nikita-rack");
 	conf.setRosterLoadedAtLogin(false);
 	con = new XMPPConnection(conf);
-	
+
 	try {
-		
+
 	    con.connect();
 	    JingleManager.setJingleServiceEnabled();
-		ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(con);
-	    //NOTE  Classe gerant le service discovery (ce qui permet aux autres de savoir ce qu'on sait faire)
-	    
-	    
-	    //Pour rajouter une liste de feature supporter (de format : "http://jabber.org/protocol/disco#info")
+	    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(con);
+	    // NOTE Classe gerant le service discovery (ce qui permet aux autres de savoir ce qu'on
+	    // sait faire)
+
+	    // Pour rajouter une liste de feature supporter (de format :
+	    // "http://jabber.org/protocol/disco#info")
 	    sdm.addFeature("http://jabber.org/protocol/disco#info");
 	    sdm.addFeature("TOTO");
-	    
+
 	    con.login(username, pass, "TEST-JAVA");
 	    initialize();
 	    // Le client demande les services dispo en face a son roster
 	    // il doit en suite fournir lui meme une liste de feature
-	    
-	    //DiscoverInfo di = sdm.discoverInfo("test@nikita-rack/pidgin");
-	    //DiscoverInfo di2 = sdm.discoverInfo("nikita@nikita-rack/Telepathy");
+
+	    // DiscoverInfo di = sdm.discoverInfo("test@nikita-rack/pidgin");
+	    // DiscoverInfo di2 = sdm.discoverInfo("nikita@nikita-rack/Telepathy");
 
 	} catch (XMPPException e) {
 	    // TODO Auto-generated catch block
@@ -60,62 +76,60 @@
     }
 
     private void initialize() {
-    BasicTransportManager bt = new BasicTransportManager();
+	BasicTransportManager bt = new BasicTransportManager();
 	mediaManagers = new ArrayList<JingleMediaManager>();
 	mediaManagers.add(new RTPMediaManager(bt));
 	mediaManagers.add(new SenderMediaManager(bt));
-	
+
 	jingleManager = new JingleManager(con, mediaManagers);
 	jingleManager.addJingleSessionRequestListener(new JingleSessionRequestListener() {
 
 	    @Override
 	    public void sessionRequested(JingleSessionRequest request) {
-		System.out.println("Jingle Session request from "+request.getFrom());
+		System.out.println("Jingle Session request from " + request.getFrom());
 		try {
 		    in = request.accept();
 		    in.addListener(new JingleSessionListener() {
 
 			@Override
-			public void sessionRedirected(String redirection,
-			    JingleSession jingleSession) {
+			public void sessionClosed(String reason, JingleSession jingleSession) {
+			    System.out.println("Session " + jingleSession.getResponder() + "closedd because " + reason);
+			}
+
+			@Override
+			public void sessionClosedOnError(XMPPException e, JingleSession jingleSession) {
+			    // TODO Auto-generated method stub
+			    System.out.println("Session " + jingleSession.getResponder() + " closed");
+
 			}
 
 			@Override
-			public void sessionMediaReceived(JingleSession jingleSession,
-			    String participant) {
-			    System.out.println("Session Media received from " + participant);
+			public void sessionDeclined(String reason, JingleSession jingleSession) {
+			    // TODO Auto-generated method stub
+			    System.out
+				    .println("Session " + jingleSession.getResponder() + "declined because " + reason);
 			}
 
 			@Override
-			public void sessionEstablished(PayloadType pt,
-			    TransportCandidate remoteCandidate,
-			    TransportCandidate localCandidate, JingleSession jingleSession) {
+			public void sessionEstablished(PayloadType pt, TransportCandidate remoteCandidate,
+			        TransportCandidate localCandidate, JingleSession jingleSession) {
 			    System.out.println("Session established");
-			    try{
-				System.out.println("Je recois sur " + remoteCandidate.getIp() + ":" + remoteCandidate.getPort() );
+			    try {
+				System.out.println("Je recois sur " + remoteCandidate.getIp() + ":"
+				        + remoteCandidate.getPort());
 				receiveData(remoteCandidate.getIp(), remoteCandidate.getPort());
-			    } catch (IOException e){
+			    } catch (IOException e) {
 				e.printStackTrace();
 			    }
 			}
 
 			@Override
-			public void sessionDeclined(String reason, JingleSession jingleSession) {
-			    // TODO Auto-generated method stub
-			    System.out.println("Session "+ jingleSession.getResponder() +"declined because "+ reason);
+			public void sessionMediaReceived(JingleSession jingleSession, String participant) {
+			    System.out.println("Session Media received from " + participant);
 			}
 
 			@Override
-			public void sessionClosedOnError(XMPPException e,
-				JingleSession jingleSession) {
-			    // TODO Auto-generated method stub
-			    System.out.println("Session "+ jingleSession.getResponder() + " closed"); 
-
-			}
-
-			@Override
-			public void sessionClosed(String reason, JingleSession jingleSession) {
-			    System.out.println("Session "+ jingleSession.getResponder() +"closedd because "+ reason);
+			public void sessionRedirected(String redirection, JingleSession jingleSession) {
 			}
 		    });
 		    in.startIncoming();
@@ -127,15 +141,14 @@
 
     }
 
-
     private void receiveData(String ip, int port) throws IOException {
 	Socket s = null;
 	try {
-	    s = new Socket(ip, port); 
+	    s = new Socket(ip, port);
 	    System.out.println("Waiting data");
 	    InputStream in = s.getInputStream();
 	    int a;
-	    while ( (a = in.read()) != -1) {
+	    while ((a = in.read()) != -1) {
 		System.out.println("Received " + a);
 	    }
 	    System.out.println("End receiving data");
@@ -145,17 +158,4 @@
 	}
     }
 
-    /**
-     * @param args
-     * @throws InterruptedException 
-     * @throws InterruptedException 
-     */
-    public static void main(String[] args) throws InterruptedException {
-	Receiver rec = new Receiver("test2", "test2");
-	System.out.println("Receiver initialized");
-
-	Thread.sleep(60000);
-
-    }
-
 }
--- a/src/com/beem/project/beem/jingle/ReceiverMediaManager.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/ReceiverMediaManager.java	Tue May 26 19:56:38 2009 +0200
@@ -13,41 +13,41 @@
 import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
 
 public class ReceiverMediaManager extends JingleMediaManager {
-	
-	private static final SmackLogger LOGGER = SmackLogger.getLogger(ReceiverMediaManager.class);
+
+    private static final SmackLogger LOGGER     = SmackLogger.getLogger(ReceiverMediaManager.class);
 
-	public static final String MEDIA_NAME = "69Test";
-	
-	private List<PayloadType> payloads;
+    public static final String       MEDIA_NAME = "69Test";
+
+    private List<PayloadType>        payloads;
 
-	public ReceiverMediaManager(JingleTransportManager transportManager) {
-		super(transportManager);
-		// TODO Auto-generated constructor stub
-		setupPayloads();
-		LOGGER.info("A TestMedia Manager is created");
-	}
+    public ReceiverMediaManager(JingleTransportManager transportManager) {
+	super(transportManager);
+	// TODO Auto-generated constructor stub
+	setupPayloads();
+	LOGGER.info("A TestMedia Manager is created");
+    }
 
-	@Override
-	public JingleMediaSession createMediaSession(PayloadType payloadType,
-			TransportCandidate remote, TransportCandidate local,
-			JingleSession jingleSession) {
-		// TODO Auto-generated method stub
-		return new TestMediaSession(payloadType, remote, local, null, jingleSession);
-	}
+    @Override
+    public JingleMediaSession createMediaSession(PayloadType payloadType, TransportCandidate remote,
+	    TransportCandidate local, JingleSession jingleSession) {
+	// TODO Auto-generated method stub
+	return new TestMediaSession(payloadType, remote, local, null, jingleSession);
+    }
+
+    @Override
+    public String getName() {
+	return MEDIA_NAME;
+    }
 
-	@Override
-	public List<PayloadType> getPayloads() {
-		// TODO Auto-generated method stub
-		return payloads;
-	}
+    @Override
+    public List<PayloadType> getPayloads() {
+	// TODO Auto-generated method stub
+	return payloads;
+    }
 
-	private void setupPayloads() {
-		payloads = new ArrayList<PayloadType>();
-		payloads.add(new PayloadType.Audio(42, "Test"));
-		payloads.add(new PayloadType.Audio(69, "Test2"));
-	}
-	
-	public String getName() {
-		return MEDIA_NAME;
-	}
+    private void setupPayloads() {
+	payloads = new ArrayList<PayloadType>();
+	payloads.add(new PayloadType.Audio(42, "Test"));
+	payloads.add(new PayloadType.Audio(69, "Test2"));
+    }
 }
--- a/src/com/beem/project/beem/jingle/SenderMediaManager.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/SenderMediaManager.java	Tue May 26 19:56:38 2009 +0200
@@ -2,6 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+
 import org.jivesoftware.smackx.jingle.JingleSession;
 import org.jivesoftware.smackx.jingle.SmackLogger;
 import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
@@ -12,42 +13,39 @@
 
 public class SenderMediaManager extends JingleMediaManager {
 
-	private static final SmackLogger LOGGER = SmackLogger
-			.getLogger(SenderMediaManager.class);
+    private static final SmackLogger LOGGER     = SmackLogger.getLogger(SenderMediaManager.class);
 
-	public static final String MEDIA_NAME = "42Test";
+    public static final String       MEDIA_NAME = "42Test";
 
-	private List<PayloadType> payloads;
+    private List<PayloadType>        payloads;
 
-	public SenderMediaManager(JingleTransportManager transportManager) {
-		super(transportManager);
-		// TODO Auto-generated constructor stub
-		setupPayloads();
-		LOGGER.info("A TestMedia Manager is created(Sender)");
-	}
+    public SenderMediaManager(JingleTransportManager transportManager) {
+	super(transportManager);
+	// TODO Auto-generated constructor stub
+	setupPayloads();
+	LOGGER.info("A TestMedia Manager is created(Sender)");
+    }
 
-	@Override
-	public JingleMediaSession createMediaSession(PayloadType payloadType,
-			TransportCandidate remote, TransportCandidate local,
-			JingleSession jingleSession) {
-		// TODO Auto-generated method stub
-		return new RTPMediaSession(payloadType, remote, local, null,
-				jingleSession);
-	}
+    @Override
+    public JingleMediaSession createMediaSession(PayloadType payloadType, TransportCandidate remote,
+	    TransportCandidate local, JingleSession jingleSession) {
+	// TODO Auto-generated method stub
+	return new RTPMediaSession(payloadType, remote, local, null, jingleSession);
+    }
+
+    @Override
+    public String getName() {
+	return MEDIA_NAME;
+    }
 
-	@Override
-	public List<PayloadType> getPayloads() {
-		return payloads;
-	}
+    @Override
+    public List<PayloadType> getPayloads() {
+	return payloads;
+    }
 
-	private void setupPayloads() {
-		payloads = new ArrayList<PayloadType>();
-		payloads.add(new PayloadType.Audio(42, "Test"));
-		payloads.add(new PayloadType.Audio(15, "Speex"));
-	}
-
-	@Override
-	public String getName() {
-		return MEDIA_NAME;
-	}
+    private void setupPayloads() {
+	payloads = new ArrayList<PayloadType>();
+	payloads.add(new PayloadType.Audio(42, "Test"));
+	payloads.add(new PayloadType.Audio(15, "Speex"));
+    }
 }
--- a/src/com/beem/project/beem/jingle/SenderMediaSession.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/jingle/SenderMediaSession.java	Tue May 26 19:56:38 2009 +0200
@@ -11,14 +11,16 @@
 
 /**
  * @author darisk
- *
  */
 public class SenderMediaSession extends JingleMediaSession {
 
-    private static final SmackLogger LOGGER = SmackLogger.getLogger(SenderMediaSession.class);
-    private boolean active = false;
-    private boolean started = false;
-    private FileSender fileSender;
+    private static final SmackLogger LOGGER  = SmackLogger.getLogger(SenderMediaSession.class);
+    @SuppressWarnings("unused")
+    private boolean                  active  = false;
+    @SuppressWarnings("unused")
+    private boolean                  started = false;
+    @SuppressWarnings("unused")
+    private FileSender               fileSender;
 
     /**
      * @param payloadType
@@ -27,22 +29,25 @@
      * @param mediaLocator
      * @param jingleSession
      */
-    public SenderMediaSession(PayloadType payloadType, TransportCandidate remote,
-	    TransportCandidate local, String mediaLocator,
-	    JingleSession jingleSession) {
+    public SenderMediaSession(PayloadType payloadType, TransportCandidate remote, TransportCandidate local,
+	    String mediaLocator, JingleSession jingleSession) {
 	super(payloadType, remote, local, mediaLocator, jingleSession);
 	initialize();
-	LOGGER.info("Demarrage d'une session avec local: "+ local +" #remote: "+remote );
+	LOGGER.info("Demarrage d'une session avec local: " + local + " #remote: " + remote);
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#initialize()
      */
     @Override
     public void initialize() {
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#setTrasmit(boolean)
      */
     @Override
@@ -51,7 +56,9 @@
 	this.active = active;
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#startReceive()
      */
     @Override
@@ -60,14 +67,18 @@
 
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#startTrasmit()
      */
     @Override
     public void startTrasmit() {
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#stopReceive()
      */
     @Override
@@ -76,7 +87,9 @@
 
     }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see org.jivesoftware.smackx.jingle.media.JingleMediaSession#stopTrasmit()
      */
     @Override
@@ -85,6 +98,4 @@
 	started = false;
     }
 
-
-
 }
--- a/src/com/beem/project/beem/provider/Beem.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/provider/Beem.java	Tue May 26 19:56:38 2009 +0200
@@ -8,150 +8,162 @@
  */
 public final class Beem {
 
-	public final static String 	AUTHORITY = "com.beem.project.provider";
+    /**
+     * Contacts table
+     */
+    public static final class Contacts implements BaseColumns {
 
-	public final static String	DB_NAME = "beem.db";
-	public final static int		DB_VERSION = 2;
-
-	public final static String	USERS_TABLE_NAME = "users";
-	public final static String	CONTACTS_TABLE_NAME = "contacts";
+	/**
+	 * The query used to create the table
+	 */
+	public final static String QUERY_CREATE       = "CREATE TABLE " + Beem.CONTACTS_TABLE_NAME + " ("
+	                                                      + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+	                                                      + Contacts.UID + " INTEGER, " + Contacts.JID
+	                                                      + " INTEGER," + Contacts.NICKNAME + " TEXT,"
+	                                                      + Contacts.ALIAS + " TEXT," + Contacts.DATE_CREATED
+	                                                      + " INTEGER," + Contacts.DATE_MODIFIED + " INTEGER"
+	                                                      + ");";
 
 	/**
-	 * Constructor
+	 * The content:// style URL for Contacts table
+	 */
+	public final static Uri    CONTENT_URI        = Uri.parse("content://" + AUTHORITY + "/contacts");
+
+	/**
+	 * The MIME type of {@link #CONTENT_URI} providing a directory of contacts.
 	 */
-	private Beem() {}
+	public static final String CONTENT_TYPE       = "vnd.android.cursor.dir/vnd.beem.project.contact";
 
+	/**
+	 * The MIME type of a {@link #CONTENT_URI} sub-directory of a single contact.
+	 */
+	public static final String CONTENT_ITEM_TYPE  = "vnd.android.cursor.item/vnd.beem.project.contact";
+
+	/**
+	 * The default sort order for this table
+	 */
+	public final static String DEFAULT_SORT_ORDER = "nickname ASC";
 
 	/**
-	 * Users table
+	 * The user id having the contact
+	 * <P>
+	 * Type: INTEGER
+	 * </P>
 	 */
-	public static final class Users implements BaseColumns {
-		
-		/**
-		 * The query used to create the table
-		 */
-		public final static String	QUERY_CREATE = 
-			"CREATE TABLE " + Beem.USERS_TABLE_NAME + " ("
-			+ Users._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
-			+ Users.JUSERNAME + " TEXT,"
-			+ Users.DATE_CREATED + " INTEGER,"
-			+ Users.DATE_MODIFIED + " INTEGER"
-			+ ");";
-		
-		/**
-		 * The content:// style URL for Contacts table
-		 */
-		public final static Uri		CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/users");
+	public final static String UID                = "uid";
 
-		/**
-		 * The MIME type of {@link #CONTENT_URI} providing a directory of users.
-		 */
-		public static final String	CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.user";
+	/**
+	 * The JabberID of the contact
+	 * <P>
+	 * Type: INTEGER
+	 * </P>
+	 */
+	public final static String JID                = "jid";
 
-		/**
-		 * The MIME type of a {@link #CONTENT_URI} sub-directory of a single user.
-		 */
-		public static final String	CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.user";
-
-		/**
-		 * The default sort order for this table
-		 */
-		public final static String 	DEFAULT_SORT_ORDER = "_id ASC";
+	/**
+	 * The nickname of the contact
+	 * <P>
+	 * Type: TEXT
+	 * </P>
+	 */
+	public final static String NICKNAME           = "nickname";
 
-		/**
-		 * The Jabber username of the user
-		 * <P>Type: TEXT</P>
-		 */
-		public final static String	JUSERNAME = "username";
-		
-		/**
-		 * The timestamp for when the user was created
-		 * <P>Type: INTEGER (long from System.curentTimeMillis())</P>
-		 */
-		public final static String	DATE_CREATED = "created";
+	/**
+	 * The alias of the contact
+	 * <P>
+	 * Type: TEXT
+	 * </P>
+	 */
+	public final static String ALIAS              = "alias";
 
-		/**
-		 * The timestamp for when the user was last modified
-		 * <P>Type: INTEGER (long from System.curentTimeMillis())</P>
-		 */
-		public final static String	DATE_MODIFIED = "modified";
-	}
-
+	/**
+	 * The timestamp for when the contact was created
+	 * <P>
+	 * Type: INTEGER (long from System.curentTimeMillis())
+	 * </P>
+	 */
+	public final static String DATE_CREATED       = "created";
 
 	/**
-	 * Contacts table
+	 * The timestamp for when the contact was last modified
+	 * <P>
+	 * Type: INTEGER (long from System.curentTimeMillis())
+	 * </P>
 	 */
-	public static final class Contacts implements BaseColumns {
+	public final static String DATE_MODIFIED      = "modified";
 
-		/**
-		 * The query used to create the table
-		 */
-		public final static String	QUERY_CREATE = 
-			"CREATE TABLE " + Beem.CONTACTS_TABLE_NAME + " ("
-			+ Contacts._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
-			+ Contacts.UID + " INTEGER, "
-			+ Contacts.JID + " INTEGER,"
-			+ Contacts.NICKNAME + " TEXT,"
-			+ Contacts.ALIAS + " TEXT,"
-			+ Contacts.DATE_CREATED + " INTEGER,"
-			+ Contacts.DATE_MODIFIED + " INTEGER"
-			+ ");";
+    }
+
+    /**
+     * Users table
+     */
+    public static final class Users implements BaseColumns {
 
-		/**
-		 * The content:// style URL for Contacts table
-		 */
-		public final static Uri		CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/contacts");
-
-		/**
-		 * The MIME type of {@link #CONTENT_URI} providing a directory of contacts.
-		 */
-		public static final String	CONTENT_TYPE = "vnd.android.cursor.dir/vnd.beem.project.contact";
+	/**
+	 * The query used to create the table
+	 */
+	public final static String QUERY_CREATE       = "CREATE TABLE " + Beem.USERS_TABLE_NAME + " ("
+	                                                      + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+	                                                      + Users.JUSERNAME + " TEXT," + Users.DATE_CREATED
+	                                                      + " INTEGER," + Users.DATE_MODIFIED + " INTEGER" + ");";
 
-		/**
-		 * The MIME type of a {@link #CONTENT_URI} sub-directory of a single contact.
-		 */
-		public static final String	CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.beem.project.contact";
+	/**
+	 * The content:// style URL for Contacts table
+	 */
+	public final static Uri    CONTENT_URI        = Uri.parse("content://" + AUTHORITY + "/users");
 
-		/**
-		 * The default sort order for this table
-		 */
-		public final static String 	DEFAULT_SORT_ORDER = "nickname ASC";
+	/**
+	 * The MIME type of {@link #CONTENT_URI} providing a directory of users.
+	 */
+	public static final String CONTENT_TYPE       = "vnd.android.cursor.dir/vnd.beem.project.user";
+
+	/**
+	 * The MIME type of a {@link #CONTENT_URI} sub-directory of a single user.
+	 */
+	public static final String CONTENT_ITEM_TYPE  = "vnd.android.cursor.item/vnd.beem.project.user";
 
-		/**
-		 * The user id having the contact
-		 * <P>Type: INTEGER</P>
-		 */
-		public final static String	UID = "uid";
+	/**
+	 * The default sort order for this table
+	 */
+	public final static String DEFAULT_SORT_ORDER = "_id ASC";
 
-		/**
-		 * The JabberID of the contact
-		 * <P>Type: INTEGER</P>
-		 */
-		public final static String	JID = "jid";
+	/**
+	 * The Jabber username of the user
+	 * <P>
+	 * Type: TEXT
+	 * </P>
+	 */
+	public final static String JUSERNAME          = "username";
 
-		/**
-		 * The nickname of the contact
-		 * <P>Type: TEXT</P>
-		 */
-		public final static String	NICKNAME = "nickname";
+	/**
+	 * The timestamp for when the user was created
+	 * <P>
+	 * Type: INTEGER (long from System.curentTimeMillis())
+	 * </P>
+	 */
+	public final static String DATE_CREATED       = "created";
 
-		/**
-		 * The alias of the contact
-		 * <P>Type: TEXT</P>
-		 */
-		public final static String	ALIAS = "alias";
+	/**
+	 * The timestamp for when the user was last modified
+	 * <P>
+	 * Type: INTEGER (long from System.curentTimeMillis())
+	 * </P>
+	 */
+	public final static String DATE_MODIFIED      = "modified";
+    }
+
+    public final static String AUTHORITY           = "com.beem.project.provider";
 
-		/**
-		 * The timestamp for when the contact was created
-		 * <P>Type: INTEGER (long from System.curentTimeMillis())</P>
-		 */
-		public final static String	DATE_CREATED = "created";
+    public final static String DB_NAME             = "beem.db";
+    public final static int    DB_VERSION          = 2;
+
+    public final static String USERS_TABLE_NAME    = "users";
+
+    public final static String CONTACTS_TABLE_NAME = "contacts";
 
-		/**
-		 * The timestamp for when the contact was last modified
-		 * <P>Type: INTEGER (long from System.curentTimeMillis())</P>
-		 */
-		public final static String	DATE_MODIFIED = "modified";
-
-	}
+    /**
+     * Constructor
+     */
+    private Beem() {
+    }
 }
--- a/src/com/beem/project/beem/provider/BeemDatabaseHelper.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/provider/BeemDatabaseHelper.java	Tue May 26 19:56:38 2009 +0200
@@ -6,30 +6,29 @@
 import android.util.Log;
 
 public class BeemDatabaseHelper extends SQLiteOpenHelper {
-	
-	private String tag;
-	private String tableName;
-	private String creationQuery;
+
+    private String tag;
+    private String tableName;
+    private String creationQuery;
+
+    public BeemDatabaseHelper(Context context, String tag, String tableName, String creationQuery) {
+	super(context, Beem.DB_NAME, null, Beem.DB_VERSION);
+
+	this.tag = tag;
+	this.tableName = tableName;
+	this.creationQuery = creationQuery;
+    }
 
-	public BeemDatabaseHelper(Context context, String tag, String tableName, String creationQuery) {
-		super(context, Beem.DB_NAME, null, Beem.DB_VERSION);
-		
-		this.tag = tag;
-		this.tableName = tableName;
-		this.creationQuery = creationQuery;
-	}
-	
-	@Override
-	public void onCreate(SQLiteDatabase db) {
-		db.execSQL(this.creationQuery);
-	}
-	
+    @Override
+    public void onCreate(SQLiteDatabase db) {
+	db.execSQL(this.creationQuery);
+    }
 
-	@Override
-	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-		Log.w(this.tag, "Upgrading database from version " + oldVersion + " to "
-				+ newVersion + ", which will destroy all old data");
-		db.execSQL("DROP TABLE IF EXISTS " + this.tableName + ";");
-		onCreate(db);
-	}
+    @Override
+    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+	Log.w(this.tag, "Upgrading database from version " + oldVersion + " to " + newVersion
+	        + ", which will destroy all old data");
+	db.execSQL("DROP TABLE IF EXISTS " + this.tableName + ";");
+	onCreate(db);
+    }
 }
--- a/src/com/beem/project/beem/provider/ContactProvider.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/provider/ContactProvider.java	Tue May 26 19:56:38 2009 +0200
@@ -14,196 +14,194 @@
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteQueryBuilder;
 import android.net.Uri;
+import android.provider.BaseColumns;
 import android.text.TextUtils;
 
 /**
  * @author dasilvj
- *
  */
 public class ContactProvider extends ContentProvider {
 
-	private final static String				TAG = "ContactProvider";
+    private final static String            TAG        = "ContactProvider";
 
-	private static HashMap<String, String>	sContactsProjectionMap;
-
-	private static final int				CONTACTS = 1;
-	private static final int				CONTACT_ID = 2;
+    private static HashMap<String, String> sContactsProjectionMap;
 
-	private static final UriMatcher			sUriMatcher;
-	private BeemDatabaseHelper				mOpenHelper;
+    private static final int               CONTACTS   = 1;
+    private static final int               CONTACT_ID = 2;
 
-	@Override
-	public int delete(Uri uri, String selection, String[] selectionArgs) {
-		SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-		int count;
+    private static final UriMatcher        sUriMatcher;
+    static {
+	sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+	sUriMatcher.addURI(Beem.AUTHORITY, "contacts", CONTACTS);
+	sUriMatcher.addURI(Beem.AUTHORITY, "contacts/#", CONTACT_ID);
 
-		switch (sUriMatcher.match(uri)) {
-		case CONTACTS:
-			count = db.delete(Beem.CONTACTS_TABLE_NAME, selection, selectionArgs);
-			break;
+	sContactsProjectionMap = new HashMap<String, String>();
+	sContactsProjectionMap.put(BaseColumns._ID, BaseColumns._ID);
+	sContactsProjectionMap.put(Beem.Contacts.UID, Beem.Contacts.UID);
+	sContactsProjectionMap.put(Beem.Contacts.JID, Beem.Contacts.JID);
+	sContactsProjectionMap.put(Beem.Contacts.NICKNAME, Beem.Contacts.NICKNAME);
+	sContactsProjectionMap.put(Beem.Contacts.ALIAS, Beem.Contacts.ALIAS);
+	sContactsProjectionMap.put(Beem.Contacts.DATE_CREATED, Beem.Contacts.DATE_CREATED);
+	sContactsProjectionMap.put(Beem.Contacts.DATE_MODIFIED, Beem.Contacts.DATE_MODIFIED);
+    }
+
+    private BeemDatabaseHelper             mOpenHelper;
 
-		case CONTACT_ID:
-			String contactId = uri.getPathSegments().get(1);
-			count = db.delete(Beem.CONTACTS_TABLE_NAME, Beem.Contacts._ID + "=" + contactId
-					+ (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
-			break;
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+	int count;
 
-		default:
-			throw new IllegalArgumentException("Unknown URI " + uri);
-		}
+	switch (sUriMatcher.match(uri)) {
+	case CONTACTS:
+	    count = db.delete(Beem.CONTACTS_TABLE_NAME, selection, selectionArgs);
+	    break;
 
-		getContext().getContentResolver().notifyChange(uri, null);
-		return count;
+	case CONTACT_ID:
+	    String contactId = uri.getPathSegments().get(1);
+	    count = db.delete(Beem.CONTACTS_TABLE_NAME, BaseColumns._ID + "=" + contactId
+		    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
+	    break;
+
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
 	}
 
-	@Override
-	public String getType(Uri uri) {
-		switch (sUriMatcher.match(uri)) {
-		case CONTACTS:
-			return Beem.Contacts.CONTENT_TYPE;
+	getContext().getContentResolver().notifyChange(uri, null);
+	return count;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+	switch (sUriMatcher.match(uri)) {
+	case CONTACTS:
+	    return Beem.Contacts.CONTENT_TYPE;
+
+	case CONTACT_ID:
+	    return Beem.Contacts.CONTENT_ITEM_TYPE;
+
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
+	}
+    }
 
-		case CONTACT_ID:
-			return Beem.Contacts.CONTENT_ITEM_TYPE;
+    @Override
+    public Uri insert(Uri uri, ContentValues initialValues) {
+	// Validate the requested uri
+	if (sUriMatcher.match(uri) != CONTACTS) {
+	    throw new IllegalArgumentException("Unknown URI " + uri);
+	}
 
-		default:
-			throw new IllegalArgumentException("Unknown URI " + uri);
-		}
+	ContentValues values;
+	if (initialValues != null) {
+	    values = new ContentValues(initialValues);
+	} else {
+	    values = new ContentValues();
+	}
+
+	Long now = Long.valueOf(System.currentTimeMillis());
+
+	// Make sure that the fields are all set
+	if (values.containsKey(Beem.Contacts.UID) == false) {
+	    // TODO :: Must check that the UID exists using UserProvider
+	    throw new SQLException("No UID specified. Failed to insert row into " + uri);
+	}
+
+	if (values.containsKey(Beem.Contacts.JID) == false) {
+	    values.put(Beem.Contacts.JID, "");
 	}
 
-	@Override
-	public Uri insert(Uri uri, ContentValues initialValues) {
-        // Validate the requested uri
-        if (sUriMatcher.match(uri) != CONTACTS) {
-            throw new IllegalArgumentException("Unknown URI " + uri);
-        }
-
-        ContentValues values;
-        if (initialValues != null) {
-            values = new ContentValues(initialValues);
-        } else {
-            values = new ContentValues();
-        }
-
-        Long now = Long.valueOf(System.currentTimeMillis());
-
-        // Make sure that the fields are all set
-        if (values.containsKey(Beem.Contacts.UID) == false) {
-        	// TODO :: Must check that the UID exists using UserProvider
-            throw new SQLException("No UID specified. Failed to insert row into " + uri);
-        }
+	if (values.containsKey(Beem.Contacts.NICKNAME) == false) {
+	    values.put(Beem.Contacts.JID, "");
+	}
 
-        if (values.containsKey(Beem.Contacts.JID) == false) {
-            values.put(Beem.Contacts.JID, "");
-        }
-        
-        if (values.containsKey(Beem.Contacts.NICKNAME) == false) {
-            values.put(Beem.Contacts.JID, "");
-        }
-        
-        if (values.containsKey(Beem.Contacts.ALIAS) == false) {
-            values.put(Beem.Contacts.JID, "");
-        }
-        
-        if (values.containsKey(Beem.Contacts.DATE_CREATED) == false) {
-            values.put(Beem.Contacts.DATE_CREATED, now);
-        }
-
-        if (values.containsKey(Beem.Contacts.DATE_MODIFIED) == false) {
-            values.put(Beem.Contacts.DATE_MODIFIED, now);
-        }
-
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        long rowId = db.insert(Beem.CONTACTS_TABLE_NAME, Beem.Contacts._ID, values);
-        if (rowId > 0) {
-            Uri contactUri = ContentUris.withAppendedId(Beem.Contacts.CONTENT_URI, rowId);
-            getContext().getContentResolver().notifyChange(contactUri, null);
-            return contactUri;
-        }
-
-        throw new SQLException("Failed to insert row into " + uri);
+	if (values.containsKey(Beem.Contacts.ALIAS) == false) {
+	    values.put(Beem.Contacts.JID, "");
 	}
 
-	@Override
-	public boolean onCreate() {
-		mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.CONTACTS_TABLE_NAME, Beem.Contacts.QUERY_CREATE);
-		return true;
+	if (values.containsKey(Beem.Contacts.DATE_CREATED) == false) {
+	    values.put(Beem.Contacts.DATE_CREATED, now);
+	}
+
+	if (values.containsKey(Beem.Contacts.DATE_MODIFIED) == false) {
+	    values.put(Beem.Contacts.DATE_MODIFIED, now);
+	}
+
+	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+	long rowId = db.insert(Beem.CONTACTS_TABLE_NAME, BaseColumns._ID, values);
+	if (rowId > 0) {
+	    Uri contactUri = ContentUris.withAppendedId(Beem.Contacts.CONTENT_URI, rowId);
+	    getContext().getContentResolver().notifyChange(contactUri, null);
+	    return contactUri;
 	}
 
-	@Override
-	public Cursor query(Uri uri, String[] projection, String selection,
-			String[] selectionArgs, String sortOrder) {
-		SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
+	throw new SQLException("Failed to insert row into " + uri);
+    }
 
-		switch (sUriMatcher.match(uri)) {
-		case CONTACTS:
-			qb.setTables(Beem.CONTACTS_TABLE_NAME);
-			qb.setProjectionMap(sContactsProjectionMap);
-			break;
+    @Override
+    public boolean onCreate() {
+	mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.CONTACTS_TABLE_NAME, Beem.Contacts.QUERY_CREATE);
+	return true;
+    }
 
-		case CONTACT_ID:
-			qb.setTables(Beem.USERS_TABLE_NAME);
-			qb.setProjectionMap(sContactsProjectionMap);
-			qb.appendWhere(Beem.Contacts._ID + "=" + uri.getPathSegments().get(1));
-			break;
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+	SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
 
-		default:
-			throw new IllegalArgumentException("Unknown URI " + uri);        
-		}
+	switch (sUriMatcher.match(uri)) {
+	case CONTACTS:
+	    qb.setTables(Beem.CONTACTS_TABLE_NAME);
+	    qb.setProjectionMap(sContactsProjectionMap);
+	    break;
 
-		// If no sort order is specified use the default
-		String orderBy;
-		if (TextUtils.isEmpty(sortOrder)) {
-			orderBy = Beem.Contacts.DEFAULT_SORT_ORDER;
-		} else {
-			orderBy = sortOrder;
-		}
+	case CONTACT_ID:
+	    qb.setTables(Beem.USERS_TABLE_NAME);
+	    qb.setProjectionMap(sContactsProjectionMap);
+	    qb.appendWhere(BaseColumns._ID + "=" + uri.getPathSegments().get(1));
+	    break;
 
-		// Get the database and run the query
-		SQLiteDatabase db = mOpenHelper.getReadableDatabase();
-		Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
-
-		// Tell the cursor what uri to watch, so it knows when its source data changes
-		c.setNotificationUri(getContext().getContentResolver(), uri);
-		return c;
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
 	}
 
-	@Override
-	public int update(Uri uri, ContentValues values, String selection,
-			String[] selectionArgs) {
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        int count;
-        
-        switch (sUriMatcher.match(uri)) {
-        case CONTACTS:
-            count = db.update(Beem.CONTACTS_TABLE_NAME, values, selection, selectionArgs);
-            break;
-
-        case CONTACT_ID:
-            String contactId = uri.getPathSegments().get(1);
-            count = db.update(Beem.CONTACTS_TABLE_NAME, values, Beem.Contacts._ID + "=" + contactId
-                    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
-            break;
-
-        default:
-            throw new IllegalArgumentException("Unknown URI " + uri);
-        }
-
-        getContext().getContentResolver().notifyChange(uri, null);
-        return count;
+	// If no sort order is specified use the default
+	String orderBy;
+	if (TextUtils.isEmpty(sortOrder)) {
+	    orderBy = Beem.Contacts.DEFAULT_SORT_ORDER;
+	} else {
+	    orderBy = sortOrder;
 	}
 
-	static {
-		sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
-		sUriMatcher.addURI(Beem.AUTHORITY, "contacts", CONTACTS);
-		sUriMatcher.addURI(Beem.AUTHORITY, "contacts/#", CONTACT_ID);
+	// Get the database and run the query
+	SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+	Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
+
+	// Tell the cursor what uri to watch, so it knows when its source data changes
+	c.setNotificationUri(getContext().getContentResolver(), uri);
+	return c;
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+	int count;
 
-		sContactsProjectionMap = new HashMap<String, String>();
-		sContactsProjectionMap.put(Beem.Contacts._ID, Beem.Contacts._ID);
-		sContactsProjectionMap.put(Beem.Contacts.UID, Beem.Contacts.UID);
-		sContactsProjectionMap.put(Beem.Contacts.JID, Beem.Contacts.JID);
-		sContactsProjectionMap.put(Beem.Contacts.NICKNAME, Beem.Contacts.NICKNAME);
-		sContactsProjectionMap.put(Beem.Contacts.ALIAS, Beem.Contacts.ALIAS);
-		sContactsProjectionMap.put(Beem.Contacts.DATE_CREATED, Beem.Contacts.DATE_CREATED);
-		sContactsProjectionMap.put(Beem.Contacts.DATE_MODIFIED, Beem.Contacts.DATE_MODIFIED);
+	switch (sUriMatcher.match(uri)) {
+	case CONTACTS:
+	    count = db.update(Beem.CONTACTS_TABLE_NAME, values, selection, selectionArgs);
+	    break;
+
+	case CONTACT_ID:
+	    String contactId = uri.getPathSegments().get(1);
+	    count = db.update(Beem.CONTACTS_TABLE_NAME, values, BaseColumns._ID + "=" + contactId
+		    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
+	    break;
+
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
 	}
+
+	getContext().getContentResolver().notifyChange(uri, null);
+	return count;
+    }
 }
--- a/src/com/beem/project/beem/provider/UserProvider.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/provider/UserProvider.java	Tue May 26 19:56:38 2009 +0200
@@ -11,176 +11,175 @@
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteQueryBuilder;
 import android.net.Uri;
+import android.provider.BaseColumns;
 import android.text.TextUtils;
 
 public class UserProvider extends ContentProvider {
 
-	private final static String				TAG = "UserProvider";
+    private final static String            TAG     = "UserProvider";
 
-	private static HashMap<String, String>	sUsersProjectionMap;
+    private static HashMap<String, String> sUsersProjectionMap;
 
-	private static final int				USERS = 1;
-	private static final int				USER_ID = 2;
+    private static final int               USERS   = 1;
+    private static final int               USER_ID = 2;
 
-	private static final UriMatcher			sUriMatcher;
-	private BeemDatabaseHelper				mOpenHelper;
+    private static final UriMatcher        sUriMatcher;
+    static {
+	sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+	sUriMatcher.addURI(Beem.AUTHORITY, "users", USERS);
+	sUriMatcher.addURI(Beem.AUTHORITY, "users/#", USER_ID);
 
-	@Override
-	public int delete(Uri uri, String selection, String[] selectionArgs) {
-		SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-		int count;
+	sUsersProjectionMap = new HashMap<String, String>();
+	sUsersProjectionMap.put(BaseColumns._ID, BaseColumns._ID);
+	sUsersProjectionMap.put(Beem.Users.JUSERNAME, Beem.Users.JUSERNAME);
+	sUsersProjectionMap.put(Beem.Users.DATE_CREATED, Beem.Users.DATE_CREATED);
+	sUsersProjectionMap.put(Beem.Users.DATE_MODIFIED, Beem.Users.DATE_MODIFIED);
+    }
 
-		switch (sUriMatcher.match(uri)) {
-		case USERS:
-			count = db.delete(Beem.USERS_TABLE_NAME, selection, selectionArgs);
-			break;
+    private BeemDatabaseHelper             mOpenHelper;
+
+    @Override
+    public int delete(Uri uri, String selection, String[] selectionArgs) {
+	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+	int count;
 
-		case USER_ID:
-			String userID = uri.getPathSegments().get(1);
-			count = db.delete(Beem.USERS_TABLE_NAME, Beem.Users._ID + "=" + userID
-					+ (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
-			break;
+	switch (sUriMatcher.match(uri)) {
+	case USERS:
+	    count = db.delete(Beem.USERS_TABLE_NAME, selection, selectionArgs);
+	    break;
 
-		default:
-			throw new IllegalArgumentException("Unknown URI " + uri);
-		}
+	case USER_ID:
+	    String userID = uri.getPathSegments().get(1);
+	    count = db.delete(Beem.USERS_TABLE_NAME, BaseColumns._ID + "=" + userID
+		    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
+	    break;
 
-		getContext().getContentResolver().notifyChange(uri, null);
-		return count;
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
 	}
 
-	@Override
-	public String getType(Uri uri) {
-		switch (sUriMatcher.match(uri)) {
-		case USERS:
-			return Beem.Users.CONTENT_TYPE;
+	getContext().getContentResolver().notifyChange(uri, null);
+	return count;
+    }
+
+    @Override
+    public String getType(Uri uri) {
+	switch (sUriMatcher.match(uri)) {
+	case USERS:
+	    return Beem.Users.CONTENT_TYPE;
+
+	case USER_ID:
+	    return Beem.Users.CONTENT_ITEM_TYPE;
+
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
+	}
+    }
 
-		case USER_ID:
-			return Beem.Users.CONTENT_ITEM_TYPE;
+    @Override
+    public Uri insert(Uri uri, ContentValues initialValues) {
+	// Validate the requested uri
+	if (sUriMatcher.match(uri) != USERS) {
+	    throw new IllegalArgumentException("Unknown URI " + uri);
+	}
 
-		default:
-			throw new IllegalArgumentException("Unknown URI " + uri);
-		}
+	ContentValues values;
+	if (initialValues != null) {
+	    values = new ContentValues(initialValues);
+	} else {
+	    values = new ContentValues();
+	}
+
+	Long now = Long.valueOf(System.currentTimeMillis());
+
+	// Make sure that the fields are all set
+	if (values.containsKey(Beem.Users.JUSERNAME) == false) {
+	    throw new SQLException("No JUSERNAME specified. Failed to insert row into " + uri);
 	}
 
-	@Override
-	public Uri insert(Uri uri, ContentValues initialValues) {
-        // Validate the requested uri
-        if (sUriMatcher.match(uri) != USERS) {
-            throw new IllegalArgumentException("Unknown URI " + uri);
-        }
-
-        ContentValues values;
-        if (initialValues != null) {
-            values = new ContentValues(initialValues);
-        } else {
-            values = new ContentValues();
-        }
-
-        Long now = Long.valueOf(System.currentTimeMillis());
-
-        // Make sure that the fields are all set
-        if (values.containsKey(Beem.Users.JUSERNAME) == false) {
-            throw new SQLException("No JUSERNAME specified. Failed to insert row into " + uri);
-        }
-        
-        if (values.containsKey(Beem.Users.DATE_CREATED) == false) {
-            values.put(Beem.Users.DATE_CREATED, now);
-        }
-
-        if (values.containsKey(Beem.Users.DATE_MODIFIED) == false) {
-            values.put(Beem.Users.DATE_MODIFIED, now);
-        }
-
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        long rowId = db.insert(Beem.USERS_TABLE_NAME, Beem.Users._ID, values);
-        if (rowId > 0) {
-            Uri userUri = ContentUris.withAppendedId(Beem.Users.CONTENT_URI, rowId);
-            getContext().getContentResolver().notifyChange(userUri, null);
-            return userUri;
-        }
-
-        throw new SQLException("Failed to insert row into " + uri);
+	if (values.containsKey(Beem.Users.DATE_CREATED) == false) {
+	    values.put(Beem.Users.DATE_CREATED, now);
 	}
 
-	@Override
-	public boolean onCreate() {
-		mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.USERS_TABLE_NAME, Beem.Users.QUERY_CREATE);
-		return true;
+	if (values.containsKey(Beem.Users.DATE_MODIFIED) == false) {
+	    values.put(Beem.Users.DATE_MODIFIED, now);
+	}
+
+	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+	long rowId = db.insert(Beem.USERS_TABLE_NAME, BaseColumns._ID, values);
+	if (rowId > 0) {
+	    Uri userUri = ContentUris.withAppendedId(Beem.Users.CONTENT_URI, rowId);
+	    getContext().getContentResolver().notifyChange(userUri, null);
+	    return userUri;
 	}
 
-	@Override
-	public Cursor query(Uri uri, String[] projection, String selection,
-			String[] selectionArgs, String sortOrder) {
-		SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
+	throw new SQLException("Failed to insert row into " + uri);
+    }
 
-		switch (sUriMatcher.match(uri)) {
-		case USERS:
-			qb.setTables(Beem.USERS_TABLE_NAME);
-			qb.setProjectionMap(sUsersProjectionMap);
-			break;
+    @Override
+    public boolean onCreate() {
+	mOpenHelper = new BeemDatabaseHelper(getContext(), TAG, Beem.USERS_TABLE_NAME, Beem.Users.QUERY_CREATE);
+	return true;
+    }
 
-		case USER_ID:
-			qb.setTables(Beem.USERS_TABLE_NAME);
-			qb.setProjectionMap(sUsersProjectionMap);
-			qb.appendWhere(Beem.Users._ID + "=" + uri.getPathSegments().get(1));
-			break;
+    @Override
+    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+	SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
 
-		default:
-			throw new IllegalArgumentException("Unknown URI " + uri);        
-		}
+	switch (sUriMatcher.match(uri)) {
+	case USERS:
+	    qb.setTables(Beem.USERS_TABLE_NAME);
+	    qb.setProjectionMap(sUsersProjectionMap);
+	    break;
 
-		// If no sort order is specified use the default
-		String orderBy;
-		if (TextUtils.isEmpty(sortOrder)) {
-			orderBy = Beem.Users.DEFAULT_SORT_ORDER;
-		} else {
-			orderBy = sortOrder;
-		}
+	case USER_ID:
+	    qb.setTables(Beem.USERS_TABLE_NAME);
+	    qb.setProjectionMap(sUsersProjectionMap);
+	    qb.appendWhere(BaseColumns._ID + "=" + uri.getPathSegments().get(1));
+	    break;
 
-		// Get the database and run the query
-		SQLiteDatabase db = mOpenHelper.getReadableDatabase();
-		Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
-
-		// Tell the cursor what uri to watch, so it knows when its source data changes
-		c.setNotificationUri(getContext().getContentResolver(), uri);
-		return c;
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
 	}
 
-	@Override
-	public int update(Uri uri, ContentValues values, String selection,
-			String[] selectionArgs) {
-        SQLiteDatabase db = mOpenHelper.getWritableDatabase();
-        int count;
-        
-        switch (sUriMatcher.match(uri)) {
-        case USERS:
-            count = db.update(Beem.USERS_TABLE_NAME, values, selection, selectionArgs);
-            break;
-
-        case USER_ID:
-            String userId = uri.getPathSegments().get(1);
-            count = db.update(Beem.USERS_TABLE_NAME, values, Beem.Users._ID + "=" + userId
-                    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
-            break;
-
-        default:
-            throw new IllegalArgumentException("Unknown URI " + uri);
-        }
-
-        getContext().getContentResolver().notifyChange(uri, null);
-        return count;
+	// If no sort order is specified use the default
+	String orderBy;
+	if (TextUtils.isEmpty(sortOrder)) {
+	    orderBy = Beem.Users.DEFAULT_SORT_ORDER;
+	} else {
+	    orderBy = sortOrder;
 	}
 
-	static {
-		sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
-		sUriMatcher.addURI(Beem.AUTHORITY, "users", USERS);
-		sUriMatcher.addURI(Beem.AUTHORITY, "users/#", USER_ID);
+	// Get the database and run the query
+	SQLiteDatabase db = mOpenHelper.getReadableDatabase();
+	Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
+
+	// Tell the cursor what uri to watch, so it knows when its source data changes
+	c.setNotificationUri(getContext().getContentResolver(), uri);
+	return c;
+    }
+
+    @Override
+    public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+	int count;
 
-		sUsersProjectionMap = new HashMap<String, String>();
-		sUsersProjectionMap.put(Beem.Users._ID, Beem.Users._ID);
-		sUsersProjectionMap.put(Beem.Users.JUSERNAME, Beem.Users.JUSERNAME);
-		sUsersProjectionMap.put(Beem.Users.DATE_CREATED, Beem.Users.DATE_CREATED);
-		sUsersProjectionMap.put(Beem.Users.DATE_MODIFIED, Beem.Users.DATE_MODIFIED);
+	switch (sUriMatcher.match(uri)) {
+	case USERS:
+	    count = db.update(Beem.USERS_TABLE_NAME, values, selection, selectionArgs);
+	    break;
+
+	case USER_ID:
+	    String userId = uri.getPathSegments().get(1);
+	    count = db.update(Beem.USERS_TABLE_NAME, values, BaseColumns._ID + "=" + userId
+		    + (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""), selectionArgs);
+	    break;
+
+	default:
+	    throw new IllegalArgumentException("Unknown URI " + uri);
 	}
+
+	getContext().getContentResolver().notifyChange(uri, null);
+	return count;
+    }
 }
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Tue May 26 19:56:38 2009 +0200
@@ -32,99 +32,14 @@
 
 /**
  * An adapter for smack's ChatManager. This class provides functionnality to handle chats.
+ * 
  * @author darisk
  */
 public class BeemChatManager extends IChatManager.Stub {
 
     /**
-     * Tag to use with log methods.
-     */
-    public static final String TAG = "BeemChatManager";
-    private ChatManager mAdaptee;
-    private Map<String, ChatAdapter> mChats = new HashMap<String, ChatAdapter>();
-    private ChatListener mChatListener = new ChatListener();
-    private RemoteCallbackList<IChatManagerListener> mRemoteChatCreationListeners = new RemoteCallbackList<IChatManagerListener>();
-    private RemoteCallbackList<IMessageListener> mRemoteMessageListeners = new RemoteCallbackList<IMessageListener>();
-    private BeemService mService;
-
-    /**
-     * Constructor.
-     * @param chatManager the smack ChatManager to adapt
-     */
-    public BeemChatManager(final ChatManager chatManager, BeemService service) {
-	mService = service;
-	mAdaptee = chatManager;
-	mAdaptee.addChatListener(mChatListener);
-    }
-
-    /**
-     * Create a chat session.
-     * @param jid the jid of the contact you want to chat with
-     * @param listener listener to use for chat events on this chat session
-     * @return the chat session
-     */
-    public IChat createChat(String jid, IMessageListener listener) {
-	mRemoteMessageListeners.register(listener);
-	String key = StringUtils.parseBareAddress(jid);
-	if (mChats.containsKey(key)) {
-	    return (mChats.get(key));
-	}
-	// create the chat. the adaptee will be add automatically in the map
-	mAdaptee.createChat(key, mChatListener);
-	return mChats.get(key);
-    }
-
-    /**
-     * Create a chat session.
-     * @param contact the contact you want to chat with
-     * @param listener listener to use for chat events on this chat session
-     * @return the chat session
-     */
-    public IChat createChat(Contact contact, IMessageListener listener) {
-	String jid = contact.getJID();
-	return createChat(jid, listener);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addChatCreationListener(IChatManagerListener listener) throws RemoteException {
-	mRemoteChatCreationListeners.register(listener);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException {
-	mRemoteChatCreationListeners.unregister(listener);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void destroyChat(IChat chat) throws RemoteException {
-	// TODO gerer les resources egalement
-	Log.d(TAG, "destroy chat jid "+ chat.getParticipant().getJID());
-	IChat c = mChats.remove(chat.getParticipant().getJID());
-	if (c == null)
-	    Log.w(TAG, "CA devrait pas 1!!" + chat.getParticipant().getJID());
-    }
-
-    private IChat getChat(Chat chat) {
-	String key = StringUtils.parseBareAddress(chat.getParticipant());
-	if (mChats.containsKey(key)) {
-	    return mChats.get(key);
-	}
-	ChatAdapter res = new ChatAdapter(chat);
-	mChats.put(key, res);
-	return res;
-    }
-
-    /**
      * A listener for all the chat creation event that happens on the connection.
+     * 
      * @author darisk
      */
     private class ChatListener implements ChatStateListener, ChatManagerListener, MessageListener {
@@ -168,14 +83,14 @@
 	    try {
 		String text = chat.getParticipant().getJID();
 		Notification notif = new Notification(com.beem.project.beem.R.drawable.notify_message, text, System
-		    .currentTimeMillis());
+		        .currentTimeMillis());
 		notif.defaults = Notification.DEFAULT_ALL;
 		notif.flags = Notification.FLAG_AUTO_CANCEL;
 		Intent intent = new Intent(mService, SendIM.class);
 		// TODO use prefix for name
 		intent.putExtra("contact", chat.getParticipant());
 		notif.setLatestEventInfo(mService, text, mService.getString(R.string.BeemChatManagerNewMessage),
-		    PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT));
+		        PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT));
 		int id = chat.hashCode();
 		mService.sendNotification(id, notif);
 	    } catch (RemoteException e) {
@@ -228,4 +143,100 @@
 	}
     }
 
+    /**
+     * Tag to use with log methods.
+     */
+    public static final String                       TAG                          = "BeemChatManager";
+    private ChatManager                              mAdaptee;
+    private Map<String, ChatAdapter>                 mChats                       = new HashMap<String, ChatAdapter>();
+    private ChatListener                             mChatListener                = new ChatListener();
+    private RemoteCallbackList<IChatManagerListener> mRemoteChatCreationListeners = new RemoteCallbackList<IChatManagerListener>();
+    private RemoteCallbackList<IMessageListener>     mRemoteMessageListeners      = new RemoteCallbackList<IMessageListener>();
+
+    private BeemService                              mService;
+
+    /**
+     * Constructor.
+     * 
+     * @param chatManager
+     *            the smack ChatManager to adapt
+     */
+    public BeemChatManager(final ChatManager chatManager, BeemService service) {
+	mService = service;
+	mAdaptee = chatManager;
+	mAdaptee.addChatListener(mChatListener);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addChatCreationListener(IChatManagerListener listener) throws RemoteException {
+	mRemoteChatCreationListeners.register(listener);
+    }
+
+    /**
+     * Create a chat session.
+     * 
+     * @param contact
+     *            the contact you want to chat with
+     * @param listener
+     *            listener to use for chat events on this chat session
+     * @return the chat session
+     */
+    public IChat createChat(Contact contact, IMessageListener listener) {
+	String jid = contact.getJID();
+	return createChat(jid, listener);
+    }
+
+    /**
+     * Create a chat session.
+     * 
+     * @param jid
+     *            the jid of the contact you want to chat with
+     * @param listener
+     *            listener to use for chat events on this chat session
+     * @return the chat session
+     */
+    public IChat createChat(String jid, IMessageListener listener) {
+	mRemoteMessageListeners.register(listener);
+	String key = StringUtils.parseBareAddress(jid);
+	if (mChats.containsKey(key)) {
+	    return (mChats.get(key));
+	}
+	// create the chat. the adaptee will be add automatically in the map
+	mAdaptee.createChat(key, mChatListener);
+	return mChats.get(key);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void destroyChat(IChat chat) throws RemoteException {
+	// TODO gerer les resources egalement
+	Log.d(TAG, "destroy chat jid " + chat.getParticipant().getJID());
+	IChat c = mChats.remove(chat.getParticipant().getJID());
+	if (c == null)
+	    Log.w(TAG, "CA devrait pas 1!!" + chat.getParticipant().getJID());
+    }
+
+    private IChat getChat(Chat chat) {
+	String key = StringUtils.parseBareAddress(chat.getParticipant());
+	if (mChats.containsKey(key)) {
+	    return mChats.get(key);
+	}
+	ChatAdapter res = new ChatAdapter(chat);
+	mChats.put(key, res);
+	return res;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException {
+	mRemoteChatCreationListeners.unregister(listener);
+    }
+
 }
--- a/src/com/beem/project/beem/service/ChatAdapter.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/ChatAdapter.java	Tue May 26 19:56:38 2009 +0200
@@ -12,18 +12,22 @@
 
 /**
  * An adapter for smack's Chat class.
+ * 
  * @author darisk
  */
 public class ChatAdapter extends IChat.Stub {
-    private Chat mAdaptee;
-    private Contact mParticipant;
-    private String mState;
+
+    private Chat         mAdaptee;
+    private Contact      mParticipant;
+    private String       mState;
     private StringBuffer mLastMessages;
-    private boolean isOpen;
- 
+    private boolean      isOpen;
+
     /**
      * Constructor.
-     * @param chat The chat to adapt
+     * 
+     * @param chat
+     *            The chat to adapt
      */
     public ChatAdapter(final Chat chat) {
 	mLastMessages = new StringBuffer();
@@ -31,6 +35,25 @@
 	mParticipant = new Contact(chat.getParticipant());
     }
 
+    @Override
+    public void addToLastMessages(String msg) throws RemoteException {
+	mLastMessages.append(msg).append('\n');
+    }
+
+    @Override
+    public void clearLastMessages() throws RemoteException {
+	mLastMessages.delete(0, mLastMessages.length());
+    }
+
+    public Chat getAdaptee() {
+	return mAdaptee;
+    }
+
+    @Override
+    public String getLastMessages() throws RemoteException {
+	return mLastMessages.toString();
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -39,6 +62,18 @@
 	return mParticipant;
     }
 
+    @Override
+    public String getState() throws RemoteException {
+	return mState;
+    }
+
+    /**
+     * @return the isOpen
+     */
+    public boolean isOpen() {
+	return isOpen;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -60,47 +95,17 @@
 	}
     }
 
-    @Override
-    public String getState() throws RemoteException {
-	return mState;
+    /**
+     * @param isOpen
+     *            the isOpen to set
+     */
+    public void setOpen(boolean isOpen) {
+	this.isOpen = isOpen;
     }
-    
+
     @Override
     public void setState(String state) throws RemoteException {
 	mState = state;
     }
 
-    public Chat getAdaptee() {
-	return mAdaptee;
-    }
-
-    @Override
-    public String getLastMessages() throws RemoteException {
-	return mLastMessages.toString();
-    }
-
-    @Override
-    public void addToLastMessages(String msg) throws RemoteException {
-	mLastMessages.append(msg).append('\n');
-    }
-
-    @Override
-    public void clearLastMessages() throws RemoteException {
-	mLastMessages.delete(0, mLastMessages.length());
-    }
-
-    /**
-     * @param isOpen the isOpen to set
-     */
-    public void setOpen(boolean isOpen) {
-	this.isOpen = isOpen;
-    }
-
-    /**
-     * @return the isOpen
-     */
-    public boolean isOpen() {
-	return isOpen;
-    }
-
 }
--- a/src/com/beem/project/beem/service/Contact.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Tue May 26 19:56:38 2009 +0200
@@ -10,43 +10,44 @@
 import org.jivesoftware.smack.RosterGroup;
 import org.jivesoftware.smack.packet.Presence;
 
-import com.beem.project.beem.utils.Status;
-
 import android.os.Parcel;
 import android.os.Parcelable;
-import android.util.Log;
+
+import com.beem.project.beem.utils.Status;
 
 /**
  * This class contains informations on a jabber contact.
+ * 
  * @author darisk
  */
 public class Contact implements Parcelable {
 
-    private static final String TAG = "Contact";
+    @SuppressWarnings("unused")
+    private static final String                     TAG     = "Contact";
 
-    private int mID;
-    private int mStatus;
-    private String mJID;
-    private String mName;
-    private String mMsgState;
-    private List<String> mRes;
-    private List<String> mGroups;
+    private int                                     mID;
+    private int                                     mStatus;
+    private String                                  mJID;
+    private String                                  mName;
+    private String                                  mMsgState;
+    private List<String>                            mRes;
+    private List<String>                            mGroups;
 
     /**
      * Parcelable.Creator needs by Android.
      */
     public static final Parcelable.Creator<Contact> CREATOR = new Parcelable.Creator<Contact>() {
 
-	@Override
-	public Contact createFromParcel(Parcel source) {
-	    return new Contact(source);
-	}
+	                                                        @Override
+	                                                        public Contact createFromParcel(Parcel source) {
+		                                                    return new Contact(source);
+	                                                        }
 
-	@Override
-	public Contact[] newArray(int size) {
-	    return new Contact[size];
-	}
-    };
+	                                                        @Override
+	                                                        public Contact[] newArray(int size) {
+		                                                    return new Contact[size];
+	                                                        }
+	                                                    };
 
     /**
      * Constructor.
@@ -56,21 +57,10 @@
     }
 
     /**
-     * Constructor.
-     * @param jid JID of the contact
-     */
-    public Contact(final String jid) {
-	mJID = jid;
-	mName = jid;
-	mStatus = Status.CONTACT_STATUS_DISCONNECT;
-	mRes = new ArrayList<String>();
-	mRes.add("none");
-	mGroups = new ArrayList<String>();
-    }
-
-    /**
      * Construct a contact from a parcel.
-     * @param in parcel to use for construction
+     * 
+     * @param in
+     *            parcel to use for construction
      */
     private Contact(final Parcel in) {
 	mID = in.readInt();
@@ -85,6 +75,201 @@
     }
 
     /**
+     * Constructor.
+     * 
+     * @param jid
+     *            JID of the contact
+     */
+    public Contact(final String jid) {
+	mJID = jid;
+	mName = jid;
+	mStatus = Status.CONTACT_STATUS_DISCONNECT;
+	mRes = new ArrayList<String>();
+	mRes.add("none");
+	mGroups = new ArrayList<String>();
+    }
+
+    public void addGroup(String group) {
+	mGroups.add(group);
+    }
+
+    /**
+     * @param res
+     */
+    public void addRes(String res) {
+	if (!mRes.contains(res))
+	    mRes.add(res);
+    }
+
+    /**
+     * @param res
+     */
+    public void delRes(String res) {
+	mRes.remove(res);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int describeContents() {
+	// TODO Auto-generated method stub
+	return 0;
+    }
+
+    /**
+     * @return the mGroups
+     */
+    public List<String> getGroups() {
+	return mGroups;
+    }
+
+    /**
+     * Get the id of the contact on the phone contact list.
+     * 
+     * @return the mID
+     */
+    public int getID() {
+	return mID;
+    }
+
+    /**
+     * Get the Jabber ID of the contact.
+     * 
+     * @return the Jabber ID
+     */
+    public String getJID() {
+	return mJID;
+    }
+
+    /**
+     * @return the mRes
+     */
+    public List<String> getMRes() {
+	return mRes;
+    }
+
+    /**
+     * Get the message status of the contact.
+     * 
+     * @return the message status of the contact.
+     */
+    public String getMsgState() {
+	return mMsgState;
+    }
+
+    /**
+     * @return the mName
+     */
+    public String getName() {
+	return mName;
+    }
+
+    /**
+     * Get the status of the contact.
+     * 
+     * @return the mStatus
+     */
+    public int getStatus() {
+	return mStatus;
+    }
+
+    public void setGroups(Collection<RosterGroup> groups) {
+	for (RosterGroup rosterGroup : groups) {
+	    mGroups.add(rosterGroup.getName());
+	}
+    }
+
+    /**
+     * @param mGroups
+     *            the mGroups to set
+     */
+    public void setGroups(List<String> mGroups) {
+	this.mGroups = mGroups;
+    }
+
+    /**
+     * set the id of te contact on the phone contact list.
+     * 
+     * @param mid
+     *            the mID to set
+     */
+    public void setID(int mid) {
+	mID = mid;
+    }
+
+    /**
+     * Set the Jabber ID of the contact.
+     * 
+     * @param mjid
+     *            the jabber ID to set
+     */
+    public void setJID(String mjid) {
+	mJID = mjid;
+    }
+
+    /**
+     * @param mRes
+     *            the mRes to set
+     */
+    public void setMRes(List<String> mRes) {
+	this.mRes = mRes;
+    }
+
+    /**
+     * Set the message status of the contact.
+     * 
+     * @param msgState
+     *            the message status of the contact to set
+     */
+    public void setMsgState(String msgState) {
+	mMsgState = msgState;
+    }
+
+    /**
+     * @param mName
+     *            the mName to set
+     */
+    public void setName(String mName) {
+	if (mName != null)
+	    this.mName = mName;
+    }
+
+    /**
+     * Set the status of the contact.
+     * 
+     * @param status
+     *            the mStatus to set
+     */
+    public void setStatus(int status) {
+	mStatus = status;
+    }
+
+    /**
+     * Set the status of the contact using a presence packet.
+     * 
+     * @param presence
+     *            the presence containing status
+     */
+    public void setStatus(Presence presence) {
+	mStatus = Status.getStatusFromPresence(presence);
+	mMsgState = presence.getStatus();
+    }
+
+    public void setStatus(PresenceAdapter presence) {
+	mStatus = presence.getStatus();
+	mMsgState = presence.getStatusText();
+
+    }
+
+    @Override
+    public String toString() {
+	if (mJID != null)
+	    return mJID;
+	return super.toString();
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -97,169 +282,4 @@
 	dest.writeStringList(getMRes());
 	dest.writeStringList(getGroups());
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int describeContents() {
-	// TODO Auto-generated method stub
-	return 0;
-    }
-
-    /**
-     * Get the id of the contact on the phone contact list.
-     * @return the mID
-     */
-    public int getID() {
-	return mID;
-    }
-
-    /**
-     * set the id of te contact on the phone contact list.
-     * @param mid the mID to set
-     */
-    public void setID(int mid) {
-	mID = mid;
-    }
-
-    /**
-     * Get the status of the contact.
-     * @return the mStatus
-     */
-    public int getStatus() {
-	return mStatus;
-    }
-
-    /**
-     * Set the status of the contact.
-     * @param status the mStatus to set
-     */
-    public void setStatus(int status) {
-	mStatus = status;
-    }
-
-    /**
-     * Set the status of the contact using a presence packet.
-     * @param presence the presence containing status
-     */
-    public void setStatus(Presence presence) {
-	mStatus = Status.getStatusFromPresence(presence);
-	mMsgState = presence.getStatus();
-    }
-    
-    public void setStatus(PresenceAdapter presence) {
-	mStatus = presence.getStatus();
-	mMsgState = presence.getStatusText();
-	
-    }
-
-    /**
-     * Get the message status of the contact.
-     * @return the message status of the contact.
-     */
-    public String getMsgState() {
-	return mMsgState;
-    }
-
-    /**
-     * Set the message status of the contact.
-     * @param msgState the message status of the contact to set
-     */
-    public void setMsgState(String msgState) {
-	mMsgState = msgState;
-    }
-
-    /**
-     * Get the Jabber ID of the contact.
-     * @return the Jabber ID
-     */
-    public String getJID() {
-	return mJID;
-    }
-
-    /**
-     * Set the Jabber ID of the contact.
-     * @param mjid the jabber ID to set
-     */
-    public void setJID(String mjid) {
-	mJID = mjid;
-    }
-
-    /**
-     * 
-     * @param res
-     */
-    public void addRes(String res) {
-	if (!mRes.contains(res))
-	    mRes.add(res);
-    }
-
-    /**
-     * 
-     * @param res
-     */
-    public void delRes(String res) {
-	mRes.remove(res);
-    }
-
-    /**
-     * @param mRes the mRes to set
-     */
-    public void setMRes(List<String> mRes) {
-	this.mRes = mRes;
-    }
-
-    /**
-     * @return the mRes
-     */
-    public List<String> getMRes() {
-	return mRes;
-    }
-    
-    @Override
-    public String toString() {
-	if (mJID != null)
-	    return mJID;
-	return super.toString();
-    }
-
-    public void setGroups(Collection<RosterGroup> groups) {
-	for (RosterGroup rosterGroup : groups) {
-	    mGroups.add(rosterGroup.getName());
-	}
-    }
-    
-    public void addGroup(String group) {
-	mGroups.add(group);
-    }
-
-    /**
-     * @param mGroups the mGroups to set
-     */
-    public void setGroups(List<String> mGroups) {
-	this.mGroups = mGroups;
-    }
-    
-    /**
-     * @return the mGroups
-     */
-    public List<String> getGroups() {
-	return mGroups;
-    }
-
-    /**
-     * @param mName the mName to set
-     */
-    public void setName(String mName) {
-	if (mName != null)
-	    this.mName = mName;
-    }
-
-    /**
-     * @return the mName
-     */
-    public String getName() {
-	return mName;
-    }    
 }
--- a/src/com/beem/project/beem/service/Message.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/Message.java	Tue May 26 19:56:38 2009 +0200
@@ -11,6 +11,7 @@
 
 /**
  * This class represents a instant message.
+ * 
  * @author darisk
  */
 public class Message implements Parcelable {
@@ -18,87 +19,67 @@
     /**
      * Normal message type. Theese messages are like an email, with subject.
      */
-    public static final int MSG_TYPE_NORMAL = 100;
+    public static final int                         MSG_TYPE_NORMAL     = 100;
 
     /**
      * Chat message type.
      */
-    public static final int MSG_TYPE_CHAT = 200;
+    public static final int                         MSG_TYPE_CHAT       = 200;
 
     /**
      * Group chat message type.
      */
-    public static final int MSG_TYPE_GROUP_CHAT = 300;
+    public static final int                         MSG_TYPE_GROUP_CHAT = 300;
 
     /**
      * Error message type.
      */
-    public static final int MSG_TYPE_ERROR = 400;
+    public static final int                         MSG_TYPE_ERROR      = 400;
 
-    private int mType;
-    private String mBody;
-    private String mSubject;
-    private String mTo;
-    private String mThread;
+    private int                                     mType;
+    private String                                  mBody;
+    private String                                  mSubject;
+    private String                                  mTo;
+    private String                                  mThread;
     // TODO ajouter l'erreur
 
     /**
      * Parcelable.Creator needs by Android.
      */
-    public static final Parcelable.Creator<Message> CREATOR = new Parcelable.Creator<Message>() {
-
-	@Override
-	public Message createFromParcel(Parcel source) {
-	    return new Message(source);
-	}
-
-	@Override
-	public Message[] newArray(int size) {
-	    return new Message[size];
-	}
-    };
+    public static final Parcelable.Creator<Message> CREATOR             = new Parcelable.Creator<Message>() {
 
-    /**
-     * Constructor.
-     * @param to the destinataire of the message
-     * @param type the message type
-     */
-    public Message(final String to, final int type) {
-	mTo = to;
-	mType = type;
-	mBody = "";
-	mSubject = "";
-	mThread = "";
-    }
+	                                                                    @Override
+	                                                                    public Message createFromParcel(
+	                                                                            Parcel source) {
+		                                                                return new Message(source);
+	                                                                    }
 
-    /**
-     * Constructor a message of type chat.
-     * @param to the destinataire of the message
-     */
-    public Message(final String to) {
-	this(to, MSG_TYPE_CHAT);
-    }
+	                                                                    @Override
+	                                                                    public Message[] newArray(int size) {
+		                                                                return new Message[size];
+	                                                                    }
+	                                                                };
 
     public Message(org.jivesoftware.smack.packet.Message smackMsg) {
 	this(smackMsg.getTo());
 	switch (smackMsg.getType()) {
-	    case chat:
-		mType = MSG_TYPE_CHAT;
-		break;
-	    case groupchat:
-		mType = MSG_TYPE_GROUP_CHAT;
-		break;
-	    case normal:
-		mType = MSG_TYPE_NORMAL;
-		break;
-	    // TODO gerer les message de type error
-	    // this a little work around waiting for a better handling of error messages
-	    case error:
-		mType = MSG_TYPE_ERROR;
-		break;
-	    default:
-		Log.w("BEEM_MESSAGE", "type de message non gerer" + smackMsg.getType());
-		break;
+	case chat:
+	    mType = MSG_TYPE_CHAT;
+	    break;
+	case groupchat:
+	    mType = MSG_TYPE_GROUP_CHAT;
+	    break;
+	case normal:
+	    mType = MSG_TYPE_NORMAL;
+	    break;
+	// TODO gerer les message de type error
+	// this a little work around waiting for a better handling of error messages
+	case error:
+	    mType = MSG_TYPE_ERROR;
+	    break;
+	default:
+	    Log.w("BEEM_MESSAGE", "type de message non gerer" + smackMsg.getType());
+	    break;
 	}
 	if (mType == MSG_TYPE_ERROR) {
 	    XMPPError er = smackMsg.getError();
@@ -116,7 +97,9 @@
 
     /**
      * Construct a message from a parcel.
-     * @param in parcel to use for construction
+     * 
+     * @param in
+     *            parcel to use for construction
      */
     private Message(final Parcel in) {
 	mType = in.readInt();
@@ -127,6 +110,136 @@
     }
 
     /**
+     * Constructor a message of type chat.
+     * 
+     * @param to
+     *            the destinataire of the message
+     */
+    public Message(final String to) {
+	this(to, MSG_TYPE_CHAT);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param to
+     *            the destinataire of the message
+     * @param type
+     *            the message type
+     */
+    public Message(final String to, final int type) {
+	mTo = to;
+	mType = type;
+	mBody = "";
+	mSubject = "";
+	mThread = "";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int describeContents() {
+	// TODO Auto-generated method stub
+	return 0;
+    }
+
+    /**
+     * Get the body of the message.
+     * 
+     * @return the Body of the message
+     */
+    public String getBody() {
+	return mBody;
+    }
+
+    /**
+     * Get the subject of the message.
+     * 
+     * @return the subject
+     */
+    public String getSubject() {
+	return mSubject;
+    }
+
+    /**
+     * Get the thread of the message.
+     * 
+     * @return the thread
+     */
+    public String getThread() {
+	return mThread;
+    }
+
+    /**
+     * Get the destinataire of the message.
+     * 
+     * @return the destinataire of the message
+     */
+    public String getTo() {
+	return mTo;
+    }
+
+    /**
+     * Get the type of the message.
+     * 
+     * @return the type of the message.
+     */
+    public int getType() {
+	return mType;
+    }
+
+    /**
+     * Set the body of the message.
+     * 
+     * @param body
+     *            the body to set
+     */
+    public void setBody(String body) {
+	mBody = body;
+    }
+
+    /**
+     * Set the subject of the message.
+     * 
+     * @param subject
+     *            the subject to set
+     */
+    public void setSubject(String subject) {
+	mSubject = subject;
+    }
+
+    /**
+     * Set the thread of the message.
+     * 
+     * @param thread
+     *            the thread to set
+     */
+    public void setThread(String thread) {
+	mThread = thread;
+    }
+
+    /**
+     * Set the destinataire of the message.
+     * 
+     * @param to
+     *            the destinataire to set
+     */
+    public void setTo(String to) {
+	mTo = to;
+    }
+
+    /**
+     * Set the type of the message.
+     * 
+     * @param type
+     *            the type to set
+     */
+    public void setType(int type) {
+	mType = type;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -139,93 +252,4 @@
 	dest.writeString(mThread);
     }
 
-    /**
-     * Get the type of the message.
-     * @return the type of the message.
-     */
-    public int getType() {
-	return mType;
-    }
-
-    /**
-     * Set the type of the message.
-     * @param type the type to set
-     */
-    public void setType(int type) {
-	mType = type;
-    }
-
-    /**
-     * Get the body of the message.
-     * @return the Body of the message
-     */
-    public String getBody() {
-	return mBody;
-    }
-
-    /**
-     * Set the body of the message.
-     * @param body the body to set
-     */
-    public void setBody(String body) {
-	mBody = body;
-    }
-
-    /**
-     * Get the subject of the message.
-     * @return the subject
-     */
-    public String getSubject() {
-	return mSubject;
-    }
-
-    /**
-     * Set the subject of the message.
-     * @param subject the subject to set
-     */
-    public void setSubject(String subject) {
-	mSubject = subject;
-    }
-
-    /**
-     * Get the destinataire of the message.
-     * @return the destinataire of the message
-     */
-    public String getTo() {
-	return mTo;
-    }
-
-    /**
-     * Set the destinataire of the message.
-     * @param to the destinataire to set
-     */
-    public void setTo(String to) {
-	mTo = to;
-    }
-
-    /**
-     * Get the thread of the message.
-     * @return the thread
-     */
-    public String getThread() {
-	return mThread;
-    }
-
-    /**
-     * Set the thread of the message.
-     * @param thread the thread to set
-     */
-    public void setThread(String thread) {
-	mThread = thread;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int describeContents() {
-	// TODO Auto-generated method stub
-	return 0;
-    }
-
 }
--- a/src/com/beem/project/beem/service/PresenceAdapter.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/PresenceAdapter.java	Tue May 26 19:56:38 2009 +0200
@@ -2,144 +2,140 @@
 
 import org.jivesoftware.smack.packet.Presence;
 
-import com.beem.project.beem.utils.PresenceType;
-import com.beem.project.beem.utils.Status;
-
 import android.os.Parcel;
 import android.os.Parcelable;
 
-public class PresenceAdapter implements  Parcelable {
-	
-	private int mType;
-	private int mStatus;
-	private String mTo;
-	private String mFrom;
-	private String mStatusText;
-	
-	/**
-	 * Parcelable.Creator needs by Android.
-	 */
-	public static final Parcelable.Creator<PresenceAdapter> CREATOR = new Parcelable.Creator<PresenceAdapter>() {
+import com.beem.project.beem.utils.PresenceType;
+import com.beem.project.beem.utils.Status;
+
+public class PresenceAdapter implements Parcelable {
+
+    private int                                             mType;
+    private int                                             mStatus;
+    private String                                          mTo;
+    private String                                          mFrom;
+    private String                                          mStatusText;
 
-		@Override
-		public PresenceAdapter createFromParcel(Parcel source) {
-			return new PresenceAdapter(source);
-		}
+    /**
+     * Parcelable.Creator needs by Android.
+     */
+    public static final Parcelable.Creator<PresenceAdapter> CREATOR = new Parcelable.Creator<PresenceAdapter>() {
+
+	                                                                @Override
+	                                                                public PresenceAdapter createFromParcel(
+	                                                                        Parcel source) {
+		                                                            return new PresenceAdapter(source);
+	                                                                }
+
+	                                                                @Override
+	                                                                public PresenceAdapter[] newArray(int size) {
+		                                                            return new PresenceAdapter[size];
+	                                                                }
+	                                                            };
 
-		@Override
-		public PresenceAdapter[] newArray(int size) {
-			return new PresenceAdapter[size];
-		}
-	};
-	
-	public PresenceAdapter(Presence presence) {
-		mType = PresenceType.getPresenceType(presence);
-		mStatus = Status.getStatusFromPresence(presence);
-		mTo = presence.getTo();
-		mFrom = presence.getFrom();
-		mStatusText = presence.getStatus();
-	}
-	
-	
-	public PresenceAdapter(Parcel source) {
-		mType = source.readInt();
-		mStatus = source.readInt();
-		mTo = source.readString();
-		mFrom = source.readString();
-		mStatusText = source.readString();
-	}
+    public PresenceAdapter(Parcel source) {
+	mType = source.readInt();
+	mStatus = source.readInt();
+	mTo = source.readString();
+	mFrom = source.readString();
+	mStatusText = source.readString();
+    }
+
+    public PresenceAdapter(Presence presence) {
+	mType = PresenceType.getPresenceType(presence);
+	mStatus = Status.getStatusFromPresence(presence);
+	mTo = presence.getTo();
+	mFrom = presence.getFrom();
+	mStatusText = presence.getStatus();
+    }
 
-	@Override
-	public int describeContents() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
+    @Override
+    public int describeContents() {
+	// TODO Auto-generated method stub
+	return 0;
+    }
 
-	@Override
-	public void writeToParcel(Parcel dest, int flags) {
-		dest.writeInt(mType);
-		dest.writeInt(mStatus);
-		dest.writeString(mTo);
-		dest.writeString(mFrom);
-		dest.writeString(mStatusText);
-	}
+    /**
+     * @return the mFrom
+     */
+    public String getFrom() {
+	return mFrom;
+    }
 
-
-	/**
-	 * @param mStatus the mStatus to set
-	 */
-	public void setStatus(int mStatus) {
-	    this.mStatus = mStatus;
-	}
-
+    /**
+     * @return the mStatus
+     */
+    public int getStatus() {
+	return mStatus;
+    }
 
-	/**
-	 * @return the mStatus
-	 */
-	public int getStatus() {
-	    return mStatus;
-	}
+    /**
+     * @return the mStatusText
+     */
+    public String getStatusText() {
+	return mStatusText;
+    }
 
-
-	/**
-	 * @param mType the mType to set
-	 */
-	public void setType(int mType) {
-	    this.mType = mType;
-	}
+    /**
+     * @return the mTo
+     */
+    public String getTo() {
+	return mTo;
+    }
 
-
-	/**
-	 * @return the mType
-	 */
-	public int getType() {
-	    return mType;
-	}
+    /**
+     * @return the mType
+     */
+    public int getType() {
+	return mType;
+    }
 
-
-	/**
-	 * @param mTo the mTo to set
-	 */
-	public void setTo(String mTo) {
-	    this.mTo = mTo;
-	}
+    /**
+     * @param mFrom
+     *            the mFrom to set
+     */
+    public void setFrom(String mFrom) {
+	this.mFrom = mFrom;
+    }
 
-	/**
-	 * @return the mTo
-	 */
-	public String getTo() {
-	    return mTo;
-	}
-
+    /**
+     * @param mStatus
+     *            the mStatus to set
+     */
+    public void setStatus(int mStatus) {
+	this.mStatus = mStatus;
+    }
 
-	/**
-	 * @param mFrom the mFrom to set
-	 */
-	public void setFrom(String mFrom) {
-	    this.mFrom = mFrom;
-	}
-
+    /**
+     * @param mStatusText
+     *            the mStatusText to set
+     */
+    public void setStatusText(String mStatusText) {
+	this.mStatusText = mStatusText;
+    }
 
-	/**
-	 * @return the mFrom
-	 */
-	public String getFrom() {
-	    return mFrom;
-	}
-
+    /**
+     * @param mTo
+     *            the mTo to set
+     */
+    public void setTo(String mTo) {
+	this.mTo = mTo;
+    }
 
-	/**
-	 * @param mStatusText the mStatusText to set
-	 */
-	public void setStatusText(String mStatusText) {
-	    this.mStatusText = mStatusText;
-	}
-
+    /**
+     * @param mType
+     *            the mType to set
+     */
+    public void setType(int mType) {
+	this.mType = mType;
+    }
 
-	/**
-	 * @return the mStatusText
-	 */
-	public String getStatusText() {
-	    return mStatusText;
-	}
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+	dest.writeInt(mType);
+	dest.writeInt(mStatus);
+	dest.writeString(mTo);
+	dest.writeString(mFrom);
+	dest.writeString(mStatusText);
+    }
 }
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Tue May 26 19:56:38 2009 +0200
@@ -17,127 +17,22 @@
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.util.StringUtils;
 
-import com.beem.project.beem.service.aidl.IBeemRosterListener;
-
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
 import android.util.Log;
 
+import com.beem.project.beem.service.aidl.IBeemRosterListener;
+
 /**
  * This class implement a Roster adapter for BEEM.
+ * 
  * @author darisk
  */
 public class RosterAdapter extends com.beem.project.beem.service.aidl.IRoster.Stub {
 
-    private static final String TAG = "RosterAdapter";
-    private Roster mAdaptee;
-    private RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners = new RemoteCallbackList<IBeemRosterListener>();
-    private Map<String, Contact> mContacts = new HashMap<String, Contact>();
-
-    private RosterListenerAdapter mRosterListener = new RosterListenerAdapter();
-
-    /**
-     * Constructor.
-     * @param roster the roster to adapt
-     */
-    public RosterAdapter(final Roster roster) {
-	mAdaptee = roster;
-	roster.addRosterListener(mRosterListener);
-	for (RosterEntry entry : roster.getEntries()) {
-	    String user = StringUtils.parseBareAddress(entry.getUser());
-	    if (!mContacts.containsKey(user)) {
-		Contact c = new Contact(user);
-		c.setStatus(roster.getPresence(user));
-		c.setGroups(entry.getGroups());
-		c.setName(entry.getName());
-		mContacts.put(user, c);
-	    }
-	}
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void createGroup(String groupname) throws RemoteException {
-	mAdaptee.createGroup(groupname);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Contact addContact(String user, String name, String[] groups) throws RemoteException {
-	try {
-	    mAdaptee.createEntry(user, name, groups);
-	    Contact res = new Contact(user);
-	    mContacts.put(user, res);
-	    for (String group : groups) {
-		// mAdaptee.createGroup(group);
-		res.addGroup(group);
-	    }
-	    return res;
-	} catch (XMPPException e) {
-	    Log.e(TAG, "Error while adding new contact", e);
-	    return null;
-	}
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void deleteContact(Contact contact) throws RemoteException {
-	mContacts.remove(contact.getJID());
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addConnectionListener(IBeemRosterListener listen) throws RemoteException {
-	if (listen != null)
-	    mRemoteRosListeners.register(listen);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void removeConnectionListener(IBeemRosterListener listen) throws RemoteException {
-	if (listen != null)
-	    mRemoteRosListeners.unregister(listen);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Contact getContact(String jid) throws RemoteException {
-	return mContacts.get(jid);
-    }
-
-    /**
-     * 
-     */
-    @Override
-    public void setContactName(String jid, String name) throws RemoteException {
-	mContacts.get(jid).setName(name);
-	mAdaptee.getEntry(jid).setName(name);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public List<Contact> getContactList() throws RemoteException {
-	List<Contact> res = new ArrayList<Contact>();
-	res.addAll(mContacts.values());
-	return res;
-    }
-
     /**
      * Listener for the roster events. It will call the remote listeners registered.
+     * 
      * @author darisk
      */
     private class RosterListenerAdapter implements RosterListener {
@@ -253,6 +148,98 @@
 	}
     }
 
+    private static final String                     TAG                 = "RosterAdapter";
+    private Roster                                  mAdaptee;
+    private RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners = new RemoteCallbackList<IBeemRosterListener>();
+
+    private Map<String, Contact>                    mContacts           = new HashMap<String, Contact>();
+
+    private RosterListenerAdapter                   mRosterListener     = new RosterListenerAdapter();
+
+    /**
+     * Constructor.
+     * 
+     * @param roster
+     *            the roster to adapt
+     */
+    public RosterAdapter(final Roster roster) {
+	mAdaptee = roster;
+	roster.addRosterListener(mRosterListener);
+	for (RosterEntry entry : roster.getEntries()) {
+	    String user = StringUtils.parseBareAddress(entry.getUser());
+	    if (!mContacts.containsKey(user)) {
+		Contact c = new Contact(user);
+		c.setStatus(roster.getPresence(user));
+		c.setGroups(entry.getGroups());
+		c.setName(entry.getName());
+		mContacts.put(user, c);
+	    }
+	}
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addConnectionListener(IBeemRosterListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteRosListeners.register(listen);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact addContact(String user, String name, String[] groups) throws RemoteException {
+	try {
+	    mAdaptee.createEntry(user, name, groups);
+	    Contact res = new Contact(user);
+	    mContacts.put(user, res);
+	    for (String group : groups) {
+		// mAdaptee.createGroup(group);
+		res.addGroup(group);
+	    }
+	    return res;
+	} catch (XMPPException e) {
+	    Log.e(TAG, "Error while adding new contact", e);
+	    return null;
+	}
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void createGroup(String groupname) throws RemoteException {
+	mAdaptee.createGroup(groupname);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void deleteContact(Contact contact) throws RemoteException {
+	mContacts.remove(contact.getJID());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact getContact(String jid) throws RemoteException {
+	return mContacts.get(jid);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<Contact> getContactList() throws RemoteException {
+	List<Contact> res = new ArrayList<Contact>();
+	res.addAll(mContacts.values());
+	return res;
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -266,4 +253,22 @@
 	return result;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeConnectionListener(IBeemRosterListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteRosListeners.unregister(listen);
+    }
+
+    /**
+     * 
+     */
+    @Override
+    public void setContactName(String jid, String name) throws RemoteException {
+	mContacts.get(jid).setName(name);
+	mAdaptee.getEntry(jid).setName(name);
+    }
+
 }
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Tue May 26 19:56:38 2009 +0200
@@ -8,13 +8,14 @@
 import org.jivesoftware.smack.Roster;
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smackx.ChatStateManager;
 import org.jivesoftware.smackx.ServiceDiscoveryManager;
 import org.jivesoftware.smackx.jingle.JingleManager;
+
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
 import android.util.Log;
+
 import com.beem.project.beem.BeemService;
 import com.beem.project.beem.service.aidl.IBeemConnectionListener;
 import com.beem.project.beem.service.aidl.IChatManager;
@@ -23,170 +24,14 @@
 
 /**
  * This class implements an adapter for XMPPConnection.
+ * 
  * @author darisk
  */
 public class XmppConnectionAdapter extends IXmppConnection.Stub {
 
-    private static final String TAG = "XMPPConnectionAdapter";
-    private XMPPConnection mAdaptee;
-    private IChatManager mChatManager;
-    private String mLogin;
-    private String mPassword;
-    private RosterAdapter mRoster;
-    private BeemService mService;
-
-    private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
-    private ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter();
-
-    /**
-     * Constructor.
-     * @param con The connection to adapt
-     * @param login The login to use
-     * @param password The password to use
-     */
-    public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password, BeemService service) {
-	mAdaptee = con;
-	mLogin = login;
-	mPassword = password;
-	mService = service;
-    }
-
-    /**
-     * Constructor.
-     * @param serviceName name of the service to connect to
-     * @param login login to use on connect
-     * @param password password to use on connect
-     */
-    public XmppConnectionAdapter(final String serviceName, final String login, final String password, BeemService service) {
-	this(new XMPPConnection(serviceName), login, password, service);
-    }
-
-    /**
-     * Constructor.
-     * @param config Configuration to use in order to connect
-     * @param login login to use on connect
-     * @param password password to use on connect
-     */
-    public XmppConnectionAdapter(final ConnectionConfiguration config, final String login, final String password, BeemService service) {
-	this(new XMPPConnection(config), login, password, service);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean connectSync() throws RemoteException {
-	try {
-	    mAdaptee.connect();
-	    mAdaptee.addConnectionListener(mConListener);
-	    mAdaptee.login(mLogin, mPassword, "BEEM");
-	    
-	    mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
-	    // TODO find why this cause a null pointer exception
-	    this.initFeatures(); // pour declarer les features xmpp qu'on supporte
-	    ChatStateManager.getInstance(mAdaptee);
-	    triggerAsynchronousConnectEvent();
-	    return true;
-	} catch (XMPPException e) {
-	    Log.e(TAG, "Error while connecting", e);
-	    if (e.getXMPPError() != null)
-		mConListener.connectionFailed(e.getXMPPError().getMessage()); //
-	    else
-		mConListener.connectionFailed("Error On Connection");
-	}
-	return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean disconnect() {
-	mAdaptee.disconnect();
-	return true;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IRoster getRoster() throws RemoteException {
-	if (mRoster != null)
-	    return mRoster;
-	Roster adap = mAdaptee.getRoster();
-	if (adap == null)
-	    return null;
-	mRoster = new RosterAdapter(adap);
-	return mRoster;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public final void connectAsync() throws RemoteException {
-	Thread t = new Thread(new Runnable() {
-
-	    @Override
-	    public void run() {
-		try {
-		    connectSync();
-		} catch (RemoteException e) {
-		    Log.e(TAG, "Error while connecting", e);
-		}
-	    }
-	});
-	t.start();
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addConnectionListener(IBeemConnectionListener listen) throws RemoteException {
-	if (listen != null)
-	    mRemoteConnListeners.register(listen);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void removeConnectionListener(IBeemConnectionListener listen) throws RemoteException {
-	if (listen != null)
-	    mRemoteConnListeners.unregister(listen);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IChatManager getChatManager() throws RemoteException {
-	return mChatManager;
-    }
-
-    /**
-     * Trigger Connection event.
-     */
-    private void triggerAsynchronousConnectEvent() {
-	mConListener.onConnect();
-    }
-
-    /**
-     * enregistre les features dispo dans notre version Liste de features que Telepathy supporte.
-     */
-    private void initFeatures() {
-	ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mAdaptee);
-	if (sdm == null)
-	    sdm = new ServiceDiscoveryManager(mAdaptee);
-	sdm.addFeature("http://jabber.org/protocol/disco#info");
-	JingleManager.setJingleServiceEnabled();
-	// sdm.addFeature("http://jabber.org/protocol/nick");
-
-    }
-
     /**
      * Listener for XMPP connection events. It will calls the remote listeners for connexion events.
+     * 
      * @author darisk
      */
     private class ConnexionListenerAdapter implements ConnectionListener {
@@ -199,25 +44,6 @@
 	}
 
 	/**
-	 * Method to execute when a connection event occurs.
-	 */
-	public void onConnect() {
-	    final int n = mRemoteConnListeners.beginBroadcast();
-
-	    for (int i = 0; i < n; i++) {
-		IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
-		try {
-		    listener.onConnect();
-		} catch (RemoteException e) {
-		    // The RemoteCallbackList will take care of removing the
-		    // dead listeners.
-		    Log.w(TAG, "Error while triggering remote connection listeners", e);
-		}
-	    }
-	    mRemoteConnListeners.finishBroadcast();
-	}
-
-	/**
 	 * {@inheritDoc}
 	 */
 	@Override
@@ -259,6 +85,42 @@
 	    mRemoteConnListeners.finishBroadcast();
 	}
 
+	public void connectionFailed(String errorMsg) {
+	    Log.i(TAG, "Connection Failed");
+	    final int n = mRemoteConnListeners.beginBroadcast();
+
+	    for (int i = 0; i < n; i++) {
+		IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
+		try {
+		    listener.connectionFailed(errorMsg);
+		} catch (RemoteException e) {
+		    // The RemoteCallbackList will take care of removing the
+		    // dead listeners.
+		    Log.w(TAG, "Error while triggering remote connection listeners", e);
+		}
+	    }
+	    mRemoteConnListeners.finishBroadcast();
+	}
+
+	/**
+	 * Method to execute when a connection event occurs.
+	 */
+	public void onConnect() {
+	    final int n = mRemoteConnListeners.beginBroadcast();
+
+	    for (int i = 0; i < n; i++) {
+		IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
+		try {
+		    listener.onConnect();
+		} catch (RemoteException e) {
+		    // The RemoteCallbackList will take care of removing the
+		    // dead listeners.
+		    Log.w(TAG, "Error while triggering remote connection listeners", e);
+		}
+	    }
+	    mRemoteConnListeners.finishBroadcast();
+	}
+
 	/**
 	 * {@inheritDoc}
 	 */
@@ -318,39 +180,197 @@
 	    }
 	    mRemoteConnListeners.finishBroadcast();
 	}
-	
-	public void connectionFailed(String errorMsg) {
-	    Log.i(TAG, "Connection Failed");
-	    final int n = mRemoteConnListeners.beginBroadcast();
+    }
+
+    private static final String                         TAG                  = "XMPPConnectionAdapter";
+    private XMPPConnection                              mAdaptee;
+    private IChatManager                                mChatManager;
+    private String                                      mLogin;
+    private String                                      mPassword;
+    private RosterAdapter                               mRoster;
+
+    private BeemService                                 mService;
+    private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
+
+    private ConnexionListenerAdapter                    mConListener         = new ConnexionListenerAdapter();
+
+    /**
+     * Constructor.
+     * 
+     * @param config
+     *            Configuration to use in order to connect
+     * @param login
+     *            login to use on connect
+     * @param password
+     *            password to use on connect
+     */
+    public XmppConnectionAdapter(final ConnectionConfiguration config, final String login, final String password,
+	    BeemService service) {
+	this(new XMPPConnection(config), login, password, service);
+    }
 
-	    for (int i = 0; i < n; i++) {
-		IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
+    /**
+     * Constructor.
+     * 
+     * @param serviceName
+     *            name of the service to connect to
+     * @param login
+     *            login to use on connect
+     * @param password
+     *            password to use on connect
+     */
+    public XmppConnectionAdapter(final String serviceName, final String login, final String password,
+	    BeemService service) {
+	this(new XMPPConnection(serviceName), login, password, service);
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param con
+     *            The connection to adapt
+     * @param login
+     *            The login to use
+     * @param password
+     *            The password to use
+     */
+    public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password,
+	    BeemService service) {
+	mAdaptee = con;
+	mLogin = login;
+	mPassword = password;
+	mService = service;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addConnectionListener(IBeemConnectionListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteConnListeners.register(listen);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public final void connectAsync() throws RemoteException {
+	Thread t = new Thread(new Runnable() {
+
+	    @Override
+	    public void run() {
 		try {
-		    listener.connectionFailed(errorMsg);
+		    connectSync();
 		} catch (RemoteException e) {
-		    // The RemoteCallbackList will take care of removing the
-		    // dead listeners.
-		    Log.w(TAG, "Error while triggering remote connection listeners", e);
+		    Log.e(TAG, "Error while connecting", e);
 		}
 	    }
-	    mRemoteConnListeners.finishBroadcast();
+	});
+	t.start();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean connectSync() throws RemoteException {
+	try {
+	    mAdaptee.connect();
+	    mAdaptee.addConnectionListener(mConListener);
+	    mAdaptee.login(mLogin, mPassword, "BEEM");
+
+	    mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
+	    // TODO find why this cause a null pointer exception
+	    this.initFeatures(); // pour declarer les features xmpp qu'on supporte
+	    ChatStateManager.getInstance(mAdaptee);
+	    triggerAsynchronousConnectEvent();
+	    return true;
+	} catch (XMPPException e) {
+	    Log.e(TAG, "Error while connecting", e);
+	    if (e.getXMPPError() != null)
+		mConListener.connectionFailed(e.getXMPPError().getMessage()); //
+	    else
+		mConListener.connectionFailed("Error On Connection");
 	}
+	return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean disconnect() {
+	mAdaptee.disconnect();
+	return true;
+    }
+
+    public XMPPConnection getAdaptee() {
+	return mAdaptee;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IChatManager getChatManager() throws RemoteException {
+	return mChatManager;
+    }
+
+    public BeemService getContext() {
+	return mService;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IRoster getRoster() throws RemoteException {
+	if (mRoster != null)
+	    return mRoster;
+	Roster adap = mAdaptee.getRoster();
+	if (adap == null)
+	    return null;
+	mRoster = new RosterAdapter(adap);
+	return mRoster;
+    }
+
+    /**
+     * enregistre les features dispo dans notre version Liste de features que Telepathy supporte.
+     */
+    private void initFeatures() {
+	ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mAdaptee);
+	if (sdm == null)
+	    sdm = new ServiceDiscoveryManager(mAdaptee);
+	sdm.addFeature("http://jabber.org/protocol/disco#info");
+	JingleManager.setJingleServiceEnabled();
+	// sdm.addFeature("http://jabber.org/protocol/nick");
+
     }
 
     /**
      * Returns true if currently authenticated by successfully calling the login method.
+     * 
      * @return true when successfully authenticated
      */
     public boolean isAuthentificated() {
 	return mAdaptee.isAuthenticated();
     }
 
-    public XMPPConnection getAdaptee() {
-	return mAdaptee;
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeConnectionListener(IBeemConnectionListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteConnListeners.unregister(listen);
     }
-    
-    public BeemService getContext() {
-	return mService;
+
+    /**
+     * Trigger Connection event.
+     */
+    private void triggerAsynchronousConnectEvent() {
+	mConListener.onConnect();
     }
-    
+
 }
--- a/src/com/beem/project/beem/service/XmppFacade.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppFacade.java	Tue May 26 19:56:38 2009 +0200
@@ -17,17 +17,21 @@
 
 /**
  * This class is a facade for the Beem Service.
+ * 
  * @author darisk
  */
 public class XmppFacade extends IXmppFacade.Stub {
 
     private XmppConnectionAdapter mConnexion;
-    private BeemService mBeemService;
+    private BeemService           mBeemService;
 
     /**
      * Constructor for XMPPFacade.
-     * @param connection the connection use by the facade
-     * @param service the service which holds the facade
+     * 
+     * @param connection
+     *            the connection use by the facade
+     * @param service
+     *            the service which holds the facade
      */
     public XmppFacade(final XmppConnectionAdapter connection, final BeemService service) {
 	this.mConnexion = connection;
@@ -38,6 +42,32 @@
      * {@inheritDoc}
      */
     @Override
+    public void changeStatus(int status, String msg) {
+	Presence pres = new Presence(Presence.Type.available);
+	if (msg != null)
+	    pres.setStatus(msg);
+	Presence.Mode mode = com.beem.project.beem.utils.Status.getPresenceModeFromStatus(status);
+	if (mode != null)
+	    pres.setMode(mode);
+	mConnexion.getAdaptee().sendPacket(pres);
+
+	Notification mStatusNotification;
+	String text = (msg == null ? "" : msg);
+	mStatusNotification = new Notification(com.beem.project.beem.R.drawable.notify_signal, text, System
+	        .currentTimeMillis());
+	mStatusNotification.defaults = Notification.DEFAULT_ALL;
+	mStatusNotification.flags = Notification.FLAG_NO_CLEAR;
+
+	// mStatusNotification.contentView = ;
+	mStatusNotification.setLatestEventInfo(mBeemService, "Beem Status", text, PendingIntent.getActivity(
+	        mBeemService, 0, new Intent(mBeemService, ChangeStatus.class), 0));
+	mBeemService.sendNotification(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public void connectAsync() throws RemoteException {
 	mConnexion.connectAsync();
     }
@@ -70,14 +100,6 @@
      * {@inheritDoc}
      */
     @Override
-    public IRoster getRoster() throws RemoteException {
-	return mConnexion.getRoster();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public IChatManager getChatManager() throws RemoteException {
 	return mConnexion.getChatManager();
     }
@@ -86,25 +108,8 @@
      * {@inheritDoc}
      */
     @Override
-    public void changeStatus(int status, String msg) {
-	Presence pres = new Presence(Presence.Type.available);
-	if (msg != null)
-	    pres.setStatus(msg);
-	Presence.Mode mode = com.beem.project.beem.utils.Status.getPresenceModeFromStatus(status);
-	if (mode != null)
-	    pres.setMode(mode);
-	mConnexion.getAdaptee().sendPacket(pres);
-	
-	Notification mStatusNotification;
-	String text = (msg == null ? "" : msg);
-	mStatusNotification = new Notification(com.beem.project.beem.R.drawable.notify_signal, text, System.currentTimeMillis());
-	mStatusNotification.defaults = Notification.DEFAULT_ALL;
-	mStatusNotification.flags = Notification.FLAG_NO_CLEAR;
-
-	// mStatusNotification.contentView = ;
-	mStatusNotification.setLatestEventInfo(mBeemService, "Beem Status", text, PendingIntent.getActivity(
-	    mBeemService, 0, new Intent(mBeemService,ChangeStatus.class), 0));
-	mBeemService.sendNotification(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification);
+    public IRoster getRoster() throws RemoteException {
+	return mConnexion.getRoster();
     }
 
     @Override
--- a/src/com/beem/project/beem/ui/AccountCreation.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/AccountCreation.java	Tue May 26 19:56:38 2009 +0200
@@ -11,8 +11,6 @@
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
 
-import com.beem.project.beem.R;
-
 import android.app.Activity;
 import android.content.SharedPreferences;
 import android.os.Bundle;
@@ -23,70 +21,66 @@
 import android.widget.EditText;
 import android.widget.Toast;
 
+import com.beem.project.beem.R;
+
 /**
  * @author nikita
- *
  */
-public class AccountCreation extends Activity {    
+public class AccountCreation extends Activity {
 
-    protected static final String TAG = "AccountCreation";
-    private SharedPreferences mSettings;
-    Map<String, String> mAttributes = new HashMap<String, String>();
+    protected static final String TAG         = "AccountCreation";
+    private SharedPreferences     mSettings;
+    Map<String, String>           mAttributes = new HashMap<String, String>();
+
+    private OnClickListener       mOkListener = new OnClickListener() {
 
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-	super.onCreate(savedInstanceState);
-	setContentView(R.layout.accountcreation);
-	Button ok = (Button) findViewById(R.id.ac_ok);
-	mSettings = getSharedPreferences(
-		getString(R.string.PreferenceFileName), MODE_PRIVATE);
-	ok.setOnClickListener(mOkListener);
-    }
+	                                          @Override
+	                                          public void onClick(View v) {
+		                                      boolean valid = true;
+		                                      if (getWidgetText(R.id.ac_login).length() == 0) {
+		                                          valid = false;
+		                                      } else {
+		                                          mAttributes.put("login", getWidgetText(R.id.ac_login));
+		                                          mAttributes.put("name", getWidgetText(R.id.ac_login));
+		                                      }
+		                                      if (getWidgetText(R.id.ac_password).length() == 0
+		                                              || !getWidgetText(R.id.ac_password).contains(
+		                                                      getWidgetText(R.id.ac_password2))) {
+		                                          valid = false;
 
-    private OnClickListener mOkListener = new OnClickListener() {
-	
-	@Override
-	public void onClick(View v) {
-	    boolean valid = true;
-	    if (getWidgetText(R.id.ac_login).length() == 0) {
-		valid = false;
-	    } else {
-		mAttributes.put("login", getWidgetText(R.id.ac_login));
-		mAttributes.put("name", getWidgetText(R.id.ac_login));
-	    }
-	    if (getWidgetText(R.id.ac_password).length() == 0 || !getWidgetText(R.id.ac_password).contains(getWidgetText(R.id.ac_password2))) {
-		valid = false;
-		
-	    } else {
-		mAttributes.put("password", getWidgetText(R.id.ac_password));
-	    }
-	    if (getWidgetText(R.id.ac_email).length() == 0) {
-		valid = false;
-	    } else {
-		mAttributes.put("email", getWidgetText(R.id.ac_email));
-	    }
-	    
-	    if (valid) {
-		setResult(RESULT_OK);
-		try {
-		    createAccount();
-		    Toast.makeText(AccountCreation.this, getString(R.string.ACCreated),
-	                    Toast.LENGTH_SHORT).show();
-		    finish();
-		} catch (XMPPException e) {
-		    Log.e(TAG, "Account creation failed", e);
-		    Toast.makeText(AccountCreation.this, e.getMessage(),
-	                    Toast.LENGTH_SHORT).show();
-		    e.printStackTrace();
-		}
-	    } else {
-		Toast.makeText(AccountCreation.this, getString(R.string.ACBadForm),
-                    Toast.LENGTH_SHORT).show();
-		setResult(RESULT_CANCELED);
-	    }
-	    
-	}
-    };
+		                                      } else {
+		                                          mAttributes.put("password", getWidgetText(R.id.ac_password));
+		                                      }
+		                                      if (getWidgetText(R.id.ac_email).length() == 0) {
+		                                          valid = false;
+		                                      } else {
+		                                          mAttributes.put("email", getWidgetText(R.id.ac_email));
+		                                      }
+
+		                                      if (valid) {
+		                                          setResult(RESULT_OK);
+		                                          try {
+			                                      createAccount();
+			                                      Toast
+			                                              .makeText(AccountCreation.this,
+			                                                      getString(R.string.ACCreated),
+			                                                      Toast.LENGTH_SHORT).show();
+			                                      finish();
+		                                          } catch (XMPPException e) {
+			                                      Log.e(TAG, "Account creation failed", e);
+			                                      Toast.makeText(AccountCreation.this, e.getMessage(),
+			                                              Toast.LENGTH_SHORT).show();
+			                                      e.printStackTrace();
+		                                          }
+		                                      } else {
+		                                          Toast.makeText(AccountCreation.this,
+		                                                  getString(R.string.ACBadForm), Toast.LENGTH_SHORT)
+		                                                  .show();
+		                                          setResult(RESULT_CANCELED);
+		                                      }
+
+	                                          }
+	                                      };
 
     protected void createAccount() throws XMPPException {
 	String mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
@@ -96,14 +90,23 @@
 	accM.createAccount(mAttributes.get("login"), mAttributes.get("password"), mAttributes);
 	xmmpCo.disconnect();
 	SharedPreferences.Editor editor = mSettings.edit();
-	
+
 	editor.putString(getString(R.string.PreferenceLoginKey), mAttributes.get("login"));
 	editor.putString(getString(R.string.PreferencePasswordKey), mAttributes.get("password"));
-	editor.commit();	
+	editor.commit();
     }
-    
+
     private String getWidgetText(int id) {
 	EditText widget = (EditText) this.findViewById(id);
 	return widget.getText().toString();
     }
-}
\ No newline at end of file
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.accountcreation);
+	Button ok = (Button) findViewById(R.id.ac_ok);
+	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	ok.setOnClickListener(mOkListener);
+    }
+}
--- a/src/com/beem/project/beem/ui/AddContact.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java	Tue May 26 19:56:38 2009 +0200
@@ -6,10 +6,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import com.beem.project.beem.BeemApplication;
-import com.beem.project.beem.R;
-import com.beem.project.beem.service.aidl.IXmppFacade;
-
 import android.app.Activity;
 import android.os.Bundle;
 import android.os.RemoteException;
@@ -19,17 +15,69 @@
 import android.widget.EditText;
 import android.widget.Toast;
 
+import com.beem.project.beem.BeemApplication;
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+
 /**
  * @author nikita
- *
  */
 public class AddContact extends Activity {
-    
-    protected static final String TAG = "AddContact";
-    private String mLogin;
-    private String mAlias;
-    private List<String> mGroup = new ArrayList<String>();
-    private IXmppFacade mService;
+
+    protected static final String TAG         = "AddContact";
+    private String                mLogin;
+    private String                mAlias;
+    private List<String>          mGroup      = new ArrayList<String>();
+    private IXmppFacade           mService;
+
+    private OnClickListener       mOkListener = new OnClickListener() {
+
+	                                          @Override
+	                                          public void onClick(View v) {
+		                                      boolean valid = true;
+		                                      if (getWidgetText(R.id.addc_login).length() == 0) {
+		                                          valid = false;
+		                                      } else {
+		                                          mLogin = getWidgetText(R.id.addc_login);
+		                                      }
+		                                      if (getWidgetText(R.id.addc_alias).length() == 0) {
+		                                          valid = false;
+		                                      } else {
+		                                          mAlias = getWidgetText(R.id.addc_alias);
+		                                      }
+		                                      if (getWidgetText(R.id.addc_group).length() == 0) {
+		                                          valid = false;
+		                                      } else {
+		                                          mGroup.add(getWidgetText(R.id.addc_group));
+		                                      }
+		                                      if (valid) {
+		                                          try {
+			                                      mService.getRoster().addContact(mLogin, mAlias,
+			                                              mGroup.toArray(new String[mGroup.size()]));
+			                                      Toast.makeText(AddContact.this,
+			                                              getString(R.string.AddCContactAdded),
+			                                              Toast.LENGTH_SHORT).show();
+			                                      finish();
+		                                          } catch (RemoteException e) {
+			                                      Toast.makeText(AddContact.this, e.getMessage(),
+			                                              Toast.LENGTH_SHORT).show();
+			                                      e.printStackTrace();
+		                                          }
+		                                          setResult(RESULT_OK);
+		                                      } else {
+		                                          Toast.makeText(AddContact.this,
+		                                                  getString(R.string.AddCBadForm), Toast.LENGTH_SHORT)
+		                                                  .show();
+		                                          setResult(RESULT_CANCELED);
+		                                      }
+
+	                                          }
+	                                      };
+
+    private String getWidgetText(int id) {
+	EditText widget = (EditText) this.findViewById(id);
+	return widget.getText().toString();
+    }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -39,50 +87,4 @@
 	ok.setOnClickListener(mOkListener);
 	mService = BeemApplication.getApplication(this).getXmppFacade();
     }
-    
-    private OnClickListener mOkListener = new OnClickListener() {
-	
-	@Override
-	public void onClick(View v) {
-	    boolean valid = true;
-	    if (getWidgetText(R.id.addc_login).length() == 0) {
-		valid = false;
-	    } else {
-		mLogin = getWidgetText(R.id.addc_login);
-	    }
-	    if (getWidgetText(R.id.addc_alias).length() == 0) {
-		valid = false;
-	    } else {
-		mAlias = getWidgetText(R.id.addc_alias);
-	    }
-	    if (getWidgetText(R.id.addc_group).length() == 0) {
-		valid = false;
-	    } else {
-		mGroup.add(getWidgetText(R.id.addc_group));
-	    }
-	    if (valid) {
-		try {
-		    mService.getRoster().addContact(mLogin, mAlias, (String[])mGroup.toArray(new String[mGroup.size()]));
-		    Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded),
-	                    Toast.LENGTH_SHORT).show();
-		    finish();
-		} catch (RemoteException e) {
-		    Toast.makeText(AddContact.this, e.getMessage(),
-	                    Toast.LENGTH_SHORT).show();
-		    e.printStackTrace();
-		}
-		setResult(RESULT_OK);
-	    } else {
-		Toast.makeText(AddContact.this, getString(R.string.AddCBadForm),
-                    Toast.LENGTH_SHORT).show();
-		setResult(RESULT_CANCELED);
-	    }
-	    
-	}
-    };
-    
-    private String getWidgetText(int id) {
-	EditText widget = (EditText) this.findViewById(id);
-	return widget.getText().toString();
-    }
 }
--- a/src/com/beem/project/beem/ui/ChangeStatus.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java	Tue May 26 19:56:38 2009 +0200
@@ -23,43 +23,134 @@
 import com.beem.project.beem.utils.Status;
 
 public class ChangeStatus extends Activity {
-    private TextView mStatusText;
-    private Button mOk;
-    private Button mClear;
-    private Handler mHandler;
-    private BeemApplication mBeemApplication;
-    private IXmppFacade mService = null;
-    private Spinner mSpinner;
-    private static final String[] STATUS = { "Available for chat", "Available", "Busy", "Away", "Unavailable",
-	"Disconnected" };
-    private static final int DISCONNECTED_IDX = 5;
-    private static final int AVAILABLE_FOR_CHAT_IDX = 0;
-    private static final int AVAILABLE_IDX = 1;
-    private static final int BUSY_IDX = 2;
-    private static final int AWAY_IDX = 3;
-    private static final int UNAVAILABLE_IDX = 4;
-    private SharedPreferences mSettings;
-    private ArrayAdapter<String> mAdapter;
-    private Toast mToast;
-    private static Integer nb = 0;
+
+    private TextView              mStatusText;
+    private Button                mOk;
+    private Button                mClear;
+    private Handler               mHandler;
+    private BeemApplication       mBeemApplication;
+    private IXmppFacade           mService               = null;
+    private Spinner               mSpinner;
+    private static final String[] STATUS                 = { "Available for chat", "Available", "Busy", "Away",
+	    "Unavailable", "Disconnected"               };
+    private static final int      DISCONNECTED_IDX       = 5;
+    private static final int      AVAILABLE_FOR_CHAT_IDX = 0;
+    private static final int      AVAILABLE_IDX          = 1;
+    private static final int      BUSY_IDX               = 2;
+    private static final int      AWAY_IDX               = 3;
+    private static final int      UNAVAILABLE_IDX        = 4;
+    private SharedPreferences     mSettings;
+    private ArrayAdapter<String>  mAdapter;
+    private Toast                 mToast;
+    private static Integer        nb                     = 0;
+
+    private final OnClickListener       mOnClickOk             = new OnClickListener() {
+
+	                                                     public void onClick(View v) {
+		                                                 if (v == mOk) {
+		                                                     if (textHasChanged() || statusHasChanged()) {
+			                                                 String msg = mStatusText.getText().toString();
+			                                                 int status = getStatusForService((String) mSpinner
+			                                                         .getSelectedItem());
+			                                                 Editor edit = mSettings.edit();
+			                                                 edit
+			                                                         .putString(
+			                                                                 getString(R.string.PreferenceStatusText),
+			                                                                 msg);
+			                                                 edit.putInt(
+			                                                         getString(R.string.PreferenceStatus),
+			                                                         mSpinner.getSelectedItemPosition());
+			                                                 edit.commit();
+			                                                 if (status == Status.CONTACT_STATUS_DISCONNECT) {
+			                                                     stopService(new Intent(ChangeStatus.this,
+			                                                             BeemService.class));
+			                                                 } else {
+			                                                     try {
+				                                                 mService.changeStatus(status, msg
+				                                                         .toString());
+			                                                     } catch (RemoteException e) {
+				                                                 // TODO
+				                                                 // Auto-generated
+				                                                 // catch block
+				                                                 e.printStackTrace();
+			                                                     }
+			                                                     mToast.show();
+			                                                 }
+		                                                     }
+		                                                     ChangeStatus.this.finish();
+		                                                 } else if (v == mClear) {
+		                                                     mStatusText.setText(null);
+		                                                 }
+
+	                                                     }
+
+	                                                     private boolean statusHasChanged() {
+		                                                 return (mSettings.getInt(
+		                                                         getString(R.string.PreferenceStatus), 0) != mSpinner
+		                                                         .getSelectedItemPosition());
+	                                                     }
+
+	                                                     private boolean textHasChanged() {
+		                                                 return (!mStatusText
+		                                                         .getText()
+		                                                         .toString()
+		                                                         .equals(
+		                                                                 getPreferenceString(R.string.PreferenceStatusText)));
+	                                                     }
+	                                                 };
+
+    private int getPreferenceStatusIndex() {
+	return mSettings.getInt(getString(R.string.PreferenceStatus), 0);
+    }
+
+    private String getPreferenceString(int id) {
+	return mSettings.getString(getString(id), "");
+    }
+
+    private int getStatusForService(String item) {
+	int res = Status.CONTACT_STATUS_AVAILABLE;
+	for (int i = 0; i < ChangeStatus.STATUS.length; i++) {
+	    String str = ChangeStatus.STATUS[i];
+	    if (str.equals(item)) {
+		switch (i) {
+		case ChangeStatus.DISCONNECTED_IDX:
+		    return Status.CONTACT_STATUS_DISCONNECT;
+		case ChangeStatus.AVAILABLE_FOR_CHAT_IDX:
+		    return Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
+		case ChangeStatus.AVAILABLE_IDX:
+		    return Status.CONTACT_STATUS_AVAILABLE;
+		case ChangeStatus.AWAY_IDX:
+		    return Status.CONTACT_STATUS_AWAY;
+		case ChangeStatus.BUSY_IDX:
+		    return Status.CONTACT_STATUS_BUSY;
+		case ChangeStatus.UNAVAILABLE_IDX:
+		    return Status.CONTACT_STATUS_UNAVAILABLE;
+		default:
+		    res = Status.CONTACT_STATUS_AVAILABLE;
+		    break;
+		}
+	    }
+	}
+	return res;
+    }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
 	super.onCreate(savedInstanceState);
-	
+
 	nb++;
 	Log.i("nb de oncreate changestatus", nb.toString());
 	// Beem Application specific
 	mHandler = new Handler();
 	mBeemApplication = BeemApplication.getApplication(this);
-	
+
 	setContentView(R.layout.changestatus);
 	mStatusText = (TextView) findViewById(R.id.ChangeStatusText);
 	mOk = (Button) findViewById(R.id.ChangeStatusOk);
 	mClear = (Button) findViewById(R.id.ChangeStatusClear);
 	mOk.setOnClickListener(mOnClickOk);
 	mClear.setOnClickListener(mOnClickOk);
-	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
 
 	mSpinner = (Spinner) findViewById(R.id.ChangeStatusSpinner);
 	mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, STATUS);
@@ -70,15 +161,16 @@
     }
 
     @Override
-    protected void onStart() {
-	super.onStart();
-	mBeemApplication.startBeemService();
+    protected void onDestroy() {
+	super.onDestroy();
+	mBeemApplication.unbindBeemService();
     }
 
     @Override
     protected void onResume() {
 	super.onResume();
 	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
+
 	    @Override
 	    public void run() {
 		mService = mBeemApplication.getXmppFacade();
@@ -87,9 +179,9 @@
     }
 
     @Override
-    protected void onDestroy() {
-	super.onDestroy();
-	mBeemApplication.unbindBeemService();
+    protected void onStart() {
+	super.onStart();
+	mBeemApplication.startBeemService();
     }
 
     private void showSettings() {
@@ -97,79 +189,4 @@
 	mSpinner.setSelection(getPreferenceStatusIndex());
     }
 
-    private int getStatusForService(String item) {
-	int res = Status.CONTACT_STATUS_AVAILABLE;
-	for (int i = 0; i < ChangeStatus.STATUS.length; i++) {
-	    String str = ChangeStatus.STATUS[i];
-	    if (str.equals(item)) {
-		switch (i) {
-		    case ChangeStatus.DISCONNECTED_IDX:
-			return Status.CONTACT_STATUS_DISCONNECT;
-		    case ChangeStatus.AVAILABLE_FOR_CHAT_IDX:
-			return Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
-		    case ChangeStatus.AVAILABLE_IDX:
-			return Status.CONTACT_STATUS_AVAILABLE;
-		    case ChangeStatus.AWAY_IDX:
-			return Status.CONTACT_STATUS_AWAY;
-		    case ChangeStatus.BUSY_IDX:
-			return Status.CONTACT_STATUS_BUSY;
-		    case ChangeStatus.UNAVAILABLE_IDX:
-			return Status.CONTACT_STATUS_UNAVAILABLE;
-		    default:
-			res = Status.CONTACT_STATUS_AVAILABLE;
-			break;
-		}
-	    }
-	}
-	return res;
-    }
-
-    private String getPreferenceString(int id) {
-	return mSettings.getString(getString(id), "");
-    }
-
-    private int getPreferenceStatusIndex() {
-	return mSettings.getInt(getString(R.string.PreferenceStatus), 0);
-    }
-
-    
-    private OnClickListener mOnClickOk = new OnClickListener() {
-
-	private boolean textHasChanged() {
-	    return (!mStatusText.getText().toString().equals(getPreferenceString(R.string.PreferenceStatusText)));
-	}
-
-	private boolean statusHasChanged() {
-	    return (mSettings.getInt(getString(R.string.PreferenceStatus), 0) != mSpinner.getSelectedItemPosition());
-	}
-
-	public void onClick(View v) {
-	    if (v == mOk) {
-		if (textHasChanged() || statusHasChanged()) {
-		    String msg = mStatusText.getText().toString();
-		    int status = getStatusForService( (String) mSpinner.getSelectedItem());
-		    Editor edit = mSettings.edit();
-		    edit.putString(getString(R.string.PreferenceStatusText), msg);
-		    edit.putInt(getString(R.string.PreferenceStatus), mSpinner.getSelectedItemPosition());
-		    edit.commit();
-		    if (status == Status.CONTACT_STATUS_DISCONNECT) {
-			stopService(new Intent(ChangeStatus.this, BeemService.class));
-		    } else {
-			try {
-			    mService.changeStatus(status, msg.toString());
-			} catch (RemoteException e) {
-			    // TODO Auto-generated catch block
-			    e.printStackTrace();
-			}
-			mToast.show();
-		    }
-		}
-		ChangeStatus.this.finish();
-	    } else if (v == mClear) {
-		mStatusText.setText(null);
-	    }
-
-	}
-    };
-
 }
--- a/src/com/beem/project/beem/ui/ContactDialog.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java	Tue May 26 19:56:38 2009 +0200
@@ -19,10 +19,75 @@
 
 public class ContactDialog extends Dialog {
 
+    class aliasListener implements View.OnClickListener {
+
+	@Override
+	public void onClick(View v) {
+
+	    ContactDialogAliasDialog dialog = new ContactDialogAliasDialog(mContext, mContact);
+	    dialog.setOwnerActivity(ContactDialog.this.getOwnerActivity());
+	    dialog.initService();
+	    dialog.show();
+	}
+
+    }
+
+    class chatListener implements View.OnClickListener {
+
+	@Override
+	public void onClick(View v) {
+	    Activity a = ContactDialog.this.getOwnerActivity();
+	    Intent i = new Intent(mContext, SendIM.class);
+	    i.putExtra("contact", mContact);
+	    a.startActivity(i);
+	    dismiss();
+	}
+
+    }
+
+    class groupListener implements View.OnClickListener {
+
+	@Override
+	public void onClick(View v) {
+	    // TODO Auto-generated method stub
+	    dismiss();
+	}
+
+    }
+
+    class infosListener implements View.OnClickListener {
+
+	@Override
+	public void onClick(View v) {
+	    // TODO Auto-generated method stub
+	    dismiss();
+	}
+
+    }
+
+    class resendListener implements View.OnClickListener {
+
+	@Override
+	public void onClick(View v) {
+	    Presence presencePacket = new Presence(Presence.Type.subscribe);
+	    presencePacket.setTo(mContact.getJID());
+	    try {
+		mService.sendPresencePacket(new PresenceAdapter(presencePacket));
+	    } catch (RemoteException e) {
+		Log.e(TAG, "resend subscription error", e);
+	    }
+	    dismiss();
+	}
+
+    }
+
     public static final String TAG = "Option Dialog";
-    private Contact mContact;
-    private Context mContext;
-    private IXmppFacade mService;
+
+    private Contact            mContact;
+
+    private Context            mContext;
+
+    private IXmppFacade        mService;
 
     public ContactDialog(final Context context, Contact curContact) {
 	super(context);
@@ -48,66 +113,4 @@
 	mService = BeemApplication.getApplication(ContactDialog.this.getOwnerActivity()).getXmppFacade();
     }
 
-    class chatListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-	    Activity a = ContactDialog.this.getOwnerActivity();
-	    Intent i = new Intent(mContext, SendIM.class);
-	    i.putExtra("contact", mContact);
-	    a.startActivity(i);
-	    dismiss();
-	}
-
-    }
-
-    class aliasListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-
-	    ContactDialogAliasDialog dialog = new ContactDialogAliasDialog(mContext, mContact);
-	    dialog.setOwnerActivity(ContactDialog.this.getOwnerActivity());
-	    dialog.initService();
-	    dialog.show();
-	}
-
-    }
-
-    class groupListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-	    // TODO Auto-generated method stub
-	    dismiss();
-	}
-
-    }
-
-    class resendListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-	    Presence presencePacket = new Presence(Presence.Type.subscribe);
-	    presencePacket.setTo(mContact.getJID());
-	    try {
-		mService.sendPresencePacket(new PresenceAdapter(presencePacket));
-	    } catch (RemoteException e) {
-		Log.e(TAG, "resend subscription error", e);
-	    }
-	    dismiss();
-	}
-
-    }
-
-    class infosListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-	    // TODO Auto-generated method stub
-	    dismiss();
-	}
-
-    }
-
 }
--- a/src/com/beem/project/beem/ui/ContactDialogAliasDialog.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialogAliasDialog.java	Tue May 26 19:56:38 2009 +0200
@@ -21,8 +21,9 @@
  */
 public class ContactDialogAliasDialog extends Dialog {
 
-    private String mName;
-    private Contact mContact;
+    @SuppressWarnings("unused")
+    private String      mName;
+    private Contact     mContact;
     private IXmppFacade mService;
 
     public ContactDialogAliasDialog(Context context, Contact contact) {
@@ -35,6 +36,7 @@
 
 	Button ok = (Button) findViewById(R.id.CDAliasDialogOk);
 	ok.setOnClickListener(new View.OnClickListener() {
+
 	    @Override
 	    public void onClick(View v) {
 		EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
@@ -53,19 +55,4 @@
 	Activity a = ContactDialogAliasDialog.this.getOwnerActivity();
 	mService = BeemApplication.getApplication(a).getXmppFacade();
     }
-
-    /**
-     * @param mName the mName to set
-     */
-    private void setName(String mName) {
-	this.mName = mName;
-    }
-
-    /**
-     * @return the mName
-     */
-    private String getName() {
-	return mName;
-    }
-
 }
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Tue May 26 19:56:38 2009 +0200
@@ -7,10 +7,7 @@
 
 import org.jivesoftware.smack.util.StringUtils;
 
-import android.app.AlertDialog;
-import android.app.Dialog;
 import android.app.ExpandableListActivity;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.database.DataSetObserver;
@@ -31,7 +28,6 @@
 import android.widget.ExpandableListAdapter;
 import android.widget.ImageView;
 import android.widget.TextView;
-import android.widget.Toast;
 
 import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.R;
@@ -44,163 +40,213 @@
 
 public class ContactList extends ExpandableListActivity {
 
-    private static final String TAG = "CONTACTLIST_ACT";
-    private static final int PREFERENCECHANGED = 0;
-    private static final String DEFAULT_GROUP = "Default";
-    private IXmppFacade mService = null;
-    private MyExpandableListAdapter mAdapter;
-    private BeemApplication mBeemApplication;
-    private BeemRosterListener mRosterListener;
-    private SharedPreferences mSettings;
-    private IRoster mRoster;
-    private Map<String, List<Contact>> groupMap;
-    private List<String> groupName;
-    private List<Contact> mListContact;
-    private Handler mHandler;
+    private class BeemRosterListener extends IBeemRosterListener.Stub {
 
-    @Override
-    protected void onCreate(Bundle saveBundle) {
-	super.onCreate(saveBundle);
-	mHandler = new Handler();
-	mRosterListener = new BeemRosterListener();
-	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
-	mBeemApplication = BeemApplication.getApplication(this);
-	groupMap = new HashMap<String, List<Contact>>();
-	groupName = new ArrayList<String>();
-	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
-	    @Override
-	    public void run() {
-		mService = mBeemApplication.getXmppFacade();
-		try {
-		    mRoster = mService.getRoster();
-		} catch (RemoteException e1) {
-		    Log.e(TAG, "Get roster failed", e1);
+	@Override
+	public void onEntriesAdded(List<String> addresses) throws RemoteException {
+	    for (String str : addresses) {
+		Contact curContact = mRoster.getContact(str);
+		for (String group : curContact.getGroups()) {
+		    if (!groupMap.containsKey(group)) {
+			groupMap.put(group, new ArrayList<Contact>());
+			groupName.add(group);
+		    }
+		    try {
+			groupMap.get(group).add(curContact);
+		    } catch (NullPointerException e) {
+			Log.e(TAG, "Failed to find group in groupMap", e);
+		    }
 		}
-		if (mRoster != null) {
-		    try {
-			mRoster.addConnectionListener(mRosterListener);
-		    } catch (RemoteException e) {
-			e.printStackTrace();
+	    }
+	    mHandler.post(new Runnable() {
+
+		@Override
+		public void run() {
+		    mAdapter.changed();
+		}
+	    });
+	}
+
+	@Override
+	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
+	    for (List<Contact> cList : groupMap.values()) {
+		for (Contact curContact : cList) {
+		    for (String addr : addresses) {
+			if (addr.equals(curContact.getJID())) {
+			    cList.remove(curContact);
+			    if (cList.isEmpty()) {
+				groupMap.values().remove(cList);
+			    }
+			}
 		    }
 		}
-		callbackShowContactList();
 	    }
-	});
-    }
+	    mHandler.post(new Runnable() {
+
+		@Override
+		public void run() {
+		    mAdapter.changed();
+		}
+	    });
+	}
 
-    @Override
-    protected void onDestroy() {
-	mBeemApplication.unbindBeemService();
-	super.onDestroy();
-    }
+	@Override
+	public void onEntriesUpdated(List<String> addresses) throws RemoteException {
+	    for (String str : addresses) {
+		Contact curContact = mRoster.getContact(str);
+		for (String group : curContact.getGroups()) {
+		    if (!groupMap.containsKey(group)) {
+			groupMap.put(group, new ArrayList<Contact>());
+			groupName.add(group);
+			groupMap.get(group).add(curContact);
+		    } else {
+			boolean found = false;
+			for (Contact tempContact : groupMap.get(group)) {
+			    if (tempContact.getJID() == str) {
+				curContact = tempContact;
+				found = true;
+				break;
+			    }
+			}
+			if (!found) {
+			    groupMap.get(group).add(curContact);
+			}
+		    }
+		}
+	    }
+	    mHandler.post(new Runnable() {
 
-    private void callbackShowContactList() {
-	if (mRoster != null) {
-	    try {
-		buildContactList(mRoster.getContactList());
-	    } catch (RemoteException e) {
-		e.printStackTrace();
+		@Override
+		public void run() {
+		    mAdapter.changed();
+		}
+	    });
+	}
+
+	@Override
+	public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
+	    for (Contact curContact : mListContact) {
+		if (curContact.getJID().equals(StringUtils.parseBareAddress(presence.getFrom()))) {
+		    curContact.setStatus(presence);
+		    mHandler.post(new Runnable() {
+
+			@Override
+			public void run() {
+			    mAdapter.changed();
+			}
+		    });
+		    return;
+		}
 	    }
 	}
-    }
 
-    /**
-     * Callback for menu creation.
-     * @param menu the menu created
-     * @return true on success, false otherwise
-     */
-    @Override
-    public final boolean onCreateOptionsMenu(Menu menu) {
-	super.onCreateOptionsMenu(menu);
-	MenuInflater inflater = getMenuInflater();
-	inflater.inflate(R.menu.contactlistmenu, menu);
-	return true;
-    }
-
-    /**
-     * Callback for menu item selected.
-     * @param item the item selected
-     * @return true on success, false otherwise
-     */
-    @Override
-    public final boolean onOptionsItemSelected(MenuItem item) {
-	switch (item.getItemId()) {
-	    case R.id.account_edit:
-		startActivityForResult(new Intent(ContactList.this, ContactListSettings.class), PREFERENCECHANGED);
-		return true;
-	    case R.id.account_about:
-		Intent t = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.beem-project.com"));
-		startActivity(t);
-		return true;
-	    case R.id.account_create:
-		startActivity(new Intent(ContactList.this, AccountCreation.class));
-		return true;
-	    case R.id.add_contact:
-		startActivity(new Intent(ContactList.this, AddContact.class));
-		return true;
-	    default:
-		return false;
-	}
-    }
-
-    /*
-     * @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
-     * long id) { try { } catch (NullPointerException e) { Log.e(TAG, "Child not found", e); return false; } }
-     */
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-	if (requestCode == PREFERENCECHANGED) {
-	    if (resultCode == RESULT_OK) {
-		if (!groupMap.isEmpty())
-		    groupMap.clear();
-		mBeemApplication.stopBeemService();
-	    }
-	}
-    }
-
-    private void buildContactList(List<Contact> listContact) {
-	mListContact = listContact;
-	for (Contact contact : listContact) {
-	    for (String group : contact.getGroups()) {
-		if (!groupMap.containsKey(group)) {
-		    groupMap.put(group, new ArrayList<Contact>());
-		    groupName.add(group);
-		}
-		try {
-		    if (!groupMap.get(group).contains(contact))
-			groupMap.get(group).add(contact);
-		} catch (NullPointerException e) {
-		    Log.e(TAG, "Failed to find group in groupMap", e);
-		}
-	    }
-	    if (contact.getGroups().isEmpty()) {
-		if (!groupMap.containsKey(DEFAULT_GROUP)) {
-		    groupMap.put(DEFAULT_GROUP, new ArrayList<Contact>());
-		    groupName.add(DEFAULT_GROUP);
-		}
-		groupMap.get(DEFAULT_GROUP).add(contact);
-	    }
-	}
-	mAdapter = new MyExpandableListAdapter();
-	setListAdapter(mAdapter);
     }
 
     private class MyExpandableListAdapter implements ExpandableListAdapter {
 
+	class MyOnClickListener implements OnClickListener {
+
+	    private Contact mContact;
+
+	    public MyOnClickListener(Contact contact) {
+		mContact = contact;
+	    }
+
+	    @Override
+	    public void onClick(View v) {
+		Intent i = new Intent(ContactList.this, SendIM.class);
+		i.putExtra("contact", mContact);
+		startActivity(i);
+	    }
+
+	}
+
+	class MyOnLongClickListener implements OnLongClickListener {
+
+	    private Contact mContact;
+
+	    public MyOnLongClickListener(Contact contact) {
+		mContact = contact;
+	    }
+
+	    @Override
+	    public boolean onLongClick(View v) {
+		createDialog(mContact);
+		return true;
+	    }
+	}
+
 	private List<DataSetObserver> observers;
 
 	public MyExpandableListAdapter() {
 	    observers = new ArrayList<DataSetObserver>();
 	}
 
+	@Override
+	public boolean areAllItemsEnabled() {
+	    return true;
+	}
+
+	private void bindView(View view, Contact curContact) {
+
+	    if (curContact != null) {
+		ImageView imgV = (ImageView) view.findViewById(R.id.contactliststatus);
+		Drawable imageDrawable = null;
+		switch (curContact.getStatus()) {
+		case Status.CONTACT_STATUS_AVAILABLE:
+		    imageDrawable = getResources().getDrawable(R.drawable.online);
+		    break;
+		case Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+		    imageDrawable = getResources().getDrawable(R.drawable.chat);
+		    break;
+		case Status.CONTACT_STATUS_AWAY:
+		    imageDrawable = getResources().getDrawable(R.drawable.away);
+		    break;
+		case Status.CONTACT_STATUS_BUSY:
+		    imageDrawable = getResources().getDrawable(R.drawable.dnd);
+		    break;
+		case Status.CONTACT_STATUS_DISCONNECT:
+		    imageDrawable = getResources().getDrawable(R.drawable.offline);
+		    break;
+		case Status.CONTACT_STATUS_UNAVAILABLE:
+		    imageDrawable = getResources().getDrawable(R.drawable.requested);
+		    break;
+		default:
+		    imageDrawable = getResources().getDrawable(R.drawable.error);
+		    break;
+		}
+		imgV.setImageDrawable(imageDrawable);
+
+		TextView v = (TextView) view.findViewById(R.id.contactlistpseudo);
+		if (v != null) {
+		    v.setText(curContact.getName());
+		}
+
+		v = (TextView) view.findViewById(R.id.contactlistmsgperso);
+		if (v != null) {
+		    v.setText(curContact.getMsgState());
+		}
+
+		// TODO: Rajouter l'avatar du contact getAvatar() dans la classe
+		imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
+		if (imgV != null) {
+		    imageDrawable = getResources().getDrawable(R.drawable.avatar);
+		    imgV.setImageDrawable(imageDrawable);
+		}
+	    }
+	}
+
 	public void changed() {
 	    for (DataSetObserver obs : observers) {
 		obs.onChanged();
 	    }
 	}
 
-	@Override
-	public boolean areAllItemsEnabled() {
-	    return true;
+	void createDialog(Contact contact) {
+	    ContactDialog dialogContact = new ContactDialog(ContactList.this, contact);
+	    dialogContact.setOwnerActivity(ContactList.this);
+	    dialogContact.initService();
+	    dialogContact.show();
 	}
 
 	@Override
@@ -224,46 +270,19 @@
 	    return childPosition;
 	}
 
-	void createDialog(Contact contact) {
-	    ContactDialog dialogContact = new ContactDialog(ContactList.this, contact);
-	    dialogContact.setOwnerActivity(ContactList.this);
-	    dialogContact.initService();
-	    dialogContact.show();
-	}
-
-	class MyOnLongClickListener implements OnLongClickListener {
-	    private Contact mContact;
-
-	    public MyOnLongClickListener(Contact contact) {
-		mContact = contact;
+	@Override
+	public int getChildrenCount(int groupPosition) {
+	    try {
+		return groupMap.get(groupName.get(groupPosition)).size();
+	    } catch (NullPointerException e) {
+		Log.e(TAG, "Child not found", e);
+		return 0;
 	    }
-
-	    @Override
-	    public boolean onLongClick(View v) {
-		createDialog(mContact);
-		return true;
-	    }
-	}
-
-	class MyOnClickListener implements OnClickListener {
-	    private Contact mContact;
-
-	    public MyOnClickListener(Contact contact) {
-		mContact = contact;
-	    }
-
-	    @Override
-	    public void onClick(View v) {
-		Intent i = new Intent(ContactList.this, SendIM.class);
-		i.putExtra("contact", mContact);
-		startActivity(i);
-	    }
-
 	}
 
 	@Override
 	public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
-	    ViewGroup parent) {
+	        ViewGroup parent) {
 	    View v;
 	    if (convertView == null) {
 		v = LayoutInflater.from(ContactList.this).inflate(R.layout.contactlistcontact, null);
@@ -279,16 +298,6 @@
 	}
 
 	@Override
-	public int getChildrenCount(int groupPosition) {
-	    try {
-		return groupMap.get(groupName.get(groupPosition)).size();
-	    } catch (NullPointerException e) {
-		Log.e(TAG, "Child not found", e);
-		return 0;
-	    }
-	}
-
-	@Override
 	public long getCombinedChildId(long groupId, long childId) {
 	    return 1000 * groupId + childId;
 	}
@@ -360,152 +369,155 @@
 	public void unregisterDataSetObserver(DataSetObserver observer) {
 	    observers.remove(observer);
 	}
+    }
 
-	private void bindView(View view, Contact curContact) {
+    private static final String        TAG               = "CONTACTLIST_ACT";
+    private static final int           PREFERENCECHANGED = 0;
+    private static final String        DEFAULT_GROUP     = "Default";
+    private IXmppFacade                mService          = null;
+    private MyExpandableListAdapter    mAdapter;
+    private BeemApplication            mBeemApplication;
+    private BeemRosterListener         mRosterListener;
+    private IRoster                    mRoster;
+    private Map<String, List<Contact>> groupMap;
+    private List<String>               groupName;
+    private List<Contact>              mListContact;
+
+    private Handler                    mHandler;
+
+    @SuppressWarnings("unused")
+    private SharedPreferences          mSettings;
 
-	    if (curContact != null) {
-		ImageView imgV = (ImageView) view.findViewById(R.id.contactliststatus);
-		Drawable imageDrawable = null;
-		switch (curContact.getStatus()) {
-		    case Status.CONTACT_STATUS_AVAILABLE:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.online);
-			break;
-		    case Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.chat);
-			break;
-		    case Status.CONTACT_STATUS_AWAY:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.away);
-			break;
-		    case Status.CONTACT_STATUS_BUSY:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.dnd);
-			break;
-		    case Status.CONTACT_STATUS_DISCONNECT:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.offline);
-			break;
-		    case Status.CONTACT_STATUS_UNAVAILABLE:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.requested);
-			break;
-		    default:
-			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.error);
-			break;
+    private void buildContactList(List<Contact> listContact) {
+	mListContact = listContact;
+	for (Contact contact : listContact) {
+	    for (String group : contact.getGroups()) {
+		if (!groupMap.containsKey(group)) {
+		    groupMap.put(group, new ArrayList<Contact>());
+		    groupName.add(group);
+		}
+		try {
+		    if (!groupMap.get(group).contains(contact))
+			groupMap.get(group).add(contact);
+		} catch (NullPointerException e) {
+		    Log.e(TAG, "Failed to find group in groupMap", e);
+		}
+	    }
+	    if (contact.getGroups().isEmpty()) {
+		if (!groupMap.containsKey(DEFAULT_GROUP)) {
+		    groupMap.put(DEFAULT_GROUP, new ArrayList<Contact>());
+		    groupName.add(DEFAULT_GROUP);
 		}
-		imgV.setImageDrawable(imageDrawable);
-
-		TextView v = (TextView) view.findViewById(R.id.contactlistpseudo);
-		if (v != null) {
-		    v.setText(curContact.getName());
-		}
+		groupMap.get(DEFAULT_GROUP).add(contact);
+	    }
+	}
+	mAdapter = new MyExpandableListAdapter();
+	setListAdapter(mAdapter);
+    }
 
-		v = (TextView) view.findViewById(R.id.contactlistmsgperso);
-		if (v != null) {
-		    v.setText(curContact.getMsgState());
-		}
+    private void callbackShowContactList() {
+	if (mRoster != null) {
+	    try {
+		buildContactList(mRoster.getContactList());
+	    } catch (RemoteException e) {
+		e.printStackTrace();
+	    }
+	}
+    }
 
-		// TODO: Rajouter l'avatar du contact getAvatar() dans la classe
-		imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
-		if (imgV != null) {
-		    imageDrawable = (Drawable) getResources().getDrawable(R.drawable.avatar);
-		    imgV.setImageDrawable(imageDrawable);
-		}
+    /*
+     * @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
+     * int childPosition, long id) { try { } catch (NullPointerException e) { Log.e(TAG,
+     * "Child not found", e); return false; } }
+     */
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+	if (requestCode == PREFERENCECHANGED) {
+	    if (resultCode == RESULT_OK) {
+		if (!groupMap.isEmpty())
+		    groupMap.clear();
+		mBeemApplication.stopBeemService();
 	    }
 	}
     }
 
-    private class BeemRosterListener extends IBeemRosterListener.Stub {
+    @Override
+    protected void onCreate(Bundle saveBundle) {
+	super.onCreate(saveBundle);
+	mHandler = new Handler();
+	mRosterListener = new BeemRosterListener();
+	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	mBeemApplication = BeemApplication.getApplication(this);
+	groupMap = new HashMap<String, List<Contact>>();
+	groupName = new ArrayList<String>();
+	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
 
-	@Override
-	public void onEntriesAdded(List<String> addresses) throws RemoteException {
-	    for (String str : addresses) {
-		Contact curContact = mRoster.getContact(str);
-		for (String group : curContact.getGroups()) {
-		    if (!groupMap.containsKey(group)) {
-			groupMap.put(group, new ArrayList<Contact>());
-			groupName.add(group);
-		    }
-		    try {
-			groupMap.get(group).add(curContact);
-		    } catch (NullPointerException e) {
-			Log.e(TAG, "Failed to find group in groupMap", e);
-		    }
+	    @Override
+	    public void run() {
+		mService = mBeemApplication.getXmppFacade();
+		try {
+		    mRoster = mService.getRoster();
+		} catch (RemoteException e1) {
+		    Log.e(TAG, "Get roster failed", e1);
 		}
-	    }
-	    mHandler.post(new Runnable() {
-		@Override
-		public void run() {
-		    mAdapter.changed();
-		}
-	    });
-	}
-
-	@Override
-	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
-	    for (List<Contact> cList : groupMap.values()) {
-		for (Contact curContact : cList) {
-		    for (String addr : addresses) {
-			if (addr.equals(curContact.getJID())) {
-			    cList.remove(curContact);
-			    if (cList.isEmpty()) {
-				groupMap.values().remove(cList);
-			    }
-			}
+		if (mRoster != null) {
+		    try {
+			mRoster.addConnectionListener(mRosterListener);
+		    } catch (RemoteException e) {
+			e.printStackTrace();
 		    }
 		}
+		callbackShowContactList();
 	    }
-	    mHandler.post(new Runnable() {
-		@Override
-		public void run() {
-		    mAdapter.changed();
-		}
-	    });
-	}
+	});
+    }
+
+    /**
+     * Callback for menu creation.
+     * 
+     * @param menu
+     *            the menu created
+     * @return true on success, false otherwise
+     */
+    @Override
+    public final boolean onCreateOptionsMenu(Menu menu) {
+	super.onCreateOptionsMenu(menu);
+	MenuInflater inflater = getMenuInflater();
+	inflater.inflate(R.menu.contactlistmenu, menu);
+	return true;
+    }
+
+    @Override
+    protected void onDestroy() {
+	mBeemApplication.unbindBeemService();
+	super.onDestroy();
+    }
 
-	@Override
-	public void onEntriesUpdated(List<String> addresses) throws RemoteException {
-	    for (String str : addresses) {
-		Contact curContact = mRoster.getContact(str);
-		for (String group : curContact.getGroups()) {
-		    if (!groupMap.containsKey(group)) {
-			groupMap.put(group, new ArrayList<Contact>());
-			groupName.add(group);
-			groupMap.get(group).add(curContact);
-		    } else {
-			boolean found = false;
-			for (Contact tempContact : groupMap.get(group)) {
-			    if (tempContact.getJID() == str) {
-				curContact = tempContact;
-				found = true;
-				break;
-			    }
-			}
-			if (!found) {
-			    groupMap.get(group).add(curContact);
-			}
-		    }
-		}
-	    }
-	    mHandler.post(new Runnable() {
-		@Override
-		public void run() {
-		    mAdapter.changed();
-		}
-	    });
+    /**
+     * Callback for menu item selected.
+     * 
+     * @param item
+     *            the item selected
+     * @return true on success, false otherwise
+     */
+    @Override
+    public final boolean onOptionsItemSelected(MenuItem item) {
+	switch (item.getItemId()) {
+	case R.id.account_edit:
+	    startActivityForResult(new Intent(ContactList.this, ContactListSettings.class), PREFERENCECHANGED);
+	    return true;
+	case R.id.account_about:
+	    Intent t = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.beem-project.com"));
+	    startActivity(t);
+	    return true;
+	case R.id.account_create:
+	    startActivity(new Intent(ContactList.this, AccountCreation.class));
+	    return true;
+	case R.id.add_contact:
+	    startActivity(new Intent(ContactList.this, AddContact.class));
+	    return true;
+	default:
+	    return false;
 	}
-
-	@Override
-	public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
-	    for (Contact curContact : mListContact) {
-		if (curContact.getJID().equals(StringUtils.parseBareAddress(presence.getFrom()))) {
-		    curContact.setStatus(presence);
-		    mHandler.post(new Runnable() {
-			@Override
-			public void run() {
-			    mAdapter.changed();
-			}
-		    });
-		    return;
-		}
-	    }
-	}
-
     }
 }
--- a/src/com/beem/project/beem/ui/ContactListSettings.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactListSettings.java	Tue May 26 19:56:38 2009 +0200
@@ -18,10 +18,134 @@
 
 public class ContactListSettings extends Activity {
 
-    public static final int CHANGE = 1;
-    private boolean mIsChanged = false;
-    private SharedPreferences mSettings;
-    private String[] mProxyTypeString;
+    public static final int              CHANGE      = 1;
+    private boolean                      mIsChanged  = false;
+    private SharedPreferences            mSettings;
+    private String[]                     mProxyTypeString;
+
+    private final OnItemSelectedListener mProxyType  = new OnItemSelectedListener() {
+
+	                                                 @Override
+	                                                 public void onItemSelected(AdapterView<?> parent, View arg1,
+	                                                         int arg2, long arg3) {
+		                                             String value = parent.getSelectedItem().toString();
+		                                             LinearLayout ll = (LinearLayout) findViewById(R.id.proxy_layout);
+		                                             SharedPreferences.Editor editor = mSettings.edit();
+		                                             LayoutParams lp = (LayoutParams) ll.getLayoutParams();
+		                                             if (value
+		                                                     .equals(getString(R.string.PreferenceProxyTypeNone))) {
+		                                                 ll.setVisibility(View.INVISIBLE);
+		                                                 lp.height = 0;
+		                                                 ll.setLayoutParams(lp);
+		                                                 editor.putBoolean(
+		                                                         getString(R.string.PreferenceUseProxy), false);
+		                                             } else {
+		                                                 ll.setVisibility(View.VISIBLE);
+		                                                 lp.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+		                                                 ll.setLayoutParams(lp);
+		                                                 editor.putBoolean(
+		                                                         getString(R.string.PreferenceUseProxy), true);
+		                                             }
+		                                             if (!value
+		                                                     .equals(getPreferenceString(R.string.PreferenceProxyType))) {
+		                                                 editor
+		                                                         .putString(
+		                                                                 getString(R.string.PreferenceProxyType),
+		                                                                 value);
+		                                                 mIsChanged = true;
+		                                             }
+		                                             editor.commit();
+	                                                 }
+
+	                                                 @Override
+	                                                 public void onNothingSelected(AdapterView<?> arg0) {
+	                                                 }
+
+	                                             };
+
+    private final OnClickListener        mOkListener = new OnClickListener() {
+
+	                                                 public void onClick(View v) {
+		                                             SharedPreferences.Editor editor = mSettings.edit();
+
+		                                             if (isChanged(R.id.host, R.string.PreferenceHostKey)) {
+		                                                 editor.putString(
+		                                                         getString(R.string.PreferenceHostKey),
+		                                                         getWidgetText(R.id.host));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (Integer.parseInt(getWidgetText(R.id.port)) != mSettings
+		                                                     .getInt(getString(R.string.PreferencePortKey),
+		                                                             5222)) {
+		                                                 editor.putInt(getString(R.string.PreferencePortKey),
+		                                                         Integer.parseInt(getWidgetText(R.id.port)));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (isChanged(R.id.userid, R.string.PreferenceLoginKey)) {
+		                                                 editor.putString(
+		                                                         getString(R.string.PreferenceLoginKey),
+		                                                         getWidgetText(R.id.userid));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (isChanged(R.id.password,
+		                                                     R.string.PreferencePasswordKey)) {
+		                                                 editor.putString(
+		                                                         getString(R.string.PreferencePasswordKey),
+		                                                         getWidgetText(R.id.password));
+		                                                 mIsChanged = true;
+		                                             }
+
+		                                             if (isChanged(R.id.proxy_host,
+		                                                     R.string.PreferenceProxyHost)) {
+		                                                 editor.putString(
+		                                                         getString(R.string.PreferenceProxyHost),
+		                                                         getWidgetText(R.id.proxy_host));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (Integer.parseInt(getWidgetText(R.id.proxy_port)) != mSettings
+		                                                     .getInt(getString(R.string.PreferenceProxyPort), 0)) {
+		                                                 editor
+		                                                         .putInt(
+		                                                                 getString(R.string.PreferenceProxyPort),
+		                                                                 Integer
+		                                                                         .parseInt(getWidgetText(R.id.proxy_port)));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (isChanged(R.id.proxy_login,
+		                                                     R.string.PreferenceProxyUser)) {
+		                                                 editor.putString(
+		                                                         getString(R.string.PreferenceProxyUser),
+		                                                         getWidgetText(R.id.proxy_login));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (isChanged(R.id.proxy_pwd,
+		                                                     R.string.PreferenceProxyPassword)) {
+		                                                 editor.putString(
+		                                                         getString(R.string.PreferenceProxyPassword),
+		                                                         getWidgetText(R.id.proxy_pwd));
+		                                                 mIsChanged = true;
+		                                             }
+		                                             if (mIsChanged == true) {
+		                                                 editor.commit();
+		                                                 setResult(RESULT_OK);
+		                                             } else
+		                                                 setResult(RESULT_CANCELED);
+		                                             finish();
+	                                                 }
+	                                             };
+
+    private String getPreferenceString(int id) {
+	return mSettings.getString(getString(id), "");
+    }
+
+    private String getWidgetText(int id) {
+	EditText widget = (EditText) this.findViewById(id);
+	return widget.getText().toString();
+    }
+
+    private boolean isChanged(int idEdit, int idPreference) {
+	return (!getWidgetText(idEdit).equals(getPreferenceString(idPreference)));
+    }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -34,11 +158,11 @@
 	String TypeSocks5 = getString(R.string.PreferenceProxyTypeSocks5);
 
 	mProxyTypeString = new String[] { TypeNone, TypeHTTP, TypeSocks4, TypeSocks5 };
-	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
 
 	Spinner sp = (Spinner) findViewById(R.id.proxy_type);
 	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
-	    mProxyTypeString);
+	        mProxyTypeString);
 	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 	sp.setAdapter(adapter);
 	for (int i = 0; i < mProxyTypeString.length; ++i)
@@ -52,91 +176,6 @@
 	showSettings();
     }
 
-    private OnItemSelectedListener mProxyType = new OnItemSelectedListener() {
-
-	@Override
-	public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
-	    String value = parent.getSelectedItem().toString();
-	    LinearLayout ll = (LinearLayout) findViewById(R.id.proxy_layout);
-	    SharedPreferences.Editor editor = mSettings.edit();
-	    LayoutParams lp = (LayoutParams) ll.getLayoutParams();
-	    if (value.equals(getString(R.string.PreferenceProxyTypeNone))) {
-		ll.setVisibility(LinearLayout.INVISIBLE);
-		lp.height = 0;
-		ll.setLayoutParams(lp);
-		editor.putBoolean(getString(R.string.PreferenceUseProxy), false);
-	    } else {
-		ll.setVisibility(LinearLayout.VISIBLE);
-		lp.height = LayoutParams.WRAP_CONTENT;
-		ll.setLayoutParams(lp);
-		editor.putBoolean(getString(R.string.PreferenceUseProxy), true);
-	    }
-	    if (!value.equals(getPreferenceString(R.string.PreferenceProxyType))) {
-		editor.putString(getString(R.string.PreferenceProxyType), value);
-		mIsChanged = true;
-	    }
-	    editor.commit();
-	}
-
-	@Override
-	public void onNothingSelected(AdapterView<?> arg0) {
-	}
-
-    };
-
-    private OnClickListener mOkListener = new OnClickListener() {
-	public void onClick(View v) {
-	    SharedPreferences.Editor editor = mSettings.edit();
-
-	    if (isChanged(R.id.host, R.string.PreferenceHostKey)) {
-		editor.putString(getString(R.string.PreferenceHostKey), getWidgetText(R.id.host));
-		mIsChanged = true;
-	    }
-	    if (Integer.parseInt(getWidgetText(R.id.port)) != mSettings.getInt(getString(R.string.PreferencePortKey),
-		5222)) {
-		editor.putInt(getString(R.string.PreferencePortKey), Integer.parseInt(getWidgetText(R.id.port)));
-		mIsChanged = true;
-	    }
-	    if (isChanged(R.id.userid, R.string.PreferenceLoginKey)) {
-		editor.putString(getString(R.string.PreferenceLoginKey), getWidgetText(R.id.userid));
-		mIsChanged = true;
-	    }
-	    if (isChanged(R.id.password, R.string.PreferencePasswordKey)) {
-		editor.putString(getString(R.string.PreferencePasswordKey), getWidgetText(R.id.password));
-		mIsChanged = true;
-	    }
-
-	    if (isChanged(R.id.proxy_host, R.string.PreferenceProxyHost)) {
-		editor.putString(getString(R.string.PreferenceProxyHost), getWidgetText(R.id.proxy_host));
-		mIsChanged = true;
-	    }
-	    if (Integer.parseInt(getWidgetText(R.id.proxy_port)) != mSettings.getInt(
-		getString(R.string.PreferenceProxyPort), 0)) {
-		editor
-		    .putInt(getString(R.string.PreferenceProxyPort), Integer.parseInt(getWidgetText(R.id.proxy_port)));
-		mIsChanged = true;
-	    }
-	    if (isChanged(R.id.proxy_login, R.string.PreferenceProxyUser)) {
-		editor.putString(getString(R.string.PreferenceProxyUser), getWidgetText(R.id.proxy_login));
-		mIsChanged = true;
-	    }
-	    if (isChanged(R.id.proxy_pwd, R.string.PreferenceProxyPassword)) {
-		editor.putString(getString(R.string.PreferenceProxyPassword), getWidgetText(R.id.proxy_pwd));
-		mIsChanged = true;
-	    }
-	    if (mIsChanged == true) {
-		editor.commit();
-		setResult(RESULT_OK);
-	    } else
-		setResult(RESULT_CANCELED);
-	    finish();
-	}
-    };
-
-    private boolean isChanged(int idEdit, int idPreference) {
-	return (!getWidgetText(idEdit).equals(getPreferenceString(idPreference)));
-    }
-
     private void showSettings() {
 	EditText e = (EditText) findViewById(R.id.host);
 	e.setText(getPreferenceString(R.string.PreferenceHostKey));
@@ -157,13 +196,4 @@
 	e.setText(getPreferenceString(R.string.PreferenceProxyPassword));
     }
 
-    private String getWidgetText(int id) {
-	EditText widget = (EditText) this.findViewById(id);
-	return widget.getText().toString();
-    }
-
-    private String getPreferenceString(int id) {
-	return mSettings.getString(getString(id), "");
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/CreateAccount.java	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,244 @@
+package com.beem.project.beem.ui;
+
+import org.jivesoftware.smack.AccountManager;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.proxy.ProxyInfo;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.beem.project.beem.R;
+
+/**
+ * This class represents an activity which allows the user to create an account on the XMPP server
+ * saved in settings
+ * 
+ * @author dasilvj
+ */
+public class CreateAccount extends Activity {
+
+    private final static boolean DEFAULT_BOOLEAN_VALUE = false;
+    private final static String  DEFAULT_STRING_VALUE  = "";
+    private final static int     DEFAULT_INT_VALUE     = 0;
+
+    private final static String  DEFAULT_XMPP_PORT     = "5222";
+
+    private final static int     NOTIFICATION_DURATION = Toast.LENGTH_SHORT;
+
+    private SharedPreferences    settings              = null;
+    private Button               createAccountButton   = null;
+
+    /**
+     * Check if the fields password and confirm password match
+     * 
+     * @return return true if password & confirm password fields match, else false
+     */
+    private boolean checkPasswords() {
+	final String passwordFieldValue = ((EditText) findViewById(R.id.create_account_password)).getText().toString();
+	final String passwordConfirmFielddValue = ((EditText) findViewById(R.id.create_account_confirm_password))
+	        .getText().toString();
+
+	if (passwordFieldValue.equals(passwordConfirmFielddValue))
+	    return (true);
+	return (false);
+    }
+
+    /**
+     * Create an account on the XMPP server specified in settings
+     */
+    private void createAccount(String username, String password) {
+	XMPPConnection xmppConnection = null;
+	ConnectionConfiguration connectionConfiguration = null;
+
+	if (getRegisteredProxy() != null) {
+	    connectionConfiguration = new ConnectionConfiguration(getRegisteredXMPPServer(), getRegisteredXMPPPort(),
+		    getRegisteredProxy());
+	} else {
+	    connectionConfiguration = new ConnectionConfiguration(getRegisteredXMPPServer(), getRegisteredXMPPPort());
+	}
+	if (getRegisteredXMPPTLSUse())
+	    connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
+
+	xmppConnection = new XMPPConnection(connectionConfiguration);
+	try {
+	    xmppConnection.connect();
+	    AccountManager accountManager = new AccountManager(xmppConnection);
+	    accountManager.createAccount(username, password);
+	    Toast toast = Toast.makeText(getApplicationContext(), "Account " + username + " "
+		    + getString(R.string.create_account_successfull_after), NOTIFICATION_DURATION);
+	    toast.show();
+	} catch (XMPPException e) {
+	    Log.e(getString(R.string.create_account_tag), e.getMessage());
+	    createErrorDialog(e.getMessage());
+	}
+	xmppConnection.disconnect();
+    }
+
+    /**
+     * Create a dialog containing an error message
+     * 
+     * @param errMsg
+     *            the error message
+     */
+    private void createErrorDialog(String errMsg) {
+	Log.v(getString(R.string.create_account_tag), errMsg);
+	AlertDialog.Builder builder = new AlertDialog.Builder(this);
+	builder.setTitle(R.string.create_account_err_dialog_title).setMessage(errMsg).setCancelable(false);
+	builder.setNeutralButton(R.string.create_account_close_dialog_button, new DialogInterface.OnClickListener() {
+
+	    @Override
+	    public void onClick(DialogInterface dialog, int which) {
+		dialog.cancel();
+	    }
+	});
+	AlertDialog settingsErrDialog = builder.create();
+	settingsErrDialog.show();
+    }
+
+    /**
+     * Retrive proxy informations from the preferences
+     * 
+     * @return Registered proxy informations
+     */
+    private ProxyInfo getRegisteredProxy() {
+	if (getRegisteredProxyUse()) {
+	    ProxyInfo proxyInfo = new ProxyInfo(getRegisteredProxyType(), getRegisteredProxyServer(),
+		    getRegisteredProxyPort(), getRegisteredProxyUsername(), getRegisteredProxyPassword());
+	    return (proxyInfo);
+	}
+	return (null);
+    }
+
+    /**
+     * Retrieve proxy password from the preferences
+     * 
+     * @return Registered proxy password
+     */
+    private String getRegisteredProxyPassword() {
+	return (settings.getString(getString(R.string.settings_key_proxy_password), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve proxy port from the preferences
+     * 
+     * @return Registered proxy port
+     */
+    private int getRegisteredProxyPort() {
+	return (Integer.parseInt(settings.getString(getString(R.string.settings_key_proxy_port), DEFAULT_STRING_VALUE)));
+    }
+
+    /**
+     * Retrieve proxy server from the preferences
+     * 
+     * @return Registered proxy server
+     */
+    private String getRegisteredProxyServer() {
+	return (settings.getString(getString(R.string.settings_key_proxy_server), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve proxy type from the preferences
+     * 
+     * @return Registered proxy type
+     */
+    private ProxyInfo.ProxyType getRegisteredProxyType() {
+	switch (settings.getInt(getString(R.string.settings_key_proxy_type), DEFAULT_INT_VALUE)) {
+	case 0:
+	    return ProxyInfo.ProxyType.HTTP;
+	case 1:
+	    return ProxyInfo.ProxyType.SOCKS4;
+	case 2:
+	    Log.i(getString(R.string.create_account_tag), "SOCKS5 PROXY");
+	    return ProxyInfo.ProxyType.SOCKS5;
+	default:
+	    return ProxyInfo.ProxyType.NONE;
+	}
+    }
+
+    /**
+     * Retrieve proxy use from the preferences
+     * 
+     * @return Registered proxy use
+     */
+    private boolean getRegisteredProxyUse() {
+	return (settings.getBoolean(getString(R.string.settings_key_proxy_use), DEFAULT_BOOLEAN_VALUE));
+    }
+
+    /**
+     * Retrieve proxy username from the preferences
+     * 
+     * @return Registered proxy username
+     */
+    private String getRegisteredProxyUsername() {
+	return (settings.getString(getString(R.string.settings_key_proxy_username), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve xmpp port from the preferences
+     * 
+     * @return Registered xmpp port
+     */
+    private int getRegisteredXMPPPort() {
+	return (Integer.parseInt(settings.getString(getString(R.string.settings_key_xmpp_port), DEFAULT_XMPP_PORT)));
+    }
+
+    /**
+     * Retrieve xmpp server from the preferences
+     * 
+     * @return Registered xmpp server
+     */
+    private String getRegisteredXMPPServer() {
+	return (settings.getString(getString(R.string.settings_key_xmpp_server), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve TLS use from the preferences
+     * 
+     * @return Registered TLS use
+     */
+    private boolean getRegisteredXMPPTLSUse() {
+	return (settings.getBoolean(getString(R.string.settings_key_xmpp_tls_use), DEFAULT_BOOLEAN_VALUE));
+    }
+
+    /**
+     * Initialize the "Create this account" button which allows the user to create an account
+     */
+    private void initCreateAccountButton() {
+	createAccountButton = (Button) findViewById(R.id.create_account_button);
+	createAccountButton.setOnClickListener(new View.OnClickListener() {
+
+	    public void onClick(View v) {
+		String usernameFieldValue = ((EditText) findViewById(R.id.create_account_username)).getText()
+		        .toString();
+		String passwordFieldValue = ((EditText) findViewById(R.id.create_account_password)).getText()
+		        .toString();
+
+		if (!checkPasswords())
+		    createErrorDialog(getString(R.string.create_account_err_passwords));
+		else
+		    createAccount(usernameFieldValue, passwordFieldValue);
+	    }
+	});
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.create_account);
+	initCreateAccountButton();
+	settings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/EditSettings.java	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,492 @@
+package com.beem.project.beem.ui;
+
+import java.util.ArrayList;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.Spinner;
+import android.widget.TabHost;
+import android.widget.Toast;
+
+import com.beem.project.beem.R;
+
+/**
+ * This class represents an activity which allows the user to change his account or proxy parameters
+ * 
+ * @author dasilvj
+ */
+public class EditSettings extends Activity {
+
+    private final static String  LOG_MSG_SETTINGS_SAVED              = "Settings saved successfully.";
+    private final static String  LOG_MSG_XMPP_SETTINGS_REGISTERED    = "XMPP Settings has been registered.";
+    private final static String  LOG_MSG_ACCOUNT_SETTINGS_REGISTERED = "Account Settings has been registered.";
+    private final static String  LOG_MSG_PROXY_SETTINGS_REGISTERED   = "Proxy Settings has been registered.";
+
+    private final static boolean DEFAULT_BOOLEAN_VALUE               = false;
+    private final static String  DEFAULT_STRING_VALUE                = "";
+    private final static int     DEFAULT_INT_VALUE                   = 0;
+
+    private final static String  DEFAULT_XMPP_PORT                   = "5222";
+
+    private final static int     NOTIFICATION_DURATION               = Toast.LENGTH_SHORT;
+
+    private SharedPreferences    settings                            = null;
+
+    private EditText             accUsernameField                    = null;
+    private EditText             accPasswordField                    = null;
+
+    private EditText             xmppServerField                     = null;
+    private EditText             xmppPortField                       = null;
+    private CheckBox             xmppUseTLSCheckBox                  = null;
+
+    private CheckBox             proxyUseCheckBox                    = null;
+    private Spinner              proxyTypeSpinner                    = null;
+    private EditText             proxyServerField                    = null;
+    private EditText             proxyPortField                      = null;
+    private EditText             proxyUsernameField                  = null;
+    private EditText             proxyPasswordField                  = null;
+
+    /**
+     * Add a labeled "Account" tab on the tabbed window view passed by parameter
+     * 
+     * @param tHost
+     *            a tabbed window view
+     */
+    private void addAccountTab(TabHost tHost) {
+	TabHost.TabSpec accountTab = tHost.newTabSpec(getString(R.string.settings_tab_tag_account));
+	accountTab.setIndicator(getString(R.string.settings_tab_label_account));
+	accountTab.setContent(R.id.settings_account);
+	tHost.addTab(accountTab);
+    }
+
+    /**
+     * Add a labeled "Proxy" tab on the tabbed window view passed by parameter
+     * 
+     * @param tHost
+     *            a tabbed window view
+     */
+    private void addProxyTab(TabHost tHost) {
+	TabHost.TabSpec proxyTab = tHost.newTabSpec(getString(R.string.settings_tab_tag_proxy));
+	proxyTab.setIndicator(getString(R.string.settings_tab_label_proxy));
+	proxyTab.setContent(R.id.settings_proxy);
+	tHost.addTab(proxyTab);
+    }
+
+    /**
+     * Add a labeled "XMPP" tab on the tabbed window view passed by parameter
+     * 
+     * @param tHost
+     *            a tabbed window view
+     */
+    private void addXMPPTab(TabHost tHost) {
+	TabHost.TabSpec personalTab = tHost.newTabSpec(getString(R.string.settings_tab_tag_xmpp));
+	personalTab.setIndicator(getString(R.string.settings_tab_label_xmpp));
+	personalTab.setContent(R.id.settings_xmpp);
+	tHost.addTab(personalTab);
+    }
+
+    /**
+     * Disable proxy parameters fields
+     */
+    private void disableProxyParameters() {
+	proxyTypeSpinner.setEnabled(false);
+	proxyServerField.setEnabled(false);
+	proxyPortField.setEnabled(false);
+	proxyUsernameField.setEnabled(false);
+	proxyPasswordField.setEnabled(false);
+    }
+
+    private void displayNotification(CharSequence msg) {
+	Toast toast = Toast.makeText(getApplicationContext(), msg, NOTIFICATION_DURATION);
+	toast.show();
+    }
+
+    /**
+     * Enable proxy parameters fields
+     */
+    private void enableProxyParameters() {
+	proxyTypeSpinner.setEnabled(true);
+	proxyServerField.setEnabled(true);
+	proxyPortField.setEnabled(true);
+	proxyUsernameField.setEnabled(true);
+	proxyPasswordField.setEnabled(true);
+    }
+
+    /**
+     * Retrieve the value of a CheckBox
+     * 
+     * @param viewId
+     * @return true if the CheckBox is checked, else false
+     */
+    private boolean getCheckBoxValue(int viewId) {
+	final CheckBox checkBox = (CheckBox) findViewById(viewId);
+	if (checkBox.isChecked())
+	    return (true);
+	return (false);
+    }
+
+    /**
+     * Retrieve account password from the preferences
+     * 
+     * @return Registered account password
+     */
+    private String getRegisteredAccountPassword() {
+	return (settings.getString(getString(R.string.settings_key_account_password), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve account username from the preferences
+     * 
+     * @return Registered account username
+     */
+    private String getRegisteredAccountUsername() {
+	return (settings.getString(getString(R.string.settings_key_account_username), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve proxy password from the preferences
+     * 
+     * @return Registered proxy password
+     */
+    private String getRegisteredProxyPassword() {
+	return (settings.getString(getString(R.string.settings_key_proxy_password), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve proxy port from the preferences
+     * 
+     * @return Registered proxy port
+     */
+    private String getRegisteredProxyPort() {
+	return (settings.getString(getString(R.string.settings_key_proxy_port), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve proxy server from the preferences
+     * 
+     * @return Registered proxy server
+     */
+    private String getRegisteredProxyServer() {
+	return (settings.getString(getString(R.string.settings_key_proxy_server), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve proxy type from the preferences
+     * 
+     * @return Registered proxy type
+     */
+    private int getRegisteredProxyType() {
+	return (settings.getInt(getString(R.string.settings_key_proxy_type), DEFAULT_INT_VALUE));
+    }
+
+    /**
+     * Retrieve proxy use from the preferences
+     * 
+     * @return Registered proxy use
+     */
+    private boolean getRegisteredProxyUse() {
+	return (settings.getBoolean(getString(R.string.settings_key_proxy_use), DEFAULT_BOOLEAN_VALUE));
+    }
+
+    /**
+     * Retrieve proxy username from the preferences
+     * 
+     * @return Registered proxy username
+     */
+    private String getRegisteredProxyUsername() {
+	return (settings.getString(getString(R.string.settings_key_proxy_username), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve xmpp port from the preferences
+     * 
+     * @return Registered xmpp port
+     */
+    private String getRegisteredXMPPPort() {
+	return (settings.getString(getString(R.string.settings_key_xmpp_port), DEFAULT_XMPP_PORT));
+    }
+
+    /**
+     * Retrieve xmpp server from the preferences
+     * 
+     * @return Registered xmpp server
+     */
+    private String getRegisteredXMPPServer() {
+	return (settings.getString(getString(R.string.settings_key_xmpp_server), DEFAULT_STRING_VALUE));
+    }
+
+    /**
+     * Retrieve TLS use from the preferences
+     * 
+     * @return Registered TLS use
+     */
+    private boolean getRegisteredXMPPTLSUse() {
+	return (settings.getBoolean(getString(R.string.settings_key_xmpp_tls_use), DEFAULT_BOOLEAN_VALUE));
+    }
+
+    /**
+     * Initialize all of the components displayed in tabs (EditText fields, CheckBoxes, Spinners...)
+     */
+    private void initFields() {
+	accUsernameField = (EditText) findViewById(R.id.settings_account_username);
+	accPasswordField = (EditText) findViewById(R.id.settings_account_password);
+
+	xmppServerField = (EditText) findViewById(R.id.settings_xmpp_server);
+	xmppPortField = (EditText) findViewById(R.id.settings_xmpp_port);
+	xmppUseTLSCheckBox = (CheckBox) findViewById(R.id.settings_xmpp_use_tls);
+
+	proxyUseCheckBox = (CheckBox) findViewById(R.id.settings_proxy_use);
+	proxyTypeSpinner = (Spinner) findViewById(R.id.settings_proxy_type);
+	proxyServerField = (EditText) findViewById(R.id.settings_proxy_server);
+	proxyPortField = (EditText) findViewById(R.id.settings_proxy_port);
+	proxyUsernameField = (EditText) findViewById(R.id.settings_proxy_username);
+	proxyPasswordField = (EditText) findViewById(R.id.settings_proxy_password);
+    }
+
+    /**
+     * Initialize proxy's types spinner of the proxy tab
+     */
+    private void initProxyTypesSpinner() {
+	ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.proxy_types,
+	        android.R.layout.simple_spinner_item);
+	adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+	proxyTypeSpinner.setAdapter(adapter);
+    }
+
+    /**
+     * Initialize the checkbox allowing user to use a proxy
+     */
+    private void initProxyUseCheckBox() {
+	proxyUseCheckBox.setOnClickListener(new OnClickListener() {
+
+	    public void onClick(View v) {
+		if (proxyUseCheckBox.isChecked()) {
+		    enableProxyParameters();
+		} else {
+		    disableProxyParameters();
+		}
+	    }
+	});
+    }
+
+    /**
+     * Initialize "save" buttons allowing user to save settings
+     */
+    private void initSaveButtons() {
+	final ArrayList<Integer> views = new ArrayList<Integer>();
+	Button saveButton = null;
+
+	views.add(R.id.settings_account_button_save);
+	views.add(R.id.settings_proxy_button_save);
+	views.add(R.id.settings_xmpp_button_save);
+
+	for (int i = 0; i < views.size(); i++) {
+	    saveButton = (Button) findViewById(views.get(i));
+	    saveButton.setOnClickListener(new View.OnClickListener() {
+
+		public void onClick(View v) {
+		    saveSettings();
+		}
+	    });
+	}
+    }
+
+    /**
+     * Initialize tabbed window view by adding tabs and setting the default tab
+     */
+    private void initTabbedWindow() {
+	TabHost tHost = (TabHost) this.findViewById(R.id.settings_tab_host);
+	tHost.setup();
+	addAccountTab(tHost);
+	addXMPPTab(tHost);
+	addProxyTab(tHost);
+	tHost.setCurrentTab(0);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.edit_settings);
+	initTabbedWindow();
+	initFields();
+	settings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+	MenuInflater mInflater = getMenuInflater();
+	mInflater.inflate(R.menu.edit_settings, menu);
+	return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+	Intent i = null;
+	switch (item.getItemId()) {
+	case R.id.settings_menu_create_account:
+	    i = new Intent(this, CreateAccount.class);
+	    startActivity(i);
+	    return true;
+	case R.id.settings_menu_login:
+	    i = new Intent(this, Login.class);
+	    startActivity(i);
+	    return true;
+	}
+	return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onResume() {
+	super.onResume();
+	refreshAccountTabFields();
+	refreshXMPPTabFields();
+	refreshProxyTabFields();
+
+	if (!proxyUseCheckBox.isChecked())
+	    disableProxyParameters();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onStart() {
+	super.onStart();
+	initProxyTypesSpinner();
+	initProxyUseCheckBox();
+	initSaveButtons();
+    }
+
+    /**
+     * Refresh values of "Account" tab fields
+     */
+    private void refreshAccountTabFields() {
+	accUsernameField.setText(getRegisteredAccountUsername());
+	accPasswordField.setText(getRegisteredAccountPassword());
+    }
+
+    /**
+     * Refresh values of "Account" tab fields
+     */
+    private void refreshProxyTabFields() {
+	proxyUseCheckBox.setChecked(getRegisteredProxyUse());
+	proxyTypeSpinner.setSelection(getRegisteredProxyType());
+	proxyServerField.setText(getRegisteredProxyServer());
+	proxyPortField.setText(getRegisteredProxyPort());
+	proxyUsernameField.setText(getRegisteredProxyUsername());
+	proxyPasswordField.setText(getRegisteredProxyPassword());
+    }
+
+    /**
+     * Refresh values of "Account" tab fields
+     */
+    private void refreshXMPPTabFields() {
+	xmppServerField.setText(getRegisteredXMPPServer());
+	xmppPortField.setText(getRegisteredXMPPPort());
+	xmppUseTLSCheckBox.setChecked(getRegisteredXMPPTLSUse());
+    }
+
+    /**
+     * Register account settings changes in SharedPreferences.Editor object passed by parameter
+     * 
+     * @param settingsEditor
+     */
+    private void registerAccountSettingsChanges(SharedPreferences.Editor settingsEditor) {
+	final String usernameFieldValue = accUsernameField.getText().toString();
+	final String passwordFieldValue = accPasswordField.getText().toString();
+
+	if (getRegisteredAccountUsername().equals(usernameFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_account_username), usernameFieldValue);
+	if (getRegisteredAccountPassword().equals(passwordFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_account_password), passwordFieldValue);
+	Log.i(getString(R.string.edit_settings_tag), LOG_MSG_ACCOUNT_SETTINGS_REGISTERED);
+    }
+
+    /**
+     * Register proxy settings changes in SharedPreferences.Editor object passed by parameter
+     * 
+     * @param settingsEditor
+     */
+    private void registerProxySettingsChanges(SharedPreferences.Editor settingsEditor) {
+	final int proxyTypeFieldValue = proxyTypeSpinner.getSelectedItemPosition();
+	final String serverFieldValue = proxyServerField.getText().toString();
+	final String portFieldValue = proxyPortField.getText().toString();
+	final String usernameFieldValue = proxyUsernameField.getText().toString();
+	final String passwordFieldValue = proxyPasswordField.getText().toString();
+
+	if (getRegisteredProxyType() != proxyTypeFieldValue)
+	    settingsEditor.putInt(getString(R.string.settings_key_proxy_type), proxyTypeFieldValue);
+	if (getRegisteredProxyServer().equals(serverFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_proxy_server), serverFieldValue);
+	if (getRegisteredProxyPort().equals(portFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_proxy_port), portFieldValue);
+	if (getRegisteredProxyUsername().equals(usernameFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_proxy_username), usernameFieldValue);
+	if (getRegisteredProxyPassword().equals(passwordFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_proxy_password), passwordFieldValue);
+	Log.i(getString(R.string.edit_settings_tag), LOG_MSG_PROXY_SETTINGS_REGISTERED);
+    }
+
+    /**
+     * Register XMPP settings changes in SharedPreferences.Editor object passed by parameter
+     * 
+     * @param settingsEditor
+     */
+    private void registerXMPPSettingsChanges(SharedPreferences.Editor settingsEditor) {
+	final boolean tlsUseCheckBoxValue = getCheckBoxValue(R.id.settings_xmpp_use_tls);
+	final String serverFieldValue = xmppServerField.getText().toString();
+	final String portFieldValue = xmppPortField.getText().toString();
+
+	if (getRegisteredXMPPTLSUse() != tlsUseCheckBoxValue)
+	    settingsEditor.putBoolean(getString(R.string.settings_key_xmpp_tls_use), tlsUseCheckBoxValue);
+	if (getRegisteredXMPPServer().equals(serverFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_xmpp_server), serverFieldValue);
+	if (getRegisteredXMPPPort().equals(portFieldValue) == false)
+	    settingsEditor.putString(getString(R.string.settings_key_xmpp_port), portFieldValue);
+	Log.i(getString(R.string.edit_settings_tag), LOG_MSG_XMPP_SETTINGS_REGISTERED);
+    }
+
+    /**
+     * Save settings in shared preferences
+     */
+    private void saveSettings() {
+	final SharedPreferences.Editor settingsEditor = settings.edit();
+	final boolean proxyUseCheckBoxValue = getCheckBoxValue(R.id.settings_proxy_use);
+
+	if (getRegisteredProxyUse() != proxyUseCheckBoxValue)
+	    settingsEditor.putBoolean(getString(R.string.settings_key_proxy_use), proxyUseCheckBoxValue);
+	if (proxyUseCheckBoxValue)
+	    registerProxySettingsChanges(settingsEditor);
+	registerAccountSettingsChanges(settingsEditor);
+	registerXMPPSettingsChanges(settingsEditor);
+
+	if (settingsEditor.commit()) {
+	    displayNotification(getText(R.string.settings_saved_ok));
+	    Log.i(getString(R.string.edit_settings_tag), LOG_MSG_SETTINGS_SAVED);
+	}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/Login.java	Tue May 26 19:56:38 2009 +0200
@@ -0,0 +1,210 @@
+package com.beem.project.beem.ui;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.ProgressDialog;
+import android.content.ComponentName;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+
+import com.beem.project.beem.BeemApplication;
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.aidl.IBeemConnectionListener;
+import com.beem.project.beem.service.aidl.IXmppConnection;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+
+/**
+ * This class represents an activity which allows the user to connect to an XMPP server with his
+ * username/password
+ * 
+ * @author dasilvj
+ */
+public class Login extends Activity {
+
+    private class BeemConnectionListener extends IBeemConnectionListener.Stub {
+
+	private class ErrorRunnable implements Runnable {
+
+	    private final String mErrorMsg;
+
+	    public ErrorRunnable(String errorMsg) {
+		mErrorMsg = errorMsg;
+	    }
+
+	    @Override
+	    public void run() {
+		progressDialog.setMessage(mErrorMsg);
+	    }
+
+	}
+
+	@Override
+	public void connectionClosed() throws RemoteException {
+	    mIsConnected = false;
+	    beemApp.stopBeemService();
+	}
+
+	@Override
+	public void connectionClosedOnError() throws RemoteException {
+	    mIsConnected = false;
+	    beemApp.stopBeemService();
+	}
+
+	@Override
+	public void connectionFailed(String errorMsg) throws RemoteException {
+	    Log.d(getString(R.string.login_tag), "connectionFailed");
+	    connectionHandler.post(new ErrorRunnable(errorMsg));
+	    beemApp.stopBeemService();
+	    dismissProgressDialog();
+	}
+
+	private void dismissProgressDialog() {
+	    connectionHandler.post(new Runnable() {
+
+		@Override
+		public void run() {
+		    progressDialog.dismiss();
+		}
+	    });
+	}
+
+	@Override
+	public void onConnect() throws RemoteException {
+	    Log.d(getString(R.string.login_tag), "onConnect");
+	    mIsConnected = true;
+	    dismissProgressDialog();
+	    startActivity(new Intent(Login.this, ContactList.class));
+	}
+
+	@Override
+	public void reconnectingIn(int seconds) throws RemoteException {
+
+	}
+
+	@Override
+	public void reconnectionFailed() throws RemoteException {
+	    mIsConnected = false;
+	}
+
+	@Override
+	public void reconnectionSuccessful() throws RemoteException {
+	    mIsConnected = true;
+	}
+    }
+
+    protected static final String   TAG               = "LOG_AS";
+    private static final Intent     SERVICE_INTENT    = new Intent();
+    static {
+	SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+    }
+    private BeemApplication         beemApp           = null;
+    private IXmppConnection         xmppConnection    = null;
+    private IXmppFacade             xmppFacade        = null;
+    private final Handler           connectionHandler = new Handler();
+
+    private ProgressDialog          progressDialog    = null;
+
+    private boolean                 mIsConnected      = false;
+    private final ServiceConnection mServConn         = new ServiceConnection() {
+
+	                                                  @Override
+	                                                  public void onServiceConnected(ComponentName name,
+	                                                          IBinder service) {
+		                                              xmppFacade = IXmppFacade.Stub.asInterface(service);
+		                                              try {
+		                                                  xmppConnection = xmppFacade.createConnection();
+		                                                  xmppConnection
+		                                                          .addConnectionListener(new BeemConnectionListener());
+		                                              } catch (RemoteException e) {
+		                                                  e.printStackTrace();
+		                                              }
+	                                                  }
+
+	                                                  @Override
+	                                                  public void onServiceDisconnected(ComponentName name) {
+		                                              xmppFacade = null;
+		                                              mIsConnected = false;
+	                                                  }
+	                                              };
+
+    /**
+     * Create an about "BEEM" dialog
+     */
+    public void createAboutDialog() {
+	AlertDialog.Builder builder = new AlertDialog.Builder(this);
+	builder.setTitle(R.string.login_about_title).setMessage(R.string.login_about_msg).setCancelable(false);
+	builder.setNeutralButton(R.string.login_about_button, new DialogInterface.OnClickListener() {
+
+	    public void onClick(DialogInterface dialog, int whichButton) {
+		dialog.cancel();
+	    }
+	});
+	AlertDialog aboutDialog = builder.create();
+	aboutDialog.show();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.login);
+	progressDialog = new ProgressDialog(this);
+	progressDialog.setMessage("Loading. Please wait...");
+	beemApp = BeemApplication.getApplication(this);
+	this.bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+	if (!mIsConnected)
+	    progressDialog.show();
+	beemApp.startBeemService();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+	MenuInflater mInflater = getMenuInflater();
+	mInflater.inflate(R.menu.login, menu);
+	return true;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void onDestroy() {
+	super.onDestroy();
+	this.progressDialog.dismiss();
+	progressDialog = null;
+	this.unbindService(mServConn);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+	Intent i = null;
+
+	switch (item.getItemId()) {
+	case R.id.login_menu_settings:
+	    i = new Intent(this, EditSettings.class);
+	    startActivity(i);
+	    return true;
+	case R.id.login_menu_about:
+	    createAboutDialog();
+	    return true;
+	}
+	return false;
+    }
+}
--- a/src/com/beem/project/beem/ui/SendIM.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Tue May 26 19:56:38 2009 +0200
@@ -31,224 +31,11 @@
 
 /**
  * This activity class provides the view for instant messaging after selecting a correspondant.
+ * 
  * @author barbu
  */
 
 public class SendIM extends Activity implements OnClickListener, OnKeyListener {
-    private static final String TAG = "SEND_IM";
-    private EditText mToSend;
-    private SendIMDialogSmiley mSmyDialog;
-    private SharedPreferences mSet;
-    private BeemApplication mBeemApplication;
-    private Handler mHandler;
-    private IXmppFacade mService = null;
-    private Contact mContact;
-    private IChatManager mChatManager;
-    private IChatManagerListener mChatManagerListener;
-    private IMessageListener mMessageListener;
-    private IChat mChat;
-    private TextView mText;
-    private TextView mLogin;
-    private ScrollView mScrolling;
-    private boolean mSpeak;
-
-    /**
-     * Constructor.
-     */
-    public SendIM() {
-	super();
-    }
-
-    /**
-     * Overload of onCreate() Activity inherited function
-     */
-    @Override
-    public void onCreate(Bundle saveBundle) {
-	super.onCreate(saveBundle);
-	mHandler = new Handler();
-	mChatManagerListener = new OnChatListener();
-	mMessageListener = new OnMessageListener();
-	mBeemApplication = BeemApplication.getApplication(this);
-	setContentView(R.layout.sendim);
-	mToSend = (EditText) findViewById(R.id.userText);
-	mSet = getSharedPreferences("lol", MODE_PRIVATE);
-	mSmyDialog = new SendIMDialogSmiley(this, mSet);
-	mToSend.setOnClickListener(this);
-	mToSend.setOnKeyListener(this);
-	mLogin = (TextView) findViewById(R.id.sendimlogin);
-	mContact = getIntent().getParcelableExtra("contact");
-	setViewHeader();
-	mText = (TextView) findViewById(R.id.sendimlist);
-	mScrolling = (ScrollView) findViewById(R.id.sendimscroll);
-    }
-
-    private void setViewHeader() {
-	Drawable avatar = (Drawable) getResources().getDrawable(R.drawable.avatar);
-	ImageView imgV = (ImageView) findViewById(R.id.sendimavatar);
-	imgV.setImageDrawable(avatar);
-	mLogin = (TextView) findViewById(R.id.sendimlogin);
-	mLogin.setText(mContact.getJID());
-	TextView status = (TextView) findViewById(R.id.sendimstatus);
-	status.setTextSize(12);
-	mLogin.setTextColor(getResources().getColor(R.color.white));
-	String statmsg = mContact.getMsgState();
-	if (statmsg != null)
-	    status.setText(statmsg);;
-    }
-
-    @Override
-    public void onStart() {
-	super.onStart();
-	// TODO cancel the notification if any
-	if (mContact == null)
-	    mContact = getIntent().getParcelableExtra("contact");	
-	mService = mBeemApplication.getXmppFacade();
-	setViewHeader();
-
-    }
-
-
-    @Override
-    protected void onResume() {
-	super.onResume();
-	mBeemApplication = BeemApplication.getApplication(this);
-	if (!mBeemApplication.isConnected())
-	    mBeemApplication.startBeemService();
-	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
-
-	    @Override
-	    public void run() {
-		mService = mBeemApplication.getXmppFacade();
-		try {
-		    mChatManager = mService.getChatManager();
-		    mChatManager.addChatCreationListener(mChatManagerListener);
-		    mChat = mChatManager.createChat(mContact, mMessageListener);
-		    String text = mChat.getLastMessages();
-		    if (!"".equals(text)) {
-			mText.append(mContact.getJID() + " " + getString(R.string.SendIMSays));
-			mText.append(text);
-			//mChat.clearLastMessages();
-		    }
-		    mChat.setOpen(true);
-		} catch (RemoteException e) {
-		    Log.e(TAG, "Error during chat manager creation", e);
-		}
-	    }
-	});
-
-    }
-    @Override
-    protected void onPause() {
-	Log.d(TAG, "onPause");
-	try {
-	    mChat.setOpen(false);
-	} catch (RemoteException e) {
-	    Log.d(TAG, "mchat open false", e);
-	}
-	super.onPause();
-	finish();
-    }
-
-    @Override
-    protected void onStop() {
-	
-	Log.d(TAG, "onStop");
-	try {
-	    mChat.setOpen(false);
-	} catch (RemoteException e) {
-	    Log.d(TAG, "mchat open false", e);
-	}
-	mBeemApplication.unbindBeemService();
-	super.onStop();
-    }
-
-    @Override
-    protected void onDestroy() {
-	
-	if (mChatManager != null) {
-	    try {
-		mChatManager.removeChatCreationListener(mChatManagerListener);
-		mChatManager.destroyChat(mChat);
-	    } catch (RemoteException e) {
-		Log.e(TAG, "mchat manager and SendIM destroy", e);
-	    }
-	}
-	super.onDestroy();
-    }
-
-    /**
-     * Abstract method inherited from OnClickListener
-     */
-    public void onClick(View view) {
-	sendText();
-    }
-
-    /**
-     * This method send a message to the server over the XMPP connection and display it on activity view TODO :
-     * Exception si la connexion se coupe pendant la conversation
-     */
-    private void sendText() {
-	if (mSpeak)
-	    mSpeak = false;
-	String text = mToSend.getText().toString();
-	if (!text.equals("")) {
-	    Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
-	    msg.setBody(text);
-	    try {
-		mChat.sendMessage(msg);
-	    } catch (RemoteException e) {
-		// TODO Auto-generated catch block
-		e.printStackTrace();
-	    }
-	    if (!mSpeak)
-		mText.append(getString(R.string.SendIMYouSay) + text + "\n");
-	    else
-		mText.append(text + "\n");
-	    mToSend.setText(null);
-	    mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
-	    mToSend.requestFocus();
-	    mSpeak = true;
-	}
-    }
-
-    /**
-     * Abstract method inherited from OnKeyListener
-     */
-    public boolean onKey(View v, int keyCode, KeyEvent event) {
-	if (event.getAction() == KeyEvent.ACTION_DOWN) {
-	    switch (keyCode) {
-		case KeyEvent.KEYCODE_DPAD_CENTER:
-		case KeyEvent.KEYCODE_ENTER:
-		    sendText();
-		    return true;
-	    }
-	}
-	return false;
-    }
-
-    /**
-     * Callback for menu creation.
-     * @param The created menu
-     * @return true on success, false otherwise
-     */
-    @Override
-    public final boolean onCreateOptionsMenu(Menu menu) {
-	super.onCreateOptionsMenu(menu);
-	MenuInflater inflater = getMenuInflater();
-	inflater.inflate(R.menu.sendimmenu, menu);
-	return true;
-    }
-
-    @Override
-    public final boolean onOptionsItemSelected(MenuItem item) {
-	switch (item.getItemId()) {
-	    case R.id.sendim_smiley:
-		mSmyDialog.show();
-		return true;
-	    default:
-		return false;
-	}
-    }
 
     private class OnChatListener extends IChatManagerListener.Stub {
 
@@ -277,7 +64,7 @@
 			else
 			    mText.append(mContact.getJID() + " " + getString(R.string.SendIMSays) + m.getBody() + "\n");
 			mSpeak = false;
-			mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
+			mScrolling.fullScroll(View.FOCUS_DOWN);
 			mToSend.requestFocus();
 		    }
 		}
@@ -286,8 +73,228 @@
 
 	@Override
 	public void stateChanged(IChat chat) throws RemoteException {
-	    //TODO: a integrer dans l'ui
-	    //Log.d(TAG, "state changed");
+	    // TODO: a integrer dans l'ui
+	    // Log.d(TAG, "state changed");
 	}
     }
+
+    private static final String  TAG      = "SEND_IM";
+    private EditText             mToSend;
+    private SendIMDialogSmiley   mSmyDialog;
+    private SharedPreferences    mSet;
+    private BeemApplication      mBeemApplication;
+    private Handler              mHandler;
+    private IXmppFacade          mService = null;
+    private Contact              mContact;
+    private IChatManager         mChatManager;
+    private IChatManagerListener mChatManagerListener;
+    private IMessageListener     mMessageListener;
+    private IChat                mChat;
+    private TextView             mText;
+    private TextView             mLogin;
+
+    private ScrollView           mScrolling;
+
+    private boolean              mSpeak;
+
+    /**
+     * Constructor.
+     */
+    public SendIM() {
+	super();
+    }
+
+    /**
+     * Abstract method inherited from OnClickListener
+     */
+    public void onClick(View view) {
+	sendText();
+    }
+
+    /**
+     * Overload of onCreate() Activity inherited function
+     */
+    @Override
+    public void onCreate(Bundle saveBundle) {
+	super.onCreate(saveBundle);
+	mHandler = new Handler();
+	mChatManagerListener = new OnChatListener();
+	mMessageListener = new OnMessageListener();
+	mBeemApplication = BeemApplication.getApplication(this);
+	setContentView(R.layout.sendim);
+	mToSend = (EditText) findViewById(R.id.userText);
+	mSet = getSharedPreferences("lol", MODE_PRIVATE);
+	mSmyDialog = new SendIMDialogSmiley(this, mSet);
+	mToSend.setOnClickListener(this);
+	mToSend.setOnKeyListener(this);
+	mLogin = (TextView) findViewById(R.id.sendimlogin);
+	mContact = getIntent().getParcelableExtra("contact");
+	setViewHeader();
+	mText = (TextView) findViewById(R.id.sendimlist);
+	mScrolling = (ScrollView) findViewById(R.id.sendimscroll);
+    }
+
+    /**
+     * Callback for menu creation.
+     * 
+     * @param The
+     *            created menu
+     * @return true on success, false otherwise
+     */
+    @Override
+    public final boolean onCreateOptionsMenu(Menu menu) {
+	super.onCreateOptionsMenu(menu);
+	MenuInflater inflater = getMenuInflater();
+	inflater.inflate(R.menu.sendimmenu, menu);
+	return true;
+    }
+
+    @Override
+    protected void onDestroy() {
+
+	if (mChatManager != null) {
+	    try {
+		mChatManager.removeChatCreationListener(mChatManagerListener);
+		mChatManager.destroyChat(mChat);
+	    } catch (RemoteException e) {
+		Log.e(TAG, "mchat manager and SendIM destroy", e);
+	    }
+	}
+	super.onDestroy();
+    }
+
+    /**
+     * Abstract method inherited from OnKeyListener
+     */
+    public boolean onKey(View v, int keyCode, KeyEvent event) {
+	if (event.getAction() == KeyEvent.ACTION_DOWN) {
+	    switch (keyCode) {
+	    case KeyEvent.KEYCODE_DPAD_CENTER:
+	    case KeyEvent.KEYCODE_ENTER:
+		sendText();
+		return true;
+	    }
+	}
+	return false;
+    }
+
+    @Override
+    public final boolean onOptionsItemSelected(MenuItem item) {
+	switch (item.getItemId()) {
+	case R.id.sendim_smiley:
+	    mSmyDialog.show();
+	    return true;
+	default:
+	    return false;
+	}
+    }
+
+    @Override
+    protected void onPause() {
+	Log.d(TAG, "onPause");
+	try {
+	    mChat.setOpen(false);
+	} catch (RemoteException e) {
+	    Log.d(TAG, "mchat open false", e);
+	}
+	super.onPause();
+	finish();
+    }
+
+    @Override
+    protected void onResume() {
+	super.onResume();
+	mBeemApplication = BeemApplication.getApplication(this);
+	if (!mBeemApplication.isConnected())
+	    mBeemApplication.startBeemService();
+	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
+
+	    @Override
+	    public void run() {
+		mService = mBeemApplication.getXmppFacade();
+		try {
+		    mChatManager = mService.getChatManager();
+		    mChatManager.addChatCreationListener(mChatManagerListener);
+		    mChat = mChatManager.createChat(mContact, mMessageListener);
+		    String text = mChat.getLastMessages();
+		    if (!"".equals(text)) {
+			mText.append(mContact.getJID() + " " + getString(R.string.SendIMSays));
+			mText.append(text);
+			// mChat.clearLastMessages();
+		    }
+		    mChat.setOpen(true);
+		} catch (RemoteException e) {
+		    Log.e(TAG, "Error during chat manager creation", e);
+		}
+	    }
+	});
+
+    }
+
+    @Override
+    public void onStart() {
+	super.onStart();
+	// TODO cancel the notification if any
+	if (mContact == null)
+	    mContact = getIntent().getParcelableExtra("contact");
+	mService = mBeemApplication.getXmppFacade();
+	setViewHeader();
+
+    }
+
+    @Override
+    protected void onStop() {
+
+	Log.d(TAG, "onStop");
+	try {
+	    mChat.setOpen(false);
+	} catch (RemoteException e) {
+	    Log.d(TAG, "mchat open false", e);
+	}
+	mBeemApplication.unbindBeemService();
+	super.onStop();
+    }
+
+    /**
+     * This method send a message to the server over the XMPP connection and display it on activity
+     * view TODO : Exception si la connexion se coupe pendant la conversation
+     */
+    private void sendText() {
+	if (mSpeak)
+	    mSpeak = false;
+	String text = mToSend.getText().toString();
+	if (!text.equals("")) {
+	    Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT);
+	    msg.setBody(text);
+	    try {
+		mChat.sendMessage(msg);
+	    } catch (RemoteException e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	    }
+	    if (!mSpeak)
+		mText.append(getString(R.string.SendIMYouSay) + text + "\n");
+	    else
+		mText.append(text + "\n");
+	    mToSend.setText(null);
+	    mScrolling.fullScroll(View.FOCUS_DOWN);
+	    mToSend.requestFocus();
+	    mSpeak = true;
+	}
+    }
+
+    private void setViewHeader() {
+	Drawable avatar = getResources().getDrawable(R.drawable.avatar);
+	ImageView imgV = (ImageView) findViewById(R.id.sendimavatar);
+	imgV.setImageDrawable(avatar);
+	mLogin = (TextView) findViewById(R.id.sendimlogin);
+	mLogin.setText(mContact.getJID());
+	TextView status = (TextView) findViewById(R.id.sendimstatus);
+	status.setTextSize(12);
+	mLogin.setTextColor(getResources().getColor(R.color.white));
+	String statmsg = mContact.getMsgState();
+	if (statmsg != null)
+	    status.setText(statmsg);
+	;
+    }
 }
--- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java	Tue May 26 19:56:38 2009 +0200
@@ -1,12 +1,15 @@
 package com.beem.project.beem.ui;
 
-import com.beem.project.beem.R;
-
 import android.app.Dialog;
 import android.content.SharedPreferences;
 
+import com.beem.project.beem.R;
+
 public class SendIMDialogSmiley extends Dialog {
-    private SendIM mSendIM;
+
+    @SuppressWarnings("unused")
+    private SendIM            mSendIM;
+    @SuppressWarnings("unused")
     private SharedPreferences mSet;
 
     public SendIMDialogSmiley(SendIM sendim, SharedPreferences settings) {
--- a/src/com/beem/project/beem/ui/Subscription.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/ui/Subscription.java	Tue May 26 19:56:38 2009 +0200
@@ -6,11 +6,6 @@
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.packet.Presence.Type;
 
-import com.beem.project.beem.BeemApplication;
-import com.beem.project.beem.R;
-import com.beem.project.beem.service.PresenceAdapter;
-import com.beem.project.beem.service.aidl.IXmppFacade;
-
 import android.app.Activity;
 import android.os.Bundle;
 import android.os.RemoteException;
@@ -18,14 +13,58 @@
 import android.view.View.OnClickListener;
 import android.widget.Toast;
 
+import com.beem.project.beem.BeemApplication;
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.aidl.IXmppFacade;
+
 /**
  * @author nikita
- *
  */
 public class Subscription extends Activity {
 
-    private IXmppFacade mService;
-    private String mContact;
+    private IXmppFacade     mService;
+    private String          mContact;
+
+    private OnClickListener mClickListener = new OnClickListener() {
+
+	                                       @Override
+	                                       public void onClick(View v) {
+		                                   switch (v.getId()) {
+		                                   case R.id.SubscriptionAccept:
+		                                       Presence presence = new Presence(Type.subscribed);
+		                                       presence.setTo(mContact);
+		                                       PresenceAdapter preAdapt = new PresenceAdapter(presence);
+		                                       try {
+			                                   mService.sendPresencePacket(preAdapt);
+			                                   Toast.makeText(Subscription.this,
+			                                           getString(R.string.SubscriptAccept),
+			                                           Toast.LENGTH_SHORT).show();
+			                                   finish();
+		                                       } catch (RemoteException e) {
+			                                   Toast.makeText(Subscription.this,
+			                                           getString(R.string.SubscriptError),
+			                                           Toast.LENGTH_SHORT).show();
+			                                   e.printStackTrace();
+		                                       }
+		                                       break;
+		                                   case R.id.SubscriptionRefuse:
+		                                       Toast
+		                                               .makeText(Subscription.this,
+		                                                       getString(R.string.SubscriptRefused),
+		                                                       Toast.LENGTH_SHORT).show();
+
+		                                       break;
+		                                   default:
+		                                       Toast.makeText(Subscription.this,
+		                                               getString(R.string.SubscriptError), Toast.LENGTH_SHORT)
+		                                               .show();
+		                                   }
+		                                   ;
+
+	                                       }
+
+	                                   };
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -36,38 +75,4 @@
 	mContact = getIntent().getStringExtra("from");
 	mService = BeemApplication.getApplication(this).getXmppFacade();
     }
-
-    private OnClickListener mClickListener = new OnClickListener() {
-
-	@Override
-	public void onClick(View v) {
-	    switch (v.getId()) {
-		case R.id.SubscriptionAccept:
-		    Presence presence = new Presence(Type.subscribed);
-		    presence.setTo(mContact);
-		    PresenceAdapter preAdapt = new PresenceAdapter(presence);
-		    try {
-			mService.sendPresencePacket(preAdapt);
-			Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept),
-			    Toast.LENGTH_SHORT).show();
-			finish();
-		    } catch (RemoteException e) {
-			Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
-			    Toast.LENGTH_SHORT).show();
-			e.printStackTrace();
-		    }
-		    break ;
-		case R.id.SubscriptionRefuse:
-		    Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused),
-			Toast.LENGTH_SHORT).show();
-
-		    break ;
-		default:
-		    Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
-			Toast.LENGTH_SHORT).show();
-	    };
-
-	}
-
-    };
 }
--- a/src/com/beem/project/beem/utils/PresenceType.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/utils/PresenceType.java	Tue May 26 19:56:38 2009 +0200
@@ -7,35 +7,34 @@
 
 /**
  * @author nikita
- *
  */
 public class PresenceType {
 
     /**
      * The user is available to receive messages (default).
      */
-    public static final int AVAILABLE = 100;
+    public static final int AVAILABLE    = 100;
 
     /**
      * The user is unavailable to receive messages.
      */
-    public static final int UNAVAILABLE = 200;
+    public static final int UNAVAILABLE  = 200;
 
     /**
      * Request subscription to recipient's presence.
      */
 
-    public static final int SUBSCRIBE = 300;
+    public static final int SUBSCRIBE    = 300;
 
     /**
      * Grant subscription to sender's presence.
      */
-    public static final int SUBSCRIBED = 400;
+    public static final int SUBSCRIBED   = 400;
 
     /**
      * Request removal of subscription to sender's presence.
      */
-    public static final int UNSUBSCRIBE = 500;
+    public static final int UNSUBSCRIBE  = 500;
 
     /**
      * Grant removal of subscription to sender's presence.
@@ -45,72 +44,76 @@
     /**
      * The presence packet contains an error message.
      */
-    public static final int ERROR = 701;
+    public static final int ERROR        = 701;
 
     /**
      * Get the presence type from a presence packet.
-     * @param presence the presence type
+     * 
+     * @param presence
+     *            the presence type
      */
     public static int getPresenceType(Presence presence) {
 	int res = PresenceType.ERROR;
 	switch (presence.getType()) {
-	    case available:
-		res = PresenceType.AVAILABLE;
-		break;
-	    case unavailable:
-		res = PresenceType.UNAVAILABLE;
-		break;
-	    case subscribe:
-		res = PresenceType.SUBSCRIBE;
-		break;
-	    case subscribed:
-		res = PresenceType.SUBSCRIBED;
-		break;
-	    case unsubscribe:
-		res = PresenceType.UNSUBSCRIBE;
-		break;
-	    case unsubscribed:
-		res = PresenceType.UNSUBSCRIBED;
-		break;
-	    case error:
-	    default:
-		res = PresenceType.ERROR;
-	};
+	case available:
+	    res = PresenceType.AVAILABLE;
+	    break;
+	case unavailable:
+	    res = PresenceType.UNAVAILABLE;
+	    break;
+	case subscribe:
+	    res = PresenceType.SUBSCRIBE;
+	    break;
+	case subscribed:
+	    res = PresenceType.SUBSCRIBED;
+	    break;
+	case unsubscribe:
+	    res = PresenceType.UNSUBSCRIBE;
+	    break;
+	case unsubscribed:
+	    res = PresenceType.UNSUBSCRIBED;
+	    break;
+	case error:
+	default:
+	    res = PresenceType.ERROR;
+	}
+	;
 	return res;
     }
-    
+
     /**
      * Get the smack presence mode for a status
-     * @param status the status in beem
-     * @return the presence mode to use in presence packet
-     * 		or null if there is no mode to use
+     * 
+     * @param status
+     *            the status in beem
+     * @return the presence mode to use in presence packet or null if there is no mode to use
      */
-    public static Presence.Type getPresenceTypeFrom(int type){
+    public static Presence.Type getPresenceTypeFrom(int type) {
 	Presence.Type res;
 	switch (type) {
-	    case AVAILABLE:
-		res = Presence.Type.available;
-		break;
-	    case UNAVAILABLE:
-		res = Presence.Type.unavailable;		
-		break;
-	    case SUBSCRIBE:
-		res = Presence.Type.subscribe;
-		break;
-	    case SUBSCRIBED:
-		res = Presence.Type.subscribed;
-		break;
-	    case UNSUBSCRIBE:
-		res = Presence.Type.unsubscribe;
-		break;
-	    case UNSUBSCRIBED:
-		res = Presence.Type.unsubscribed;
-		break;
-	    case ERROR:
-		res = Presence.Type.error;
-		break;
-	    default:
-		return null;
+	case AVAILABLE:
+	    res = Presence.Type.available;
+	    break;
+	case UNAVAILABLE:
+	    res = Presence.Type.unavailable;
+	    break;
+	case SUBSCRIBE:
+	    res = Presence.Type.subscribe;
+	    break;
+	case SUBSCRIBED:
+	    res = Presence.Type.subscribed;
+	    break;
+	case UNSUBSCRIBE:
+	    res = Presence.Type.unsubscribe;
+	    break;
+	case UNSUBSCRIBED:
+	    res = Presence.Type.unsubscribed;
+	    break;
+	case ERROR:
+	    res = Presence.Type.error;
+	    break;
+	default:
+	    return null;
 	}
 	return res;
     }
--- a/src/com/beem/project/beem/utils/Status.java	Fri May 22 19:17:50 2009 +0200
+++ b/src/com/beem/project/beem/utils/Status.java	Tue May 26 19:56:38 2009 +0200
@@ -14,27 +14,27 @@
     /**
      * Status of a disconnected contact.
      */
-    public static final int CONTACT_STATUS_DISCONNECT = 100;
+    public static final int CONTACT_STATUS_DISCONNECT         = 100;
 
     /**
      * Status of a unavailable (long away) contact.
      */
-    public static final int CONTACT_STATUS_UNAVAILABLE = 200;
+    public static final int CONTACT_STATUS_UNAVAILABLE        = 200;
 
     /**
      * Status of a away contact.
      */
-    public static final int CONTACT_STATUS_AWAY = 300;
+    public static final int CONTACT_STATUS_AWAY               = 300;
 
     /**
      * Status of a busy contact.
      */
-    public static final int CONTACT_STATUS_BUSY = 400;
+    public static final int CONTACT_STATUS_BUSY               = 400;
 
     /**
      * Status of a available contact.
      */
-    public static final int CONTACT_STATUS_AVAILABLE = 500;
+    public static final int CONTACT_STATUS_AVAILABLE          = 500;
 
     /**
      * Status of a available for chat contact.
@@ -42,8 +42,41 @@
     public static final int CONTACT_STATUS_AVAILABLE_FOR_CHAT = 600;
 
     /**
+     * Get the smack presence mode for a status
+     * 
+     * @param status
+     *            the status in beem
+     * @return the presence mode to use in presence packet or null if there is no mode to use
+     */
+    public static Presence.Mode getPresenceModeFromStatus(int status) {
+	Presence.Mode res;
+	switch (status) {
+	case CONTACT_STATUS_AVAILABLE:
+	    res = Presence.Mode.available;
+	    break;
+	case CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+	    res = Presence.Mode.chat;
+	    break;
+	case CONTACT_STATUS_AWAY:
+	    res = Presence.Mode.away;
+	    break;
+	case CONTACT_STATUS_BUSY:
+	    res = Presence.Mode.dnd;
+	    break;
+	case CONTACT_STATUS_UNAVAILABLE:
+	    res = Presence.Mode.xa;
+	    break;
+	default:
+	    return null;
+	}
+	return res;
+    }
+
+    /**
      * Get the status of from a presence packet.
-     * @param presence the presence containing status
+     * 
+     * @param presence
+     *            the presence containing status
      */
     public static int getStatusFromPresence(Presence presence) {
 	int res = Status.CONTACT_STATUS_DISCONNECT;
@@ -55,58 +88,28 @@
 		res = Status.CONTACT_STATUS_AVAILABLE;
 	    } else {
 		switch (mode) {
-		    case available:
-			res = Status.CONTACT_STATUS_AVAILABLE;
-			break;
-		    case away:
-			res = Status.CONTACT_STATUS_AWAY;
-			break;
-		    case chat:
-			res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
-			break;
-		    case dnd:
-			res = Status.CONTACT_STATUS_BUSY;
-			break;
-		    case xa:
-			res = Status.CONTACT_STATUS_UNAVAILABLE;
-			break;
-		    default:
-			res = Status.CONTACT_STATUS_DISCONNECT;
-			break;
+		case available:
+		    res = Status.CONTACT_STATUS_AVAILABLE;
+		    break;
+		case away:
+		    res = Status.CONTACT_STATUS_AWAY;
+		    break;
+		case chat:
+		    res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
+		    break;
+		case dnd:
+		    res = Status.CONTACT_STATUS_BUSY;
+		    break;
+		case xa:
+		    res = Status.CONTACT_STATUS_UNAVAILABLE;
+		    break;
+		default:
+		    res = Status.CONTACT_STATUS_DISCONNECT;
+		    break;
 		}
 	    }
 	}
 	return res;
     }
-    
-    /**
-     * Get the smack presence mode for a status
-     * @param status the status in beem
-     * @return the presence mode to use in presence packet
-     * 		or null if there is no mode to use
-     */
-    public static Presence.Mode getPresenceModeFromStatus(int status){
-	Presence.Mode res;
-	switch (status) {
-	    case CONTACT_STATUS_AVAILABLE:
-		res = Presence.Mode.available;
-		break;
-	    case CONTACT_STATUS_AVAILABLE_FOR_CHAT:
-		res = Presence.Mode.chat;		
-		break;
-	    case CONTACT_STATUS_AWAY:
-		res = Presence.Mode.away;
-		break;
-	    case CONTACT_STATUS_BUSY:
-		res = Presence.Mode.dnd;
-		break;
-	    case CONTACT_STATUS_UNAVAILABLE:
-		res = Presence.Mode.xa;
-		break;
-	    default:
-		return null;
-	}
-	return res;
-    }
-    
+
 }