RefreshFolderOperation.java 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /**
  2. * ownCloud Android client application
  3. *
  4. * @author David A. Velasco
  5. * Copyright (C) 2015 ownCloud Inc.
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2,
  9. * as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. package com.owncloud.android.operations;
  21. import java.io.File;
  22. import java.io.FileInputStream;
  23. import java.io.FileOutputStream;
  24. import java.io.IOException;
  25. import java.io.InputStream;
  26. import java.io.OutputStream;
  27. import java.util.ArrayList;
  28. import java.util.HashMap;
  29. import java.util.List;
  30. import java.util.Map;
  31. import java.util.Vector;
  32. import org.apache.http.HttpStatus;
  33. import android.accounts.Account;
  34. import android.content.Context;
  35. import android.content.Intent;
  36. import android.util.Log;
  37. //import android.support.v4.content.LocalBroadcastManager;
  38. import com.owncloud.android.MainApp;
  39. import com.owncloud.android.datamodel.FileDataStorageManager;
  40. import com.owncloud.android.datamodel.OCFile;
  41. import com.owncloud.android.lib.common.OwnCloudClient;
  42. import com.owncloud.android.lib.resources.shares.OCShare;
  43. import com.owncloud.android.lib.common.operations.RemoteOperation;
  44. import com.owncloud.android.lib.common.operations.RemoteOperationResult;
  45. import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
  46. import com.owncloud.android.lib.common.utils.Log_OC;
  47. import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
  48. import com.owncloud.android.lib.resources.files.FileUtils;
  49. import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
  50. import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
  51. import com.owncloud.android.lib.resources.files.RemoteFile;
  52. import com.owncloud.android.syncadapter.FileSyncAdapter;
  53. import com.owncloud.android.utils.FileStorageUtils;
  54. /**
  55. * Remote operation performing the synchronization of the list of files contained
  56. * in a folder identified with its remote path.
  57. *
  58. * Fetches the list and properties of the files contained in the given folder, including their
  59. * properties, and updates the local database with them.
  60. *
  61. * Does NOT enter in the child folders to synchronize their contents also.
  62. */
  63. public class RefreshFolderOperation extends RemoteOperation {
  64. private static final String TAG = RefreshFolderOperation.class.getSimpleName();
  65. public static final String EVENT_SINGLE_FOLDER_CONTENTS_SYNCED =
  66. RefreshFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_CONTENTS_SYNCED";
  67. public static final String EVENT_SINGLE_FOLDER_SHARES_SYNCED =
  68. RefreshFolderOperation.class.getName() + ".EVENT_SINGLE_FOLDER_SHARES_SYNCED";
  69. /** Time stamp for the synchronization process in progress */
  70. private long mCurrentSyncTime;
  71. /** Remote folder to synchronize */
  72. private OCFile mLocalFolder;
  73. /** Access to the local database */
  74. private FileDataStorageManager mStorageManager;
  75. /** Account where the file to synchronize belongs */
  76. private Account mAccount;
  77. /** Android context; necessary to send requests to the download service */
  78. private Context mContext;
  79. /** Files and folders contained in the synchronized folder after a successful operation */
  80. private List<OCFile> mChildren;
  81. /** Counter of conflicts found between local and remote files */
  82. private int mConflictsFound;
  83. /** Counter of failed operations in synchronization of kept-in-sync files */
  84. private int mFailsInFavouritesFound;
  85. /**
  86. * Map of remote and local paths to files that where locally stored in a location
  87. * out of the ownCloud folder and couldn't be copied automatically into it
  88. **/
  89. private Map<String, String> mForgottenLocalFiles;
  90. /** 'True' means that this operation is part of a full account synchronization */
  91. private boolean mSyncFullAccount;
  92. /** 'True' means that Share resources bound to the files into should be refreshed also */
  93. private boolean mIsShareSupported;
  94. /** 'True' means that the remote folder changed and should be fetched */
  95. private boolean mRemoteFolderChanged;
  96. /** 'True' means that Etag will be ignored */
  97. private boolean mIgnoreETag;
  98. /**
  99. * Creates a new instance of {@link RefreshFolderOperation}.
  100. *
  101. * @param folder Folder to synchronize.
  102. * @param currentSyncTime Time stamp for the synchronization process in progress.
  103. * @param syncFullAccount 'True' means that this operation is part of a full account
  104. * synchronization.
  105. * @param isShareSupported 'True' means that the server supports the sharing API.
  106. * @param ignoreETag 'True' means that the content of the remote folder should
  107. * be fetched and updated even though the 'eTag' did not
  108. * change.
  109. * @param dataStorageManager Interface with the local database.
  110. * @param account ownCloud account where the folder is located.
  111. * @param context Application context.
  112. */
  113. public RefreshFolderOperation(OCFile folder,
  114. long currentSyncTime,
  115. boolean syncFullAccount,
  116. boolean isShareSupported,
  117. boolean ignoreETag,
  118. FileDataStorageManager dataStorageManager,
  119. Account account,
  120. Context context) {
  121. mLocalFolder = folder;
  122. mCurrentSyncTime = currentSyncTime;
  123. mSyncFullAccount = syncFullAccount;
  124. mIsShareSupported = isShareSupported;
  125. mStorageManager = dataStorageManager;
  126. mAccount = account;
  127. mContext = context;
  128. mForgottenLocalFiles = new HashMap<String, String>();
  129. mRemoteFolderChanged = false;
  130. mIgnoreETag = ignoreETag;
  131. }
  132. public int getConflictsFound() {
  133. return mConflictsFound;
  134. }
  135. public int getFailsInFavouritesFound() {
  136. return mFailsInFavouritesFound;
  137. }
  138. public Map<String, String> getForgottenLocalFiles() {
  139. return mForgottenLocalFiles;
  140. }
  141. /**
  142. * Returns the list of files and folders contained in the synchronized folder,
  143. * if called after synchronization is complete.
  144. *
  145. * @return List of files and folders contained in the synchronized folder.
  146. */
  147. public List<OCFile> getChildren() {
  148. return mChildren;
  149. }
  150. /**
  151. * Performs the synchronization.
  152. *
  153. * {@inheritDoc}
  154. */
  155. @Override
  156. protected RemoteOperationResult run(OwnCloudClient client) {
  157. RemoteOperationResult result = null;
  158. mFailsInFavouritesFound = 0;
  159. mConflictsFound = 0;
  160. mForgottenLocalFiles.clear();
  161. if (FileUtils.PATH_SEPARATOR.equals(mLocalFolder.getRemotePath()) && !mSyncFullAccount) {
  162. updateOCVersion(client);
  163. }
  164. result = checkForChanges(client);
  165. if (result.isSuccess()) {
  166. if (mRemoteFolderChanged) {
  167. result = fetchAndSyncRemoteFolder(client);
  168. } else {
  169. // TODO Enable when "On Device" is recovered ?
  170. mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
  171. }
  172. }
  173. if (!mSyncFullAccount) {
  174. sendLocalBroadcast(
  175. EVENT_SINGLE_FOLDER_CONTENTS_SYNCED, mLocalFolder.getRemotePath(), result
  176. );
  177. }
  178. if (result.isSuccess() && mIsShareSupported && !mSyncFullAccount) {
  179. refreshSharesForFolder(client); // share result is ignored
  180. }
  181. if (!mSyncFullAccount) {
  182. sendLocalBroadcast(
  183. EVENT_SINGLE_FOLDER_SHARES_SYNCED, mLocalFolder.getRemotePath(), result
  184. );
  185. }
  186. return result;
  187. }
  188. private void updateOCVersion(OwnCloudClient client) {
  189. UpdateOCVersionOperation update = new UpdateOCVersionOperation(mAccount, mContext);
  190. RemoteOperationResult result = update.execute(client);
  191. if (result.isSuccess()) {
  192. mIsShareSupported = update.getOCVersion().isSharedSupported();
  193. }
  194. }
  195. private RemoteOperationResult checkForChanges(OwnCloudClient client) {
  196. mRemoteFolderChanged = true;
  197. RemoteOperationResult result = null;
  198. String remotePath = null;
  199. remotePath = mLocalFolder.getRemotePath();
  200. Log_OC.d(TAG, "Checking changes in " + mAccount.name + remotePath);
  201. // remote request
  202. ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
  203. result = operation.execute(client);
  204. if (result.isSuccess()){
  205. OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
  206. if (!mIgnoreETag) {
  207. // check if remote and local folder are different
  208. String remoteFolderETag = remoteFolder.getEtag();
  209. if (remoteFolderETag != null) {
  210. mRemoteFolderChanged =
  211. !(remoteFolderETag.equalsIgnoreCase(mLocalFolder.getEtag()));
  212. } else {
  213. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  214. "No ETag received from server");
  215. }
  216. }
  217. result = new RemoteOperationResult(ResultCode.OK);
  218. Log_OC.i(TAG, "Checked " + mAccount.name + remotePath + " : " +
  219. (mRemoteFolderChanged ? "changed" : "not changed"));
  220. } else {
  221. // check failed
  222. if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
  223. removeLocalFolder();
  224. }
  225. if (result.isException()) {
  226. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  227. result.getLogMessage(), result.getException());
  228. } else {
  229. Log_OC.e(TAG, "Checked " + mAccount.name + remotePath + " : " +
  230. result.getLogMessage());
  231. }
  232. }
  233. return result;
  234. }
  235. private RemoteOperationResult fetchAndSyncRemoteFolder(OwnCloudClient client) {
  236. String remotePath = mLocalFolder.getRemotePath();
  237. ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
  238. RemoteOperationResult result = operation.execute(client);
  239. Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
  240. if (result.isSuccess()) {
  241. synchronizeData(result.getData(), client);
  242. if (mConflictsFound > 0 || mFailsInFavouritesFound > 0) {
  243. result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
  244. // should be a different result code, but will do the job
  245. }
  246. } else {
  247. if (result.getCode() == ResultCode.FILE_NOT_FOUND)
  248. removeLocalFolder();
  249. }
  250. return result;
  251. }
  252. private void removeLocalFolder() {
  253. if (mStorageManager.fileExists(mLocalFolder.getFileId())) {
  254. String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
  255. mStorageManager.removeFolder(
  256. mLocalFolder,
  257. true,
  258. ( mLocalFolder.isDown() &&
  259. mLocalFolder.getStoragePath().startsWith(currentSavePath)
  260. )
  261. );
  262. }
  263. }
  264. /**
  265. * Synchronizes the data retrieved from the server about the contents of the target folder
  266. * with the current data in the local database.
  267. *
  268. * Grants that mChildren is updated with fresh data after execution.
  269. *
  270. * @param folderAndFiles Remote folder and children files in Folder
  271. *
  272. * @param client Client instance to the remote server where the data were
  273. * retrieved.
  274. * @return 'True' when any change was made in the local data, 'false' otherwise
  275. */
  276. private void synchronizeData(ArrayList<Object> folderAndFiles, OwnCloudClient client) {
  277. // get 'fresh data' from the database
  278. mLocalFolder = mStorageManager.getFileByPath(mLocalFolder.getRemotePath());
  279. // parse data from remote folder
  280. OCFile remoteFolder = fillOCFile((RemoteFile)folderAndFiles.get(0));
  281. remoteFolder.setParentId(mLocalFolder.getParentId());
  282. remoteFolder.setFileId(mLocalFolder.getFileId());
  283. Log_OC.d(TAG, "Remote folder " + mLocalFolder.getRemotePath()
  284. + " changed - starting update of local data ");
  285. List<OCFile> updatedFiles = new Vector<OCFile>(folderAndFiles.size() - 1);
  286. List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
  287. // get current data about local contents of the folder to synchronize
  288. // TODO Enable when "On Device" is recovered ?
  289. List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
  290. Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
  291. for (OCFile file : localFiles) {
  292. localFilesMap.put(file.getRemotePath(), file);
  293. }
  294. // loop to update every child
  295. OCFile remoteFile = null, localFile = null;
  296. for (int i=1; i<folderAndFiles.size(); i++) {
  297. /// new OCFile instance with the data from the server
  298. remoteFile = fillOCFile((RemoteFile)folderAndFiles.get(i));
  299. remoteFile.setParentId(mLocalFolder.getFileId());
  300. /// retrieve local data for the read file
  301. // localFile = mStorageManager.getFileByPath(remoteFile.getRemotePath());
  302. localFile = localFilesMap.remove(remoteFile.getRemotePath());
  303. /// add to the remoteFile (the new one) data about LOCAL STATE (not existing in server)
  304. remoteFile.setLastSyncDateForProperties(mCurrentSyncTime);
  305. if (localFile != null) {
  306. // some properties of local state are kept unmodified
  307. remoteFile.setFileId(localFile.getFileId());
  308. remoteFile.setFavorite(localFile.isFavorite());
  309. remoteFile.setLastSyncDateForData(localFile.getLastSyncDateForData());
  310. remoteFile.setModificationTimestampAtLastSyncForData(
  311. localFile.getModificationTimestampAtLastSyncForData()
  312. );
  313. remoteFile.setStoragePath(localFile.getStoragePath());
  314. // eTag will not be updated unless contents are synchronized
  315. // (Synchronize[File|Folder]Operation with remoteFile as parameter)
  316. remoteFile.setEtag(localFile.getEtag());
  317. if (remoteFile.isFolder()) {
  318. remoteFile.setFileLength(localFile.getFileLength());
  319. // TODO move operations about size of folders to FileContentProvider
  320. } else if (mRemoteFolderChanged && remoteFile.isImage() &&
  321. remoteFile.getModificationTimestamp() !=
  322. localFile.getModificationTimestamp()) {
  323. remoteFile.setNeedsUpdateThumbnail(true);
  324. Log.d(TAG, "Image " + remoteFile.getFileName() + " updated on the server");
  325. }
  326. remoteFile.setPublicLink(localFile.getPublicLink());
  327. remoteFile.setShareByLink(localFile.isShareByLink());
  328. } else {
  329. // remote eTag will not be updated unless contents are synchronized
  330. // (Synchronize[File|Folder]Operation with remoteFile as parameter)
  331. remoteFile.setEtag("");
  332. }
  333. /// check and fix, if needed, local storage path
  334. checkAndFixForeignStoragePath(remoteFile); // policy - local files are COPIED
  335. // into the ownCloud local folder;
  336. searchForLocalFileInDefaultPath(remoteFile); // legacy
  337. /// prepare content synchronization for kept-in-sync files
  338. if (remoteFile.isFavorite()) {
  339. SynchronizeFileOperation operation = new SynchronizeFileOperation( localFile,
  340. remoteFile,
  341. mAccount,
  342. true,
  343. mContext
  344. );
  345. filesToSyncContents.add(operation);
  346. }
  347. updatedFiles.add(remoteFile);
  348. }
  349. // save updated contents in local database
  350. mStorageManager.saveFolder(remoteFolder, updatedFiles, localFilesMap.values());
  351. // request for the synchronization of file contents AFTER saving current remote properties
  352. startContentSynchronizations(filesToSyncContents, client);
  353. mChildren = updatedFiles;
  354. }
  355. /**
  356. * Performs a list of synchronization operations, determining if a download or upload is needed
  357. * or if exists conflict due to changes both in local and remote contents of the each file.
  358. *
  359. * If download or upload is needed, request the operation to the corresponding service and goes
  360. * on.
  361. *
  362. * @param filesToSyncContents Synchronization operations to execute.
  363. * @param client Interface to the remote ownCloud server.
  364. */
  365. private void startContentSynchronizations(
  366. List<SynchronizeFileOperation> filesToSyncContents, OwnCloudClient client
  367. ) {
  368. RemoteOperationResult contentsResult = null;
  369. for (SynchronizeFileOperation op: filesToSyncContents) {
  370. contentsResult = op.execute(mStorageManager, mContext); // async
  371. if (!contentsResult.isSuccess()) {
  372. if (contentsResult.getCode() == ResultCode.SYNC_CONFLICT) {
  373. mConflictsFound++;
  374. } else {
  375. mFailsInFavouritesFound++;
  376. if (contentsResult.getException() != null) {
  377. Log_OC.e(TAG, "Error while synchronizing favourites : "
  378. + contentsResult.getLogMessage(), contentsResult.getException());
  379. } else {
  380. Log_OC.e(TAG, "Error while synchronizing favourites : "
  381. + contentsResult.getLogMessage());
  382. }
  383. }
  384. } // won't let these fails break the synchronization process
  385. }
  386. }
  387. public boolean isMultiStatus(int status) {
  388. return (status == HttpStatus.SC_MULTI_STATUS);
  389. }
  390. /**
  391. * Creates and populates a new {@link OCFile} object with the data read from the server.
  392. *
  393. * @param remote remote file read from the server (remote file or folder).
  394. * @return New OCFile instance representing the remote resource described by we.
  395. */
  396. private OCFile fillOCFile(RemoteFile remote) {
  397. OCFile file = new OCFile(remote.getRemotePath());
  398. file.setCreationTimestamp(remote.getCreationTimestamp());
  399. file.setFileLength(remote.getLength());
  400. file.setMimetype(remote.getMimeType());
  401. file.setModificationTimestamp(remote.getModifiedTimestamp());
  402. file.setEtag(remote.getEtag());
  403. file.setPermissions(remote.getPermissions());
  404. file.setRemoteId(remote.getRemoteId());
  405. return file;
  406. }
  407. /**
  408. * Checks the storage path of the OCFile received as parameter.
  409. * If it's out of the local ownCloud folder, tries to copy the file inside it.
  410. *
  411. * If the copy fails, the link to the local file is nullified. The account of forgotten
  412. * files is kept in {@link #mForgottenLocalFiles}
  413. *)
  414. * @param file File to check and fix.
  415. */
  416. private void checkAndFixForeignStoragePath(OCFile file) {
  417. String storagePath = file.getStoragePath();
  418. String expectedPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file);
  419. if (storagePath != null && !storagePath.equals(expectedPath)) {
  420. /// fix storagePaths out of the local ownCloud folder
  421. File originalFile = new File(storagePath);
  422. if (FileStorageUtils.getUsableSpace(mAccount.name) < originalFile.length()) {
  423. mForgottenLocalFiles.put(file.getRemotePath(), storagePath);
  424. file.setStoragePath(null);
  425. } else {
  426. InputStream in = null;
  427. OutputStream out = null;
  428. try {
  429. File expectedFile = new File(expectedPath);
  430. File expectedParent = expectedFile.getParentFile();
  431. expectedParent.mkdirs();
  432. if (!expectedParent.isDirectory()) {
  433. throw new IOException(
  434. "Unexpected error: parent directory could not be created"
  435. );
  436. }
  437. expectedFile.createNewFile();
  438. if (!expectedFile.isFile()) {
  439. throw new IOException("Unexpected error: target file could not be created");
  440. }
  441. in = new FileInputStream(originalFile);
  442. out = new FileOutputStream(expectedFile);
  443. byte[] buf = new byte[1024];
  444. int len;
  445. while ((len = in.read(buf)) > 0){
  446. out.write(buf, 0, len);
  447. }
  448. file.setStoragePath(expectedPath);
  449. } catch (Exception e) {
  450. Log_OC.e(TAG, "Exception while copying foreign file " + expectedPath, e);
  451. mForgottenLocalFiles.put(file.getRemotePath(), storagePath);
  452. file.setStoragePath(null);
  453. } finally {
  454. try {
  455. if (in != null) in.close();
  456. } catch (Exception e) {
  457. Log_OC.d(TAG, "Weird exception while closing input stream for "
  458. + storagePath + " (ignoring)", e);
  459. }
  460. try {
  461. if (out != null) out.close();
  462. } catch (Exception e) {
  463. Log_OC.d(TAG, "Weird exception while closing output stream for "
  464. + expectedPath + " (ignoring)", e);
  465. }
  466. }
  467. }
  468. }
  469. }
  470. private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
  471. RemoteOperationResult result = null;
  472. // remote request
  473. GetRemoteSharesForFileOperation operation =
  474. new GetRemoteSharesForFileOperation(mLocalFolder.getRemotePath(), false, true);
  475. result = operation.execute(client);
  476. if (result.isSuccess()) {
  477. // update local database
  478. ArrayList<OCShare> shares = new ArrayList<OCShare>();
  479. for(Object obj: result.getData()) {
  480. shares.add((OCShare) obj);
  481. }
  482. mStorageManager.saveSharesInFolder(shares, mLocalFolder);
  483. }
  484. return result;
  485. }
  486. /**
  487. * Scans the default location for saving local copies of files searching for
  488. * a 'lost' file with the same full name as the {@link OCFile} received as
  489. * parameter.
  490. *
  491. * @param file File to associate a possible 'lost' local file.
  492. */
  493. private void searchForLocalFileInDefaultPath(OCFile file) {
  494. if (file.getStoragePath() == null && !file.isFolder()) {
  495. File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
  496. if (f.exists()) {
  497. file.setStoragePath(f.getAbsolutePath());
  498. file.setLastSyncDateForData(f.lastModified());
  499. }
  500. }
  501. }
  502. /**
  503. * Sends a message to any application component interested in the progress
  504. * of the synchronization.
  505. *
  506. * @param event
  507. * @param dirRemotePath Remote path of a folder that was just synchronized
  508. * (with or without success)
  509. * @param result
  510. */
  511. private void sendLocalBroadcast(
  512. String event, String dirRemotePath, RemoteOperationResult result
  513. ) {
  514. Log_OC.d(TAG, "Send broadcast " + event);
  515. Intent intent = new Intent(event);
  516. intent.putExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME, mAccount.name);
  517. if (dirRemotePath != null) {
  518. intent.putExtra(FileSyncAdapter.EXTRA_FOLDER_PATH, dirRemotePath);
  519. }
  520. intent.putExtra(FileSyncAdapter.EXTRA_RESULT, result);
  521. mContext.sendStickyBroadcast(intent);
  522. //LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
  523. }
  524. public boolean getRemoteFolderChanged() {
  525. return mRemoteFolderChanged;
  526. }
  527. }