27 #include <nsIClassInfoImpl.h>
28 #include <nsIProgrammingLanguage.h>
29 #include <nsIMutableArray.h>
30 #include <nsISimpleEnumerator.h>
31 #include <nsISupportsPrimitives.h>
33 #include <nsAutoLock.h>
34 #include <nsComponentManagerUtils.h>
36 #include <nsXPCOMCID.h>
46 sbIDeviceFirmwareSupport)
51 sbDeviceFirmwareSupport::sbDeviceFirmwareSupport()
56 sbDeviceFirmwareSupport::~sbDeviceFirmwareSupport()
59 nsAutoMonitor::DestroyMonitor(
mMonitor);
65 sbDeviceFirmwareSupport::GetDeviceFriendlyName(nsAString & aDeviceFriendlyName)
67 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
77 sbDeviceFirmwareSupport::GetDeviceVendorID(PRUint32 *aDeviceVendorID)
79 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
80 NS_ENSURE_ARG_POINTER(aDeviceVendorID);
92 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
93 NS_ENSURE_ARG_POINTER(aDeviceProductIDs);
98 NS_ENSURE_SUCCESS(rv, rv);
109 NS_ENSURE_ARG_POINTER(aDeviceProductIDs);
110 NS_ENSURE_FALSE(
mMonitor, NS_ERROR_ALREADY_INITIALIZED);
113 mMonitor = nsAutoMonitor::NewMonitor(
"sbDeviceFirmwareSupport::mMonitor");
114 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_OUT_OF_MEMORY);
119 nsresult rv = NS_ERROR_UNEXPECTED;
122 nsCOMPtr<nsIMutableArray> productIDs =
123 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
124 NS_ENSURE_SUCCESS(rv, rv);
126 while(NS_SUCCEEDED(rv = aDeviceProductIDs->HasMoreElements(&hasMore)) &&
129 rv = aDeviceProductIDs->GetNext(getter_AddRefs(element));
130 NS_ENSURE_SUCCESS(rv, rv);
132 nsCOMPtr<nsISupportsPRUint32> productID = do_QueryInterface(element, &rv);
133 NS_ENSURE_SUCCESS(rv, rv);
135 rv = productIDs->AppendElement(productID, PR_FALSE);
136 NS_ENSURE_SUCCESS(rv, rv);
145 sbDeviceFirmwareSupport::SimpleInit(
const nsAString & aDeviceName,
149 NS_ENSURE_FALSE(
mMonitor, NS_ERROR_ALREADY_INITIALIZED);
152 mMonitor = nsAutoMonitor::NewMonitor(
"sbDeviceFirmwareSupport::mMonitor");
153 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_OUT_OF_MEMORY);
155 nsresult rv = NS_ERROR_UNEXPECTED;
158 do_CreateInstance(
"@songbirdnest.com/moz/xpcom/threadsafe-array;1", &rv);
159 NS_ENSURE_SUCCESS(rv, rv);
164 nsCOMPtr<nsISupportsPRUint32> productID =
165 do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID, &rv);
166 NS_ENSURE_SUCCESS(rv, rv);
168 rv = productID->SetData(aProductID);
169 NS_ENSURE_SUCCESS(rv, rv);
172 NS_ENSURE_SUCCESS(rv, rv);
178 sbDeviceFirmwareSupport::AppendProductID(PRUint32 aProductID)
180 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
182 nsresult rv = NS_ERROR_UNEXPECTED;
186 nsCOMPtr<nsISupportsPRUint32> productID =
187 do_CreateInstance(NS_SUPPORTS_PRUINT32_CONTRACTID, &rv);
188 NS_ENSURE_SUCCESS(rv, rv);
190 rv = productID->SetData(aProductID);
191 NS_ENSURE_SUCCESS(rv, rv);
194 NS_ENSURE_SUCCESS(rv, rv);
NS_IMPL_QUERY_INTERFACE2_CI(sbDeviceFirmwareSupport, sbIDeviceFirmwareSupport, nsIClassInfo) NS_IMPL_CI_INTERFACE_GETTER1(sbDeviceFirmwareSupport
NS_IMPL_THREADSAFE_RELEASE(sbRequestItem)
NS_IMPL_THREADSAFE_ADDREF(sbRequestItem)
nsString mDeviceFriendlyName
nsCOMPtr< nsIMutableArray > mDeviceProductIDs
StringArrayEnumerator prototype hasMore
NS_INTERFACE_MAP_END NS_IMPL_CI_INTERFACE_GETTER1(CDatabaseQuery, sbIDatabaseQuery) CDatabaseQuery