import java.util.Vector;
import android.accounts.Account;
-import android.content.ContentProvider;
import android.content.ContentProviderClient;
import android.content.ContentProviderOperation;
import android.content.ContentProviderResult;
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, file.isSharedViaUsers() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, file.isSharedViaUsers() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, folder.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, folder.getEtag());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, folder.isSharedViaLink() ? 1 : 0);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, folder.isSharedViaUsers() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, folder.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, folder.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, folder.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, folder.getRemoteId());
file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG)));
file.setShareViaLink(c.getInt(
c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_LINK)) == 1 ? true : false);
- file.setShareViaUsers(c.getInt(
- c.getColumnIndex(ProviderTableMeta.FILE_SHARED_VIA_USERS)) == 1 ? true : false);
+ file.setShareWithSharee(c.getInt(
+ c.getColumnIndex(ProviderTableMeta.FILE_SHARED_WITH_SHAREE)) == 1 ? true : false);
file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK)));
file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS)));
file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID)));
private void resetShareFlagsInAllFiles() {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?";
String[] whereArgs = new String[]{mAccount.name};
private void resetShareFlagsInFolder(OCFile folder) {
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
ProviderTableMeta.FILE_PARENT + "=?";
private void resetShareFlagInAFile(String filePath){
ContentValues cv = new ContentValues();
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, false);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, false);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, false);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, "");
String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " +
ProviderTableMeta.FILE_PATH+ "=?";
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.isFavorite() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
cv.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, file.isSharedViaLink() ? 1 : 0);
- cv.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, file.isSharedViaUsers() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, file.isSharedWithSharee() ? 1 : 0);
cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink());
cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions());
cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId());
private String mEtagInConflict; // Save file etag in the server, when there is a conflict. No conflict = null
- private boolean mShareWithUser;
+ private boolean mShareWithSharee;
/**
mNeedsUpdateThumbnail = source.readInt() == 1;
mIsDownloading = source.readInt() == 1;
mEtagInConflict = source.readString();
- mShareWithUser = source.readInt() == 1;
+ mShareWithSharee = source.readInt() == 1;
}
dest.writeInt(mNeedsUpdateThumbnail ? 1 : 0);
dest.writeInt(mIsDownloading ? 1 : 0);
dest.writeString(mEtagInConflict);
- dest.writeInt(mShareWithUser ? 1 : 0);
+ dest.writeInt(mShareWithSharee ? 1 : 0);
}
/**
mNeedsUpdateThumbnail = false;
mIsDownloading = false;
mEtagInConflict = null;
- mShareWithUser = false;
+ mShareWithSharee = false;
}
/**
mEtagInConflict = etagInConflict;
}
- public boolean isSharedViaUsers() {
- return mShareWithUser;
+ public boolean isSharedWithSharee() {
+ return mShareWithSharee;
}
- public void setShareViaUsers(boolean shareWithUser) {
- this.mShareWithUser = shareWithUser;
+ public void setShareWithSharee(boolean shareWithSharee) {
+ this.mShareWithSharee = shareWithSharee;
}
public boolean isSharedWithMe() {
public static final String FILE_KEEP_IN_SYNC = "keep_in_sync";\r
public static final String FILE_ETAG = "etag";\r
public static final String FILE_SHARED_VIA_LINK = "share_by_link";\r
- public static final String FILE_SHARED_VIA_USERS = "shared_via_users";\r
+ public static final String FILE_SHARED_WITH_SHAREE = "shared_via_users";\r
public static final String FILE_PUBLIC_LINK = "public_link";\r
public static final String FILE_PERMISSIONS = "permissions";\r
public static final String FILE_REMOTE_ID = "remote_id";\r
getString(R.string.wait_a_moment));
Intent service = new Intent(mFileActivity, OperationsService.class);
- service.setAction(OperationsService.ACTION_CREATE_SHARE);
+ service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
service.putExtra(OperationsService.EXTRA_PASSWORD_SHARE, password);
+++ /dev/null
-/**
- * ownCloud Android client application
- *
- * @author masensio
- * Copyright (C) 2015 ownCloud Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.operations;
-
-/**
- * Creates a new share from a given file
- */
-
-
-import android.content.Context;
-import android.content.Intent;
-
-import com.owncloud.android.R;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.lib.common.OwnCloudClient;
-import com.owncloud.android.lib.common.operations.RemoteOperation;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.lib.resources.files.FileUtils;
-import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation;
-import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
-import com.owncloud.android.lib.resources.shares.OCShare;
-import com.owncloud.android.lib.resources.shares.ShareType;
-import com.owncloud.android.operations.common.SyncOperation;
-
-public class CreateShareOperation extends SyncOperation {
-
- private static final String TAG = CreateShareOperation.class.getSimpleName();
-
- protected FileDataStorageManager mStorageManager;
-
- private String mPath;
- private ShareType mShareType;
- private String mShareWith;
- private boolean mPublicUpload;
- private String mPassword;
- private int mPermissions;
- private Intent mSendIntent;
- private String mFileName;
-
- /**
- * Constructor
- * @param path Full path of the file/folder being shared. Mandatory argument
- * @param shareType 0 = user, 1 = group, 3 = Public link. Mandatory argument
- * @param shareWith User/group ID with who the file should be shared.
- * This is mandatory for shareType of 0 or 1
- * @param publicUpload If false (default) public cannot upload to a public shared folder.
- * If true public can upload to a shared folder.
- * Only available for public link shares
- * @param password Password to protect a public link share.
- * Only available for public link shares
- * @param permissions 1 - Read only - Default for public shares
- * 2 - Update
- * 4 - Create
- * 8 - Delete
- * 16- Re-share
- * 31- All above - Default for private shares
- * For user or group shares.
- * To obtain combinations, add the desired values together.
- * For instance, for Re-Share, delete, read, update, add 16+8+2+1 = 27.
- * @param sendIntent Optional Intent with the information of an app where the link to the new share (if public)
- * should be posted later.
- */
- public CreateShareOperation(String path, ShareType shareType, String shareWith,
- boolean publicUpload, String password, int permissions, Intent sendIntent) {
-
- mPath = path;
- mShareType = shareType;
- mShareWith = shareWith != null ? shareWith : "";
- mPublicUpload = publicUpload;
- mPassword = password;
- mPermissions = permissions;
- mSendIntent = sendIntent;
- mFileName = null;
- }
-
- @Override
- protected RemoteOperationResult run(OwnCloudClient client) {
- // Check if the share link already exists
- RemoteOperation operation = new GetRemoteSharesForFileOperation(mPath, false, false);
- RemoteOperationResult result = operation.execute(client);
-
- if (!result.isSuccess() || result.getData().size() <= 0) {
- operation = new CreateRemoteShareOperation(
- mPath, mShareType, mShareWith,
- mPublicUpload, mPassword, mPermissions
- );
- result = operation.execute(client);
- }
-
- if (result.isSuccess()) {
- if (result.getData().size() > 0) {
- OCShare share = (OCShare) result.getData().get(0);
- updateData(share);
- }
- }
-
- return result;
- }
-
- public String getPath() {
- return mPath;
- }
-
- public ShareType getShareType() {
- return mShareType;
- }
-
- public String getShareWith() {
- return mShareWith;
- }
-
- public boolean getPublicUpload() {
- return mPublicUpload;
- }
-
- public String getPassword() {
- return mPassword;
- }
-
- public int getPermissions() {
- return mPermissions;
- }
-
- public Intent getSendIntent() {
- return mSendIntent;
- }
-
- public Intent getSendIntentWithSubject(Context context) {
- if (context != null && mSendIntent != null && mSendIntent.getStringExtra(Intent.EXTRA_SUBJECT) != null) {
- if (getClient() == null || getClient().getCredentials().getUsername() == null) {
- mSendIntent.putExtra(
- Intent.EXTRA_SUBJECT,
- context.getString(R.string.subject_shared_with_you, mFileName)
- );
- } else {
- mSendIntent.putExtra(
- Intent.EXTRA_SUBJECT,
- context.getString(
- R.string.subject_user_shared_with_you,
- getClient().getCredentials().getUsername(),
- mFileName
- )
- );
- }
- }
- return mSendIntent;
- }
-
- private void updateData(OCShare share) {
- // Update DB with the response
- share.setPath(mPath);
- if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
- share.setIsFolder(true);
- } else {
- share.setIsFolder(false);
- }
- share.setPermissions(mPermissions);
-
- getStorageManager().saveShare(share);
-
- // Update OCFile with data from share: ShareByLink and publicLink
- OCFile file = getStorageManager().getFileByPath(mPath);
- if (file!=null) {
- mSendIntent.putExtra(Intent.EXTRA_TEXT, share.getShareLink());
- file.setPublicLink(share.getShareLink());
- file.setShareViaLink(true);
- getStorageManager().saveFile(file);
- }
- }
-
-}
--- /dev/null
+/**
+ * ownCloud Android client application
+ *
+ * @author masensio
+ * @author David A. Velasco
+ * Copyright (C) 2015 ownCloud Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.operations;
+
+/**
+ * Creates a new public share for a given file
+ */
+
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.owncloud.android.R;
+import com.owncloud.android.datamodel.FileDataStorageManager;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation;
+import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.operations.common.SyncOperation;
+
+public class CreateShareViaLinkOperation extends SyncOperation {
+
+ private static final int READ_ONLY = 1;
+
+ protected FileDataStorageManager mStorageManager;
+
+ private String mPath;
+ private String mPassword;
+ private Intent mSendIntent;
+ private String mFileName;
+
+ /**
+ * Constructor
+ * @param path Full path of the file/folder being shared. Mandatory argument
+ * @param password Password to protect a public link share.
+ * Only available for public link shares
+ * @param sendIntent Optional Intent with the information of an app where the link to the new share (if public)
+ * should be posted later.
+ */
+ public CreateShareViaLinkOperation(
+ String path,
+ String password,
+ Intent sendIntent
+ ) {
+
+ mPath = path;
+ mPassword = password;
+ mSendIntent = sendIntent;
+ mFileName = null;
+ }
+
+ @Override
+ protected RemoteOperationResult run(OwnCloudClient client) {
+ // Check if the share link already exists
+ RemoteOperation operation = new GetRemoteSharesForFileOperation(mPath, false, false);
+ RemoteOperationResult result = operation.execute(client);
+ // TODO - fix this check; if the user already shared the file with users or group, a share via link will not be created
+
+ if (!result.isSuccess() || result.getData().size() <= 0) {
+ operation = new CreateRemoteShareOperation(
+ mPath,
+ ShareType.PUBLIC_LINK,
+ "",
+ false,
+ mPassword,
+ READ_ONLY
+ );
+ result = operation.execute(client);
+ }
+
+ if (result.isSuccess()) {
+ if (result.getData().size() > 0) {
+ OCShare share = (OCShare) result.getData().get(0);
+ updateData(share);
+ }
+ }
+
+ return result;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ public String getPassword() {
+ return mPassword;
+ }
+
+ public Intent getSendIntent() {
+ return mSendIntent;
+ }
+
+ public Intent getSendIntentWithSubject(Context context) {
+ if (context != null && mSendIntent != null && mSendIntent.getStringExtra(Intent.EXTRA_SUBJECT) != null) {
+ if (getClient() == null || getClient().getCredentials().getUsername() == null) {
+ mSendIntent.putExtra(
+ Intent.EXTRA_SUBJECT,
+ context.getString(R.string.subject_shared_with_you, mFileName)
+ );
+ } else {
+ mSendIntent.putExtra(
+ Intent.EXTRA_SUBJECT,
+ context.getString(
+ R.string.subject_user_shared_with_you,
+ getClient().getCredentials().getUsername(),
+ mFileName
+ )
+ );
+ }
+ }
+ return mSendIntent;
+ }
+
+ private void updateData(OCShare share) {
+ // Update DB with the response
+ share.setPath(mPath);
+ if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
+ share.setIsFolder(true);
+ } else {
+ share.setIsFolder(false);
+ }
+ share.setPermissions(READ_ONLY);
+
+ getStorageManager().saveShare(share);
+
+ // Update OCFile with data from share: ShareByLink and publicLink
+ OCFile file = getStorageManager().getFileByPath(mPath);
+ if (file!=null) {
+ mSendIntent.putExtra(Intent.EXTRA_TEXT, share.getShareLink());
+ file.setPublicLink(share.getShareLink());
+ file.setShareViaLink(true);
+ getStorageManager().saveFile(file);
+ }
+ }
+
+}
--- /dev/null
+/**
+ * ownCloud Android client application
+ *
+ * @author masensio
+ * @author David A. Velasco
+ * Copyright (C) 2015 ownCloud Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.operations;
+
+/**
+ * Creates a new private share for a given file
+ */
+
+
+import com.owncloud.android.datamodel.FileDataStorageManager;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation;
+import com.owncloud.android.lib.resources.shares.OCShare;
+import com.owncloud.android.lib.resources.shares.ShareType;
+import com.owncloud.android.operations.common.SyncOperation;
+
+public class CreateShareWithShareeOperation extends SyncOperation {
+
+ private static final int READ_ONLY = 1;
+
+ protected FileDataStorageManager mStorageManager;
+
+ private String mPath;
+ private String mTargetName;
+ private boolean mWithGroup;
+
+ /**
+ * Constructor
+ * @param path Full path of the file/folder being shared. Mandatory argument
+ */
+ public CreateShareWithShareeOperation(
+ String path,
+ String targetName,
+ boolean withGroup
+ ) {
+
+ mPath = path;
+ mTargetName = targetName;
+ mWithGroup = withGroup;
+ }
+
+ @Override
+ protected RemoteOperationResult run(OwnCloudClient client) {
+ // Check if the share link already exists
+ // TODO or not
+ /*
+ RemoteOperation operation = new GetRemoteSharesForFileOperation(mPath, false, false);
+ RemoteOperationResult result = operation.execute(client);
+ if (!result.isSuccess() || result.getData().size() <= 0) {
+ */
+
+ RemoteOperation operation = new CreateRemoteShareOperation(
+ mPath,
+ (mWithGroup ? ShareType.GROUP : ShareType.USER),
+ mTargetName,
+ false,
+ "",
+ READ_ONLY
+ );
+ RemoteOperationResult result = operation.execute(client);
+
+
+ if (result.isSuccess()) {
+ if (result.getData().size() > 0) {
+ OCShare share = (OCShare) result.getData().get(0);
+ updateData(share);
+ }
+ }
+
+ return result;
+ }
+
+ public String getPath() {
+ return mPath;
+ }
+
+ private void updateData(OCShare share) {
+ // Update DB with the response
+ share.setPath(mPath);
+ if (mPath.endsWith(FileUtils.PATH_SEPARATOR)) {
+ share.setIsFolder(true);
+ } else {
+ share.setIsFolder(false);
+ }
+ share.setPermissions(READ_ONLY);
+
+ getStorageManager().saveShare(share);
+
+ // Update OCFile with data from share: ShareByLink and publicLink
+ OCFile file = getStorageManager().getFileByPath(mPath);
+ if (file!=null) {
+ file.setShareWithSharee(true); // TODO - this should be done by the FileContentProvider, as part of getStorageManager().saveShare(share)
+ getStorageManager().saveFile(file);
+ }
+ }
+
+}
}
updatedFile.setPublicLink(localFile.getPublicLink());
updatedFile.setShareViaLink(localFile.isSharedViaLink());
- updatedFile.setShareViaUsers(localFile.isSharedViaUsers());
+ updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
updatedFile.setEtagInConflict(localFile.getEtagInConflict());
} else {
// remote eTag will not be updated unless file CONTENTS are synchronized
}
updatedFile.setPublicLink(localFile.getPublicLink());
updatedFile.setShareViaLink(localFile.isSharedViaLink());
- updatedFile.setShareViaUsers(localFile.isSharedViaUsers());
+ updatedFile.setShareWithSharee(localFile.isSharedWithSharee());
updatedFile.setEtagInConflict(localFile.getEtagInConflict());
} else {
// remote eTag will not be updated unless file CONTENTS are synchronized
getSharesWithForAFile(mRemotePath,
getStorageManager().getAccount().name);
if (sharesWith.size() == 1) {
- file.setShareViaUsers(false);
+ file.setShareWithSharee(false);
}
}
ProviderTableMeta.FILE_ETAG);
mFileProjectionMap.put(ProviderTableMeta.FILE_SHARED_VIA_LINK,
ProviderTableMeta.FILE_SHARED_VIA_LINK);
- mFileProjectionMap.put(ProviderTableMeta.FILE_SHARED_VIA_USERS,
- ProviderTableMeta.FILE_SHARED_VIA_USERS);
+ mFileProjectionMap.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE,
+ ProviderTableMeta.FILE_SHARED_WITH_SHAREE);
mFileProjectionMap.put(ProviderTableMeta.FILE_PUBLIC_LINK,
ProviderTableMeta.FILE_PUBLIC_LINK);
mFileProjectionMap.put(ProviderTableMeta.FILE_PERMISSIONS,
if (newShareType == ShareType.PUBLIC_LINK.getValue()) {
fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_LINK, 1);
} else if (newShareType == ShareType.USER.getValue() || newShareType == ShareType.GROUP.getValue()) {
- fileValues.put(ProviderTableMeta.FILE_SHARED_VIA_USERS, 1);
+ fileValues.put(ProviderTableMeta.FILE_SHARED_WITH_SHAREE, 1);
}
String where = ProviderTableMeta.FILE_PATH + "=? AND " +
+ ProviderTableMeta.FILE_UPDATE_THUMBNAIL + " INTEGER," //boolean
+ ProviderTableMeta.FILE_IS_DOWNLOADING + " INTEGER," //boolean
+ ProviderTableMeta.FILE_ETAG_IN_CONFLICT + " TEXT,"
- + ProviderTableMeta.FILE_SHARED_VIA_USERS + " INTEGER);"
+ + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER);"
);
// Create table ocshares
db.beginTransaction();
try {
db .execSQL("ALTER TABLE " + ProviderTableMeta.FILE_TABLE_NAME +
- " ADD COLUMN " + ProviderTableMeta.FILE_SHARED_VIA_USERS + " INTEGER " +
+ " ADD COLUMN " + ProviderTableMeta.FILE_SHARED_WITH_SHAREE + " INTEGER " +
" DEFAULT 0");
upgraded = true;
db.setTransactionSuccessful();
import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
import com.owncloud.android.operations.CopyFileOperation;
import com.owncloud.android.operations.CreateFolderOperation;
-import com.owncloud.android.operations.CreateShareOperation;
+import com.owncloud.android.operations.CreateShareViaLinkOperation;
+import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.GetServerInfoOperation;
import com.owncloud.android.operations.MoveFileOperation;
import com.owncloud.android.operations.OAuth2GetAccessToken;
public static final String EXTRA_COOKIE = "COOKIE";
- public static final String ACTION_CREATE_SHARE = "CREATE_SHARE";
+ public static final String ACTION_CREATE_SHARE_VIA_LINK = "CREATE_SHARE_VIA_LINK";
+ private static final String ACTION_CREATE_SHARE_WITH_SHAREE = "CREATE_SHARE_WITH_SHAREE";
public static final String ACTION_UNSHARE = "UNSHARE";
public static final String ACTION_GET_SERVER_INFO = "GET_SERVER_INFO";
public static final String ACTION_OAUTH2_GET_ACCESS_TOKEN = "OAUTH2_GET_ACCESS_TOKEN";
".OPERATION_FINISHED";
-
private ConcurrentMap<Integer, Pair<RemoteOperation, RemoteOperationResult>>
mUndispatchedFinishedOperations =
new ConcurrentHashMap<Integer, Pair<RemoteOperation, RemoteOperationResult>>();
);
String action = operationIntent.getAction();
- if (action.equals(ACTION_CREATE_SHARE)) { // Create Share
+ if (action.equals(ACTION_CREATE_SHARE_VIA_LINK)) { // Create public share via link
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
String password = operationIntent.getStringExtra(EXTRA_PASSWORD_SHARE);
Intent sendIntent = operationIntent.getParcelableExtra(EXTRA_SEND_INTENT);
if (remotePath.length() > 0) {
- operation = new CreateShareOperation(
+ operation = new CreateShareViaLinkOperation(
remotePath,
- ShareType.PUBLIC_LINK,
- null,
- false,
password,
- 1,
- sendIntent);
+ sendIntent
+ );
}
+ } else if (action.equals(ACTION_CREATE_SHARE_WITH_SHAREE)) { // Create private share with user or group
+ String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
+ String shareeName = operationIntent.getStringExtra(EXTRA_SHARE_WITH);
+ ShareType shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE);
+ if (remotePath.length() > 0) {
+ operation = new CreateShareWithShareeOperation(
+ remotePath,
+ shareeName,
+ ShareType.GROUP.equals(shareType)
+ );
+ }
+
} else if (action.equals(ACTION_UNSHARE)) { // Unshare file
String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
ShareType shareType = (ShareType) operationIntent.
remotePath,
shareType,
shareWith,
- OperationsService.this);
+ OperationsService.this
+ );
}
} else if (action.equals(ACTION_GET_SERVER_INFO)) {
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.operations.CreateShareOperation;
+import com.owncloud.android.operations.CreateShareViaLinkOperation;
+import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.SynchronizeFolderOperation;
import com.owncloud.android.operations.UnshareOperation;
}
mTryShareAgain = false;
- } else if (operation instanceof CreateShareOperation) {
- onCreateShareOperationFinish((CreateShareOperation) operation, result);
+ } else if (operation instanceof CreateShareViaLinkOperation) {
+ onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);
+
+ } else if (operation instanceof CreateShareWithShareeOperation) {
+ onCreateShareWithShareeOperationFinish((CreateShareWithShareeOperation) operation, result);
} else if (operation instanceof UnshareOperation) {
- onUnshareLinkOperationFinish((UnshareOperation)operation, result);
+ onUnshareLinkOperationFinish((UnshareOperation) operation, result);
} else if (operation instanceof SynchronizeFolderOperation) {
- onSynchronizeFolderOperationFinish((SynchronizeFolderOperation)operation, result);
+ onSynchronizeFolderOperationFinish((SynchronizeFolderOperation) operation, result);
}else if (operation instanceof SynchronizeFileOperation) {
onSynchronizeFileOperationFinish((SynchronizeFileOperation)operation, result);
- private void onCreateShareOperationFinish(CreateShareOperation operation,
- RemoteOperationResult result) {
+ private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
+ RemoteOperationResult result) {
dismissLoadingDialog();
if (result.isSuccess()) {
mTryShareAgain = false;
}
}
+ private void onCreateShareWithShareeOperationFinish(CreateShareWithShareeOperation operation,
+ RemoteOperationResult result) {
+ dismissLoadingDialog();
+ if (result.isSuccess()) {
+ updateFileFromDB();
+
+ } else {
+ Toast t = Toast.makeText(this,
+ ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+ Toast.LENGTH_LONG);
+ t.show();
+ }
+ }
private void onUnshareLinkOperationFinish(UnshareOperation operation,
RemoteOperationResult result) {
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.CopyFileOperation;
import com.owncloud.android.operations.CreateFolderOperation;
-import com.owncloud.android.operations.CreateShareOperation;
+import com.owncloud.android.operations.CreateShareViaLinkOperation;
+import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.MoveFileOperation;
import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.operations.RemoveFileOperation;
} else if (operation instanceof CreateFolderOperation) {
onCreateFolderOperationFinish((CreateFolderOperation) operation, result);
- } else if (operation instanceof CreateShareOperation) {
- onCreateShareOperationFinish((CreateShareOperation) operation, result);
+ } else if (operation instanceof CreateShareViaLinkOperation ||
+ operation instanceof CreateShareWithShareeOperation ) {
+
+ refreshShowDetails();
+ refreshListOfFilesFragment();
} else if (operation instanceof UnshareOperation) {
onUnshareLinkOperationFinish((UnshareOperation) operation, result);
}
}
- private void onCreateShareOperationFinish(CreateShareOperation operation,
- RemoteOperationResult result) {
- if (result.isSuccess()) {
- refreshShowDetails();
- refreshListOfFilesFragment();
- }
- }
private void onUnshareLinkOperationFinish(UnshareOperation operation,
RemoteOperationResult result) {
sharedIconV.setImageResource(R.drawable.shared_via_link);\r
sharedIconV.setVisibility(View.VISIBLE);\r
sharedIconV.bringToFront();\r
- } else if (file.isSharedViaUsers() || file.isSharedWithMe() ) {\r
+ } else if (file.isSharedWithSharee() || file.isSharedWithMe() ) {\r
sharedIconV.setImageResource(R.drawable.shared_via_users);\r
sharedIconV.setVisibility(View.VISIBLE);\r
sharedIconV.bringToFront();\r
// Folder\r
fileIcon.setImageResource(\r
MimetypeIconUtil.getFolderTypeIconId(\r
- file.isSharedWithMe() || file.isSharedViaUsers(),\r
+ file.isSharedWithMe() || file.isSharedWithSharee(),\r
file.isSharedViaLink()\r
)\r
);\r
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.operations.CreateShareOperation;
+import com.owncloud.android.operations.CreateShareViaLinkOperation;
+import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.operations.UnshareOperation;
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
super.onRemoteOperationFinish(operation, result);
- if (operation instanceof CreateShareOperation) {
- onCreateShareOperationFinish((CreateShareOperation) operation, result);
-
+ if (operation instanceof CreateShareViaLinkOperation ||
+ operation instanceof CreateShareWithShareeOperation) {
+ onCreateShareOperationFinish(result);
+
} else if (operation instanceof UnshareOperation) {
onUnshareLinkOperationFinish((UnshareOperation) operation, result);
}
- private void onCreateShareOperationFinish(CreateShareOperation operation,
- RemoteOperationResult result) {
+ private void onCreateShareOperationFinish(RemoteOperationResult result) {
if (result.isSuccess()) {
OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath());
if (file != null) {
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.operations.CopyFileOperation;
import com.owncloud.android.operations.CreateFolderOperation;
-import com.owncloud.android.operations.CreateShareOperation;
+import com.owncloud.android.operations.CreateShareViaLinkOperation;
+import com.owncloud.android.operations.CreateShareWithShareeOperation;
import com.owncloud.android.operations.DownloadFileOperation;
import com.owncloud.android.operations.MoveFileOperation;
import com.owncloud.android.operations.RemoveFileOperation;
} else {
message = res.getString(R.string.create_dir_fail_msg);
}
- } else if (operation instanceof CreateShareOperation) {
+ } else if (operation instanceof CreateShareViaLinkOperation ||
+ operation instanceof CreateShareWithShareeOperation) {
if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND
message = res.getString(R.string.share_link_file_no_exist);