import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.datamodel.OCFile;\r
import com.owncloud.android.files.services.FileDownloader;\r
+import com.owncloud.android.operations.RemoteOperationResult;\r
import com.owncloud.android.utils.OwnCloudVersion;\r
\r
import android.accounts.Account;\r
Notification notification = new Notification(R.drawable.icon, getContext().getString(R.string.sync_fail_ticker), System.currentTimeMillis());\r
notification.flags |= Notification.FLAG_AUTO_CANCEL;\r
// TODO put something smart in the contentIntent below\r
- notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);\r
+ notification.contentIntent = PendingIntent.getActivity(getContext().getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);\r
notification.setLatestEventInfo(getContext().getApplicationContext(), \r
getContext().getString(R.string.sync_fail_ticker), \r
String.format(getContext().getString(R.string.sync_fail_content), account.name), \r
\r
private void fetchData(String uri, SyncResult syncResult, long parentId) {\r
PropFindMethod query = null;\r
+ Vector<OCFile> children = null;\r
try {\r
Log.d(TAG, "fetching " + uri);\r
\r
Intent intent = new Intent(this.getContext(), FileDownloader.class);\r
intent.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());\r
intent.putExtra(FileDownloader.EXTRA_FILE, file);\r
- /*intent.putExtra(FileDownloader.EXTRA_FILE_PATH, file.getRemotePath());\r
- intent.putExtra(FileDownloader.EXTRA_REMOTE_PATH, file.getRemotePath());\r
- intent.putExtra(FileDownloader.EXTRA_FILE_SIZE, file.getFileLength());*/\r
file.setKeepInSync(true);\r
getContext().startService(intent);\r
}\r
\r
// Log.v(TAG, "adding file: " + file);\r
updatedFiles.add(file);\r
- if (parentId == 0)\r
- parentId = file.getFileId();\r
}\r
/* Commented code for ugly performance tests\r
long saveDelay = System.currentTimeMillis();\r
*/\r
\r
// removal of obsolete files\r
- Vector<OCFile> files = getStorageManager().getDirectoryContent(\r
+ children = getStorageManager().getDirectoryContent(\r
getStorageManager().getFileById(parentId));\r
OCFile file;\r
String currentSavePath = FileDownloader.getSavePath(getAccount().name);\r
- for (int i=0; i < files.size(); ) {\r
- file = files.get(i);\r
+ for (int i=0; i < children.size(); ) {\r
+ file = children.get(i);\r
if (file.getLastSyncDate() != mCurrentSyncTime) {\r
Log.v(TAG, "removing file: " + file);\r
getStorageManager().removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath)));\r
- files.remove(i);\r
+ children.remove(i);\r
} else {\r
i++;\r
}\r
}\r
\r
- // recursive fetch\r
- for (int i=0; i < files.size() && !mCancellation; i++) {\r
- OCFile newFile = files.get(i);\r
- if (newFile.getMimetype().equals("DIR")) {\r
- fetchData(getUri().toString() + WebdavUtils.encodePath(newFile.getRemotePath()), syncResult, newFile.getFileId());\r
- }\r
- }\r
- if (mCancellation) Log.d(TAG, "Leaving " + uri + " because cancelation request");\r
- \r
- /* Commented code for ugly performance tests\r
- mResponseDelays[mDelaysIndex] = responseDelay;\r
- mSaveDelays[mDelaysIndex] = saveDelay;\r
- mDelaysCount++;\r
- mDelaysIndex++;\r
- if (mDelaysIndex >= MAX_DELAYS)\r
- mDelaysIndex = 0;\r
- */\r
-\r
} else {\r
syncResult.stats.numAuthExceptions++;\r
}\r
// synchronized folder -> notice to UI\r
sendStickyBroadcast(true, getStorageManager().getFileById(parentId).getRemotePath());\r
}\r
+ \r
+ \r
+ fetchChildren(children, syncResult);\r
+ if (mCancellation) Log.d(TAG, "Leaving " + uri + " because cancelation request");\r
+ \r
+ \r
+ /* Commented code for ugly performance tests\r
+ mResponseDelays[mDelaysIndex] = responseDelay;\r
+ mSaveDelays[mDelaysIndex] = saveDelay;\r
+ mDelaysCount++;\r
+ mDelaysIndex++;\r
+ if (mDelaysIndex >= MAX_DELAYS)\r
+ mDelaysIndex = 0;\r
+ */\r
+ \r
+ }\r
+\r
+ /**\r
+ * Synchronize data of folders in the list of received files\r
+ * \r
+ * @param files Files to recursively fetch \r
+ * @param syncResult Updated object to provide results to the Synchronization Manager\r
+ */\r
+ private void fetchChildren(Vector<OCFile> files, SyncResult syncResult) {\r
+ for (int i=0; i < files.size() && !mCancellation; i++) {\r
+ OCFile newFile = files.get(i);\r
+ if (newFile.getMimetype().equals("DIR")) {\r
+ fetchData(getUri().toString() + WebdavUtils.encodePath(newFile.getRemotePath()), syncResult, newFile.getFileId());\r
+ }\r
+ }\r
}\r
\r
+ \r
private OCFile fillOCFile(WebdavEntry we) {\r
OCFile file = new OCFile(we.decodedPath());\r
file.setCreationTimestamp(we.createTimestamp());\r
}\r
\r
\r
- private void sendStickyBroadcast(boolean inProgress, String dirRemotePath) {\r
+ private void sendStickyBroadcast(boolean inProgress, String dirRemotePath/*, RemoteOperationResult result*/) {\r
Intent i = new Intent(FileSyncService.SYNC_MESSAGE);\r
i.putExtra(FileSyncService.IN_PROGRESS, inProgress);\r
i.putExtra(FileSyncService.ACCOUNT_NAME, getAccount().name);\r
if (dirRemotePath != null) {\r
i.putExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH, dirRemotePath);\r
}\r
+ /*if (result != null) {\r
+ i.putExtra(FileSyncService.SYNC_RESULT, result);\r
+ }*/\r
getContext().sendStickyBroadcast(i);\r
}\r
\r