32 #ifndef __DEVICE_BASE_H__
33 #define __DEVICE_BASE_H__
35 #include "sbIDeviceBase.h"
37 #include <sbILibrary.h>
38 #include <sbIMediaList.h>
39 #include <sbIMediaListListener.h>
40 #include <sbIMediaItem.h>
42 #include <sbILocalDatabaseLibrary.h>
43 #include <sbILocalDatabaseSimpleMediaList.h>
45 #include <nsAutoPtr.h>
46 #include <nsIMutableArray.h>
47 #include <nsInterfaceHashtable.h>
48 #include <nsClassHashtable.h>
49 #include <nsDataHashtable.h>
50 #include <nsIThread.h>
51 #include <nsIRunnable.h>
53 #include <nsRefPtrHashtable.h>
56 #include <nsStringGlue.h>
58 #define SONGBIRD_DeviceBase_CONTRACTID \
59 "@songbirdnest.com/Songbird/Device/DeviceBase;1"
60 #define SONGBIRD_DeviceBase_CLASSNAME \
61 "Songbird Device Base"
62 #define SONGBIRD_DeviceBase_CID \
67 {0x82, 0xfd, 0x60, 0x9f, 0xf5, 0xf7, 0x85, 0x8} \
73 const nsAString& aOldChars,
74 const PRUnichar aNewChar);
78 const nsACString& aOldChars,
86 NS_DECL_SBIMEDIALISTLISTENER
91 nsresult
Init(
const nsAString &aDeviceIdentifier,
98 static PLDHashOperator PR_CALLBACK
118 NS_DECL_SBILOCALDATABASEMEDIALISTCOPYLISTENER
123 nsresult
Init(
const nsAString &aDeviceIdentifier,
185 nsIURI *aDeviceDatabaseURI,
296 nsIMutableArray* *aTransferQueue);
352 PRUint32* aDeviceState);
357 PRUint32 aDeviceState);
380 #endif // __DEVICE_BASE_H__
nsresult GetListenerForDeviceLibrary(const nsAString &aDeviceIdentifier, sbIMediaListListener **aMediaListListener)
nsresult RemoveItemFromTransferQueue(const nsAString &aDeviceIdentifier, sbIMediaItem *aMediaItem)
Remove an item from the internal transfer queue.
nsresult SetIgnoreListener(PRBool aIgnoreListener)
void DoStateChangedCallback(const nsAString &aDeviceIdentifier, PRUint32 aState)
void ReplaceChars(nsAString &aOldString, const nsAString &aOldChars, const PRUnichar aNewChar)
nsString mDeviceIdentifier
virtual ~sbDeviceBaseLibraryCopyListener()
nsresult SetDeviceState(const nsAString &aDeviceIdentifier, PRUint32 aDeviceState)
nsCOMPtr< sbIDeviceBase > mDevice
nsresult Init(sbBaseDevice *aDevice)
nsresult GetDeviceState(const nsAString &aDeviceIdentifier, PRUint32 *aDeviceState)
NS_IMETHOD_(nsrefcnt) AddRef(void)
nsresult IsTransferQueueEmpty(const nsAString &aDeviceIdentifier, PRBool &aEmpty)
nsresult UnregisterDeviceLibrary(sbILibrary *aDeviceLibrary)
Unregister a device library with the library manager.
nsresult GetLibraryForDevice(const nsAString &aDeviceIdentifier, sbILibrary **aDeviceLibrary)
Get the library instance for a device.
nsInterfaceHashtableMT< nsStringHashKey, nsIMutableArray > mDeviceQueues
nsresult SetManagePlaylists(PRBool aManagePlaylists)
nsClassHashtable< nsISupportsHashKey, sbRemovedItemIndexes > mBeforeRemoveIndexes
[SOON TO BE DEPRECATED AFTER 0.3] The callback class for sbIDeviceBase
nsCOMPtr< nsIEventTarget > mOwningThread
nsresult Init(const nsAString &aDeviceIdentifier, sbIDeviceBase *aDevice)
nsresult CreateTransferQueue(const nsAString &aDeviceIdentifier)
Create an internal transfer queue for a device instance.
nsresult GetTransferQueue(const nsAString &aDeviceIdentifier, nsIMutableArray **aTransferQueue)
Get the internnal transfer queue for a device instance.
sbDeviceBaseCallbackProxy()
[SOON TO BE DEPRECATED AFTER 0.3] Base interface for all supported devices.
nsresult InitDeviceState(const nsAString &aDeviceIdentifier)
nsDataHashtableMT< nsStringHashKey, PRUint32 > mDeviceStates
nsCOMPtr< sbIDeviceBaseCallback > mCallbackProxy
NS_DECL_ISUPPORTS NS_DECL_SBILOCALDATABASEMEDIALISTCOPYLISTENER sbDeviceBaseLibraryCopyListener()
nsresult RemoveTransferQueue(const nsAString &aDeviceIdentifier)
Remove an internal transfer queue for a device instance.
nsresult AddCallback(sbIDeviceBaseCallback *aCallback)
virtual ~sbDeviceBaseLibraryListener()
nsInterfaceHashtableMT< nsStringHashKey, sbILibrary > mDeviceLibraries
nsresult SetListenerForDeviceLibrary(const nsAString &aDeviceIdentifier, sbIMediaListListener *aMediaListListener)
static PLDHashOperator PR_CALLBACK ShiftIndexesCallback(nsISupportsHashKey::KeyType aKey, PRUint32 &aEntry, void *aUserData)
nsresult AddItemToTransferQueue(const nsAString &aDeviceIdentifier, sbIMediaItem *aMediaItem)
Add an item to the internal transfer queue.
nsresult GetNextItemFromTransferQueue(const nsAString &aDeviceIdentifier, sbIMediaItem **aMediaItem)
Get the next item in the transfer queue.
Media library abstraction.
nsresult CreateDeviceLibrary(const nsAString &aDeviceIdentifier, nsIURI *aDeviceDatabaseURI, sbIDeviceBase *aDevice)
Create a library for a device instance.
nsresult Init()
Initialize the base device class for use.
void DoDeviceDisconnectCallback(const nsAString &aDeviceIdentifier)
nsresult RegisterDeviceLibrary(sbILibrary *aDeviceLibrary)
Register a device library with the library manager.
NS_DECL_ISUPPORTS NS_DECL_SBIMEDIALISTLISTENER sbDeviceBaseLibraryListener()
nsresult RemoveCallback(sbIDeviceBaseCallback *aCallback)
void DoTransferStartCallback(sbIMediaItem *aMediaItem)
nsresult RemoveListenerForDeviceLibrary(const nsAString &aDeviceIdentifier)
nsInterfaceHashtableMT< nsStringHashKey, sbIMediaListListener > mDeviceLibraryListeners
nsresult RemoveDeviceLibrary(const nsAString &aDeviceIdentifier)
Remove a library for a device instance.
nsresult GetItemByIndexFromTransferQueue(const nsAString &aDeviceIdentifier, PRUint32 aItemIndex, sbIMediaItem **aMediaItem)
Get an item from the transfer queue by index.
nsRefPtrHashtableMT< nsISupportsHashKey, sbDeviceBaseCallbackProxy > mDeviceCallbacks
nsresult ClearTransferQueue(const nsAString &aDeviceIdentifier)
Clear the entire transfer queue.
void DoDeviceConnectCallback(const nsAString &aDeviceIdentifier)
nsresult ClearDeviceState(const nsAString &aDeviceIdentifier)
friend class sbDeviceThread
nsresult Init(sbIDeviceBaseCallback *aCallback)
void DoTransferCompleteCallback(sbIMediaItem *aMediaItem, PRInt32 aStatus)
nsDataHashtable< nsISupportsHashKey, PRUint32 > sbRemovedItemIndexes
nsString mDeviceIdentifier
virtual ~sbDeviceBaseCallbackProxy()