Update library reference
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / FileOperationsHelper.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author masensio
5 * @author David A. Velasco
6 * Copyright (C) 2015 ownCloud Inc.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 package com.owncloud.android.files;
23
24 import android.accounts.Account;
25 import android.content.ActivityNotFoundException;
26 import android.content.Context;
27 import android.content.Intent;
28 import android.content.pm.PackageManager;
29 import android.content.pm.ResolveInfo;
30 import android.net.Uri;
31 import android.support.v4.app.DialogFragment;
32 import android.webkit.MimeTypeMap;
33 import android.widget.Toast;
34
35 import com.owncloud.android.R;
36 import com.owncloud.android.authentication.AccountUtils;
37 import com.owncloud.android.datamodel.OCFile;
38 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
39 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
40 import com.owncloud.android.lib.common.network.WebdavUtils;
41 import com.owncloud.android.lib.common.utils.Log_OC;
42 import com.owncloud.android.lib.resources.shares.ShareType;
43 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
44 import com.owncloud.android.services.OperationsService;
45 import com.owncloud.android.services.observer.FileObserverService;
46 import com.owncloud.android.ui.activity.FileActivity;
47 import com.owncloud.android.ui.activity.ShareActivity;
48 import com.owncloud.android.ui.dialog.ShareLinkToDialog;
49 import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
50
51
52 import java.util.List;
53
54 /**
55 *
56 */
57 public class FileOperationsHelper {
58
59 private static final String TAG = FileOperationsHelper.class.getName();
60
61 private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
62
63 protected FileActivity mFileActivity = null;
64
65 /// Identifier of operation in progress which result shouldn't be lost
66 private long mWaitingForOpId = Long.MAX_VALUE;
67
68 public FileOperationsHelper(FileActivity fileActivity) {
69 mFileActivity = fileActivity;
70 }
71
72
73 public void openFile(OCFile file) {
74 if (file != null) {
75 String storagePath = file.getStoragePath();
76 String encodedStoragePath = WebdavUtils.encodePath(storagePath);
77
78 Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
79 intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath),
80 file.getMimetype());
81 intentForSavedMimeType.setFlags(
82 Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
83 );
84
85 Intent intentForGuessedMimeType = null;
86 if (storagePath.lastIndexOf('.') >= 0) {
87 String guessedMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
88 storagePath.substring(storagePath.lastIndexOf('.') + 1)
89 );
90 if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
91 intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
92 intentForGuessedMimeType.
93 setDataAndType(Uri.parse("file://"+ encodedStoragePath),
94 guessedMimeType);
95 intentForGuessedMimeType.setFlags(
96 Intent.FLAG_GRANT_READ_URI_PERMISSION |
97 Intent.FLAG_GRANT_WRITE_URI_PERMISSION
98 );
99 }
100 }
101
102 Intent openFileWithIntent;
103 if (intentForGuessedMimeType != null) {
104 openFileWithIntent = intentForGuessedMimeType;
105 } else {
106 openFileWithIntent = intentForSavedMimeType;
107 }
108
109 List<ResolveInfo> launchables = mFileActivity.getPackageManager().
110 queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS);
111
112 if(launchables != null && launchables.size() > 0) {
113 try {
114 mFileActivity.startActivity(
115 Intent.createChooser(
116 openFileWithIntent, mFileActivity.getString(R.string.actionbar_open_with)
117 )
118 );
119 } catch (ActivityNotFoundException anfe) {
120 showNoAppForFileTypeToast(mFileActivity.getApplicationContext());
121 }
122 } else {
123 showNoAppForFileTypeToast(mFileActivity.getApplicationContext());
124 }
125
126 } else {
127 Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
128 }
129 }
130
131 /**
132 * Displays a toast stating that no application could be found to open the file.
133 *
134 * @param context the context to be able to show a toast.
135 */
136 private void showNoAppForFileTypeToast(Context context) {
137 Toast.makeText(context,
138 R.string.file_list_no_app_for_file_type, Toast.LENGTH_SHORT)
139 .show();
140 }
141
142
143 /**
144 * Helper method to share a file via a public link. Starts a request to do it in {@link OperationsService}
145 *
146 * @param file The file to share.
147 * @param password Optional password to protect the public share.
148 */
149 public void shareFileViaLink(OCFile file, String password) {
150 if (isSharedSupported()) {
151 if (file != null) {
152 mFileActivity.showLoadingDialog(
153 mFileActivity.getApplicationContext().
154 getString(R.string.wait_a_moment)
155 );
156 Intent service = new Intent(mFileActivity, OperationsService.class);
157 service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
158 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
159 if (password != null && password.length() > 0) {
160 service.putExtra(OperationsService.EXTRA_SHARE_PASSWORD, password);
161 }
162 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
163 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
164
165 } else {
166 Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
167 // TODO user-level error?
168 }
169
170 } else {
171 // Show a Message
172 Toast t = Toast.makeText(
173 mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api),
174 Toast.LENGTH_LONG
175 );
176 t.show();
177 }
178 }
179
180 public void getFileWithLink(OCFile file){
181 if (isSharedSupported()) {
182 if (file != null) {
183 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
184 getString(R.string.wait_a_moment));
185
186 Intent service = new Intent(mFileActivity, OperationsService.class);
187 service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
188 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
189 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
190 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
191
192 } else {
193 Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
194 }
195 } else {
196 // Show a Message
197 Toast t = Toast.makeText(
198 mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api),
199 Toast.LENGTH_LONG
200 );
201 t.show();
202 }
203 }
204
205 public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) {
206
207 if (file != null) {
208 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
209 getString(R.string.wait_a_moment));
210
211 Intent service = new Intent(mFileActivity, OperationsService.class);
212 service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
213 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
214 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
215 service.putExtra(OperationsService.EXTRA_SHARE_PASSWORD, password);
216 service.putExtra(OperationsService.EXTRA_SEND_INTENT, sendIntent);
217 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
218
219 } else {
220 Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
221 }
222 }
223
224 /**
225 * Helper method to share a file with a known sharee. Starts a request to do it in {@link OperationsService}
226 *
227 * @param file The file to share.
228 * @param shareeName Name (user name or group name) of the target sharee.
229 * @param shareType The share type determines the sharee type.
230 */
231 public void shareFileWithSharee(OCFile file, String shareeName, ShareType shareType) {
232 if (file != null) {
233 // TODO check capability?
234 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
235 getString(R.string.wait_a_moment));
236
237 Intent service = new Intent(mFileActivity, OperationsService.class);
238 service.setAction(OperationsService.ACTION_CREATE_SHARE_WITH_SHAREE);
239 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
240 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
241 service.putExtra(OperationsService.EXTRA_SHARE_WITH, shareeName);
242 service.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
243 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
244
245 } else {
246 Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
247 }
248 }
249
250
251 /**
252 * @return 'True' if the server supports the Share API
253 */
254 public boolean isSharedSupported() {
255 if (mFileActivity.getAccount() != null) {
256 OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
257 return (serverVersion != null && serverVersion.isSharedSupported());
258 }
259 return false;
260 }
261
262
263 /**
264 * Helper method to unshare a file publicly shared via link.
265 * Starts a request to do it in {@link OperationsService}
266 *
267 * @param file The file to unshare.
268 */
269 public void unshareFileViaLink(OCFile file) {
270
271 // Unshare the file: Create the intent
272 Intent unshareService = new Intent(mFileActivity, OperationsService.class);
273 unshareService.setAction(OperationsService.ACTION_UNSHARE);
274 unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
275 unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
276 unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, ShareType.PUBLIC_LINK);
277 unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, "");
278
279 queueShareIntent(unshareService);
280 }
281
282 public void unshareFileWithUserOrGroup(OCFile file, ShareType shareType, String userOrGroup){
283
284 // Unshare the file: Create the intent
285 Intent unshareService = new Intent(mFileActivity, OperationsService.class);
286 unshareService.setAction(OperationsService.ACTION_UNSHARE);
287 unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
288 unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
289 unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
290 unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, userOrGroup);
291
292 queueShareIntent(unshareService);
293 }
294
295
296 private void queueShareIntent(Intent shareIntent){
297 if (isSharedSupported()) {
298 // Unshare the file
299 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().
300 queueNewOperation(shareIntent);
301
302 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
303 getString(R.string.wait_a_moment));
304
305 } else {
306 // Show a Message
307 Toast t = Toast.makeText(mFileActivity,
308 mFileActivity.getString(R.string.share_link_no_support_share_api),
309 Toast.LENGTH_LONG);
310 t.show();
311
312 }
313 }
314
315 /**
316 * Show an instance of {@link ShareType} for sharing or unsharing the {@OCFile} received as parameter.
317 *
318 * @param file File to share or unshare.
319 */
320 public void showShareFile(OCFile file){
321 Intent intent = new Intent(mFileActivity, ShareActivity.class);
322 intent.putExtra(mFileActivity.EXTRA_FILE, file);
323 intent.putExtra(mFileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
324 mFileActivity.startActivity(intent);
325
326 }
327
328
329 /**
330 * Starts a dialog that requests a password to the user to protect a share link.
331 *
332 * @param file File which public share will be protected by the requested password
333 * @param createShare When 'true', the request for password will be followed by the creation of a new
334 * public link; when 'false', a public share is assumed to exist, and the password
335 * is bound to it.
336 */
337 public void requestPasswordForShareViaLink(OCFile file, boolean createShare) {
338 SharePasswordDialogFragment dialog =
339 SharePasswordDialogFragment.newInstance(file, createShare);
340 dialog.show(
341 mFileActivity.getSupportFragmentManager(),
342 SharePasswordDialogFragment.PASSWORD_FRAGMENT
343 );
344 }
345
346 /**
347 * Updates a public share on a file to set its password.
348 * Starts a request to do it in {@link OperationsService}
349 *
350 * @param file File which public share will be protected with a password.
351 * @param password Password to set for the public link; null or empty string to clear
352 * the current password
353 */
354 public void setPasswordToShareViaLink(OCFile file, String password) {
355 // Set password updating share
356 Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class);
357 updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
358 updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
359 updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
360 updateShareIntent.putExtra(
361 OperationsService.EXTRA_SHARE_PASSWORD,
362 (password == null) ? "" : password
363 );
364
365 queueShareIntent(updateShareIntent);
366 }
367
368
369 /**
370 * Updates a public share on a file to set its expiration date.
371 * Starts a request to do it in {@link OperationsService}
372 *
373 * @param file File which public share will be constrained with an expiration date.
374 * @param expirationTimeInMillis Expiration date to set. A negative value clears the current expiration
375 * date, leaving the link unrestricted. Zero makes no change.
376 */
377 public void setExpirationDateToShareViaLink(OCFile file, long expirationTimeInMillis) {
378 Intent updateShareIntent = new Intent(mFileActivity, OperationsService.class);
379 updateShareIntent.setAction(OperationsService.ACTION_UPDATE_SHARE);
380 updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
381 updateShareIntent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
382 updateShareIntent.putExtra(
383 OperationsService.EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS,
384 expirationTimeInMillis
385 );
386 queueShareIntent(updateShareIntent);
387 }
388
389
390 /**
391 * @return 'True' if the server supports the Search Users API
392 */
393 public boolean isSearchUsersSupportedSupported() {
394 if (mFileActivity.getAccount() != null) {
395 OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
396 return (serverVersion != null && serverVersion.isSearchUsersSupported());
397 }
398 return false;
399 }
400
401 public void sendDownloadedFile(OCFile file) {
402 if (file != null) {
403 String storagePath = file.getStoragePath();
404 String encodedStoragePath = WebdavUtils.encodePath(storagePath);
405 Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
406 // set MimeType
407 sendIntent.setType(file.getMimetype());
408 sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath));
409 sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
410
411 // Show dialog, without the own app
412 String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
413 DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude);
414 chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
415
416 } else {
417 Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
418 }
419 }
420
421 /**
422 * Request the synchronization of a file or folder with the OC server, including its contents.
423 *
424 * @param file The file or folder to synchronize
425 */
426 public void syncFile(OCFile file) {
427 if (!file.isFolder()){
428 Intent intent = new Intent(mFileActivity, OperationsService.class);
429 intent.setAction(OperationsService.ACTION_SYNC_FILE);
430 intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
431 intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
432 intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
433 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
434 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
435 getString(R.string.wait_a_moment));
436
437 } else {
438 Intent intent = new Intent(mFileActivity, OperationsService.class);
439 intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
440 intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
441 intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
442 mFileActivity.startService(intent);
443
444 }
445 }
446
447 public void toggleFavorite(OCFile file, boolean isFavorite) {
448 file.setFavorite(isFavorite);
449 mFileActivity.getStorageManager().saveFile(file);
450
451 /// register the OCFile instance in the observer service to monitor local updates
452 Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
453 mFileActivity,
454 file,
455 mFileActivity.getAccount(),
456 isFavorite);
457 mFileActivity.startService(observedFileIntent);
458
459 /// immediate content synchronization
460 if (file.isFavorite()) {
461 syncFile(file);
462 }
463 }
464
465 public void renameFile(OCFile file, String newFilename) {
466 // RenameFile
467 Intent service = new Intent(mFileActivity, OperationsService.class);
468 service.setAction(OperationsService.ACTION_RENAME);
469 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
470 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
471 service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
472 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
473
474 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
475 getString(R.string.wait_a_moment));
476 }
477
478
479 public void removeFile(OCFile file, boolean onlyLocalCopy) {
480 // RemoveFile
481 Intent service = new Intent(mFileActivity, OperationsService.class);
482 service.setAction(OperationsService.ACTION_REMOVE);
483 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
484 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
485 service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
486 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
487
488 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
489 getString(R.string.wait_a_moment));
490 }
491
492
493 public void createFolder(String remotePath, boolean createFullPath) {
494 // Create Folder
495 Intent service = new Intent(mFileActivity, OperationsService.class);
496 service.setAction(OperationsService.ACTION_CREATE_FOLDER);
497 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
498 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);
499 service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
500 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
501
502 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
503 getString(R.string.wait_a_moment));
504 }
505
506 /**
507 * Cancel the transference in downloads (files/folders) and file uploads
508 * @param file OCFile
509 */
510 public void cancelTransference(OCFile file) {
511 Account account = mFileActivity.getAccount();
512 if (file.isFolder()) {
513 OperationsService.OperationsServiceBinder opsBinder =
514 mFileActivity.getOperationsServiceBinder();
515 if (opsBinder != null) {
516 opsBinder.cancel(account, file);
517 }
518 }
519
520 // for both files and folders
521 FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
522 if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) {
523 downloaderBinder.cancel(account, file);
524 }
525 FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
526 if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
527 uploaderBinder.cancel(account, file);
528 }
529 }
530
531 /**
532 * Start move file operation
533 *
534 * @param newfile File where it is going to be moved
535 * @param currentFile File with the previous info
536 */
537 public void moveFile(OCFile newfile, OCFile currentFile) {
538 // Move files
539 Intent service = new Intent(mFileActivity, OperationsService.class);
540 service.setAction(OperationsService.ACTION_MOVE_FILE);
541 service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, newfile.getRemotePath());
542 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, currentFile.getRemotePath());
543 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
544 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
545
546 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
547 getString(R.string.wait_a_moment));
548 }
549
550 /**
551 * Start copy file operation
552 *
553 * @param newfile File where it is going to be moved
554 * @param currentFile File with the previous info
555 */
556 public void copyFile(OCFile newfile, OCFile currentFile) {
557 // Copy files
558 Intent service = new Intent(mFileActivity, OperationsService.class);
559 service.setAction(OperationsService.ACTION_COPY_FILE);
560 service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, newfile.getRemotePath());
561 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, currentFile.getRemotePath());
562 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
563 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
564
565 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
566 getString(R.string.wait_a_moment));
567 }
568
569 public long getOpIdWaitingFor() {
570 return mWaitingForOpId;
571 }
572
573
574 public void setOpIdWaitingFor(long waitingForOpId) {
575 mWaitingForOpId = waitingForOpId;
576 }
577
578 /**
579 * @return 'True' if the server doesn't need to check forbidden characters
580 */
581 public boolean isVersionWithForbiddenCharacters() {
582 if (mFileActivity.getAccount() != null) {
583 OwnCloudVersion serverVersion =
584 AccountUtils.getServerVersion(mFileActivity.getAccount());
585 return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters());
586 }
587 return false;
588 }
589
590 }