sbDeviceFirmwareDownloader.h
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 #ifndef __SB_DEVICEFIRMWAREDOWNLOADER_H__
26 #define __SB_DEVICEFIRMWAREDOWNLOADER_H__
27 
28 #include <nsIFile.h>
29 #include <nsITimer.h>
30 #include <nsIURI.h>
31 #include <nsIXMLHttpRequest.h>
32 
33 #include <nsCOMPtr.h>
34 #include <nsStringGlue.h>
35 #include <prmon.h>
36 
37 #include <sbIDevice.h>
38 #include <sbIDeviceEvent.h>
39 #include <sbIDeviceEventListener.h>
40 #include <sbIDeviceFirmwareHandler.h>
41 #include <sbIDeviceManager.h>
42 #include <sbIFileDownloader.h>
43 
45 {
46 public:
48  NS_DECL_SBIFILEDOWNLOADERLISTENER
49 
51 
52  nsresult Init(sbIDevice *aDevice,
53  sbIDeviceEventListener *aListener,
54  sbIDeviceFirmwareHandler *aHandler);
55  nsresult Init(sbIDevice *aDevice,
56  const nsAString &aCacheDirName,
57  sbIDeviceEventListener *aListener,
58  sbIDeviceFirmwareHandler *aHandler);
59 
60  static nsresult CreateCacheRoot(nsIFile **aCacheRoot);
61  static nsresult CreateCacheDirForDevice(sbIDevice *aDevice,
62  nsIFile *aCacheRoot,
63  nsIFile **aCacheDir);
64  static nsresult CreateCacheDirForDevice(const nsAString &aCacheDirName,
65  nsIFile *aCacheRoot,
66  nsIFile **aCacheDir);
67  static nsresult CacheFirmwareUpdate(sbIDevice *aDevice,
68  sbIDeviceFirmwareUpdate *aFirmwareUpdate,
69  sbIDeviceFirmwareUpdate **aCachedFirmwareUpdate);
70  static nsresult CacheFirmwareUpdate(sbIDevice *aDevice,
71  const nsAString &aCacheDirName,
72  sbIDeviceFirmwareUpdate *aFirmwareUpdate,
73  sbIDeviceFirmwareUpdate **aCachedFirmwareUpdate);
74 
75  static nsresult CreateDirInCacheRoot(const nsAString &aDirName,
76  nsIFile **aNewDir);
77 
78  PRBool IsAlreadyInCache();
79  nsresult GetCachedFile(nsIFile **aFile);
80 
81  nsresult Start();
82  nsresult Cancel();
83 
84  nsresult HandleProgress();
85  nsresult HandleComplete();
86 
87  nsresult CreateDeviceEvent(PRUint32 aType,
88  nsIVariant *aData,
89  sbIDeviceEvent **aEvent);
90  nsresult SendDeviceEvent(sbIDeviceEvent *aEvent, PRBool aAsync = PR_TRUE);
91  nsresult SendDeviceEvent(PRUint32 aType,
92  nsIVariant *aData,
93  PRBool aAsync = PR_TRUE);
94 protected:
96 
97 private:
98  nsCOMPtr<nsIFile> mCacheDir;
99  nsCOMPtr<nsIFile> mDeviceCacheDir;
100  nsCOMPtr<sbIDevice> mDevice;
101  nsCOMPtr<sbIDeviceEventListener> mListener;
102  nsCOMPtr<sbIDeviceFirmwareHandler> mHandler;
103  nsCOMPtr<sbIFileDownloader> mDownloader;
104  PRPackedBool mIsBusy;
105 };
106 
107 #endif /*__SB_DEVICEFIRMWAREDOWNLOADER_H__*/
static nsresult CacheFirmwareUpdate(sbIDevice *aDevice, sbIDeviceFirmwareUpdate *aFirmwareUpdate, sbIDeviceFirmwareUpdate **aCachedFirmwareUpdate)
nsresult SendDeviceEvent(sbIDeviceEvent *aEvent, PRBool aAsync=PR_TRUE)
static nsresult CreateCacheDirForDevice(sbIDevice *aDevice, nsIFile *aCacheRoot, nsIFile **aCacheDir)
static nsresult CreateDirInCacheRoot(const nsAString &aDirName, nsIFile **aNewDir)
nsresult Init(sbIDevice *aDevice, sbIDeviceEventListener *aListener, sbIDeviceFirmwareHandler *aHandler)
static nsresult CreateCacheRoot(nsIFile **aCacheRoot)
nsresult GetCachedFile(nsIFile **aFile)
NS_DECL_ISUPPORTS NS_DECL_SBIFILEDOWNLOADERLISTENER sbDeviceFirmwareDownloader()
nsresult CreateDeviceEvent(PRUint32 aType, nsIVariant *aData, sbIDeviceEvent **aEvent)
_updateTextAndScrollDataForFrame aData