#include <DeviceBase.h>
Public Member Functions | |
sbDeviceBase () | |
virtual | ~sbDeviceBase () |
nsresult | Init () |
Initialize the base device class for use. More... | |
nsresult | CreateDeviceLibrary (const nsAString &aDeviceIdentifier, nsIURI *aDeviceDatabaseURI, sbIDeviceBase *aDevice) |
Create a library for a device instance. More... | |
nsresult | RemoveDeviceLibrary (const nsAString &aDeviceIdentifier) |
Remove a library for a device instance. More... | |
nsresult | GetLibraryForDevice (const nsAString &aDeviceIdentifier, sbILibrary **aDeviceLibrary) |
Get the library instance for a device. More... | |
nsresult | RegisterDeviceLibrary (sbILibrary *aDeviceLibrary) |
Register a device library with the library manager. More... | |
nsresult | UnregisterDeviceLibrary (sbILibrary *aDeviceLibrary) |
Unregister a device library with the library manager. More... | |
nsresult | CreateTransferQueue (const nsAString &aDeviceIdentifier) |
Create an internal transfer queue for a device instance. More... | |
nsresult | RemoveTransferQueue (const nsAString &aDeviceIdentifier) |
Remove an internal transfer queue for a device instance. More... | |
nsresult | AddItemToTransferQueue (const nsAString &aDeviceIdentifier, sbIMediaItem *aMediaItem) |
Add an item to the internal transfer queue. More... | |
nsresult | RemoveItemFromTransferQueue (const nsAString &aDeviceIdentifier, sbIMediaItem *aMediaItem) |
Remove an item from the internal transfer queue. More... | |
nsresult | GetNextItemFromTransferQueue (const nsAString &aDeviceIdentifier, sbIMediaItem **aMediaItem) |
Get the next item in the transfer queue. More... | |
nsresult | GetItemByIndexFromTransferQueue (const nsAString &aDeviceIdentifier, PRUint32 aItemIndex, sbIMediaItem **aMediaItem) |
Get an item from the transfer queue by index. More... | |
nsresult | GetTransferQueue (const nsAString &aDeviceIdentifier, nsIMutableArray **aTransferQueue) |
Get the internnal transfer queue for a device instance. More... | |
nsresult | ClearTransferQueue (const nsAString &aDeviceIdentifier) |
Clear the entire transfer queue. More... | |
nsresult | IsTransferQueueEmpty (const nsAString &aDeviceIdentifier, PRBool &aEmpty) |
nsresult | AddCallback (sbIDeviceBaseCallback *aCallback) |
nsresult | RemoveCallback (sbIDeviceBaseCallback *aCallback) |
void | DoTransferStartCallback (sbIMediaItem *aMediaItem) |
void | DoTransferCompleteCallback (sbIMediaItem *aMediaItem, PRInt32 aStatus) |
void | DoDeviceConnectCallback (const nsAString &aDeviceIdentifier) |
void | DoDeviceDisconnectCallback (const nsAString &aDeviceIdentifier) |
void | DoStateChangedCallback (const nsAString &aDeviceIdentifier, PRUint32 aState) |
nsresult | GetDeviceState (const nsAString &aDeviceIdentifier, PRUint32 *aDeviceState) |
nsresult | SetDeviceState (const nsAString &aDeviceIdentifier, PRUint32 aDeviceState) |
nsresult | InitDeviceState (const nsAString &aDeviceIdentifier) |
nsresult | ClearDeviceState (const nsAString &aDeviceIdentifier) |
nsresult | SetListenerForDeviceLibrary (const nsAString &aDeviceIdentifier, sbIMediaListListener *aMediaListListener) |
nsresult | GetListenerForDeviceLibrary (const nsAString &aDeviceIdentifier, sbIMediaListListener **aMediaListListener) |
nsresult | RemoveListenerForDeviceLibrary (const nsAString &aDeviceIdentifier) |
Protected Attributes | |
nsInterfaceHashtableMT < nsStringHashKey, sbILibrary > | mDeviceLibraries |
nsInterfaceHashtableMT < nsStringHashKey, nsIMutableArray > | mDeviceQueues |
nsRefPtrHashtableMT < nsISupportsHashKey, sbDeviceBaseCallbackProxy > | mDeviceCallbacks |
nsDataHashtableMT < nsStringHashKey, PRUint32 > | mDeviceStates |
nsInterfaceHashtableMT < nsStringHashKey, sbIMediaListListener > | mDeviceLibraryListeners |
Friends | |
class | sbDeviceThread |
Definition at line 150 of file DeviceBase.h.
sbDeviceBase::sbDeviceBase | ( | ) |
Definition at line 680 of file DeviceBase.cpp.
|
virtual |
Definition at line 689 of file DeviceBase.cpp.
nsresult sbDeviceBase::AddCallback | ( | sbIDeviceBaseCallback * | aCallback | ) |
Definition at line 706 of file DeviceBase.cpp.
nsresult sbDeviceBase::AddItemToTransferQueue | ( | const nsAString & | aDeviceIdentifier, |
sbIMediaItem * | aMediaItem | ||
) |
Add an item to the internal transfer queue.
aDeviceIdentifier | The device unique identifier. |
aMediaItem | The item to add to the transfer queue. |
Definition at line 1064 of file DeviceBase.cpp.
nsresult sbDeviceBase::ClearDeviceState | ( | const nsAString & | aDeviceIdentifier | ) |
Definition at line 1220 of file DeviceBase.cpp.
nsresult sbDeviceBase::ClearTransferQueue | ( | const nsAString & | aDeviceIdentifier | ) |
Clear the entire transfer queue.
Clearing the entire transfer queue does not cause transfers to be cancelled. If you wish to cancel all transfers, you must do so yourself.
aDeviceIdentifier | The device unique identifier. |
Definition at line 1145 of file DeviceBase.cpp.
nsresult sbDeviceBase::CreateDeviceLibrary | ( | const nsAString & | aDeviceIdentifier, |
nsIURI * | aDeviceDatabaseURI, | ||
sbIDeviceBase * | aDevice | ||
) |
Create a library for a device instance.
Creating a library provides you with storage for all data relating to media items present on the device. After creating a library you will typically want to register it so that it may be shown to the user.
When a library is created, two listeners are added to it. One listener takes care of advising the sbIDeviceBase interface instance when items need to be transferred to it, deleted from it or updated because data relating to those items have changed.
The second listener is responsible for detecting when items are transferred from the devices library to another library.
aDeviceIdentifier | The device unique identifier. |
aDeviceDatabaseURI | Optional URI for the database. |
aDevice | The device base interface instance to be used for this device instance. |
Definition at line 879 of file DeviceBase.cpp.
nsresult sbDeviceBase::CreateTransferQueue | ( | const nsAString & | aDeviceIdentifier | ) |
Create an internal transfer queue for a device instance.
Creating a transfer queue twice for the same device instance will cause the original queue to be overridden.
aDeviceIdentifier | The device unique identifier. |
Definition at line 1042 of file DeviceBase.cpp.
void sbDeviceBase::DoDeviceConnectCallback | ( | const nsAString & | aDeviceIdentifier | ) |
void sbDeviceBase::DoDeviceDisconnectCallback | ( | const nsAString & | aDeviceIdentifier | ) |
void sbDeviceBase::DoStateChangedCallback | ( | const nsAString & | aDeviceIdentifier, |
PRUint32 | aState | ||
) |
Definition at line 852 of file DeviceBase.cpp.
void sbDeviceBase::DoTransferCompleteCallback | ( | sbIMediaItem * | aMediaItem, |
PRInt32 | aStatus | ||
) |
void sbDeviceBase::DoTransferStartCallback | ( | sbIMediaItem * | aMediaItem | ) |
nsresult sbDeviceBase::GetDeviceState | ( | const nsAString & | aDeviceIdentifier, |
PRUint32 * | aDeviceState | ||
) |
Definition at line 1177 of file DeviceBase.cpp.
nsresult sbDeviceBase::GetItemByIndexFromTransferQueue | ( | const nsAString & | aDeviceIdentifier, |
PRUint32 | aItemIndex, | ||
sbIMediaItem ** | aMediaItem | ||
) |
Get an item from the transfer queue by index.
aDeviceIdentifier | The device unique identifier. |
aItemIndex | |
aMediaItem |
Definition at line 1114 of file DeviceBase.cpp.
nsresult sbDeviceBase::GetLibraryForDevice | ( | const nsAString & | aDeviceIdentifier, |
sbILibrary ** | aDeviceLibrary | ||
) |
Get the library instance for a device.
Get the library instance for a device. If no library instance is found, NS_ERROR_INVALID_ARG is returned.
aDeviceIdentifier | The device unique identifier. |
aDeviceLibrary | Pointer for device library instance. |
Definition at line 1001 of file DeviceBase.cpp.
nsresult sbDeviceBase::GetListenerForDeviceLibrary | ( | const nsAString & | aDeviceIdentifier, |
sbIMediaListListener ** | aMediaListListener | ||
) |
Definition at line 1242 of file DeviceBase.cpp.
nsresult sbDeviceBase::GetNextItemFromTransferQueue | ( | const nsAString & | aDeviceIdentifier, |
sbIMediaItem ** | aMediaItem | ||
) |
Get the next item in the transfer queue.
aDeviceIdentifier | The device unique identifier. |
aMediaItem |
Definition at line 1098 of file DeviceBase.cpp.
nsresult sbDeviceBase::GetTransferQueue | ( | const nsAString & | aDeviceIdentifier, |
nsIMutableArray ** | aTransferQueue | ||
) |
Get the internnal transfer queue for a device instance.
aDeviceIdentifier | The device unique identifier. |
aTransferQueue | The device transfer queue. |
Definition at line 1131 of file DeviceBase.cpp.
nsresult sbDeviceBase::Init | ( | ) |
Initialize the base device class for use.
Definition at line 694 of file DeviceBase.cpp.
nsresult sbDeviceBase::InitDeviceState | ( | const nsAString & | aDeviceIdentifier | ) |
Definition at line 1210 of file DeviceBase.cpp.
nsresult sbDeviceBase::IsTransferQueueEmpty | ( | const nsAString & | aDeviceIdentifier, |
PRBool & | aEmpty | ||
) |
nsresult sbDeviceBase::RegisterDeviceLibrary | ( | sbILibrary * | aDeviceLibrary | ) |
Register a device library with the library manager.
Registering a device library with the library manager enables the user to view the library. It becomes accessible to others programmatically as well through the library manager.
aDeviceLibrary | The library instance to register. |
Definition at line 1014 of file DeviceBase.cpp.
nsresult sbDeviceBase::RemoveCallback | ( | sbIDeviceBaseCallback * | aCallback | ) |
Definition at line 727 of file DeviceBase.cpp.
nsresult sbDeviceBase::RemoveDeviceLibrary | ( | const nsAString & | aDeviceIdentifier | ) |
Remove a library for a device instance.
Remove a library instance. This frees up resources that were used by the device library instance.
aDeviceIdentifier | The device unique identifier. |
Definition at line 994 of file DeviceBase.cpp.
nsresult sbDeviceBase::RemoveItemFromTransferQueue | ( | const nsAString & | aDeviceIdentifier, |
sbIMediaItem * | aMediaItem | ||
) |
Remove an item from the internal transfer queue.
aDeviceLibrary | The library instance to register. |
aMediaItem |
Definition at line 1078 of file DeviceBase.cpp.
nsresult sbDeviceBase::RemoveListenerForDeviceLibrary | ( | const nsAString & | aDeviceIdentifier | ) |
Definition at line 1255 of file DeviceBase.cpp.
nsresult sbDeviceBase::RemoveTransferQueue | ( | const nsAString & | aDeviceIdentifier | ) |
Remove an internal transfer queue for a device instance.
This will not cancel pending transfers. This is only meant to free up the resources used by the queue itself. One would most likely call this method at shutdown.
aDeviceLibrary | The library instance to register. |
Definition at line 1057 of file DeviceBase.cpp.
nsresult sbDeviceBase::SetDeviceState | ( | const nsAString & | aDeviceIdentifier, |
PRUint32 | aDeviceState | ||
) |
nsresult sbDeviceBase::SetListenerForDeviceLibrary | ( | const nsAString & | aDeviceIdentifier, |
sbIMediaListListener * | aMediaListListener | ||
) |
nsresult sbDeviceBase::UnregisterDeviceLibrary | ( | sbILibrary * | aDeviceLibrary | ) |
Unregister a device library with the library manager.
Unregister a device library with the library manager will make the library vanish from the list of libraries and block out access to it programatically as well.
A device should always unregister the device library when the application shuts down, when the device is disconnected suddenly and when the user ejects the device.
aDeviceLibrary | The library instance to unregister. |
Definition at line 1028 of file DeviceBase.cpp.
|
friend |
Definition at line 152 of file DeviceBase.h.
|
protected |
Definition at line 374 of file DeviceBase.h.
|
protected |
Definition at line 372 of file DeviceBase.h.
|
protected |
Definition at line 377 of file DeviceBase.h.
|
protected |
Definition at line 373 of file DeviceBase.h.
|
protected |
Definition at line 375 of file DeviceBase.h.