27 #ifndef __DOWNLOAD_DEVICE_H__
28 #define __DOWNLOAD_DEVICE_H__
53 #define SONGBIRD_DownloadDevice_CONTRACTID \
54 "@songbirdnest.com/Songbird/OldDeviceImpl/DownloadDevice;1"
55 #define SONGBIRD_DownloadDevice_CLASSNAME "Songbird Download Device"
56 #define SONGBIRD_DownloadDevice_CID \
61 { 0x81, 0x8d, 0x62, 0x2C, 0x7B, 0xD1, 0x74, 0x47} \
73 #include <sbIDownloadDevice.h>
76 #include <nsAutoPtr.h>
78 #include <nsIDialogParamBlock.h>
80 #include <nsIIOService.h>
81 #include <nsIObserverService.h>
82 #include <nsIPrefService.h>
83 #include <nsIRunnable.h>
84 #include <nsIStringBundle.h>
85 #include <nsIThreadPool.h>
90 #include <sbIDataRemote.h>
91 #include <sbILibrary.h>
92 #include <sbILibraryUtils.h>
138 NS_DECL_SBIDEVICEBASE
139 NS_DECL_SBIDOWNLOADDEVICE
140 NS_DECL_SBIMEDIALISTLISTENER
176 nsCOMPtr<sbIMediaList> mpDownloadMediaList;
177 nsRefPtr<sbDeviceBaseLibraryListener>
178 mpDeviceLibraryListener;
179 nsCOMPtr<sbILibrary> mpMainLibrary;
180 nsCOMPtr<sbILibrary> mpWebLibrary;
181 nsCOMPtr<nsIPrefBranch> mpPrefBranch;
182 nsCOMPtr<nsIIOService> mpIOService;
183 nsCOMPtr<nsIStringBundle> mpStringBundle;
185 nsCOMPtr<nsIFile> mpTmpDownloadDir;
186 nsRefPtr<sbDownloadSession> mpDownloadSession;
187 PRMonitor *mpDeviceMonitor;
188 nsString mDeviceIdentifier;
190 nsCOMPtr<nsIThreadPool> mFileMoveThreadPool;
196 nsresult InitializeDownloadMediaList();
198 void FinalizeDownloadMediaList();
200 nsresult CreateDownloadMediaList();
202 void GetDownloadMediaList();
204 nsresult UpdateDownloadMediaList();
211 nsresult EnqueueItem(
214 nsresult RunTransferQueue();
216 PRBool GetNextTransferItem(
219 nsresult ResumeTransfers();
221 nsresult SetTransferDestination(
222 nsCOMPtr<sbIMediaItem> pMediaItem);
224 nsresult CancelSession();
226 void SessionCompleted(
236 nsIFile **ppTmpFile);
238 static nsresult MakeFileUnique(
243 nsIDialogParamBlock *apDialogPB);
245 static nsresult GetStatusTarget(
266 #include <nsIFileProtocolHandler.h>
267 #include <nsIHttpChannel.h>
268 #include <nsIHttpEventSink.h>
269 #include <nsIInterfaceRequestor.h>
270 #include <nsIProgressEventSink.h>
271 #include <nsIWebBrowserPersist.h>
272 #include <nsIWebProgressListener.h>
273 #include <nsITimer.h>
312 NS_DECL_NSIWEBPROGRESSLISTENER
313 NS_DECL_NSITIMERCALLBACK
370 PRLock *mpSessionLock;
372 nsCOMPtr<nsIStringBundle> mpStringBundle;
373 nsString mCompleteStr;
375 nsCOMPtr<sbILibraryUtils> mpLibraryUtils;
376 nsCOMPtr<nsIWebBrowserPersist>
378 nsCOMPtr<nsIChannel> mpRequest;
379 nsCOMPtr<nsIFile> mpTmpFile;
380 nsCOMPtr<nsIURI> mpSrcURI;
381 nsCOMPtr<sbILibrary> mpDstLibrary;
382 nsCOMPtr<nsIFile> mpDstFile;
383 nsCOMPtr<nsIURI> mpDstURI;
384 nsCOMPtr<sbIMediaItem> mpStatusTarget;
389 PRInt64 mInitialProgressBytes;
390 PRUint64 mLastProgressBytes;
391 PRUint64 mLastProgressBytesMax;
393 nsCOMPtr<nsITimer> mIdleTimer;
394 nsCOMPtr<nsITimer> mProgressTimer;
401 nsresult SetUpRequest();
403 nsresult CompleteTransfer(nsIRequest* aRequest);
405 nsresult UpdateDstLibraryMetadata();
409 PRUint64 aProgressMax);
411 void UpdateDownloadDetails(
413 PRUint64 aProgressMax);
415 void UpdateDownloadRate(
417 PRUint64 aElapsedUSecs);
419 nsresult FormatProgress(
420 nsString &aProgressStr,
422 PRUint64 aProgressMax,
424 PRUint32 aRemSeconds);
430 nsresult FormatByteProgress(
431 nsString &aByteProgressStr,
439 nsresult StartTimers();
440 nsresult StopTimers();
441 nsresult ResetTimers();
459 NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
468 nsCOMPtr<nsIMutableArray> mpMediaItemArray;
487 NS_DECL_SBIMEDIALISTENUMERATIONLISTENER
492 mpDownloadSession(pDownloadSession)
512 PRBool aReadOnly = PR_FALSE);
515 nsAutoPtr<sbDownloadButtonPropertyValue>
value;
518 nsCOMPtr<sbIMediaItem> mMediaItem;
519 nsCOMPtr<sbIMediaItem> mStatusTarget;
527 nsIFile *aDestinationPath,
528 const nsAString &aDestinationFileName,
530 NS_ASSERTION(aSourceFile,
"aSourceFile is null!");
531 NS_ASSERTION(aDestinationPath,
"aDestinationPath is null!");
532 NS_ASSERTION(aDestinationItem,
"aDestinationItem is null!");
534 mSourceFile = aSourceFile;
535 mDestinationPath = aDestinationPath;
536 mDestinationFileName = aDestinationFileName;
537 mDestinationItem = aDestinationItem;
544 nsCOMPtr<nsIFile> mSourceFile;
545 nsCOMPtr<nsIFile> mDestinationPath;
546 nsString mDestinationFileName;
548 nsCOMPtr<sbIMediaItem> mDestinationItem;
551 #endif // __DOWNLOAD_DEVICE_H__
nsCOMPtr< sbIMediaItem > mpMediaItem
nsCString GetContentDispositionFilename(const nsACString &contentDisposition)
sbDownloadSessionMoveHandler(nsIFile *aSourceFile, nsIFile *aDestinationPath, const nsAString &aDestinationFileName, sbIMediaItem *aDestinationItem)
virtual ~sbDownloadDevice()
NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER NS_DECL_SBIDEVICEBASE NS_DECL_SBIDOWNLOADDEVICE NS_DECL_SBIMEDIALISTLISTENER sbDownloadDevice()
NS_DECL_ISUPPORTS NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSITIMERCALLBACK sbDownloadSession(sbDownloadDevice *pDownloadDevice, sbIMediaItem *pMediaItem)
Songbird DownloadDevice Interface.
virtual ~sbDownloadSession()
Songbird DeviceBase Component Definition.