X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/049f659f7710ba18299af5fa28d80f67c6548f88..e42fcc1e32fcf129889e5b58b3bc2a9fda5f4c16:/src/com/owncloud/android/datamodel/FileDataStorageManager.java diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 4ef1ba1e..44d78206 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -838,28 +838,53 @@ public class FileDataStorageManager { return overriden; } - private OCShare getShareById(long id) { - Cursor c = getShareCursorForValue(ProviderTableMeta._ID, String.valueOf(id)); - OCShare share = null; - if (c.moveToFirst()) { - share = createShareInstance(c); - } - c.close(); - return share; - } +// private OCShare getShareById(long id) { +// Cursor c = getShareCursorForValue(ProviderTableMeta._ID, String.valueOf(id)); +// OCShare share = null; +// if (c.moveToFirst()) { +// share = createShareInstance(c); +// } +// c.close(); +// return share; +// } +// +// private OCShare getShareByRemoteId(long remoteId) { +// Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, String.valueOf(remoteId)); +// OCShare share = null; +// if (c.moveToFirst()) { +// share = createShareInstance(c); +// } +// c.close(); +// return share; +// } - private OCShare getShareByRemoteId(long remoteId) { - Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, String.valueOf(remoteId)); - OCShare share = null; - if (c.moveToFirst()) { - share = createShareInstance(c); - } - c.close(); - return share; - } + public OCShare getFirstShareByPathAndType(String path, ShareType type) { + Cursor c = null; + if (getContentResolver() != null) { + c = getContentResolver().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, + ProviderTableMeta.OCSHARES_PATH + "=? AND " + + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?", + new String[] { path, Integer.toString(type.getValue()), mAccount.name }, + null); + } else { + try { + c = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, + ProviderTableMeta.OCSHARES_PATH + "=? AND " + + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?", + new String[] { path, Integer.toString(type.getValue()), mAccount.name }, + null); - public OCShare getShareByPath(String path) { - Cursor c = getShareCursorForValue(ProviderTableMeta.OCSHARES_PATH, path); + } catch (RemoteException e) { + Log_OC.e(TAG, "Could not get file details: " + e.getMessage()); + c = null; + } + } OCShare share = null; if (c.moveToFirst()) { share = createShareInstance(c);