+
+
+ public void unshareFileWithLink(OCFile file) {
+
+ if (isSharedSupported()) {
+ // Unshare the file
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_UNSHARE);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
+
+ mFileActivity.showLoadingDialog();
+
+ } else {
+ // Show a Message
+ Toast t = Toast.makeText(mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
+ t.show();
+
+ }
+ }
+
+ public void sendDownloadedFile(OCFile file) {
+ if (file != null) {
+ Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
+ // set MimeType
+ sendIntent.setType(file.getMimetype());
+ sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getStoragePath()));
+ sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
+
+ // Show dialog, without the own app
+ String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
+ DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
+ chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
+
+ } else {
+ Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
+ }
+ }
+
+
+ public void syncFile(OCFile file) {
+ // Sync file
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_SYNC_FILE);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ service.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
+
+ mFileActivity.showLoadingDialog();
+ }
+
+
+ public void renameFile(OCFile file, String newFilename) {
+ // RenameFile
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_RENAME);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
+
+ mFileActivity.showLoadingDialog();
+ }
+
+
+ public void removeFile(OCFile file, boolean onlyLocalCopy) {
+ // RemoveFile
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_REMOVE);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
+ service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
+
+ mFileActivity.showLoadingDialog();
+ }
+
+
+ public void createFolder(String remotePath, boolean createFullPath) {
+ // Create Folder
+ Intent service = new Intent(mFileActivity, OperationsService.class);
+ service.setAction(OperationsService.ACTION_CREATE_FOLDER);
+ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
+ service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);
+ service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
+ mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);
+
+ mFileActivity.showLoadingDialog();
+ }
+
+
+ public void cancelTransference(OCFile file) {
+ Account account = mFileActivity.getAccount();
+ FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
+ FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
+ if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) {
+ // Remove etag for parent, if file is a keep_in_sync
+ if (file.keepInSync()) {
+ OCFile parent = mFileActivity.getStorageManager().getFileById(file.getParentId());
+ parent.setEtag("");
+ mFileActivity.getStorageManager().saveFile(parent);
+ }
+
+ downloaderBinder.cancel(account, file);
+
+ } else if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
+ uploaderBinder.cancel(account, file);
+ }
+ }
+
+
+ public long getOpIdWaitingFor() {
+ return mWaitingForOpId;
+ }
+