/** * Creates a WebdavClient to access a URL and sets the desired parameters for ownCloud client * connections. * * @param uri URL to the ownCloud server * @param context Android context where the WebdavClient is being created. * @return A WebdavClient object ready to be used */ public static WebdavClient createOwnCloudClient( Uri uri, Context context, boolean followRedirects) { try { registerAdvancedSslContext(true, context); } catch (GeneralSecurityException e) { Log_OC.e( TAG, "Advanced SSL Context could not be loaded. Default SSL management in the system will be used for HTTPS connections", e); } catch (IOException e) { Log_OC.e( TAG, "The local server truststore could not be read. Default SSL management in the system will be used for HTTPS connections", e); } WebdavClient client = new WebdavClient(getMultiThreadedConnManager()); client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); client.setBaseUri(uri); client.setFollowRedirects(followRedirects); return client; }
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; }
/** * 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()); } }
@Override public void onDetach() { Log_OC.d(TAG, "onDetach"); mSsoWebViewClientListener = null; mWebViewClient = null; super.onDetach(); }
private Cursor getCursorForValue(String key, String value) { Cursor c = null; if (getContentResolver() != null) { c = getContentResolver() .query( ProviderTableMeta.CONTENT_URI, null, key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", new String[] {value, mAccount.name}, null); } else { try { c = getContentProvider() .query( ProviderTableMeta.CONTENT_URI, null, key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", new String[] {value, mAccount.name}, null); } catch (RemoteException e) { Log_OC.e(TAG, "Could not get file details: " + e.getMessage()); c = null; } } return c; }
private boolean fileExists(String cmp_key, String value) { Cursor c; if (getContentResolver() != null) { c = getContentResolver() .query( ProviderTableMeta.CONTENT_URI, null, cmp_key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", new String[] {value, mAccount.name}, null); } else { try { c = getContentProvider() .query( ProviderTableMeta.CONTENT_URI, null, cmp_key + "=? AND " + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", new String[] {value, mAccount.name}, null); } catch (RemoteException e) { Log_OC.e( TAG, "Couldn't determine file existance, assuming non existance: " + e.getMessage()); return false; } } boolean retval = c.moveToFirst(); c.close(); return retval; }
/** Update the size value of an OCFile in DB */ private int updateSize(long id, long size) { ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, size); int result = -1; if (getContentResolver() != null) { result = getContentResolver() .update( ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?", new String[] {String.valueOf(id)}); } else { try { result = getContentProvider() .update( ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?", new String[] {String.valueOf(id)}); } catch (RemoteException e) { Log_OC.e(TAG, "Fail to update size column into database " + e.getMessage()); } } return result; }
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); } } }
/** * 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; }
@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; }
@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); }
/** * 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(); } }
@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(); }
@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()); } }
@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); }
private Vector<OCFile> getDirectoryContent(long parentId) { Vector<OCFile> ret = new Vector<OCFile>(); Uri req_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(parentId)); Cursor c = null; if (getContentProvider() != null) { try { c = getContentProvider() .query( req_uri, null, ProviderTableMeta.FILE_PARENT + "=?", new String[] {String.valueOf(parentId)}, null); } catch (RemoteException e) { Log_OC.e(TAG, e.getMessage()); return ret; } } else { c = getContentResolver() .query( req_uri, null, ProviderTableMeta.FILE_PARENT + "=?", new String[] {String.valueOf(parentId)}, null); } if (c.moveToFirst()) { do { OCFile child = createFileInstance(c); ret.add(child); } while (c.moveToNext()); } c.close(); Collections.sort(ret); return ret; }
@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); }
@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; }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.cancelBtn: { FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) { downloaderBinder.cancel(mAccount, getFile()); getActivity().finish(); // :) /* leaveTransferProgress(); if (mFile.isDown()) { setButtonsForDown(); } else { setButtonsForRemote(); } */ } break; } default: Log_OC.e(TAG, "Incorrect view clicked!"); } }
/** * Updates database for a folder that was moved to a different location. * * <p>TODO explore better (faster) implementations TODO throw exceptions up ! */ @Override public void moveDirectory(OCFile dir, String newPath) { // TODO check newPath if (dir != null && dir.isDirectory() && dir.fileExists() && !dir.getFileName().equals(OCFile.PATH_SEPARATOR)) { /// 1. get all the descendants of 'dir' in a single QUERY (including 'dir') Cursor c = null; if (getContentProvider() != null) { try { c = getContentProvider() .query( ProviderTableMeta.CONTENT_URI, null, ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ", new String[] {mAccount.name, dir.getRemotePath() + "%"}, ProviderTableMeta.FILE_PATH + " ASC "); } catch (RemoteException e) { Log_OC.e(TAG, e.getMessage()); } } else { c = getContentResolver() .query( ProviderTableMeta.CONTENT_URI, null, ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + ProviderTableMeta.FILE_PATH + " LIKE ? ", new String[] {mAccount.name, dir.getRemotePath() + "%"}, ProviderTableMeta.FILE_PATH + " ASC "); } /// 2. prepare a batch of update operations to change all the descendants ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(c.getCount()); int lengthOfOldPath = dir.getRemotePath().length(); String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name); int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath; if (c.moveToFirst()) { do { ContentValues cv = new ContentValues(); // don't take the constructor out of the loop and clear the // object OCFile child = createFileInstance(c); cv.put( ProviderTableMeta.FILE_PATH, newPath + child.getRemotePath().substring(lengthOfOldPath)); if (child.getStoragePath() != null && child.getStoragePath().startsWith(defaultSavePath)) { cv.put( ProviderTableMeta.FILE_STORAGE_PATH, defaultSavePath + newPath + child.getStoragePath().substring(lengthOfOldStoragePath)); } operations.add( ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI) .withValues(cv) .withSelection( ProviderTableMeta._ID + "=?", new String[] {String.valueOf(child.getFileId())}) .build()); } while (c.moveToNext()); } c.close(); /// 3. apply updates in batch try { if (getContentResolver() != null) { getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations); } else { getContentProvider().applyBatch(operations); } } catch (OperationApplicationException e) { Log_OC.e(TAG, "Fail to update descendants of " + dir.getFileId() + " in database", e); } catch (RemoteException e) { Log_OC.e(TAG, "Fail to update desendants of " + dir.getFileId() + " in database", e); } } }
@Override public void saveFiles(List<OCFile> files) { Iterator<OCFile> filesIt = files.iterator(); ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>(files.size()); OCFile file = null; // prepare operations to perform while (filesIt.hasNext()) { file = filesIt.next(); ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp()); cv.put( ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, file.getModificationTimestampAtLastSyncForData()); cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp()); cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength()); cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype()); cv.put(ProviderTableMeta.FILE_NAME, file.getFileName()); if (file.getParentId() != 0) cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId()); cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath()); if (!file.isDirectory()) cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData()); cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); if (fileExists(file.getRemotePath())) { OCFile oldFile = getFileByPath(file.getRemotePath()); file.setFileId(oldFile.getFileId()); if (file.isDirectory()) { cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength()); file.setFileLength(oldFile.getFileLength()); } operations.add( ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI) .withValues(cv) .withSelection( ProviderTableMeta._ID + "=?", new String[] {String.valueOf(file.getFileId())}) .build()); } else if (fileExists(file.getFileId())) { OCFile oldFile = getFileById(file.getFileId()); if (file.getStoragePath() == null && oldFile.getStoragePath() != null) file.setStoragePath(oldFile.getStoragePath()); if (!file.isDirectory()) cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); else { cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, oldFile.getFileLength()); file.setFileLength(oldFile.getFileLength()); } operations.add( ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI) .withValues(cv) .withSelection( ProviderTableMeta._ID + "=?", new String[] {String.valueOf(file.getFileId())}) .build()); } else { operations.add( ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI) .withValues(cv) .build()); } } // apply operations in batch ContentProviderResult[] results = null; try { if (getContentResolver() != null) { results = getContentResolver().applyBatch(ProviderMeta.AUTHORITY_FILES, operations); } else { results = getContentProvider().applyBatch(operations); } } catch (OperationApplicationException e) { Log_OC.e(TAG, "Fail to update/insert list of files to database " + e.getMessage()); } catch (RemoteException e) { Log_OC.e(TAG, "Fail to update/insert list of files to database " + e.getMessage()); } // update new id in file objects for insertions if (results != null) { long newId; for (int i = 0; i < results.length; i++) { if (results[i].uri != null) { newId = Long.parseLong(results[i].uri.getPathSegments().get(1)); files.get(i).setFileId(newId); // Log_OC.v(TAG, "Found and added id in insertion for " + files.get(i).getRemotePath()); } } } for (OCFile aFile : files) { if (aFile.isDirectory() && aFile.needsUpdatingWhileSaving()) saveFiles(getDirectoryContent(aFile)); } }
@Override public boolean saveFile(OCFile file) { boolean overriden = false; ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_MODIFIED, file.getModificationTimestamp()); cv.put( ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA, file.getModificationTimestampAtLastSyncForData()); cv.put(ProviderTableMeta.FILE_CREATION, file.getCreationTimestamp()); cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, file.getFileLength()); cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, file.getMimetype()); cv.put(ProviderTableMeta.FILE_NAME, file.getFileName()); if (file.getParentId() != 0) cv.put(ProviderTableMeta.FILE_PARENT, file.getParentId()); cv.put(ProviderTableMeta.FILE_PATH, file.getRemotePath()); if (!file.isDirectory()) cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getStoragePath()); cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, mAccount.name); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties()); cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData()); cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0); boolean sameRemotePath = fileExists(file.getRemotePath()); boolean changesSizeOfAncestors = false; if (sameRemotePath || fileExists(file.getFileId())) { // for renamed files; no more delete and create OCFile oldFile = null; if (sameRemotePath) { oldFile = getFileByPath(file.getRemotePath()); file.setFileId(oldFile.getFileId()); } else { oldFile = getFileById(file.getFileId()); } changesSizeOfAncestors = (oldFile.getFileLength() != file.getFileLength()); overriden = true; if (getContentResolver() != null) { getContentResolver() .update( ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?", new String[] {String.valueOf(file.getFileId())}); } else { try { getContentProvider() .update( ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID + "=?", new String[] {String.valueOf(file.getFileId())}); } catch (RemoteException e) { Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage()); } } } else { changesSizeOfAncestors = true; Uri result_uri = null; if (getContentResolver() != null) { result_uri = getContentResolver().insert(ProviderTableMeta.CONTENT_URI_FILE, cv); } else { try { result_uri = getContentProvider().insert(ProviderTableMeta.CONTENT_URI_FILE, cv); } catch (RemoteException e) { Log_OC.e(TAG, "Fail to insert insert file to database " + e.getMessage()); } } if (result_uri != null) { long new_id = Long.parseLong(result_uri.getPathSegments().get(1)); file.setFileId(new_id); } } if (file.isDirectory()) { calculateFolderSize(file.getFileId()); if (file.needsUpdatingWhileSaving()) { for (OCFile f : getDirectoryContent(file)) saveFile(f); } } if (changesSizeOfAncestors || file.isDirectory()) { updateSizesToTheRoot(file.getParentId()); } return overriden; }
public SamlWebViewDialog() { super(); Log_OC.d(TAG, "constructor"); }
@Override public void onCancel(DialogInterface dialog) { Log_OC.d(SAML_DIALOG_TAG, "onCancel"); super.onCancel(dialog); }
@Override public void onPause() { Log_OC.d(SAML_DIALOG_TAG, "onPause"); super.onPause(); }
@Override public void onStop() { Log_OC.d(SAML_DIALOG_TAG, "onStop"); super.onStop(); }
@Override public void onDismiss(DialogInterface dialog) { Log_OC.d(SAML_DIALOG_TAG, "onDismiss"); super.onDismiss(dialog); }
@Override public int show(FragmentTransaction transaction, String tag) { Log_OC.d(SAML_DIALOG_TAG, "show (transaction)"); return super.show(transaction, tag); }
@Override public void show(FragmentManager manager, String tag) { Log_OC.d(SAML_DIALOG_TAG, "show (manager)"); super.show(manager, tag); }