Merge branch 'develop' into operations_service
authormasensio <masensio@solidgear.es>
Tue, 1 Apr 2014 12:18:32 +0000 (14:18 +0200)
committermasensio <masensio@solidgear.es>
Tue, 1 Apr 2014 12:18:32 +0000 (14:18 +0200)
res/values/strings.xml
src/com/owncloud/android/authentication/AuthenticatorActivity.java
src/com/owncloud/android/operations/DetectAuthenticationMethodOperation.java
src/com/owncloud/android/services/OperationsService.java
src/com/owncloud/android/ui/activity/FileActivity.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

index a73f906..65c0dbc 100644 (file)
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 
-    <string name="about_android">%1$s Android App</string>
-    <string name="about_version">version %1$s</string>
-    <string name="actionbar_sync">Refresh account</string>
-    <string name="actionbar_upload">Upload</string>
-    <string name="actionbar_upload_from_apps">Content from other apps</string>
-    <string name="actionbar_upload_files">Files</string>
-    <string name="actionbar_open_with">Open with</string>
-    <string name="actionbar_mkdir">Create directory</string>
-    <string name="actionbar_settings">Settings</string>
-    <string name="actionbar_see_details">Details</string>
-    <string name="actionbar_send_file">Send</string>
-    <string name="prefs_category_general">General</string>
-    <string name="prefs_category_more">More</string>
-    <string name="prefs_accounts">Accounts</string>
-    <string name="prefs_manage_accounts">Manage Accounts</string>
-    <string name="prefs_pincode">App PIN</string>
-    <string name="prefs_pincode_summary">Protect your client</string>
-    <string name="prefs_instant_upload">Enable instant uploads</string>
-    <string name="prefs_instant_upload_summary">Instantly upload photos taken by camera</string>
-    <string name="prefs_log_title">Enable Logging</string>
-    <string name="prefs_log_summary">This is used to log problems</string>
-    <string name="prefs_log_title_history">Logging History</string>
-    <string name="prefs_log_summary_history">This shows the recorded logs</string>
-    <string name="prefs_log_delete_history_button">Delete History</string>
-    <string name="prefs_help">Help</string>
-    <string name="prefs_recommend">Recommend to a friend</string>
-    <string name="prefs_feedback">Feedback</string>
-    <string name="prefs_imprint">Imprint</string>
-    
+       <string name="about_android">%1$s Android App</string>
+       <string name="about_version">version %1$s</string>
+       <string name="actionbar_sync">Refresh account</string>
+       <string name="actionbar_upload">Upload</string>
+       <string name="actionbar_upload_from_apps">Content from other apps</string>
+       <string name="actionbar_upload_files">Files</string>
+       <string name="actionbar_open_with">Open with</string>
+       <string name="actionbar_mkdir">Create directory</string>
+       <string name="actionbar_settings">Settings</string>
+       <string name="actionbar_see_details">Details</string>
+       <string name="actionbar_send_file">Send</string>
+       <string name="prefs_category_general">General</string>
+       <string name="prefs_category_more">More</string>
+       <string name="prefs_accounts">Accounts</string>
+       <string name="prefs_manage_accounts">Manage Accounts</string>
+       <string name="prefs_pincode">App PIN</string>
+       <string name="prefs_pincode_summary">Protect your client</string>
+       <string name="prefs_instant_upload">Enable instant uploads</string>
+       <string name="prefs_instant_upload_summary">Instantly upload photos taken by camera</string>
+       <string name="prefs_log_title">Enable Logging</string>
+       <string name="prefs_log_summary">This is used to log problems</string>
+       <string name="prefs_log_summary_history">This shows the recorded logs</string>
+       <string name="prefs_log_delete_history_button">Delete History</string>
+       <string name="prefs_help">Help</string>
+       <string name="prefs_recommend">Recommend to a friend</string>
+       <string name="prefs_feedback">Feedback</string>
+       <string name="prefs_imprint">Imprint</string>
+
        <string name="recommend_subject">"Try %1$s on your smartphone!"</string>
-       <string name="recommend_text">"I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s"</string>  
+       <string name="recommend_text">"I want to invite you to use %1$s on your smartphone!\nDownload here: %2$s"
+       </string>
 
-    <string name="auth_check_server">Check Server</string>
-    <string name="auth_host_url">Server address https://…</string>
-    <string name="auth_username">Username</string>
-    <string name="auth_password">Password</string>
-    <string name="auth_register">New to %1$s?</string>
-    <string name="sync_string_files">Files</string>
-    <string name="setup_btn_connect">Connect</string>
-    <string name="uploader_btn_upload_text">Upload</string>
-    <string name="uploader_top_message">Choose upload directory:</string>
-    <string name="uploader_wrn_no_account_title">No account found</string>
-    <string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please setup an account first.</string>
-    <string name="uploader_wrn_no_account_setup_btn_text">Setup</string>
-    <string name="uploader_wrn_no_account_quit_btn_text">Quit</string>
-    <string name="uploader_wrn_no_content_title">No content to upload</string>
-    <string name="uploader_wrn_no_content_text">No content was received. Nothing to upload.</string>
-    <string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
-    <string name="uploader_info_uploading">Uploading</string>
-    <string name="file_list_empty">There are no files in this folder.\nNew files can be added with the \"Upload\" menu option.</string>
-    <string name="filedetails_select_file">Tap on a file to display additional information.</string>
-    <string name="filedetails_size">Size:</string>
-    <string name="filedetails_type">Type:</string>
-    <string name="filedetails_created">Created:</string>
-    <string name="filedetails_modified">Modified:</string>
-    <string name="filedetails_download">Download</string>
-    <string name="filedetails_sync_file">Refresh file</string>
-    <string name="filedetails_renamed_in_upload_msg">File was renamed to %1$s during upload</string>
-    <string name="action_share_file">Share link</string>
-    <string name="action_unshare_file">Unshare link</string>
-    <string name="common_yes">Yes</string>
-    <string name="common_no">No</string>
-    <string name="common_ok">OK</string>
-    <string name="common_cancel_download">Cancel download</string>
-    <string name="common_cancel_upload">Cancel upload</string>
-    <string name="common_cancel">Cancel</string>
-    <string name="common_save_exit">Save &amp; Exit</string>
-    <string name="common_error">Error</string>
-    <string name="common_loading">Loading &#8230;</string>
-    <string name="common_error_unknown">Unknown error</string>
-    <string name="about_title">About</string>
-    <string name="change_password">Change password</string>
-    <string name="delete_account">Delete account</string>
-    <string name="create_account">Create account</string>
-    <string name="upload_chooser_title">Upload from &#8230;</string>
-    <string name="uploader_info_dirname">Directory name</string>
-    <string name="uploader_upload_in_progress_ticker">Uploading &#8230;</string>
-    <string name="uploader_upload_in_progress_content">%1$d%% Uploading %2$s</string>
-    <string name="uploader_upload_succeeded_ticker">Upload succeeded</string>
-    <string name="uploader_upload_succeeded_content_single">%1$s was successfully uploaded</string>
-    <string name="uploader_upload_failed_ticker">Upload failed</string>
-    <string name="uploader_upload_failed_content_single">Upload of %1$s could not be completed</string>
-    <string name="downloader_download_in_progress_ticker">Downloading &#8230;</string>
-    <string name="downloader_download_in_progress_content">%1$d%% Downloading %2$s</string>
-    <string name="downloader_download_succeeded_ticker">Download succeeded</string>
-    <string name="downloader_download_succeeded_content">%1$s was successfully downloaded</string>
-    <string name="downloader_download_failed_ticker">Download failed</string>
-    <string name="downloader_download_failed_content">Download of %1$s could not be completed</string>
-    <string name="downloader_not_downloaded_yet">Not downloaded yet</string>
-    <string name="common_choose_account">Choose account</string>
-    <string name="sync_fail_ticker">Synchronization failed</string>
-    <string name="sync_fail_content">Synchronization of %1$s could not be completed</string>
-    <string name="sync_fail_content_unauthorized">Invalid password for %1$s</string>
+       <string name="auth_check_server">Check Server</string>
+       <string name="auth_host_url">Server address https://…</string>
+       <string name="auth_username">Username</string>
+       <string name="auth_password">Password</string>
+       <string name="auth_register">New to %1$s?</string>
+       <string name="sync_string_files">Files</string>
+       <string name="setup_btn_connect">Connect</string>
+       <string name="uploader_btn_upload_text">Upload</string>
+       <string name="uploader_top_message">Choose upload directory:</string>
+       <string name="uploader_wrn_no_account_title">No account found</string>
+       <string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please setup an account first.
+       </string>
+       <string name="uploader_wrn_no_account_setup_btn_text">Setup</string>
+       <string name="uploader_wrn_no_account_quit_btn_text">Quit</string>
+       <string name="uploader_wrn_no_content_title">No content to upload</string>
+       <string name="uploader_wrn_no_content_text">No content was received. Nothing to upload.</string>
+       <string name="uploader_error_forbidden_content">%1$s is not allowed to access the shared content</string>
+       <string name="uploader_info_uploading">Uploading</string>
+       <string name="file_list_empty">There are no files in this folder.\nNew files can be added with the \"Upload\"
+               menu option.</string>
+       <string name="filedetails_select_file">Tap on a file to display additional information.</string>
+       <string name="filedetails_size">Size:</string>
+       <string name="filedetails_type">Type:</string>
+       <string name="filedetails_created">Created:</string>
+       <string name="filedetails_modified">Modified:</string>
+       <string name="filedetails_download">Download</string>
+       <string name="filedetails_sync_file">Refresh file</string>
+       <string name="filedetails_renamed_in_upload_msg">File was renamed to %1$s during upload</string>
+       <string name="action_share_file">Share link</string>
+       <string name="action_unshare_file">Unshare link</string>
+       <string name="common_yes">Yes</string>
+       <string name="common_no">No</string>
+       <string name="common_ok">OK</string>
+       <string name="common_cancel_download">Cancel download</string>
+       <string name="common_cancel_upload">Cancel upload</string>
+       <string name="common_cancel">Cancel</string>
+       <string name="common_save_exit">Save &amp; Exit</string>
+       <string name="common_error">Error</string>
+       <string name="common_loading">Loading &#8230;</string>
+       <string name="common_error_unknown">Unknown error</string>
+       <string name="about_title">About</string>
+       <string name="change_password">Change password</string>
+       <string name="delete_account">Delete account</string>
+       <string name="create_account">Create account</string>
+       <string name="upload_chooser_title">Upload from &#8230;</string>
+       <string name="uploader_info_dirname">Directory name</string>
+       <string name="uploader_upload_in_progress_ticker">Uploading &#8230;</string>
+       <string name="uploader_upload_in_progress_content">%1$d%% Uploading %2$s</string>
+       <string name="uploader_upload_succeeded_ticker">Upload succeeded</string>
+       <string name="uploader_upload_succeeded_content_single">%1$s was successfully uploaded</string>
+       <string name="uploader_upload_failed_ticker">Upload failed</string>
+       <string name="uploader_upload_failed_content_single">Upload of %1$s could not be completed</string>
+       <string name="downloader_download_in_progress_ticker">Downloading &#8230;</string>
+       <string name="downloader_download_in_progress_content">%1$d%% Downloading %2$s</string>
+       <string name="downloader_download_succeeded_ticker">Download succeeded</string>
+       <string name="downloader_download_succeeded_content">%1$s was successfully downloaded</string>
+       <string name="downloader_download_failed_ticker">Download failed</string>
+       <string name="downloader_download_failed_content">Download of %1$s could not be completed</string>
+       <string name="downloader_not_downloaded_yet">Not downloaded yet</string>
+       <string name="common_choose_account">Choose account</string>
+       <string name="sync_fail_ticker">Synchronization failed</string>
+       <string name="sync_fail_content">Synchronization of %1$s could not be completed</string>
+       <string name="sync_fail_content_unauthorized">Invalid password for %1$s</string>
        <string name="sync_conflicts_in_favourites_ticker">Conflicts found</string>
        <string name="sync_conflicts_in_favourites_content">%1$d kept-in-sync files could not be sync\'ed</string>
-    <string name="sync_fail_in_favourites_ticker">Kept-in-sync files failed</string>
-    <string name="sync_fail_in_favourites_content">Contents of %1$d files could not be sync\'ed (%2$d conflicts)</string>
-    <string name="sync_foreign_files_forgotten_ticker">Some local files were forgotten</string>
-    <string name="sync_foreign_files_forgotten_content">%1$d files out of the %2$s directory could not be copied into</string>
-    <string name="sync_foreign_files_forgotten_explanation">As of version 1.3.16, files uploaded from this device are copied into the local %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to this change, all files uploaded in previous versions of this app were copied into the %2$s folder. However, an error prevented the completion of this operation during account synchronization. You may either leave the file(s) as is and remove the link to %3$s, or move the file(s) into the %1$s directory and retain the link to %4$s.\n\nListed below are the local file(s), and the remote file(s) in %5$s they were linked to.</string>
-       <string name="sync_current_folder_was_removed">Folder %1$s does not exist anymore</string>    
-    <string name="foreign_files_move">"Move all"</string>
-    <string name="foreign_files_success">"All files were moved"</string>
-    <string name="foreign_files_fail">"Some files could not be moved"</string>
-    <string name="foreign_files_local_text">"Local: %1$s"</string>
-    <string name="foreign_files_remote_text">"Remote: %1$s"</string>
-    <string name="upload_query_move_foreign_files">There is not space enough to copy the selected files into the %1$s folder. Would like to move them into instead? </string>
-    <string name="pincode_enter_pin_code">Please, insert your App PIN</string>
-    <string name="pincode_configure_your_pin">Enter your App PIN</string>
-    <string name="pincode_configure_your_pin_explanation">The PIN will be requested every time the app is started</string>
-    <string name="pincode_reenter_your_pincode">Please, reenter your App PIN</string>
-    <string name="pincode_remove_your_pincode">Remove your App PIN</string>
-    <string name="pincode_mismatch">The App PINs are not the same</string>
-    <string name="pincode_wrong">Incorrect App PIN</string>
-    <string name="pincode_removed">App PIN removed</string>
-    <string name="pincode_stored">App PIN stored</string>
-    
-    <string name="media_notif_ticker">"%1$s music player"</string>
-    <string name="media_state_playing">"%1$s (playing)"</string>
-    <string name="media_state_loading">"%1$s (loading)"</string>
-    <string name="media_event_done">"%1$s playback finished"</string>
-    <string name="media_err_nothing_to_play">No media file found</string>
+       <string name="sync_fail_in_favourites_ticker">Kept-in-sync files failed</string>
+       <string name="sync_fail_in_favourites_content">Contents of %1$d files could not be sync\'ed (%2$d conflicts)</string>
+       <string name="sync_foreign_files_forgotten_ticker">Some local files were forgotten</string>
+       <string name="sync_foreign_files_forgotten_content">%1$d files out of the %2$s directory could not be copied into</string>
+       <string name="sync_foreign_files_forgotten_explanation">As of version 1.3.16, files uploaded from this device are copied into the local
+               %1$s folder to prevent data loss when a single file is synced with multiple accounts.\n\nDue to
+               this change, all files uploaded in previous versions of this app were copied into the %2$s folder.
+               However, an error prevented the completion of this operation during account synchronization. You
+               may either leave the file(s) as is and remove the link to %3$s, or move the file(s) into the %1$s
+               directory and retain the link to %4$s.\n\nListed below are the local file(s), and the remote
+               file(s) in %5$s they were linked to.</string>
+       <string name="sync_current_folder_was_removed">Folder %1$s does not exist anymore</string>
+       <string name="foreign_files_move">"Move all"</string>
+       <string name="foreign_files_success">"All files were moved"</string>
+       <string name="foreign_files_fail">"Some files could not be moved"</string>
+       <string name="foreign_files_local_text">"Local: %1$s"</string>
+       <string name="foreign_files_remote_text">"Remote: %1$s"</string>
+       <string name="upload_query_move_foreign_files">There is not space enough to copy the selected files into the %1$s folder.
+               Would like to move them into instead? </string>
+       <string name="pincode_enter_pin_code">Please, insert your App PIN</string>
+       <string name="pincode_configure_your_pin">Enter your App PIN</string>
+       <string name="pincode_configure_your_pin_explanation">The PIN will be requested every time the app is started</string>
+       <string name="pincode_reenter_your_pincode">Please, reenter your App PIN</string>
+       <string name="pincode_remove_your_pincode">Remove your App PIN</string>
+       <string name="pincode_mismatch">The App PINs are not the same</string>
+       <string name="pincode_wrong">Incorrect App PIN</string>
+       <string name="pincode_removed">App PIN removed</string>
+       <string name="pincode_stored">App PIN stored</string>
+
+       <string name="media_notif_ticker">"%1$s music player"</string>
+       <string name="media_state_playing">"%1$s (playing)"</string>
+       <string name="media_state_loading">"%1$s (loading)"</string>
+       <string name="media_event_done">"%1$s playback finished"</string>
+       <string name="media_err_nothing_to_play">No media file found</string>
        <string name="media_err_no_account">No account provided</string>
-    <string name="media_err_not_in_owncloud">File not in a valid account</string>
-    <string name="media_err_unsupported">Unsupported media codec</string>
-    <string name="media_err_io">Media file could not be read</string>
-    <string name="media_err_malformed">Media file not correctly encoded</string>
-    <string name="media_err_timeout">Timed out while trying to play</string>
-    <string name="media_err_invalid_progressive_playback">Media file cannot be streamed</string>
-    <string name="media_err_unknown">Media file cannot be played with the stock media player</string>
-    <string name="media_err_security_ex">Security error trying to play %1$s</string>
+       <string name="media_err_not_in_owncloud">File not in a valid account</string>
+       <string name="media_err_unsupported">Unsupported media codec</string>
+       <string name="media_err_io">Media file could not be read</string>
+       <string name="media_err_malformed">Media file not correctly encoded</string>
+       <string name="media_err_timeout">Timed out while trying to play</string>
+       <string name="media_err_invalid_progressive_playback">Media file cannot be streamed</string>
+       <string name="media_err_unknown">Media file cannot be played with the stock media player</string>
+       <string name="media_err_security_ex">Security error trying to play %1$s</string>
        <string name="media_err_io_ex">Input error trying to play %1$s</string>
        <string name="media_err_unexpected">Unexpected error trying to play %1$s</string>
        <string name="media_rewind_description">Rewind button</string>
        <string name="media_play_pause_description">Play or pause button</string>
        <string name="media_forward_description">Fast forward button</string>
 
-    <string name="auth_trying_to_login">Trying to login&#8230;</string>
-    <string name="auth_no_net_conn_title">No network connection</string>
-    <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
-    <string name="auth_connection_established">Connection established</string>
-    <string name="auth_testing_connection">Testing connection&#8230;</string>
-    <string name="auth_not_configured_title">Malformed server configuration</string>
-    <string name="auth_account_not_new">An account for the same user and server already exists in the device</string>
-    <string name="auth_account_not_the_same">The entered user does not match the user of this account</string>
-    <string name="auth_unknown_error_title">Unknown error occurred!</string>
-    <string name="auth_unknown_host_title">Couldn\'t find host</string>
-    <string name="auth_incorrect_path_title">Server instance not found</string>
-    <string name="auth_timeout_title">The server took too long to respond</string>
-    <string name="auth_incorrect_address_title">Malformed URL</string>
-    <string name="auth_ssl_general_error_title">SSL initialization failed</string>
-    <string name="auth_ssl_unverified_server_title">Couldn\'t verify SSL server\'s identity</string>
-    <string name="auth_bad_oc_version_title">Unrecognized server version</string>
-    <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
-    <string name="auth_secure_connection">Secure connection established</string>
-    <string name="auth_unauthorized">Wrong username or password</string>
+       <string name="auth_trying_to_login">Trying to login&#8230;</string>
+       <string name="auth_no_net_conn_title">No network connection</string>
+       <string name="auth_nossl_plain_ok_title">Secure connection unavailable.</string>
+       <string name="auth_connection_established">Connection established</string>
+       <string name="auth_testing_connection">Testing connection&#8230;</string>
+       <string name="auth_not_configured_title">Malformed server configuration</string>
+       <string name="auth_account_not_new">An account for the same user and server already exists in the device</string>
+       <string name="auth_account_not_the_same">The entered user does not match the user of this account</string>
+       <string name="auth_unknown_error_title">Unknown error occurred!</string>
+       <string name="auth_unknown_host_title">Couldn\'t find host</string>
+       <string name="auth_incorrect_path_title">Server instance not found</string>
+       <string name="auth_timeout_title">The server took too long to respond</string>
+       <string name="auth_incorrect_address_title">Malformed URL</string>
+       <string name="auth_ssl_general_error_title">SSL initialization failed</string>
+       <string name="auth_ssl_unverified_server_title">Couldn\'t verify SSL server\'s identity</string>
+       <string name="auth_bad_oc_version_title">Unrecognized server version</string>
+       <string name="auth_wrong_connection_title">Couldn\'t establish connection</string>
+       <string name="auth_secure_connection">Secure connection established</string>
+       <string name="auth_unauthorized">Wrong username or password</string>
        <string name="auth_oauth_error">Unsuccessful authorization</string>
        <string name="auth_oauth_error_access_denied">Access denied by authorization server</string>
-    <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
-    <string name="auth_expired_oauth_token_toast">Your authorization expired. Please, authorize again</string>
-    <string name="auth_expired_basic_auth_toast">Please, enter the current password</string>
-    <string name="auth_expired_saml_sso_token_toast">Your session expired. Please connect again</string>
+       <string name="auth_wtf_reenter_URL">Unexpected state; please, enter the server URL again</string>
+       <string name="auth_expired_oauth_token_toast">Your authorization expired. Please, authorize again</string>
+       <string name="auth_expired_basic_auth_toast">Please, enter the current password</string>
+       <string name="auth_expired_saml_sso_token_toast">Your session expired. Please connect again</string>
        <string name="auth_connecting_auth_server">Connecting to authentication server…</string>
-       <string name="auth_unsupported_auth_method">The server does not support this authentication method</string>    
+       <string name="auth_unsupported_auth_method">The server does not support this authentication method</string>
        <string name="auth_unsupported_multiaccount">%1$s does not support multiple accounts</string>
-       <string name="auth_fail_get_user_name">Your server is not returning a correct user id, please contact an administrator</string>
+       <string name="auth_fail_get_user_name">Your server is not returning a correct user id, please contact an administrator
+       </string>
        <string name="auth_can_not_auth_against_server">Can not authenticate against this server</string>
-    
-    <string name="fd_keep_in_sync">Keep file up to date</string>
-    <string name="common_rename">Rename</string>
-    <string name="common_remove">Remove</string>
-    <string name="confirmation_remove_alert">"Do you really want to remove %1$s ?"</string>
-    <string name="confirmation_remove_folder_alert">"Do you really want to remove %1$s and its contents ?"</string>
-    <string name="confirmation_remove_local">Local only</string>
-    <string name="confirmation_remove_folder_local">Local contents only</string>
-    <string name="confirmation_remove_remote">Remove from server</string>
-    <string name="confirmation_remove_remote_and_local">Remote and local</string>
-    <string name="remove_success_msg">"Removal succeeded"</string>
-    <string name="remove_fail_msg">"Removal failed"</string>
-    <string name="rename_dialog_title">Enter a new name</string>
-    <string name="rename_local_fail_msg">"Local copy could not be renamed; try a different name"</string>
-    <string name="rename_server_fail_msg">"Rename could not be completed"</string>
-    <string name="sync_file_fail_msg">Remote file could not be checked</string>
-    <string name="sync_file_nothing_to_do_msg">File contents already synchronized</string>
-    <string name="create_dir_fail_msg">Directory could not be created</string>
-    <string name="filename_forbidden_characters">Forbidden characters: / \\ &lt; &gt; : " | ? *</string>
-    <string name="wait_a_moment">Wait a moment</string>
-    <string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
-    <string name="filedisplay_no_file_selected">No file was selected</string>
-    <string name="activity_chooser_title">Send link to &#8230;</string>
-    
-    <string name="oauth_check_onoff">Login with oAuth2</string> 
-    <string name="oauth_login_connection">Connecting to oAuth2 server…</string>    
-        
-    <string name="ssl_validator_header">The identity of the site could not be verified</string>
-    <string name="ssl_validator_reason_cert_not_trusted">- The server certificate is not trusted</string>
-    <string name="ssl_validator_reason_cert_expired">- The server certificate expired</string>
-    <string name="ssl_validator_reason_cert_not_yet_valid">- The server certificate valid dates are in the future</string>
-    <string name="ssl_validator_reason_hostname_not_verified">- The URL does not match the hostname in the certificate</string>
-    <string name="ssl_validator_question">Do you want to trust this certificate anyway?</string>
-    <string name="ssl_validator_not_saved">The certificate could not be saved</string>
-    <string name="ssl_validator_btn_details_see">Details</string>
-    <string name="ssl_validator_btn_details_hide">Hide</string>
-    <string name="ssl_validator_label_subject">Issued to:</string>
-    <string name="ssl_validator_label_issuer">Issued by:</string>
-    <string name="ssl_validator_label_CN">Common name:</string>
-    <string name="ssl_validator_label_O">Organization:</string>
-    <string name="ssl_validator_label_OU">Organizational unit:</string>
-    <string name="ssl_validator_label_C">Country:</string>
-    <string name="ssl_validator_label_ST">State:</string>
-    <string name="ssl_validator_label_L">Location:</string>
-    <string name="ssl_validator_label_validity">Validity:</string>
-    <string name="ssl_validator_label_validity_from">From:</string>
+
+       <string name="fd_keep_in_sync">Keep file up to date</string>
+       <string name="common_rename">Rename</string>
+       <string name="common_remove">Remove</string>
+       <string name="confirmation_remove_alert">"Do you really want to remove %1$s ?"</string>
+       <string name="confirmation_remove_folder_alert">"Do you really want to remove %1$s and its contents ?"</string>
+       <string name="confirmation_remove_local">Local only</string>
+       <string name="confirmation_remove_folder_local">Local contents only</string>
+       <string name="confirmation_remove_remote">Remove from server</string>
+       <string name="confirmation_remove_remote_and_local">Remote and local</string>
+       <string name="remove_success_msg">"Removal succeeded"</string>
+       <string name="remove_fail_msg">"Removal failed"</string>
+       <string name="rename_dialog_title">Enter a new name</string>
+       <string name="rename_local_fail_msg">"Local copy could not be renamed; try a different name"</string>
+       <string name="rename_server_fail_msg">"Rename could not be completed"</string>
+       <string name="sync_file_fail_msg">Remote file could not be checked</string>
+       <string name="sync_file_nothing_to_do_msg">File contents already synchronized</string>
+       <string name="create_dir_fail_msg">Directory could not be created</string>
+       <string name="filename_forbidden_characters">Forbidden characters: / \\ &lt; &gt; : " | ? *</string>
+       <string name="wait_a_moment">Wait a moment</string>
+       <string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
+       <string name="filedisplay_no_file_selected">No file was selected</string>
+       <string name="activity_chooser_title">Send link to &#8230;</string>
+
+       <string name="oauth_check_onoff">Login with oAuth2</string>
+       <string name="oauth_login_connection">Connecting to oAuth2 server…</string>
+
+       <string name="ssl_validator_header">The identity of the site could not be verified</string>
+       <string name="ssl_validator_reason_cert_not_trusted">- The server certificate is not trusted</string>
+       <string name="ssl_validator_reason_cert_expired">- The server certificate expired</string>
+       <string name="ssl_validator_reason_cert_not_yet_valid">- The server certificate valid dates are in the future</string>
+       <string name="ssl_validator_reason_hostname_not_verified">- The URL does not match the hostname in the certificate</string>
+       <string name="ssl_validator_question">Do you want to trust this certificate anyway?</string>
+       <string name="ssl_validator_not_saved">The certificate could not be saved</string>
+       <string name="ssl_validator_btn_details_see">Details</string>
+       <string name="ssl_validator_btn_details_hide">Hide</string>
+       <string name="ssl_validator_label_subject">Issued to:</string>
+       <string name="ssl_validator_label_issuer">Issued by:</string>
+       <string name="ssl_validator_label_CN">Common name:</string>
+       <string name="ssl_validator_label_O">Organization:</string>
+       <string name="ssl_validator_label_OU">Organizational unit:</string>
+       <string name="ssl_validator_label_C">Country:</string>
+       <string name="ssl_validator_label_ST">State:</string>
+       <string name="ssl_validator_label_L">Location:</string>
+       <string name="ssl_validator_label_validity">Validity:</string>
+       <string name="ssl_validator_label_validity_from">From:</string>
        <string name="ssl_validator_label_validity_to">To:</string>
        <string name="ssl_validator_label_signature">Signature:</string>
        <string name="ssl_validator_label_signature_algorithm">Algorithm:</string>
        <string name="ssl_validator_null_cert">The certificate could not be shown.</string>
        <string name="ssl_validator_no_info_about_error">- No information about the error</string>
-                       
-    <string name="placeholder_sentence">This is a placeholder</string>
-    <string name="placeholder_filename">placeholder.txt</string>
-    <string name="placeholder_filetype">PNG Image</string>
-    <string name="placeholder_filesize">389 KB</string>
-    <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
-    <string name="placeholder_media_time">12:23:45</string>
-    
-    <string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
-    <string name="instant_upload_path">/InstantUpload</string>
-    <string name="conflict_title">Update conflict</string>
-    <string name="conflict_message">Remote file %s is not synchronized with local file. Continuing will replace content of file on server.</string>
-    <string name="conflict_keep_both">Keep both</string>
-    <string name="conflict_overwrite">Overwrite</string>
-    <string name="conflict_dont_upload">Don\'t upload</string>
-    
-    <string name="preview_image_description">Image preview</string>
-    <string name="preview_image_error_unknown_format">This image can not be shown</string>
-    
-    <string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local directory</string>
-    <string name="actionbar_failed_instant_upload">Failed InstantUpload</string>
-    <string name="failed_upload_headline_text">Failed instant uploads</string>
-    <string name="failed_upload_headline_hint">Summary of all failed instant uploads</string>
-    <string name="failed_upload_all_cb">select all</string>
-    <string name="failed_upload_headline_retryall_btn">retry all selected</string>
-    <string name="failed_upload_headline_delete_all_btn">delete all  selected from uploadqueue</string>
-    <string name="failed_upload_retry_text">retry to upload the image: </string>
-    <string name="failed_upload_load_more_images">Load more Picrures</string>
-    <string name="failed_upload_retry_do_nothing_text">do nothing you are not online for instant upload</string>
+
+       <string name="placeholder_sentence">This is a placeholder</string>
+       <string name="placeholder_filename">placeholder.txt</string>
+       <string name="placeholder_filetype">PNG Image</string>
+       <string name="placeholder_filesize">389 KB</string>
+       <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
+       <string name="placeholder_media_time">12:23:45</string>
+
+       <string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
+       <string name="instant_upload_path">/InstantUpload</string>
+       <string name="conflict_title">Update conflict</string>
+       <string name="conflict_message">Remote file %s is not synchronized with local file. Continuing will replace
+               content of file on server.</string>
+       <string name="conflict_keep_both">Keep both</string>
+       <string name="conflict_overwrite">Overwrite</string>
+       <string name="conflict_dont_upload">Don\'t upload</string>
+
+       <string name="preview_image_description">Image preview</string>
+       <string name="preview_image_error_unknown_format">This image can not be shown</string>
+
+       <string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local directory</string>
+       <string name="actionbar_failed_instant_upload">Failed InstantUpload</string>
+       <string name="failed_upload_headline_text">Failed instant uploads</string>
+       <string name="failed_upload_headline_hint">Summary of all failed instant uploads</string>
+       <string name="failed_upload_all_cb">select all</string>
+       <string name="failed_upload_headline_retryall_btn">retry all selected</string>
+       <string name="failed_upload_headline_delete_all_btn">delete all selected from uploadqueue</string>
+       <string name="failed_upload_retry_text">retry to upload the image: </string>
+       <string name="failed_upload_load_more_images">Load more Picrures</string>
+       <string name="failed_upload_retry_do_nothing_text">do nothing you are not online for instant upload</string>
        <string name="failed_upload_failure_text">Failure Message: </string>
        <string name="failed_upload_quota_exceeded_text">Please check your server configuration,maybe your quota is exceeded.</string>
-       
-       <string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your administrator.</string>
+
+       <string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your
+               administrator.</string>
        <string name="share_link_file_no_exist">Unable to share this file or folder. Please, make sure it exists</string>
        <string name="share_link_file_error">An error occurred while trying to share this file or folder</string>
        <string name="unshare_link_file_no_exist">Unable to unshare this file or folder. It does not exist.</string>
 
        <string name="activity_chooser_send_file_title">Send</string>
 
-       <string name="copy_link">Copy link</string>     
+       <string name="copy_link">Copy link</string>
        <string name="clipboard_text_copied">Copied to clipboard</string>
-       
+
+       <string name="error_cant_bind_to_operations_service">Critical error: can not perform operations</string>
 </resources>
index 8cbe7ad..69eea77 100644 (file)
@@ -25,8 +25,11 @@ import android.accounts.AccountManager;
 import android.app.AlertDialog;\r
 import android.app.Dialog;\r
 import android.app.ProgressDialog;\r
+import android.content.ComponentName;\r
+import android.content.Context;\r
 import android.content.DialogInterface;\r
 import android.content.Intent;\r
+import android.content.ServiceConnection;\r
 import android.content.SharedPreferences;\r
 import android.graphics.Rect;\r
 import android.graphics.drawable.Drawable;\r
@@ -34,6 +37,7 @@ import android.net.Uri;
 import android.net.http.SslError;\r
 import android.os.Bundle;\r
 import android.os.Handler;\r
+import android.os.IBinder;\r
 import android.preference.PreferenceManager;\r
 import android.support.v4.app.Fragment;\r
 import android.support.v4.app.FragmentManager;\r
@@ -41,6 +45,7 @@ import android.support.v4.app.FragmentTransaction;
 import android.text.Editable;\r
 import android.text.InputType;\r
 import android.text.TextWatcher;\r
+import android.util.Log;\r
 import android.view.KeyEvent;\r
 import android.view.MotionEvent;\r
 import android.view.View;\r
@@ -54,6 +59,7 @@ import android.widget.CheckBox;
 import android.widget.EditText;\r
 import android.widget.TextView;\r
 import android.widget.TextView.OnEditorActionListener;\r
+import android.widget.Toast;\r
 \r
 import com.actionbarsherlock.app.SherlockDialogFragment;\r
 import com.owncloud.android.MainApp;\r
@@ -76,6 +82,8 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCo
 import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;\r
 import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;\r
 \r
+import com.owncloud.android.services.OperationsService;\r
+import com.owncloud.android.services.OperationsService.OperationsServiceBinder;\r
 import com.owncloud.android.ui.dialog.SamlWebViewDialog;\r
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;\r
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;\r
@@ -116,6 +124,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON";\r
     private static final String KEY_REFRESH_BUTTON_ENABLED = "KEY_REFRESH_BUTTON_ENABLED";\r
     //private static final String KEY_IS_SHARED_SUPPORTED = "KEY_IS_SHARE_SUPPORTED";\r
+    private static final String KEY_SERVER_AUTH_METHOD = "KEY_SERVER_AUTH_METHOD";\r
+    private static final String KEY_DETECT_AUTH_OP_ID = "KEY_DETECT_AUTH_OP_ID";\r
+\r
 \r
     private static final String AUTH_ON = "on";\r
     private static final String AUTH_OFF = "off";\r
@@ -136,6 +147,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private String mAuthMessageText;\r
     private int mAuthMessageVisibility, mServerStatusText, mServerStatusIcon;\r
     private boolean mServerIsChecked, mServerIsValid, mIsSslConn;\r
+    private AuthenticationMethod mServerAuthMethod = AuthenticationMethod.UNKNOWN;\r
+    private int mDetectAuthOpId = -1;\r
+\r
     private int mAuthStatusText, mAuthStatusIcon;    \r
     private TextView mAuthStatusLayout;\r
 \r
@@ -176,9 +190,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private boolean mResumed; // Control if activity is resumed\r
 \r
     public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";\r
-\r
-    private DetectAuthenticationMethodOperation mDetectAuthenticationOperation;\r
-\r
+    \r
+    private ServiceConnection mOperationsServiceConnection = null;\r
+    \r
+    private OperationsServiceBinder mOperationsServiceBinder = null;\r
 \r
     /**\r
      * {@inheritDoc}\r
@@ -190,6 +205,18 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         super.onCreate(savedInstanceState);\r
         getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
 \r
+        // bind to Operations Service\r
+        mOperationsServiceConnection = new OperationsServiceConnection();\r
+        if (!bindService(new Intent(this, OperationsService.class), \r
+                mOperationsServiceConnection, \r
+                Context.BIND_AUTO_CREATE)) {\r
+            Toast.makeText(this, \r
+                    R.string.error_cant_bind_to_operations_service, \r
+                    Toast.LENGTH_LONG)\r
+                        .show();\r
+            finish();\r
+        }\r
+                \r
         /// set view and get references to view elements\r
         setContentView(R.layout.account_setup);\r
         mAuthMessage = (TextView) findViewById(R.id.auth_message);\r
@@ -306,6 +333,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
 \r
 \r
+            mServerAuthMethod = AuthenticationMethod.valueOf(\r
+                    savedInstanceState.getString(KEY_SERVER_AUTH_METHOD));\r
+            mDetectAuthOpId = savedInstanceState.getInt(KEY_DETECT_AUTH_OP_ID);\r
+\r
         }\r
 \r
         if (mAuthMessageVisibility== View.VISIBLE) {\r
@@ -391,6 +422,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 return false;\r
             }\r
         });\r
+        \r
     }\r
 \r
 \r
@@ -443,6 +475,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      */\r
     @Override\r
     protected void onSaveInstanceState(Bundle outState) {\r
+        //Log.wtf(TAG, "onSaveInstanceState init" );\r
         super.onSaveInstanceState(outState);\r
 \r
         /// connection state and info\r
@@ -472,8 +505,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
         // refresh button enabled\r
         outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
-\r
-\r
+        \r
+        outState.putString(KEY_SERVER_AUTH_METHOD, mServerAuthMethod.name());\r
+        outState.putInt(KEY_DETECT_AUTH_OP_ID, mDetectAuthOpId);\r
+        //Log.wtf(TAG, "onSaveInstanceState end" );\r
     }\r
 \r
 \r
@@ -500,7 +535,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      */\r
     @Override\r
     protected void onResume() {\r
+        //Log.wtf(TAG, "onResume init" );\r
         super.onResume();\r
+        \r
         if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {\r
             if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
                 //Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();\r
@@ -517,9 +554,35 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         if (mNewCapturedUriFromOAuth2Redirection != null) {\r
             getOAuth2AccessTokenFromCapturedRedirection();            \r
         }\r
-\r
+        \r
         mJustCreated = false;\r
 \r
+        if (mOperationsServiceBinder != null) {\r
+            doOnResumeAndBound();\r
+        }\r
+        \r
+        //Log.wtf(TAG, "onResume end" );\r
+    }\r
+\r
+    \r
+    @Override\r
+    protected void onPause() {\r
+        //Log.wtf(TAG, "onPause init" );\r
+        if (mOperationsServiceBinder != null) {\r
+            //Log.wtf(TAG, "unregistering to listen for operation callbacks" );\r
+            mOperationsServiceBinder.removeOperationListener(this);\r
+        }\r
+        super.onPause();\r
+        //Log.wtf(TAG, "onPause end" );\r
+    }\r
+    \r
+    @Override\r
+    protected void onDestroy() {\r
+        if (mOperationsServiceConnection != null) {\r
+            unbindService(mOperationsServiceConnection);\r
+            mOperationsServiceBinder = null;\r
+        }\r
+        super.onDestroy();\r
     }\r
 \r
 \r
@@ -811,13 +874,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             onGetUserNameFinish((GetRemoteUserNameOperation) operation, result);\r
 \r
         } else if (operation instanceof DetectAuthenticationMethodOperation) {\r
-            onDetectAutheticationFinish((DetectAuthenticationMethodOperation) operation, result);\r
+            Log.wtf(TAG, "received detection response through callback" );\r
+            onDetectAuthenticationFinish(result);\r
         }\r
 \r
     }\r
 \r
-    private void onDetectAutheticationFinish(DetectAuthenticationMethodOperation operation, RemoteOperationResult result) {\r
+    private void onDetectAuthenticationFinish(RemoteOperationResult result) {\r
         // Read authentication method\r
+        mDetectAuthOpId = -1;\r
         if (result.getData().size() > 0) {\r
             AuthenticationMethod authMethod = (AuthenticationMethod) result.getData().get(0);\r
             String basic = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
@@ -959,14 +1024,23 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private void detectAuthorizationMethod() {\r
 \r
         Log_OC.d(TAG, "Trying empty authorization to detect authentication method");\r
-\r
-        /// get the path to the root folder through WebDAV from the version server\r
+        \r
         String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);\r
-\r
+        \r
         /// test credentials \r
-        mDetectAuthenticationOperation = new DetectAuthenticationMethodOperation(this);\r
-        OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);\r
-        mOperationThread = mDetectAuthenticationOperation.execute(client, this, mHandler);\r
+        //Intent detectAuthIntent = new Intent(this, OperationsService.class);\r
+        Intent detectAuthIntent = new Intent();\r
+        detectAuthIntent.setAction(OperationsService.ACTION_DETECT_AUTHENTICATION_METHOD);\r
+        detectAuthIntent.putExtra(OperationsService.EXTRA_SERVER_URL, mHostBaseUrl);\r
+        detectAuthIntent.putExtra(OperationsService.EXTRA_WEBDAV_PATH, webdav_path);\r
+        \r
+        //if (mOperationsBinder != null) {  // let's let it crash to detect if is really possible\r
+        mServerAuthMethod = AuthenticationMethod.UNKNOWN;\r
+        if (mOperationsServiceBinder != null) {\r
+            //Log.wtf(TAG, "starting detection..." );\r
+            mDetectAuthOpId = mOperationsServiceBinder.newOperation(detectAuthIntent);\r
+        }\r
+        //}\r
     }\r
 \r
 \r
@@ -1790,5 +1864,49 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         }\r
 \r
     }\r
+    \r
+    \r
+    private void doOnResumeAndBound() {\r
+        //Log.wtf(TAG, "registering to listen for operation callbacks" );\r
+        mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);\r
+        \r
+        if (mDetectAuthOpId != -1) {\r
+            RemoteOperationResult result = \r
+                    mOperationsServiceBinder.getOperationResultIfFinished(mDetectAuthOpId);\r
+            if (result != null) {\r
+                //Log.wtf(TAG, "found result of operation finished while rotating");\r
+                onDetectAuthenticationFinish(result);\r
+            }\r
+        }\r
+    }\r
+    \r
+    /** \r
+     * Implements callback methods for service binding. \r
+     */\r
+    private class OperationsServiceConnection implements ServiceConnection {\r
+\r
+        @Override\r
+        public void onServiceConnected(ComponentName component, IBinder service) {\r
+            if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) {\r
+                //Log_OC.wtf(TAG, "Operations service connected");\r
+                mOperationsServiceBinder = (OperationsServiceBinder) service;\r
+                \r
+                doOnResumeAndBound();\r
+                \r
+            } else {\r
+                return;\r
+            }\r
+            \r
+        }\r
 \r
+        @Override\r
+        public void onServiceDisconnected(ComponentName component) {\r
+            if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) {\r
+                Log_OC.e(TAG, "Operations service crashed");\r
+                mOperationsServiceBinder = null;\r
+            }\r
+        }\r
+    \r
+    }\r
+    \r
 }\r
index c670316..6bc8750 100644 (file)
@@ -64,14 +64,17 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
     }
     
     private Context mContext;
+    private String mWebDavUrl;
     
     /**
      * Constructor
      * 
      * @param context       Android context of the caller.
+     * @param webdavUrl
      */
-    public DetectAuthenticationMethodOperation(Context context) {
+    public DetectAuthenticationMethodOperation(Context context, String webdavUrl) {
         mContext = context;
+        mWebDavUrl = webdavUrl;
     }
     
 
@@ -90,6 +93,7 @@ public class DetectAuthenticationMethodOperation extends RemoteOperation {
         AuthenticationMethod authMethod = AuthenticationMethod.UNKNOWN;
         
         RemoteOperation operation = new ExistenceCheckRemoteOperation("", mContext, false);
+        client.setWebdavUri(Uri.parse(mWebDavUrl));
         client.setBasicCredentials("", "");
         client.setFollowRedirects(false);
         
index 80caea7..0ccd909 100644 (file)
@@ -1,5 +1,5 @@
 /* ownCloud Android client application
- *   Copyright (C) 2012-2013 ownCloud Inc.
+ *   Copyright (C) 2012-2014 ownCloud Inc.
  *
  *   This program is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License version 2,
 package com.owncloud.android.services;
 
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ConcurrentMap;
 
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.lib.common.OwnCloudClientFactory;
@@ -32,6 +32,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.resources.shares.ShareType;
 import com.owncloud.android.operations.common.SyncOperation;
 import com.owncloud.android.operations.CreateShareOperation;
+import com.owncloud.android.operations.DetectAuthenticationMethodOperation;
 import com.owncloud.android.operations.UnshareLinkOperation;
 import com.owncloud.android.utils.Log_OC;
 
@@ -47,7 +48,6 @@ import android.os.IBinder;
 import android.os.Looper;
 import android.os.Message;
 import android.os.Process;
-//import android.support.v4.content.LocalBroadcastManager;
 import android.util.Pair;
 
 public class OperationsService extends Service {
@@ -59,14 +59,20 @@ public class OperationsService extends Service {
     public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
     public static final String EXTRA_SEND_INTENT = "SEND_INTENT";
     public static final String EXTRA_RESULT = "RESULT";
+    public static final String EXTRA_WEBDAV_PATH = "WEBDAV_PATH";
     
     public static final String ACTION_CREATE_SHARE = "CREATE_SHARE";
     public static final String ACTION_UNSHARE = "UNSHARE";
+    public static final String ACTION_DETECT_AUTHENTICATION_METHOD = "DETECT_AUTHENTICATION_METHOD";
     
     public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() + ".OPERATION_ADDED";
     public static final String ACTION_OPERATION_FINISHED = OperationsService.class.getName() + ".OPERATION_FINISHED";
 
-    private ConcurrentLinkedQueue<Pair<Target, RemoteOperation>> mPendingOperations = new ConcurrentLinkedQueue<Pair<Target, RemoteOperation>>();
+    private ConcurrentLinkedQueue<Pair<Target, RemoteOperation>> mPendingOperations = 
+            new ConcurrentLinkedQueue<Pair<Target, RemoteOperation>>();
+    
+    private ConcurrentMap<Integer, RemoteOperationResult> mOperationResults =
+            new ConcurrentHashMap<Integer, RemoteOperationResult>();
     
     private static class Target {
         public Uri mServerUrl = null;
@@ -99,6 +105,7 @@ public class OperationsService extends Service {
         mBinder = new OperationsServiceBinder();
     }
 
+    
     /**
      * Entry point to add a new operation to the queue of operations.
      * 
@@ -110,47 +117,11 @@ public class OperationsService extends Service {
      */
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
-        if (!intent.hasExtra(EXTRA_ACCOUNT) && !intent.hasExtra(EXTRA_SERVER_URL)) {
-            Log_OC.e(TAG, "Not enough information provided in intent");
-            return START_NOT_STICKY;
-        }
-        try {
-            Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
-            String serverUrl = intent.getStringExtra(EXTRA_SERVER_URL);
-            
-            Target target = new Target(account, (serverUrl == null) ? null : Uri.parse(serverUrl));
-            RemoteOperation operation = null;
-            
-            String action = intent.getAction();
-            if (action.equals(ACTION_CREATE_SHARE)) {  // Create Share
-                String remotePath = intent.getStringExtra(EXTRA_REMOTE_PATH);
-                Intent sendIntent = intent.getParcelableExtra(EXTRA_SEND_INTENT);
-                if (remotePath.length() > 0) {
-                    operation = new CreateShareOperation(remotePath, ShareType.PUBLIC_LINK, 
-                            "", false, "", 1, sendIntent);
-                }
-            } else if (action.equals(ACTION_UNSHARE)) {  // Unshare file
-                String remotePath = intent.getStringExtra(EXTRA_REMOTE_PATH);
-                if (remotePath.length() > 0) {
-                    operation = new UnshareLinkOperation(remotePath, this.getApplicationContext());
-                }
-            } else {
-                // nothing we are going to handle
-                return START_NOT_STICKY;
-            }
-            
-            mPendingOperations.add(new Pair<Target , RemoteOperation>(target, operation));
-            //sendBroadcastNewOperation(target, operation);
-            
-            Message msg = mServiceHandler.obtainMessage();
-            msg.arg1 = startId;
-            mServiceHandler.sendMessage(msg);
-            
-        } catch (IllegalArgumentException e) {
-            Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage());
-            return START_NOT_STICKY;
-        }
-        
+        //Log.wtf(TAG, "onStartCommand init" );
+        Message msg = mServiceHandler.obtainMessage();
+        msg.arg1 = startId;
+        mServiceHandler.sendMessage(msg);
+        //Log.wtf(TAG, "onStartCommand end" );
         return START_NOT_STICKY;
     }
 
@@ -161,6 +132,7 @@ public class OperationsService extends Service {
      */
     @Override
     public IBinder onBind(Intent intent) {
+        //Log.wtf(TAG, "onBind" );
         return mBinder;
     }
 
@@ -170,7 +142,7 @@ public class OperationsService extends Service {
      */
     @Override
     public boolean onUnbind(Intent intent) {
-        //((OperationsServiceBinder)mBinder).clearListeners();
+        ((OperationsServiceBinder)mBinder).clearListeners();
         return false;   // not accepting rebinding (default behaviour)
     }
 
@@ -185,7 +157,8 @@ public class OperationsService extends Service {
         /** 
          * Map of listeners that will be reported about the end of operations from a {@link OperationsServiceBinder} instance 
          */
-        private Map<OnRemoteOperationListener, Handler> mBoundListeners = new HashMap<OnRemoteOperationListener, Handler>();
+        private ConcurrentMap<OnRemoteOperationListener, Handler> mBoundListeners = 
+                new ConcurrentHashMap<OnRemoteOperationListener, Handler>();
         
         /**
          * Cancels an operation
@@ -210,7 +183,9 @@ public class OperationsService extends Service {
          * @param callbackHandler   {@link Handler} to access the listener without breaking Android threading protection.
          */
         public void addOperationListener (OnRemoteOperationListener listener, Handler callbackHandler) {
-            mBoundListeners.put(listener, callbackHandler);
+            synchronized (mBoundListeners) {
+                mBoundListeners.put(listener, callbackHandler);
+            }
         }
         
         
@@ -220,7 +195,9 @@ public class OperationsService extends Service {
          * @param listener      Object to notify about progress of transfer.    
          */
         public void removeOperationListener (OnRemoteOperationListener listener) {
-            mBoundListeners.remove(listener);
+            synchronized (mBoundListeners) {
+                mBoundListeners.remove(listener);
+            }
         }
 
 
@@ -233,6 +210,74 @@ public class OperationsService extends Service {
             return (!mPendingOperations.isEmpty());
         }
 
+
+        /**
+         * Creates and adds to the queue a new operation, as described by operationIntent
+         * 
+         * @param operationIntent       Intent describing a new operation to queue and execute.
+         * @return                      Identifier of the operation created, or -1 if failed.
+         */
+        public int newOperation(Intent operationIntent) {
+            RemoteOperation operation = null;
+            Target target = null;
+            try {
+                if (!operationIntent.hasExtra(EXTRA_ACCOUNT) && 
+                        !operationIntent.hasExtra(EXTRA_SERVER_URL)) {
+                    Log_OC.e(TAG, "Not enough information provided in intent");
+                    
+                } else {
+                    Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT);
+                    String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL);
+                    target = new Target(
+                            account, 
+                            (serverUrl == null) ? null : Uri.parse(serverUrl)
+                    );
+                    
+                    String action = operationIntent.getAction();
+                    if (action.equals(ACTION_CREATE_SHARE)) {  // Create Share
+                        String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
+                        Intent sendIntent = operationIntent.getParcelableExtra(EXTRA_SEND_INTENT);
+                        if (remotePath.length() > 0) {
+                            operation = new CreateShareOperation(remotePath, ShareType.PUBLIC_LINK, 
+                                    "", false, "", 1, sendIntent);
+                        }
+                    } else if (action.equals(ACTION_UNSHARE)) {  // Unshare file
+                        String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
+                        if (remotePath.length() > 0) {
+                            operation = new UnshareLinkOperation(
+                                    remotePath, 
+                                    OperationsService.this);
+                        }
+                    } else if (action.equals(ACTION_DETECT_AUTHENTICATION_METHOD)) { 
+                        // Detect Authentication Method
+                        String webdav_url = 
+                                serverUrl + operationIntent.getStringExtra(EXTRA_WEBDAV_PATH);
+                        operation = new DetectAuthenticationMethodOperation(
+                                OperationsService.this, 
+                                webdav_url);
+                    }
+                }
+                    
+            } catch (IllegalArgumentException e) {
+                Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage());
+                operation = null;
+            }
+
+            if (operation != null) {
+                mPendingOperations.add(new Pair<Target , RemoteOperation>(target, operation));
+                startService(new Intent(OperationsService.this, OperationsService.class));
+                return operation.hashCode();
+                
+            } else {
+                return -1;
+            }
+        }
+
+        public RemoteOperationResult getOperationResultIfFinished(int mDetectAuthOpId) {
+            //Log_OC.wtf(TAG, "Searching result for operation with id " + mDetectAuthOpId);
+            return mOperationResults.remove(mDetectAuthOpId);
+        }
+
     }
     
     
@@ -265,6 +310,8 @@ public class OperationsService extends Service {
      */
     private void nextOperation() {
         
+        //Log.wtf(TAG, "nextOperation init" );
+        
         Pair<Target, RemoteOperation> next = null;
         synchronized(mPendingOperations) {
             next = mPendingOperations.peek();
@@ -320,6 +367,7 @@ public class OperationsService extends Service {
             } finally {
                 synchronized(mPendingOperations) {
                     mPendingOperations.poll();
+                    mOperationResults.put(mCurrentOperation.hashCode(), result);
                 }
             }
             
@@ -382,7 +430,9 @@ public class OperationsService extends Service {
      * @param operation         Finished operation.
      * @param result            Result of the operation.
      */
-    private void callbackOperationListeners(Target target, final RemoteOperation operation, final RemoteOperationResult result) {
+    private void callbackOperationListeners(
+            Target target, final RemoteOperation operation, final RemoteOperationResult result) {
+        int count = 0;
         Iterator<OnRemoteOperationListener> listeners = mBinder.mBoundListeners.keySet().iterator();
         while (listeners.hasNext()) {
             final OnRemoteOperationListener listener = listeners.next();
@@ -394,9 +444,10 @@ public class OperationsService extends Service {
                         listener.onRemoteOperationFinish(operation, result);
                     }
                 });
+                count += 1;
             }
         }
-            
+        Log_OC.d(TAG, "Called " + count + " listeners");
     }
     
 
index 42b90ae..c4dd28a 100644 (file)
@@ -150,22 +150,26 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp
     
     @Override 
     protected void onStart() {
-        super.onStart();
+
         if (mAccountWasSet) {
             onAccountSet(mAccountWasRestored);
         }
         if (mOperationsServiceBinder != null) {
             mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler);
         }
+        
+        super.onStart();
     }
     
     
     @Override 
     protected void onStop() {
-        super.onStop();
+
         if (mOperationsServiceBinder != null) {
             mOperationsServiceBinder.removeOperationListener(this);
         }
+        
+        super.onStop();
     }
     
     
index 867e4cf..f6136ed 100644 (file)
@@ -19,6 +19,7 @@
 package com.owncloud.android.ui.activity;
 
 import java.io.File;
+
 import android.accounts.Account;
 import android.app.AlertDialog;
 import android.app.Dialog;