#include <sbBaseDeviceFirmwareHandler.h>
Public Types | |
enum | handlerstate_t { HANDLER_IDLE = 0, HANDLER_REFRESHING_INFO, HANDLER_UPDATING_DEVICE, HANDLER_X } |
Public Member Functions | |
sbBaseDeviceFirmwareHandler () | |
nsresult | Init () |
nsresult | AppendSupportedDevice (const nsAString &aDeviceFriendlyName, const PRUint32 aDeviceVendorID, const PRUint32 aDeviceProductID) |
Append an entry to the list of supported devices. More... | |
nsresult | AppendSupportedDeviceProductID (const nsAString &aDeviceFriendlyName, const PRUint32 aDeviceProductID) |
nsresult | CreateProxiedURI (const nsACString &aURISpec, nsIURI **aURI) |
Create an nsIURI from a spec string (e.g. http://some.url.com/path) in a thread-safe manner. More... | |
nsresult | SendHttpRequest (const nsACString &aMethod, const nsACString &aUrl, const nsAString &aUsername=EmptyString(), const nsAString &aPassword=EmptyString(), const nsACString &aContentType=EmptyCString(), nsIVariant *aRequestBody=nsnull) |
Send an HTTP request. More... | |
nsresult | AbortHttpRequest () |
Abort an HTTP request. More... | |
nsresult | CreateDeviceEvent (PRUint32 aType, nsIVariant *aData, sbIDeviceEvent **aEvent) |
Create a device event. More... | |
nsresult | SendDeviceEvent (sbIDeviceEvent *aEvent, PRBool aAsync=PR_TRUE) |
Send a device event. More... | |
nsresult | SendDeviceEvent (PRUint32 aType, nsIVariant *aData, PRBool aAsync=PR_TRUE) |
Send a device event. More... | |
handlerstate_t | GetState () |
Set internal state. More... | |
nsresult | SetState (handlerstate_t aState) |
Get internal state. More... | |
nsresult | CheckForError (const nsresult &aResult, PRUint32 aEventType, nsIVariant *aData=nsnull) |
Check nsresult value, send error event if nsresult value is an error. More... | |
virtual nsresult | OnInit () |
virtual nsresult | OnGetCurrentFirmwareVersion (PRUint32 *aCurrentFirmwareVersion) |
virtual nsresult | OnGetCurrentFirmwareReadableVersion (nsAString &aCurrentFirmwareReadableVersion) |
virtual nsresult | OnGetRecoveryMode (PRBool *aRecoveryMode) |
virtual nsresult | OnGetDeviceModelNumber (nsAString &aModelNumber) |
virtual nsresult | OnGetDeviceModelVersion (nsAString &aModelVersion) |
virtual nsresult | OnGetDeviceVendor (nsAString &aDeviceVendor) |
virtual nsresult | OnGetSupportedDevices (nsISimpleEnumerator **aSupportedDevices) |
virtual nsresult | OnCanUpdate (sbIDevice *aDevice, PRUint32 aDeviceVendorID, PRUint32 aDeviceProductID, PRBool *_retval) |
virtual nsresult | OnBeginRecoveryModeSwitch (PRUint32 aDeviceVendorID, PRUint32 aDeviceProductID) |
virtual nsresult | OnEndRecoveryModeSwitch () |
virtual nsresult | OnRebind (sbIDevice *aDevice, sbIDeviceEventListener *aListener, PRBool *_retval) |
virtual nsresult | OnCancel () |
virtual nsresult | OnRefreshInfo () |
virtual nsresult | OnUpdate (sbIDeviceFirmwareUpdate *aFirmwareUpdate) |
virtual nsresult | OnRecover (sbIDeviceFirmwareUpdate *aFirmwareUpdate) |
virtual nsresult | OnVerifyDevice () |
virtual nsresult | OnVerifyUpdate (sbIDeviceFirmwareUpdate *aFirmwareUpdate) |
virtual nsresult | OnHttpRequestCompleted () |
Public Member Functions inherited from sbIDeviceFirmwareHandler | |
boolean | canUpdate (in sbIDevice aDevice, in unsigned long aDeviceVendorID, in unsigned long aDeviceProductID) |
Check to see if this handler can update the specified device. More... | |
void | initiateRecoveryModeSwitch ([optional] in unsigned long aDeviceVendorID, [optional] in unsigned long aDeviceProductID) |
Notify the handler to expect a device to connect in recovery mode. More... | |
void | bind (in sbIDevice aDevice, in sbIDeviceEventListener aListener) |
Bind the handler to a device. More... | |
boolean | rebind (in sbIDevice aDevice, in sbIDeviceEventListener aListener) |
Rebind a device to an already running handler. More... | |
void | unbind () |
Unbind the handler. More... | |
void | cancel () |
Cancel the current operation. More... | |
void | refreshInfo () |
Refresh the firmware location, version, readable version, notes, and instructions. More... | |
void | update (in sbIDeviceFirmwareUpdate aFirmwareUpdate) |
Perform a firmware update on the specified device. More... | |
void | recover (in sbIDeviceFirmwareUpdate aFirmwareUpdate) |
Perform a recovery update on the specified device. More... | |
void | verifyDevice () |
Verify the firmware already on the device. More... | |
void | verifyUpdate (in sbIDeviceFirmwareUpdate aFirmwareUpdate) |
Verify the firmware update image. More... | |
Protected Member Functions | |
virtual | ~sbBaseDeviceFirmwareHandler () |
Protected Attributes | |
PRMonitor * | mMonitor |
nsCOMPtr< sbIDevice > | mDevice |
nsCOMPtr< sbIDeviceEventListener > | mListener |
nsCOMPtr< sbIDeviceEventListener > | mProxiedListener |
handlerstate_t | mHandlerState |
PRUint32 | mFirmwareVersion |
PRUint32 | mDefaultFirmwareVersion |
nsString | mContractId |
nsString | mReadableFirmwareVersion |
nsString | mDefaultReadableFirmwareVersion |
nsCOMPtr< nsIURI > | mDefaultFirmwareLocation |
nsCOMPtr< nsIURI > | mFirmwareLocation |
nsCOMPtr< nsIURI > | mDefaultReleaseNotesLocation |
nsCOMPtr< nsIURI > | mReleaseNotesLocation |
nsCOMPtr< nsIURI > | mResetInstructionsLocation |
nsString | mRecoveryModeKeyCombination |
nsCOMPtr< nsIURI > | mSupportLocation |
nsCOMPtr< nsIURI > | mRegisterLocation |
PRPackedBool | mNeedsRecoveryMode |
PRPackedBool | mRecoveryMode |
nsCOMPtr< nsIXMLHttpRequest > | mXMLHttpRequest |
nsCOMPtr< nsITimer > | mXMLHttpRequestTimer |
nsCOMPtr< nsIMutableArray > | mSupportedDevices |
Additional Inherited Members | |
Public Attributes inherited from sbIDeviceFirmwareHandler | |
readonly attribute AString | contractId |
The Contract ID for this handler. More... | |
readonly attribute nsIURI | latestFirmwareLocation |
URI for latest firmware (where it can be downloaded from). More... | |
readonly attribute unsigned long | latestFirmwareVersion |
The latest firmware version, in machine friendly format. More... | |
readonly attribute AString | latestFirmwareReadableVersion |
The latest firmware version, in human readable format. More... | |
readonly attribute unsigned long | currentFirmwareVersion |
The current firmware version, in machine friendly format. More... | |
readonly attribute AString | currentFirmwareReadableVersion |
The current firmware version on the device, in human readable format (eg. xx.xx.xx.xx). More... | |
readonly attribute nsIURI | releaseNotesLocation |
Location for the release notes of the latest firmware. More... | |
readonly attribute nsIURI | resetInstructionsLocation |
Location of the reset instructions. More... | |
readonly attribute AString | recoveryModeKeyCombination |
Magic key combination required by the device to go into recovery or firmware flashing mode. More... | |
readonly attribute nsIURI | customerSupportLocation |
Device Customer Support URL. More... | |
readonly attribute nsIURI | registerLocation |
Location where one can perform owner registration with the device manufacturer. More... | |
readonly attribute boolean | needsRecoveryMode |
Whether the device needs to be in recovery mode to have its firmware updated. More... | |
readonly attribute boolean | recoveryMode |
Indicates whether the device is in recovery mode or not. More... | |
readonly attribute sbIDeviceFirmwareUpdate | defaultFirmwareUpdate |
The default firmware update that is packaged with the firmware handler. This update should always be available. More... | |
readonly attribute sbIDevice | boundDevice |
The device bound to this handler, or null. More... | |
readonly attribute AString | deviceModelNumber |
Device model number / name as reported by the firmware handler. More... | |
readonly attribute AString | deviceModelVersion |
Device model version / version name as reported by the firmware handler. More... | |
readonly attribute AString | deviceVendor |
Device manufacturer as reported by the firmware handler. More... | |
readonly attribute nsISimpleEnumerator | supportedDevices |
Array containing the list of devices supported by the firmware handler. More... | |
Definition at line 44 of file sbBaseDeviceFirmwareHandler.h.
Enumerator | |
---|---|
HANDLER_IDLE | |
HANDLER_REFRESHING_INFO | |
HANDLER_UPDATING_DEVICE | |
HANDLER_X |
Definition at line 52 of file sbBaseDeviceFirmwareHandler.h.
sbBaseDeviceFirmwareHandler::sbBaseDeviceFirmwareHandler | ( | ) |
|
protectedvirtual |
Definition at line 89 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::AbortHttpRequest | ( | ) |
Abort an HTTP request.
Definition at line 294 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::AppendSupportedDevice | ( | const nsAString & | aDeviceFriendlyName, |
const PRUint32 | aDeviceVendorID, | ||
const PRUint32 | aDeviceProductID | ||
) |
Append an entry to the list of supported devices.
Definition at line 137 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::AppendSupportedDeviceProductID | ( | const nsAString & | aDeviceFriendlyName, |
const PRUint32 | aDeviceProductID | ||
) |
Definition at line 159 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::CheckForError | ( | const nsresult & | aResult, |
PRUint32 | aEventType, | ||
nsIVariant * | aData = nsnull |
||
) |
Check nsresult value, send error event if nsresult value is an error.
aResult | - The result to check |
aEventType | - The event to send in the case where aResult is an error. |
Definition at line 446 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::CreateDeviceEvent | ( | PRUint32 | aType, |
nsIVariant * | aData, | ||
sbIDeviceEvent ** | aEvent | ||
) |
Create a device event.
Definition at line 319 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::CreateProxiedURI | ( | const nsACString & | aURISpec, |
nsIURI ** | aURI | ||
) |
Create an nsIURI from a spec string (e.g. http://some.url.com/path) in a thread-safe manner.
aURISpec | - The spec string |
aURI | - The pointer which will hold the new URI |
Definition at line 191 of file sbBaseDeviceFirmwareHandler.cpp.
sbBaseDeviceFirmwareHandler::handlerstate_t sbBaseDeviceFirmwareHandler::GetState | ( | ) |
Set internal state.
Definition at line 426 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::Init | ( | ) |
Definition at line 100 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
This is called when the application expects a device with the specified NORMAL MODE baseband IDs to connect in recovery mode. The handler should expect a device with ANY corresponding recovery mode IDs to connect. If aDeviceVendorID is zero, then expect the currently bound device to reconnect in recovery mode.
Definition at line 605 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Cancel whatever operation is happening. This is a synchronous call. After this call returns, your object will be destroyed.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 655 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you will want to verify the incoming sbIDevice object to determine if your handler can support updating the firmware on the device. _retval should be set to either PR_TRUE (yes, can update) or PR_FALSE (no, cannot update).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 588 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
The application calls this function when it determines that the handler should not expect a recovery mode connection. Reverse the effects, if any, of OnBeginRecoveryModeSwitch().
Calls to OnBeginRecoveryModeSwitch() and OnEndRecoveryModeSwitch() are not necessarily balanced.
Definition at line 621 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
You should return the current human readable version of the firmware on the device.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 504 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
You should return the current version of the firmware on the device.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 494 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you may return the internal model number for the device. This is optional, if you don't want to implement it, just skip overriding this method as the default version already does the right thing by default.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 525 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you may return the internal model version for the device. This is optional, if you don't want to implement it, just skip overriding this method as the default version already does the right thing by default.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 542 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you may return the vendor name for the device. This is optional, if you don't want to implement it, just skip overriding this method as the default version already does the right thing by default.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 560 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
You should return if the bound device is in recovery mode or not.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 515 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you would return a list of sbIDeviceFirmwareSupport objects which describe which devices your firmware handler supports.
Definition at line 577 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 801 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you will want to initialize yourself for the first time. This should include setting the following member variables to the the values you need: mContractId.
You should end up with a string that looks something like this: "@yourdomain.com/FirmwareHandler/AcmePortablePlayer900x;1"
The ';1' at the end of the contract id is the implementation version of the object. If you ever update your object and break or modify behavior, make sure to increment that number to ensure no one gets nasty surprises when creating your handler.
The other values only need to be set when OnRefreshInfo is called. These values are: mFirmwareVersion, mReadableFirmwareVersion, mFirmwareLocation mResetInstructionsLocation and mReleaseNotesLocation.
Events must be sent to both the device and the listener (if it is specified during the call).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 466 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
When a handler is already active and the device it is bound to requires to be reconnected in recovery mode (or a special mode so that it can be flashed) this function will be called to attempt to re-associate the new device instance with the old one so that the update process can continue.
If you manage to rebind properly, _retval should be set to PR_TRUE. Otherwise, set it to PR_FALSE.
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 636 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you will want to actually perform the firmware update on the device. The firmware update object will contain the local location for the firmware image. It also contains the version of the firmware image.
If no firmware update object is passed, the handler is expected to use a firmware update it packaged as part of its add-on. This is to enable a device to always be recovered even if the user is off line or has never updated their firmware before and have no firmware update present in their cache.
This method is expected to also reset the device to factory settings.
The implementation of this method must be asynchronous and not block the main thread. The flow of expected events is as follows: firmware update start, firmware write start, firmware write progress, firmware write end, firmware verify start, firmware verify progress, firmware verify end, firmware update end.
See sbIDeviceEvent for more infomation about event payload.
Events must be sent to both the device and the listener (if it is specified during the call).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 718 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you will want to refresh the info for your handler. This includes the latest firmware version, firmware location, reset instructions and release notes locations.
Always use CreateProxiedURI when creating the nsIURIs for the firmware, reset instructions and release notes location. This will ensure that the object is thread-safe and it is created in a thread-safe manner.
This method must be asynchronous and should not block the main thread. Progress for this operation is also expected. The flow of expected events is as follows: firmware refresh info start, N * firmware refresh info progress, firmware refresh info end. See sbIDeviceEvent for more information about event payload.
Events must be sent to both the device and the listener (if it is specified during the call).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 667 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you will want to actually perform the firmware update on the device. The firmware update object will contain the local location for the firmware image. It also contains the version of the firmware image.
The implementation of this method must be asynchronous and not block the main thread. The flow of expected events is as follows: firmware update start, firmware write start, firmware write progress, firmware write end, firmware verify start, firmware verify progress, firmware verify end, firmware update end.
See sbIDeviceEvent for more infomation about event payload.
Events must be sent to both the device and the listener (if it is specified during the call).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 693 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you will want to verify the firmware on the device itself to ensure that it is not corrupt. Whichever method you use will most likely be device specific.
The implementation of this method must be asynchronous and not block the main thread. The flow of expected events is as follows: firmware verify start, firmware verify progress, firmware verify end.
If any firmware verify error events are sent during the process the firmware is considered corrupted.
See sbIDeviceEvent for more infomation about event payload.
Events must be sent to both the device and the listener (if it is specified during the call).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 751 of file sbBaseDeviceFirmwareHandler.cpp.
|
virtual |
Here is where you should provide a way to verify the firmware update image itself to make sure that it is not corrupt in any way.
The implementation of this method must be asynchronous and not block the main thread. The flow of expected events is as follows: firmware image verify start, firmware image verify progress, firmware image verify end.
If any firmware image verify error events are sent during the process the firmware image is considered corrupted.
See sbIDeviceEvent for more infomation about event payload.
Events must be sent to both the device and the listener (if it is specified during the call).
Reimplemented in sbMockDeviceFirmwareHandler.
Definition at line 776 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::SendDeviceEvent | ( | sbIDeviceEvent * | aEvent, |
PRBool | aAsync = PR_TRUE |
||
) |
Send a device event.
Definition at line 351 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::SendDeviceEvent | ( | PRUint32 | aType, |
nsIVariant * | aData, | ||
PRBool | aAsync = PR_TRUE |
||
) |
Send a device event.
Definition at line 408 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::SendHttpRequest | ( | const nsACString & | aMethod, |
const nsACString & | aUrl, | ||
const nsAString & | aUsername = EmptyString() , |
||
const nsAString & | aPassword = EmptyString() , |
||
const nsACString & | aContentType = EmptyCString() , |
||
nsIVariant * | aRequestBody = nsnull |
||
) |
Send an HTTP request.
aMethod | - The HTTP Method to use, currently we support POST and GET |
aUrl | - The URL to send the request to, as a string. |
aUsername | [optional] - HTTP authentication username. |
aPassword | [optional] - HTTP authentication password. |
aContentType | [optional] - Content type to use for request |
aRequestBody | [optional] - Request body, if any (string or input stream) |
NS_ERROR_ABORT | when there is already a request pending. |
Definition at line 234 of file sbBaseDeviceFirmwareHandler.cpp.
nsresult sbBaseDeviceFirmwareHandler::SetState | ( | handlerstate_t | aState | ) |
Get internal state.
Definition at line 434 of file sbBaseDeviceFirmwareHandler.cpp.
|
protected |
Definition at line 214 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 218 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 212 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 216 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 220 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 206 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 219 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 211 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 210 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 207 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 204 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 227 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 208 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 215 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 228 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 223 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 225 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 221 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 222 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 233 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 224 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 230 of file sbBaseDeviceFirmwareHandler.h.
|
protected |
Definition at line 231 of file sbBaseDeviceFirmwareHandler.h.