#include <sbDeviceXMLInfo.h>
Public Member Functions | |
nsresult | Read (const char *aDeviceXMLInfoSpecList, const char *aExtensionsList=nsnull) |
nsresult | Read (nsIURI *aDeviceXMLInfoURI, const nsAString &aExtensionsList) |
nsresult | Read (nsIFile *aDeviceXMLInfoFile, const nsAString &aExtensionsList) |
nsresult | Read (nsIInputStream *aDeviceXMLInfoStream) |
nsresult | Read (nsIDOMDocument *aDeviceXMLInfoDocument) |
nsresult | GetDeviceInfoPresent (PRBool *aDeviceInfoPresent) |
nsresult | GetDeviceInfoElement (nsIDOMElement **aDeviceInfoElement) |
nsresult | GetDefaultName (nsAString &aDefaultName) |
nsresult | GetDeviceFolder (const nsAString &aFolderType, nsAString &aFolderURL) |
nsresult | GetDeviceFolder (PRUint32 aContentType, nsAString &aFolderURL) |
nsresult | GetImportRules (nsIArray **aImportRules) |
nsresult | GetMountTimeout (PRUint32 *aMountTimeout) |
nsresult | GetDoesDeviceSupportReformat (PRBool *aOutSupportsReformat) |
nsresult | GetOnlyMountMediaFolders (PRBool *aOnlyMountMediaFolders) |
nsresult | GetExcludedFolders (nsAString &aExcludedFolders) |
nsresult | GetStorageDeviceInfoList (nsIArray **aStorageDeviceInfoList) |
nsresult | GetDeviceIcon (nsAString &aDeviceIconURL) |
sbDeviceXMLInfo (sbIDevice *aDevice=nsnull) | |
virtual | ~sbDeviceXMLInfo () |
Static Public Member Functions | |
static nsCString | GetDeviceIdentifier (sbIDevice *aDevice) |
This class implements the Songbird device XML info object. This class reads in and processes a device XML info document or file. It may optionally be given a device object. If it is provided a device object, it searches the device XML info document for device info elements and device elements matching the device object. Elements within the device XML info document provide information about a device such as supported media formats, where media files are stored, and whether a device has removable storage. A device XML info document can contain multiple device info elements. Each device info element can contain a list of device elements that specify what devices match the device info element. Only the information within the matching device info element will be returned. Device information can also be specified within a device element. If a device object matches a device element that contains device information, only that device information will be returned for the device. In the example below, the storage volume with LUN 0 of an HTC Incredible will be marked as removable. However, the storage volume with LUN 0 of an HTC Magic will be marked as non-removable and primary. However, the audio formats returned will be the same for both devices.
Example:
<deviceinfo> <devices>
<device usbvendorid="0x0bb4" usbproductid="0x0c9e"> <storage lun="0" removable="true"> <storage lun="1" primary="true"> </device>
<device usbVendorId="0x0bb4" usbProductId="0x0c02" />
</devices>
<storage lun="0" primary="true"> <storage lun="1" removable="true">
<devicecaps xmlns="http://songbirdnest.com/devicecaps/1.0"> <audio> <format mime="audio/mpeg" container="audio/mpeg" codec="audio/mpeg"> ... </format> </audio> </devicecaps> </deviceinfo>
<deviceinfo> <devices>
<device usbvendorid="0x0421" usbproductid="0x0091"> </devices>
<devicecaps xmlns="http://songbirdnest.com/devicecaps/1.0"> <audio> <format mime="audio/x-ms-wma" container="video/x-ms-asf" codec="audio/x-ms-wma"> ... </format> </audio> </devicecaps> </deviceinfo>
Definition at line 146 of file sbDeviceXMLInfo.h.
sbDeviceXMLInfo::sbDeviceXMLInfo | ( | sbIDevice * | aDevice = nsnull | ) |
Construct a Songbird device XML info object to be used for the device specified by aDevice.
aDevice | Device to use with XML info. May be null. |
Definition at line 1029 of file sbDeviceXMLInfo.cpp.
|
virtual |
Destroy the Songbird device XML info object.
Definition at line 1041 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetDefaultName | ( | nsAString & | aDefaultName | ) |
Return in aDefaultName the default name for the device. If no name is present in the device info, return a void string.
aDefaultName | Returned default name value. |
Definition at line 463 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetDeviceFolder | ( | const nsAString & | aFolderType, |
nsAString & | aFolderURL | ||
) |
Return in aFolderURL the URL for the device folder of the type specified by aFolderType. If no folder of the specified type is present in the device info, return a void URL. The returned URL is relative to the device mount path.
aFolderType | Type of folder (e.g., "music", "video"). |
aFolderURL | Returned folder URL. |
Definition at line 502 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetDeviceFolder | ( | PRUint32 | aContentType, |
nsAString & | aFolderURL | ||
) |
Return in aFolderURL the URL for the device folder of the content type specified by aContentType. If no folder of the specified type is present in the device info, return a void URL. The returned URL is relative to the device mount path.
aContentType | Folder content type from sbIDeviceCapabilities. |
aFolderURL | Returned folder URL. |
Definition at line 550 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetDeviceIcon | ( | nsAString & | aDeviceIconURL | ) |
Return in aDeviceIconURL the URL for the device icon file. The returned URL is relative to the device mount path.
aDeviceIconURL | Returned device icon file URL. |
Definition at line 988 of file sbDeviceXMLInfo.cpp.
|
static |
Returns the device identifier for logging
nsresult sbDeviceXMLInfo::GetDeviceInfoElement | ( | nsIDOMElement ** | aDeviceInfoElement | ) |
Return in aDeviceInfoElement the root device info DOM element. If no device info is present, return null in aDeviceInfoElement.
aDeviceInfoElement | Returned device info root DOM element. |
Definition at line 450 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetDeviceInfoPresent | ( | PRBool * | aDeviceInfoPresent | ) |
If device info is present, return true in aDeviceInfoPresent; otherwise, return false.
aDeviceInfoPresent | Returned true if device info is present. |
Definition at line 429 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetDoesDeviceSupportReformat | ( | PRBool * | aOutSupportsReformat | ) |
Return in aOutSupportsReformat if the device supports reformat. This value will default to PR_TRUE if the format tag is not specified in the XML document.
aOutSupportsReformat | Returned supported reformat boolean value. |
Definition at line 802 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetExcludedFolders | ( | nsAString & | aExcludedFolders | ) |
Returns a list of excluded folders folders in the array passed in. Each array entry may be folder name or a path to a specific folder.
aFolders | This is an array that the excluded folders will be added |
Definition at line 689 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetImportRules | ( | nsIArray ** | aImportRules | ) |
Return in aImportRules a list of "rules" to apply to files imported from the device. Each rule is itself an nsIArray of two nsISupportsStrings: a path and an "import type" of files residing (recursively) within that path. The import type can determine how to set the media item properties when importing items of that type from the device.
aImportRules | an array to populate with the list of import rules. This array can be stored with an sbIDevice as SB_DEVICE_PROPERTY_IMPORT_RULES. |
Definition at line 593 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetMountTimeout | ( | PRUint32 * | aMountTimeout | ) |
Return in aMountTimeout the mount timeout value in seconds. If no mount timeout value is available, return NS_ERROR_NOT_AVAILABLE.
aMountTimeout | Returned mount timeout value. |
Definition at line 752 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetOnlyMountMediaFolders | ( | PRBool * | aOnlyMountMediaFolders | ) |
Return true in aOnlyMountMediaFolders if only the media folders should be mounted rather than the entire storage volume.
aOnlyMountMediaFolders | True if only the media folders should be mounted. |
Definition at line 848 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::GetStorageDeviceInfoList | ( | nsIArray ** | aStorageDeviceInfoList | ) |
Return in aStorageDeviceInfoList a list of information for storage devices. Each element in the list is an nsIPropertyBag of storage device properties. See sbIDeviceInfoRegistrar.getStorageDeviceInfoList for storage device info examples.
aStorageDeviceInfoList | Returned storage device info list. |
Definition at line 901 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::Read | ( | const char * | aDeviceXMLInfoSpecList, |
const char * | aExtensionsList = nsnull |
||
) |
Search one or more XML files specified by the space-delimited list of URI strings and load the newest device info element–according to its version attribute–that matches this device.
aDeviceXMLInfoSpecList | A space-delimited list of URI strings pointing to device XML info files or directories containing such files to be searched recursively |
aExtensionsList | A space-delimited list of file extensions (without dots) to scan for when searching a directory for device XML info files. If nsnull, then directories are not searched |
Definition at line 93 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::Read | ( | nsIURI * | aDeviceXMLInfoURI, |
const nsAString & | aExtensionsList | ||
) |
Search the specified XML file or, if the URI points to a directory, all files in that directory recursively that have one of the specified file name extensions and load the newest device info element–according to its version attribute–that matches this device.
aDeviceXMLInfoURI | A URI pointing either to a device XML info file or to a directory to be searched recursively for such files |
aExtensionsList | A space-delimited list of file extensions (without dots) to scan for when searching a directory for device XML info files |
Definition at line 144 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::Read | ( | nsIFile * | aDeviceXMLInfoFile, |
const nsAString & | aExtensionsList | ||
) |
Search the specified XML file or, if the nsIFile is a directory, all files in that directory recursively that have one of the specified file name extensions and load the newest device info element–according to its version attribute–that matches this device.
aDeviceXMLInfoFile | Either a device XML info file or a directory to be searched recursively for such files |
aExtensionsList | A space-delimited list of file extensions (without dots) to scan for when searching a directory for device XML info files |
Definition at line 187 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::Read | ( | nsIInputStream * | aDeviceXMLInfoStream | ) |
Read the device info from the XML stream specified by aDeviceXMLInfoStream.
aDeviceXMLInfoStream | Device XML info stream. |
Definition at line 287 of file sbDeviceXMLInfo.cpp.
nsresult sbDeviceXMLInfo::Read | ( | nsIDOMDocument * | aDeviceXMLInfoDocument | ) |
Read the device info from the XML document specified aDeviceXMLInfoDocument.
aDeviceXMLInfoDocument | Device XML info document. |
Definition at line 319 of file sbDeviceXMLInfo.cpp.