X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/0db4fc9b17d0988c64a2949093dbb37230e1db2d..3de67c45e4a2cbd8869ea28ef422eab1762d3e9b:/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 7c94ca26..0b89efc4 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.Vector; import android.accounts.Account; +import android.content.ContentProvider; import android.content.ContentProviderClient; import android.content.ContentProviderOperation; import android.content.ContentProviderResult; @@ -1359,10 +1360,9 @@ public class FileDataStorageManager { // adding a new share resource operations.add( ContentProviderOperation.newInsert(ProviderTableMeta.CONTENT_URI_SHARE). - withValues(cv). - build() + withValues(cv). + build() ); - //} } } @@ -1409,6 +1409,46 @@ public class FileDataStorageManager { return preparedOperations; } + public ArrayList getSharesWithForAFile(String filePath, String accountName){ + // Condition + String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"+ "AND" + + " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR " + + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) "; + String [] whereArgs = new String[]{ filePath, accountName , + Integer.toString(ShareType.USER.getValue()), + Integer.toString(ShareType.GROUP.getValue()) }; + + Cursor c = null; + if (getContentResolver() != null) { + c = getContentResolver().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, where, whereArgs, null); + } else { + try { + c = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, where, whereArgs, null); + + } catch (RemoteException e) { + Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage()); + c = null; + } + } + ArrayList shares = new ArrayList<>(); + OCShare share = null; + if (c.moveToFirst()) { + do { + share = createShareInstance(c); + shares.add(share); + // } + } while (c.moveToNext()); + } + c.close(); + + return shares; + } + public void triggerMediaScan(String path) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(path)));