private void onRenameFileOperationFinish(
      RenameFileOperation operation, RemoteOperationResult result) {
    boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
    getActivity()
        .dismissDialog(
            (inDisplayActivity)
                ? FileDisplayActivity.DIALOG_SHORT_WAIT
                : FileDetailActivity.DIALOG_SHORT_WAIT);

    if (result.isSuccess()) {
      updateFileDetails(((RenameFileOperation) operation).getFile(), mAccount);
      mContainerActivity.onFileStateChanged();

    } else {
      if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
        Toast msg =
            Toast.makeText(getActivity(), R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
        msg.show();
        // TODO throw again the new rename dialog
      } else {
        Toast msg =
            Toast.makeText(getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
        msg.show();
        if (result.isSslRecoverableException()) {
          // TODO show the SSL warning dialog
        }
      }
    }
  }
  private boolean tryConnection(WebdavClient wc, String urlSt) {
    boolean retval = false;
    GetMethod get = null;
    try {
      get = new GetMethod(urlSt);
      int status = wc.executeMethod(get, TRY_CONNECTION_TIMEOUT, TRY_CONNECTION_TIMEOUT);
      String response = get.getResponseBodyAsString();
      if (status == HttpStatus.SC_OK) {
        JSONObject json = new JSONObject(response);
        if (!json.getBoolean("installed")) {
          mLatestResult =
              new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
        } else {
          mOCVersion = new OwnCloudVersion(json.getString("version"));
          if (!mOCVersion.isVersionValid()) {
            mLatestResult =
                new RemoteOperationResult(RemoteOperationResult.ResultCode.BAD_OC_VERSION);

          } else {
            mLatestResult =
                new RemoteOperationResult(
                    urlSt.startsWith("https://")
                        ? RemoteOperationResult.ResultCode.OK_SSL
                        : RemoteOperationResult.ResultCode.OK_NO_SSL);

            retval = true;
          }
        }

      } else {
        mLatestResult = new RemoteOperationResult(false, status, get.getResponseHeaders());
      }

    } catch (JSONException e) {
      mLatestResult =
          new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);

    } catch (Exception e) {
      mLatestResult = new RemoteOperationResult(e);

    } finally {
      if (get != null) get.releaseConnection();
    }

    if (mLatestResult.isSuccess()) {
      Log_OC.i(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage());

    } else if (mLatestResult.getException() != null) {
      Log_OC.e(
          TAG,
          "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage(),
          mLatestResult.getException());

    } else {
      Log_OC.e(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage());
    }

    return retval;
  }
  private void onSynchronizeFileOperationFinish(
      SynchronizeFileOperation operation, RemoteOperationResult result) {
    boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
    getActivity()
        .dismissDialog(
            (inDisplayActivity)
                ? FileDisplayActivity.DIALOG_SHORT_WAIT
                : FileDetailActivity.DIALOG_SHORT_WAIT);

    if (!result.isSuccess()) {
      if (result.getCode() == ResultCode.SYNC_CONFLICT) {
        Intent i = new Intent(getActivity(), ConflictsResolveActivity.class);
        i.putExtra(ConflictsResolveActivity.EXTRA_FILE, mFile);
        i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, mAccount);
        startActivity(i);

      } else {
        Toast msg = Toast.makeText(getActivity(), R.string.sync_file_fail_msg, Toast.LENGTH_LONG);
        msg.show();
      }

      if (mFile.isDown()) {
        setButtonsForDown();

      } else {
        setButtonsForRemote();
      }

    } else {
      if (operation.transferWasRequested()) {
        setButtonsForTransferring();
        mContainerActivity
            .onFileStateChanged(); // this is not working; FileDownloader won't do NOTHING at all
                                   // until this method finishes, so
        // checking the service to see if the file is downloading results in FALSE
      } else {
        Toast msg =
            Toast.makeText(getActivity(), R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG);
        msg.show();
        if (mFile.isDown()) {
          setButtonsForDown();

        } else {
          setButtonsForRemote();
        }
      }
    }
  }
  private void onRemoveFileOperationFinish(
      RemoveFileOperation operation, RemoteOperationResult result) {
    boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
    getActivity()
        .dismissDialog(
            (inDisplayActivity)
                ? FileDisplayActivity.DIALOG_SHORT_WAIT
                : FileDetailActivity.DIALOG_SHORT_WAIT);

    if (result.isSuccess()) {
      Toast msg =
          Toast.makeText(
              getActivity().getApplicationContext(),
              R.string.remove_success_msg,
              Toast.LENGTH_LONG);
      msg.show();
      if (inDisplayActivity) {
        // double pane
        FragmentTransaction transaction =
            getActivity().getSupportFragmentManager().beginTransaction();
        transaction.replace(
            R.id.file_details_container,
            new FileDetailFragment(null, null)); // empty FileDetailFragment
        transaction.commit();
        mContainerActivity.onFileStateChanged();
      } else {
        getActivity().finish();
      }

    } else {
      Toast msg = Toast.makeText(getActivity(), R.string.remove_fail_msg, Toast.LENGTH_LONG);
      msg.show();
      if (result.isSslRecoverableException()) {
        // TODO show the SSL warning dialog
      }
    }
  }