sbDeviceFirmwareUpdate.cpp
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 #include "sbDeviceFirmwareUpdate.h"
26 
27 #include <nsIClassInfoImpl.h>
28 #include <nsIProgrammingLanguage.h>
29 
30 #include <nsAutoLock.h>
31 #include <nsMemory.h>
32 
35 
39 
40 NS_IMPL_CI_INTERFACE_GETTER1(sbDeviceFirmwareUpdate,
41  sbIDeviceFirmwareUpdate)
42 
43 NS_DECL_CLASSINFO(sbDeviceFirmwareUpdate)
44 NS_IMPL_THREADSAFE_CI(sbDeviceFirmwareUpdate)
45 
46 sbDeviceFirmwareUpdate::sbDeviceFirmwareUpdate()
47 : mMonitor(nsnull)
48 , mFirmwareReadableVersion(NS_LITERAL_STRING("0"))
49 , mFirmwareVersion(0)
50 {
51 }
52 
53 sbDeviceFirmwareUpdate::~sbDeviceFirmwareUpdate()
54 {
55  if(mMonitor) {
56  nsAutoMonitor::DestroyMonitor(mMonitor);
57  }
58 }
59 
60 NS_IMETHODIMP
61 sbDeviceFirmwareUpdate::GetFirmwareImageFile(nsIFile * *aFirmwareImageFile)
62 {
63  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
64  NS_ENSURE_STATE(mFirmwareImageFile);
65 
66  nsAutoMonitor mon(mMonitor);
67 
68  nsresult rv = mFirmwareImageFile->Clone(aFirmwareImageFile);
69  NS_ENSURE_SUCCESS(rv, rv);
70 
71  return NS_OK;
72 }
73 
74 NS_IMETHODIMP
75 sbDeviceFirmwareUpdate::GetFirmwareReadableVersion(nsAString & aFirmwareReadableVersion)
76 {
77  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
78 
79  nsAutoMonitor mon(mMonitor);
80  aFirmwareReadableVersion = mFirmwareReadableVersion;
81 
82  return NS_OK;
83 }
84 
85 NS_IMETHODIMP
86 sbDeviceFirmwareUpdate::GetFirmwareVersion(PRUint32 *aFirmwareVersion)
87 {
88  NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED);
89  NS_ENSURE_ARG_POINTER(aFirmwareVersion);
90 
91  nsAutoMonitor mon(mMonitor);
92  *aFirmwareVersion = mFirmwareVersion;
93 
94  return NS_OK;
95 }
96 
97 NS_IMETHODIMP sbDeviceFirmwareUpdate::Init(nsIFile *aFirmwareImageFile,
98  const nsAString & aFirmwareReadableVersion,
99  PRUint32 aFirmwareVersion)
100 {
101  NS_ENSURE_ARG_POINTER(aFirmwareImageFile);
102 
103  mMonitor = nsAutoMonitor::NewMonitor("sbDeviceFirmwareUpdate::mMonitor");
104  NS_ENSURE_TRUE(mMonitor, NS_ERROR_OUT_OF_MEMORY);
105 
106  mFirmwareImageFile = aFirmwareImageFile;
107  mFirmwareReadableVersion = aFirmwareReadableVersion;
108  mFirmwareVersion = aFirmwareVersion;
109 
110  return NS_OK;
111 }
return NS_OK
NS_IMPL_QUERY_INTERFACE2_CI(sbDeviceFirmwareUpdate, sbIDeviceFirmwareUpdate, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER1(sbDeviceFirmwareUpdate
NS_IMPL_THREADSAFE_CI(sbMediaListEnumeratorWrapper)
nsCOMPtr< nsIFile > mFirmwareImageFile
NS_IMPL_THREADSAFE_RELEASE(sbRequestItem)
NS_IMPL_THREADSAFE_ADDREF(sbRequestItem)
function Init()
sbIJobCancelable NS_DECL_CLASSINFO(sbGstreamerMediaInspector)
NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER1(CDatabaseQuery, sbIDatabaseQuery) CDatabaseQuery