sbDeviceBase Class Reference

#include <DeviceBase.h>

Inheritance diagram for sbDeviceBase:
[legend]

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
 

Detailed Description

Definition at line 150 of file DeviceBase.h.

Constructor & Destructor Documentation

sbDeviceBase::sbDeviceBase ( )

Definition at line 680 of file DeviceBase.cpp.

sbDeviceBase::~sbDeviceBase ( )
virtual

Definition at line 689 of file DeviceBase.cpp.

Member Function Documentation

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.

Parameters
aDeviceIdentifierThe device unique identifier.
aMediaItemThe 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.

Parameters
aDeviceIdentifierThe 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.

Parameters
aDeviceIdentifierThe device unique identifier.
aDeviceDatabaseURIOptional URI for the database.
aDeviceThe device base interface instance to be used for this device instance.
See Also
RemoveDeviceLibrary, RegisterDeviceLibrary, UnregisterDeviceLibrary

Definition at line 879 of file DeviceBase.cpp.

Here is the call graph for this function:

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.

Parameters
aDeviceIdentifierThe device unique identifier.

Definition at line 1042 of file DeviceBase.cpp.

void sbDeviceBase::DoDeviceConnectCallback ( const nsAString &  aDeviceIdentifier)

Definition at line 800 of file DeviceBase.cpp.

Here is the call graph for this function:

void sbDeviceBase::DoDeviceDisconnectCallback ( const nsAString &  aDeviceIdentifier)

Definition at line 826 of file DeviceBase.cpp.

Here is the call graph for this function:

void sbDeviceBase::DoStateChangedCallback ( const nsAString &  aDeviceIdentifier,
PRUint32  aState 
)

Definition at line 852 of file DeviceBase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void sbDeviceBase::DoTransferCompleteCallback ( sbIMediaItem aMediaItem,
PRInt32  aStatus 
)

Definition at line 772 of file DeviceBase.cpp.

Here is the call graph for this function:

void sbDeviceBase::DoTransferStartCallback ( sbIMediaItem aMediaItem)

Definition at line 745 of file DeviceBase.cpp.

Here is the call graph for this function:

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.

Parameters
aDeviceIdentifierThe 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.

Parameters
aDeviceIdentifierThe device unique identifier.
aDeviceLibraryPointer 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.

Parameters
aDeviceIdentifierThe 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.

Parameters
aDeviceIdentifierThe device unique identifier.
aTransferQueueThe device transfer queue.

Definition at line 1131 of file DeviceBase.cpp.

Here is the caller graph for this function:

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 
)

Definition at line 1156 of file DeviceBase.cpp.

Here is the call graph for this function:

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.

Parameters
aDeviceLibraryThe 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.

Parameters
aDeviceIdentifierThe 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.

Parameters
aDeviceLibraryThe 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.

Parameters
aDeviceLibraryThe library instance to register.

Definition at line 1057 of file DeviceBase.cpp.

nsresult sbDeviceBase::SetDeviceState ( const nsAString &  aDeviceIdentifier,
PRUint32  aDeviceState 
)

Definition at line 1191 of file DeviceBase.cpp.

Here is the call graph for this function:

nsresult sbDeviceBase::SetListenerForDeviceLibrary ( const nsAString &  aDeviceIdentifier,
sbIMediaListListener aMediaListListener 
)

Definition at line 1229 of file DeviceBase.cpp.

Here is the caller graph for this function:

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.

Parameters
aDeviceLibraryThe library instance to unregister.

Definition at line 1028 of file DeviceBase.cpp.

Friends And Related Function Documentation

friend class sbDeviceThread
friend

Definition at line 152 of file DeviceBase.h.

Member Data Documentation

nsRefPtrHashtableMT<nsISupportsHashKey, sbDeviceBaseCallbackProxy> sbDeviceBase::mDeviceCallbacks
protected

Definition at line 374 of file DeviceBase.h.

nsInterfaceHashtableMT<nsStringHashKey, sbILibrary> sbDeviceBase::mDeviceLibraries
protected

Definition at line 372 of file DeviceBase.h.

nsInterfaceHashtableMT<nsStringHashKey, sbIMediaListListener> sbDeviceBase::mDeviceLibraryListeners
protected

Definition at line 377 of file DeviceBase.h.

nsInterfaceHashtableMT<nsStringHashKey, nsIMutableArray> sbDeviceBase::mDeviceQueues
protected

Definition at line 373 of file DeviceBase.h.

nsDataHashtableMT<nsStringHashKey, PRUint32> sbDeviceBase::mDeviceStates
protected

Definition at line 375 of file DeviceBase.h.


The documentation for this class was generated from the following files: