Cancel the current upload when it hasn't started yet
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / services / FileDownloader.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 * Copyright (C) 2012-2015 ownCloud Inc.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2,
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19 package com.owncloud.android.files.services;
20
21 import java.io.File;
22 import java.io.IOException;
23 import java.util.AbstractList;
24 import java.util.HashMap;
25 import java.util.Iterator;
26 import java.util.Map;
27 import java.util.Vector;
28
29 import com.owncloud.android.R;
30 import com.owncloud.android.authentication.AuthenticatorActivity;
31 import com.owncloud.android.datamodel.FileDataStorageManager;
32 import com.owncloud.android.datamodel.OCFile;
33
34 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
35 import com.owncloud.android.lib.common.OwnCloudAccount;
36 import com.owncloud.android.lib.common.OwnCloudClient;
37 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
38 import com.owncloud.android.notifications.NotificationBuilderWithProgressBar;
39 import com.owncloud.android.notifications.NotificationDelayer;
40 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
41 import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
42 import com.owncloud.android.lib.common.utils.Log_OC;
43 import com.owncloud.android.lib.resources.files.FileUtils;
44 import com.owncloud.android.operations.DownloadFileOperation;
45 import com.owncloud.android.ui.activity.FileActivity;
46 import com.owncloud.android.ui.activity.FileDisplayActivity;
47 import com.owncloud.android.ui.preview.PreviewImageActivity;
48 import com.owncloud.android.ui.preview.PreviewImageFragment;
49 import com.owncloud.android.utils.ErrorMessageAdapter;
50
51 import android.accounts.Account;
52 import android.accounts.AccountsException;
53 import android.app.NotificationManager;
54 import android.app.PendingIntent;
55 import android.app.Service;
56 import android.content.Intent;
57 import android.os.Binder;
58 import android.os.Handler;
59 import android.os.HandlerThread;
60 import android.os.IBinder;
61 import android.os.Looper;
62 import android.os.Message;
63 import android.os.Process;
64 import android.support.v4.app.NotificationCompat;
65 import android.util.Pair;
66
67 public class FileDownloader extends Service implements OnDatatransferProgressListener {
68
69 public static final String EXTRA_ACCOUNT = "ACCOUNT";
70 public static final String EXTRA_FILE = "FILE";
71
72 private static final String DOWNLOAD_ADDED_MESSAGE = "DOWNLOAD_ADDED";
73 private static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH";
74 public static final String EXTRA_DOWNLOAD_RESULT = "RESULT";
75 public static final String EXTRA_FILE_PATH = "FILE_PATH";
76 public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
77 public static final String EXTRA_LINKED_TO_PATH = "LINKED_TO";
78 public static final String ACCOUNT_NAME = "ACCOUNT_NAME";
79
80 private static final String TAG = "FileDownloader";
81
82 private Looper mServiceLooper;
83 private ServiceHandler mServiceHandler;
84 private IBinder mBinder;
85 private OwnCloudClient mDownloadClient = null;
86 private Account mCurrentAccount = null;
87 private FileDataStorageManager mStorageManager;
88
89 private IndexedForest<DownloadFileOperation> mPendingDownloads = new IndexedForest<DownloadFileOperation>();
90
91 private DownloadFileOperation mCurrentDownload = null;
92
93 private NotificationManager mNotificationManager;
94 private NotificationCompat.Builder mNotificationBuilder;
95 private int mLastPercent;
96
97
98 public static String getDownloadAddedMessage() {
99 return FileDownloader.class.getName() + DOWNLOAD_ADDED_MESSAGE;
100 }
101
102 public static String getDownloadFinishMessage() {
103 return FileDownloader.class.getName() + DOWNLOAD_FINISH_MESSAGE;
104 }
105
106 /**
107 * Service initialization
108 */
109 @Override
110 public void onCreate() {
111 super.onCreate();
112 mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
113 HandlerThread thread = new HandlerThread("FileDownloaderThread",
114 Process.THREAD_PRIORITY_BACKGROUND);
115 thread.start();
116 mServiceLooper = thread.getLooper();
117 mServiceHandler = new ServiceHandler(mServiceLooper, this);
118 mBinder = new FileDownloaderBinder();
119 }
120
121 /**
122 * Entry point to add one or several files to the queue of downloads.
123 *
124 * New downloads are added calling to startService(), resulting in a call to this method.
125 * This ensures the service will keep on working although the caller activity goes away.
126 */
127 @Override
128 public int onStartCommand(Intent intent, int flags, int startId) {
129 if ( !intent.hasExtra(EXTRA_ACCOUNT) ||
130 !intent.hasExtra(EXTRA_FILE)
131 ) {
132 Log_OC.e(TAG, "Not enough information provided in intent");
133 return START_NOT_STICKY;
134 } else {
135 final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
136 final OCFile file = intent.getParcelableExtra(EXTRA_FILE);
137
138 /*Log_OC.v(
139 "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
140 "Received request to download file"
141 );*/
142
143 AbstractList<String> requestedDownloads = new Vector<String>();
144 try {
145 DownloadFileOperation newDownload = new DownloadFileOperation(account, file);
146 newDownload.addDatatransferProgressListener(this);
147 newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder);
148 Pair<String, String> putResult = mPendingDownloads.putIfAbsent(
149 account, file.getRemotePath(), newDownload
150 );
151 String downloadKey = putResult.first;
152 requestedDownloads.add(downloadKey);
153 /*Log_OC.v(
154 "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
155 "Download on " + file.getRemotePath() + " added to queue"
156 );*/
157
158 // Store file on db with state 'downloading'
159 /*
160 TODO - check if helps with UI responsiveness, letting only folders use FileDownloaderBinder to check
161 FileDataStorageManager storageManager = new FileDataStorageManager(account, getContentResolver());
162 file.setDownloading(true);
163 storageManager.saveFile(file);
164 */
165
166 sendBroadcastNewDownload(newDownload, putResult.second);
167
168 } catch (IllegalArgumentException e) {
169 Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage());
170 return START_NOT_STICKY;
171 }
172
173 if (requestedDownloads.size() > 0) {
174 Message msg = mServiceHandler.obtainMessage();
175 msg.arg1 = startId;
176 msg.obj = requestedDownloads;
177 mServiceHandler.sendMessage(msg);
178 }
179 //}
180 }
181
182 return START_NOT_STICKY;
183 }
184
185
186 /**
187 * Provides a binder object that clients can use to perform operations on the queue of downloads,
188 * excepting the addition of new files.
189 *
190 * Implemented to perform cancellation, pause and resume of existing downloads.
191 */
192 @Override
193 public IBinder onBind(Intent arg0) {
194 return mBinder;
195 }
196
197
198 /**
199 * Called when ALL the bound clients were onbound.
200 */
201 @Override
202 public boolean onUnbind(Intent intent) {
203 ((FileDownloaderBinder)mBinder).clearListeners();
204 return false; // not accepting rebinding (default behaviour)
205 }
206
207
208 /**
209 * Binder to let client components to perform operations on the queue of downloads.
210 *
211 * It provides by itself the available operations.
212 */
213 public class FileDownloaderBinder extends Binder implements OnDatatransferProgressListener {
214
215 /**
216 * Map of listeners that will be reported about progress of downloads from a {@link FileDownloaderBinder}
217 * instance.
218 */
219 private Map<Long, OnDatatransferProgressListener> mBoundListeners =
220 new HashMap<Long, OnDatatransferProgressListener>();
221
222
223 /**
224 * Cancels a pending or current download of a remote file.
225 *
226 * @param account ownCloud account where the remote file is stored.
227 * @param file A file in the queue of pending downloads
228 */
229 public void cancel(Account account, OCFile file) {
230 /*Log_OC.v(
231 "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
232 "Received request to cancel download of " + file.getRemotePath()
233 );
234 Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
235 "Removing download of " + file.getRemotePath());*/
236 Pair<DownloadFileOperation, String> removeResult = mPendingDownloads.remove(account, file.getRemotePath());
237 DownloadFileOperation download = removeResult.first;
238 if (download != null) {
239 /*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
240 "Canceling returned download of " + file.getRemotePath());*/
241 download.cancel();
242 } else {
243 if (mCurrentDownload != null && mCurrentAccount != null &&
244 mCurrentDownload.getRemotePath().startsWith(file.getRemotePath()) &&
245 account.name.equals(mCurrentAccount.name)) {
246 /*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
247 "Canceling current sync as descendant: " + mCurrentDownload.getRemotePath());*/
248 mCurrentDownload.cancel();
249 }
250 }
251 }
252
253
254 public void clearListeners() {
255 mBoundListeners.clear();
256 }
257
258
259 /**
260 * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or
261 * waiting to download.
262 *
263 * If 'file' is a directory, returns 'true' if any of its descendant files is downloading or
264 * waiting to download.
265 *
266 * @param account ownCloud account where the remote file is stored.
267 * @param file A file that could be in the queue of downloads.
268 */
269 public boolean isDownloading(Account account, OCFile file) {
270 if (account == null || file == null) return false;
271 return (mPendingDownloads.contains(account, file.getRemotePath()));
272 }
273
274
275 /**
276 * Adds a listener interested in the progress of the download for a concrete file.
277 *
278 * @param listener Object to notify about progress of transfer.
279 * @param account ownCloud account holding the file of interest.
280 * @param file {@link OCFile} of interest for listener.
281 */
282 public void addDatatransferProgressListener (
283 OnDatatransferProgressListener listener, Account account, OCFile file
284 ) {
285 if (account == null || file == null || listener == null) return;
286 //String targetKey = buildKey(account, file.getRemotePath());
287 mBoundListeners.put(file.getFileId(), listener);
288 }
289
290
291 /**
292 * Removes a listener interested in the progress of the download for a concrete file.
293 *
294 * @param listener Object to notify about progress of transfer.
295 * @param account ownCloud account holding the file of interest.
296 * @param file {@link OCFile} of interest for listener.
297 */
298 public void removeDatatransferProgressListener (
299 OnDatatransferProgressListener listener, Account account, OCFile file
300 ) {
301 if (account == null || file == null || listener == null) return;
302 //String targetKey = buildKey(account, file.getRemotePath());
303 Long fileId = file.getFileId();
304 if (mBoundListeners.get(fileId) == listener) {
305 mBoundListeners.remove(fileId);
306 }
307 }
308
309 @Override
310 public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer,
311 String fileName) {
312 //String key = buildKey(mCurrentDownload.getAccount(), mCurrentDownload.getFile().getRemotePath());
313 OnDatatransferProgressListener boundListener = mBoundListeners.get(mCurrentDownload.getFile().getFileId());
314 if (boundListener != null) {
315 boundListener.onTransferProgress(progressRate, totalTransferredSoFar, totalToTransfer, fileName);
316 }
317 }
318
319 }
320
321
322 /**
323 * Download worker. Performs the pending downloads in the order they were requested.
324 *
325 * Created with the Looper of a new thread, started in {@link FileUploader#onCreate()}.
326 */
327 private static class ServiceHandler extends Handler {
328 // don't make it a final class, and don't remove the static ; lint will warn about a possible memory leak
329 FileDownloader mService;
330 public ServiceHandler(Looper looper, FileDownloader service) {
331 super(looper);
332 if (service == null)
333 throw new IllegalArgumentException("Received invalid NULL in parameter 'service'");
334 mService = service;
335 }
336
337 @Override
338 public void handleMessage(Message msg) {
339 @SuppressWarnings("unchecked")
340 AbstractList<String> requestedDownloads = (AbstractList<String>) msg.obj;
341 if (msg.obj != null) {
342 Iterator<String> it = requestedDownloads.iterator();
343 while (it.hasNext()) {
344 String next = it.next();
345 /*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
346 "Handling download file " + next);*/
347 mService.downloadFile(next);
348 }
349 }
350 mService.stopSelf(msg.arg1);
351 }
352 }
353
354
355 /**
356 * Core download method: requests a file to download and stores it.
357 *
358 * @param downloadKey Key to access the download to perform, contained in mPendingDownloads
359 */
360 private void downloadFile(String downloadKey) {
361
362 /*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
363 "Getting download of " + downloadKey);*/
364 mCurrentDownload = mPendingDownloads.get(downloadKey);
365
366 if (mCurrentDownload != null) {
367
368 notifyDownloadStart(mCurrentDownload);
369
370 RemoteOperationResult downloadResult = null;
371 try {
372 /// prepare client object to send the request to the ownCloud server
373 if (mCurrentAccount == null || !mCurrentAccount.equals(mCurrentDownload.getAccount())) {
374 mCurrentAccount = mCurrentDownload.getAccount();
375 mStorageManager = new FileDataStorageManager(
376 mCurrentAccount,
377 getContentResolver()
378 );
379 } // else, reuse storage manager from previous operation
380
381 // always get client from client manager, to get fresh credentials in case of update
382 OwnCloudAccount ocAccount = new OwnCloudAccount(mCurrentAccount, this);
383 mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
384 getClientFor(ocAccount, this);
385
386
387 /// perform the download
388 /*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
389 "Executing download of " + mCurrentDownload.getRemotePath());*/
390 downloadResult = mCurrentDownload.execute(mDownloadClient);
391 if (downloadResult.isSuccess()) {
392 saveDownloadedFile();
393 }
394
395 } catch (AccountsException e) {
396 Log_OC.e(TAG, "Error while trying to get authorization for " + mCurrentAccount.name, e);
397 downloadResult = new RemoteOperationResult(e);
398 } catch (IOException e) {
399 Log_OC.e(TAG, "Error while trying to get authorization for " + mCurrentAccount.name, e);
400 downloadResult = new RemoteOperationResult(e);
401
402 } finally {
403 /*Log_OC.v( "NOW " + TAG + ", thread " + Thread.currentThread().getName(),
404 "Removing payload " + mCurrentDownload.getRemotePath());*/
405
406 Pair<DownloadFileOperation, String> removeResult =
407 mPendingDownloads.removePayload(mCurrentAccount, mCurrentDownload.getRemotePath());
408
409 /// notify result
410 notifyDownloadResult(mCurrentDownload, downloadResult);
411
412 sendBroadcastDownloadFinished(mCurrentDownload, downloadResult, removeResult.second);
413 }
414
415 }
416 }
417
418
419 /**
420 * Updates the OC File after a successful download.
421 */
422 private void saveDownloadedFile() {
423 OCFile file = mStorageManager.getFileById(mCurrentDownload.getFile().getFileId());
424 long syncDate = System.currentTimeMillis();
425 file.setLastSyncDateForProperties(syncDate);
426 file.setLastSyncDateForData(syncDate);
427 file.setNeedsUpdateThumbnail(true);
428 file.setModificationTimestamp(mCurrentDownload.getModificationTimestamp());
429 file.setModificationTimestampAtLastSyncForData(mCurrentDownload.getModificationTimestamp());
430 // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available
431 file.setMimetype(mCurrentDownload.getMimeType());
432 file.setStoragePath(mCurrentDownload.getSavePath());
433 file.setFileLength((new File(mCurrentDownload.getSavePath()).length()));
434 file.setRemoteId(mCurrentDownload.getFile().getRemoteId());
435 mStorageManager.saveFile(file);
436 mStorageManager.triggerMediaScan(file.getStoragePath());
437 }
438
439 /**
440 * Update the OC File after a unsuccessful download
441 */
442 private void updateUnsuccessfulDownloadedFile() {
443 OCFile file = mStorageManager.getFileById(mCurrentDownload.getFile().getFileId());
444 file.setDownloading(false);
445 mStorageManager.saveFile(file);
446 }
447
448
449 /**
450 * Creates a status notification to show the download progress
451 *
452 * @param download Download operation starting.
453 */
454 private void notifyDownloadStart(DownloadFileOperation download) {
455 /// create status notification with a progress bar
456 mLastPercent = 0;
457 mNotificationBuilder =
458 NotificationBuilderWithProgressBar.newNotificationBuilderWithProgressBar(this);
459 mNotificationBuilder
460 .setSmallIcon(R.drawable.notification_icon)
461 .setTicker(getString(R.string.downloader_download_in_progress_ticker))
462 .setContentTitle(getString(R.string.downloader_download_in_progress_ticker))
463 .setOngoing(true)
464 .setProgress(100, 0, download.getSize() < 0)
465 .setContentText(
466 String.format(getString(R.string.downloader_download_in_progress_content), 0,
467 new File(download.getSavePath()).getName())
468 );
469
470 /// includes a pending intent in the notification showing the details view of the file
471 Intent showDetailsIntent = null;
472 if (PreviewImageFragment.canBePreviewed(download.getFile())) {
473 showDetailsIntent = new Intent(this, PreviewImageActivity.class);
474 } else {
475 showDetailsIntent = new Intent(this, FileDisplayActivity.class);
476 }
477 showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
478 showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
479 showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
480
481 mNotificationBuilder.setContentIntent(PendingIntent.getActivity(
482 this, (int) System.currentTimeMillis(), showDetailsIntent, 0
483 ));
484
485 mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotificationBuilder.build());
486 }
487
488
489 /**
490 * Callback method to update the progress bar in the status notification.
491 */
492 @Override
493 public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filePath)
494 {
495 int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer));
496 if (percent != mLastPercent) {
497 mNotificationBuilder.setProgress(100, percent, totalToTransfer < 0);
498 String fileName = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1);
499 String text = String.format(getString(R.string.downloader_download_in_progress_content), percent, fileName);
500 mNotificationBuilder.setContentText(text);
501 mNotificationManager.notify(R.string.downloader_download_in_progress_ticker, mNotificationBuilder.build());
502 }
503 mLastPercent = percent;
504 }
505
506
507 /**
508 * Updates the status notification with the result of a download operation.
509 *
510 * @param downloadResult Result of the download operation.
511 * @param download Finished download operation
512 */
513 private void notifyDownloadResult(DownloadFileOperation download, RemoteOperationResult downloadResult) {
514 mNotificationManager.cancel(R.string.downloader_download_in_progress_ticker);
515 if (!downloadResult.isCancelled()) {
516 int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker :
517 R.string.downloader_download_failed_ticker;
518
519 boolean needsToUpdateCredentials = (
520 downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
521 downloadResult.isIdPRedirection()
522 );
523 tickerId = (needsToUpdateCredentials) ?
524 R.string.downloader_download_failed_credentials_error : tickerId;
525
526 mNotificationBuilder
527 .setTicker(getString(tickerId))
528 .setContentTitle(getString(tickerId))
529 .setAutoCancel(true)
530 .setOngoing(false)
531 .setProgress(0, 0, false);
532
533 if (needsToUpdateCredentials) {
534
535 // let the user update credentials with one click
536 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
537 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount());
538 updateAccountCredentials.putExtra(
539 AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN
540 );
541 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
542 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
543 updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
544 mNotificationBuilder
545 .setContentIntent(PendingIntent.getActivity(
546 this, (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT));
547
548 } else {
549 // TODO put something smart in showDetailsIntent
550 Intent showDetailsIntent = new Intent();
551 mNotificationBuilder
552 .setContentIntent(PendingIntent.getActivity(
553 this, (int) System.currentTimeMillis(), showDetailsIntent, 0));
554 }
555
556 mNotificationBuilder.setContentText(
557 ErrorMessageAdapter.getErrorCauseMessage(downloadResult, download, getResources())
558 );
559 mNotificationManager.notify(tickerId, mNotificationBuilder.build());
560
561 // Remove success notification
562 if (downloadResult.isSuccess()) {
563 // Sleep 2 seconds, so show the notification before remove it
564 NotificationDelayer.cancelWithDelay(
565 mNotificationManager,
566 R.string.downloader_download_succeeded_ticker,
567 2000);
568 }
569
570 }
571 }
572
573
574 /**
575 * Sends a broadcast when a download finishes in order to the interested activities can update their view
576 *
577 * @param download Finished download operation
578 * @param downloadResult Result of the download operation
579 * @param unlinkedFromRemotePath Path in the downloads tree where the download was unlinked from
580 */
581 private void sendBroadcastDownloadFinished(
582 DownloadFileOperation download,
583 RemoteOperationResult downloadResult,
584 String unlinkedFromRemotePath) {
585 Intent end = new Intent(getDownloadFinishMessage());
586 end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess());
587 end.putExtra(ACCOUNT_NAME, download.getAccount().name);
588 end.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
589 end.putExtra(EXTRA_FILE_PATH, download.getSavePath());
590 if (unlinkedFromRemotePath != null) {
591 end.putExtra(EXTRA_LINKED_TO_PATH, unlinkedFromRemotePath);
592 }
593 sendStickyBroadcast(end);
594 }
595
596
597 /**
598 * Sends a broadcast when a new download is added to the queue.
599 *
600 * @param download Added download operation
601 * @param linkedToRemotePath Path in the downloads tree where the download was linked to
602 */
603 private void sendBroadcastNewDownload(DownloadFileOperation download, String linkedToRemotePath) {
604 Intent added = new Intent(getDownloadAddedMessage());
605 added.putExtra(ACCOUNT_NAME, download.getAccount().name);
606 added.putExtra(EXTRA_REMOTE_PATH, download.getRemotePath());
607 added.putExtra(EXTRA_FILE_PATH, download.getSavePath());
608 added.putExtra(EXTRA_LINKED_TO_PATH, linkedToRemotePath);
609 sendStickyBroadcast(added);
610 }
611
612 }