Ejemplo n.º 1
0
 @Override
 public void onDetach() {
   Log_OC.d(TAG, "onDetach");
   mSsoWebViewClientListener = null;
   mWebViewClient = null;
   super.onDetach();
 }
  /**
   * Listener method to perform the MOVE / CANCEL action available in this activity.
   *
   * @param v Clicked view (button MOVE or CANCEL)
   */
  @Override
  public void onClick(View v) {
    if (v.getId() == R.id.ok) {
      /// perform movement operation in background thread
      Log_OC.d(TAG, "Clicked MOVE, start movement");
      new MoveFilesTask().execute();

    } else if (v.getId() == R.id.cancel) {
      /// just finish
      Log_OC.d(TAG, "Clicked CANCEL, bye");
      finish();

    } else {
      Log_OC.e(TAG, "Clicked phantom button, id: " + v.getId());
    }
  }
Ejemplo n.º 3
0
  private RemoteOperationResult(boolean success, int httpCode) {
    mSuccess = success;
    mHttpCode = httpCode;

    if (success) {
      mCode = ResultCode.OK;

    } else if (httpCode > 0) {
      switch (httpCode) {
        case HttpStatus.SC_UNAUTHORIZED:
          mCode = ResultCode.UNAUTHORIZED;
          break;
        case HttpStatus.SC_NOT_FOUND:
          mCode = ResultCode.FILE_NOT_FOUND;
          break;
        case HttpStatus.SC_INTERNAL_SERVER_ERROR:
          mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
          break;
        case HttpStatus.SC_CONFLICT:
          mCode = ResultCode.CONFLICT;
          break;
        case HttpStatus.SC_INSUFFICIENT_STORAGE:
          mCode = ResultCode.QUOTA_EXCEEDED;
          break;
        default:
          mCode = ResultCode.UNHANDLED_HTTP_CODE;
          Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
      }
    }
  }
Ejemplo n.º 4
0
 /**
  * Public factory method to get dialog instances.
  *
  * @param handler
  * @param Url Url to open at WebView
  * @param targetURL mHostBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion,
  *     mCurrentAuthTokenType)
  * @return New dialog instance, ready to show.
  */
 public static SamlWebViewDialog newInstance(String url, String targetUrl) {
   Log_OC.d(TAG, "New instance");
   SamlWebViewDialog fragment = new SamlWebViewDialog();
   Bundle args = new Bundle();
   args.putString(ARG_INITIAL_URL, url);
   args.putString(ARG_TARGET_URL, targetUrl);
   fragment.setArguments(args);
   return fragment;
 }
Ejemplo n.º 5
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateView");

    // Inflate layout of the dialog
    View rootView =
        inflater.inflate(
            R.layout.sso_dialog,
            container,
            false); // null parent view because it will go in the dialog layout
    mSsoWebView = (WebView) rootView.findViewById(R.id.sso_webview);

    mWebViewClient.setTargetUrl(mTargetUrl);
    mSsoWebView.setWebViewClient(mWebViewClient);

    if (savedInstanceState == null) {
      Log_OC.d(TAG, "   initWebView start");
      CookieManager cookieManager = CookieManager.getInstance();
      cookieManager.setAcceptCookie(true);
      cookieManager.removeAllCookie();
      mSsoWebView.loadUrl(mInitialUrl);

    } else {
      Log_OC.d(TAG, "   restoreWebView start");
      WebBackForwardList history =
          mSsoWebView.restoreState(savedInstanceState.getBundle(KEY_WEBVIEW_STATE));
      if (history == null) {
        Log_OC.e(TAG, "Error restoring WebView state ; back to starting URL");
        mSsoWebView.loadUrl(mInitialUrl);
      }
    }

    WebSettings webSettings = mSsoWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setLoadWithOverviewMode(false);
    webSettings.setSavePassword(false);
    webSettings.setUserAgentString(WebdavClient.USER_AGENT);
    webSettings.setSaveFormData(false);

    return rootView;
  }
Ejemplo n.º 6
0
  @Override
  public void onSaveInstanceState(Bundle outState) {
    Log_OC.d(SAML_DIALOG_TAG, "onSaveInstanceState being CALLED");
    super.onSaveInstanceState(outState);

    // save URLs
    outState.putString(ARG_INITIAL_URL, mInitialUrl);
    outState.putString(ARG_TARGET_URL, mTargetUrl);

    // Save the state of the WebView
    Bundle webviewState = new Bundle();
    mSsoWebView.saveState(webviewState);
    outState.putBundle(KEY_WEBVIEW_STATE, webviewState);
  }
Ejemplo n.º 7
0
  /**
   * Update the size of a subtree of folder from a file to the root
   *
   * @param parentId: parent of the file
   */
  private void updateSizesToTheRoot(long parentId) {

    OCFile file;

    while (parentId != 0) {

      Log_OC.d(TAG, "parent = " + parentId);
      // Update the size of the parent
      calculateFolderSize(parentId);

      // search the next parent
      file = getFileById(parentId);
      parentId = file.getParentId();
    }
  }
Ejemplo n.º 8
0
  @Override
  public void onAttach(Activity activity) {
    Log_OC.d(TAG, "onAttach");
    super.onAttach(activity);
    try {
      mSsoWebViewClientListener = (SsoWebViewClientListener) activity;
      mHandler = new Handler();
      mWebViewClient = new SsoWebViewClient(mHandler, mSsoWebViewClientListener);

    } catch (ClassCastException e) {
      throw new ClassCastException(
          activity.toString()
              + " must implement "
              + SsoWebViewClientListener.class.getSimpleName());
    }
  }
Ejemplo n.º 9
0
  @Override
  public void onDestroyView() {
    Log_OC.d(TAG, "onDestroyView");

    mSsoWebView.setWebViewClient(null);

    // Work around bug: http://code.google.com/p/android/issues/detail?id=17423
    Dialog dialog = getDialog();
    if ((dialog != null)) {
      dialog.setOnDismissListener(null);
      // dialog.dismiss();
      // dialog.setDismissMessage(null);
    }

    super.onDestroyView();
  }
Ejemplo n.º 10
0
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreateDialog");

    /*
    // build the dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity());
    if (mSsoRootView.getParent() != null) {
        ((ViewGroup)(mSsoRootView.getParent())).removeView(mSsoRootView);
    }
    builder.setView(mSsoRootView);
    //builder.setView(mSsoWebView);
    Dialog dialog = builder.create();
    */

    return super.onCreateDialog(savedInstanceState);
  }
Ejemplo n.º 11
0
  @SuppressLint("SetJavaScriptEnabled")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log_OC.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    CookieSyncManager.createInstance(getActivity());

    if (savedInstanceState == null) {
      mInitialUrl = getArguments().getString(ARG_INITIAL_URL);
      mTargetUrl = getArguments().getString(ARG_TARGET_URL);
    } else {
      mInitialUrl = savedInstanceState.getString(ARG_INITIAL_URL);
      mTargetUrl = savedInstanceState.getString(ARG_TARGET_URL);
    }

    setStyle(SherlockDialogFragment.STYLE_NO_TITLE, R.style.Theme_ownCloud_Dialog);
  }
Ejemplo n.º 12
0
  @Override
  protected RemoteOperationResult run(WebdavClient client) {
    if (!isOnline()) {
      return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION);
    }
    if (mUrl.startsWith("http://") || mUrl.startsWith("https://")) {
      tryConnection(client, mUrl + AccountUtils.STATUS_PATH);

    } else {
      client.setBaseUri(Uri.parse("https://" + mUrl + AccountUtils.STATUS_PATH));
      boolean httpsSuccess = tryConnection(client, "https://" + mUrl + AccountUtils.STATUS_PATH);
      if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) {
        Log_OC.d(TAG, "establishing secure connection failed, trying non secure connection");
        client.setBaseUri(Uri.parse("http://" + mUrl + AccountUtils.STATUS_PATH));
        tryConnection(client, "http://" + mUrl + AccountUtils.STATUS_PATH);
      }
    }
    return mLatestResult;
  }
 /**
  * Returns the local store of reliable server certificates, explicitly accepted by the user.
  *
  * <p>Returns a KeyStore instance with empty content if the local store was never created.
  *
  * <p>Loads the store from the storage environment if needed.
  *
  * @param context Android context where the operation is being performed.
  * @return KeyStore instance with explicitly-accepted server certificates.
  * @throws KeyStoreException When the KeyStore instance could not be created.
  * @throws IOException When an existing local trust store could not be loaded.
  * @throws NoSuchAlgorithmException When the existing local trust store was saved with an
  *     unsupported algorithm.
  * @throws CertificateException When an exception occurred while loading the certificates from the
  *     local trust store.
  */
 private static KeyStore getKnownServersStore(Context context)
     throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
   if (mKnownServersStore == null) {
     // mKnownServersStore = KeyStore.getInstance("BKS");
     mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
     File localTrustStoreFile = new File(context.getFilesDir(), LOCAL_TRUSTSTORE_FILENAME);
     Log_OC.d(TAG, "Searching known-servers store at " + localTrustStoreFile.getAbsolutePath());
     if (localTrustStoreFile.exists()) {
       InputStream in = new FileInputStream(localTrustStoreFile);
       try {
         mKnownServersStore.load(in, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
       } finally {
         in.close();
       }
     } else {
       mKnownServersStore.load(
           null,
           LOCAL_TRUSTSTORE_PASSWORD
               .toCharArray()); // necessary to initialize an empty KeyStore instance
     }
   }
   return mKnownServersStore;
 }
Ejemplo n.º 14
0
 @Override
 public void onCancel(DialogInterface dialog) {
   Log_OC.d(SAML_DIALOG_TAG, "onCancel");
   super.onCancel(dialog);
 }
Ejemplo n.º 15
0
 @Override
 public void onDestroy() {
   Log_OC.d(TAG, "onDestroy");
   super.onDestroy();
 }
Ejemplo n.º 16
0
 public SamlWebViewDialog() {
   super();
   Log_OC.d(TAG, "constructor");
 }
Ejemplo n.º 17
0
 @Override
 public void onDismiss(DialogInterface dialog) {
   Log_OC.d(SAML_DIALOG_TAG, "onDismiss");
   super.onDismiss(dialog);
 }
Ejemplo n.º 18
0
 @Override
 public void show(FragmentManager manager, String tag) {
   Log_OC.d(SAML_DIALOG_TAG, "show (manager)");
   super.show(manager, tag);
 }
Ejemplo n.º 19
0
 @Override
 public int show(FragmentTransaction transaction, String tag) {
   Log_OC.d(SAML_DIALOG_TAG, "show (transaction)");
   return super.show(transaction, tag);
 }
Ejemplo n.º 20
0
 @Override
 public void onPause() {
   Log_OC.d(SAML_DIALOG_TAG, "onPause");
   super.onPause();
 }
Ejemplo n.º 21
0
 @Override
 public void onStop() {
   Log_OC.d(SAML_DIALOG_TAG, "onStop");
   super.onStop();
 }