sbDeviceXMLInfo.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 :miv */
3 /*
4  *=BEGIN SONGBIRD GPL
5  *
6  * This file is part of the Songbird web player.
7  *
8  * Copyright(c) 2005-2010 POTI, Inc.
9  * http://www.songbirdnest.com
10  *
11  * This file may be licensed under the terms of of the
12  * GNU General Public License Version 2 (the ``GPL'').
13  *
14  * Software distributed under the License is distributed
15  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
16  * express or implied. See the GPL for the specific language
17  * governing rights and limitations.
18  *
19  * You should have received a copy of the GPL along with this
20  * program. If not, go to http://www.gnu.org/licenses/gpl.html
21  * or write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23  *
24  *=END SONGBIRD GPL
25  */
26 
27 #ifndef _SB_DEVICE_XML_INFO_H_
28 #define _SB_DEVICE_XML_INFO_H_
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // Songbird device XML info defs.
34 //
35 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 
43 //------------------------------------------------------------------------------
44 //
45 // Songbird device XML info imported services.
46 //
47 //------------------------------------------------------------------------------
48 
49 // Standard Includes
50 #include <stdarg.h>
51 
52 // Songbird imports.
53 #include <sbIDevice.h>
54 
55 // Mozilla imports.
56 #include <nsCOMPtr.h>
57 #include <nsIArray.h>
58 #include <nsIDOMDocument.h>
59 #include <nsIDOMElement.h>
60 #include <nsStringAPI.h>
61 #include <nsTArray.h>
62 
63 
64 //------------------------------------------------------------------------------
65 //
66 // Songbird device XML info defs.
67 //
68 //------------------------------------------------------------------------------
69 
70 // Device info XML namespace.
71 #define SB_DEVICE_INFO_NS "http://songbirdnest.com/deviceinfo/1.0"
72 
73 
74 //------------------------------------------------------------------------------
75 //
76 // Songbird device XML info classes.
77 //
78 //------------------------------------------------------------------------------
79 
147 {
148  //----------------------------------------------------------------------------
149  //
150  // Public interface.
151  //
152  //----------------------------------------------------------------------------
153 
154 public :
155 
156  //
157  // Public services.
158  //
159 
176  nsresult Read(const char* aDeviceXMLInfoSpecList,
177  const char* aExtensionsList = nsnull);
178 
193  nsresult Read(nsIURI * aDeviceXMLInfoURI,
194  const nsAString & aExtensionsList);
195 
210  nsresult Read(nsIFile * aDeviceXMLInfoFile,
211  const nsAString & aExtensionsList);
212 
219  nsresult Read(nsIInputStream * aDeviceXMLInfoStream);
220 
227  nsresult Read(nsIDOMDocument* aDeviceXMLInfoDocument);
228 
235  nsresult GetDeviceInfoPresent(PRBool* aDeviceInfoPresent);
236 
243  nsresult GetDeviceInfoElement(nsIDOMElement** aDeviceInfoElement);
244 
251  nsresult GetDefaultName(nsAString& aDefaultName);
252 
262  nsresult GetDeviceFolder(const nsAString& aFolderType,
263  nsAString& aFolderURL);
264 
274  nsresult GetDeviceFolder(PRUint32 aContentType,
275  nsAString& aFolderURL);
276 
288  nsresult GetImportRules(nsIArray ** aImportRules);
289 
299  nsresult GetMountTimeout(PRUint32* aMountTimeout);
300 
308  nsresult GetDoesDeviceSupportReformat(PRBool *aOutSupportsReformat);
309 
318  nsresult GetOnlyMountMediaFolders(PRBool* aOnlyMountMediaFolders);
319 
325  nsresult GetExcludedFolders(nsAString & aExcludedFolders);
326 
335  nsresult GetStorageDeviceInfoList(nsIArray** aStorageDeviceInfoList);
336 
343  nsresult GetDeviceIcon(nsAString& aDeviceIconURL);
344 
351  sbDeviceXMLInfo(sbIDevice* aDevice = nsnull);
352 
356  virtual ~sbDeviceXMLInfo();
357 
361  static nsCString GetDeviceIdentifier(sbIDevice * aDevice);
362 
363  //----------------------------------------------------------------------------
364  //
365  // Private interface.
366  //
367  //----------------------------------------------------------------------------
368 
369 private :
370 
371  //
372  // mDevice Device to use with XML info.
373  // mDeviceInfoElement Root device info element.
374  // mDeviceElement Device element matching device. May be null if
375  // device does not match a specific device element.
376  //
377 
378  sbIDevice* mDevice;
379  nsString mDeviceInfoVersion;
380  nsCOMPtr<nsIDOMElement> mDeviceInfoElement;
381  nsCOMPtr<nsIDOMElement> mDeviceElement;
382  bool mLogDeviceInfo;
383 
384 
400  nsresult DeviceMatchesDeviceInfoNode(nsIDOMNode* aDeviceInfoNode,
401  nsAString & aFoundVersion,
402  nsIDOMNode** aDeviceNode);
403 
412  nsresult GetDeviceInfoVersion(nsIDOMElement * aDeviceInfoElement,
413  nsAString & aVersion);
414 
424  nsresult DeviceMatchesDeviceNode(nsIDOMNode* aDeviceNode,
425  nsIPropertyBag2* aDeviceProperties,
426  PRBool* aDeviceMatches);
427 
441  nsresult GetDeviceInfoNodes(const nsAString& aNameSpace,
442  const nsAString& aTagName,
443  nsTArray< nsCOMPtr<nsIDOMNode> >& aNodeList);
444 
457  nsresult GetDeviceInfoNodes(const nsAString& aTagName,
458  nsTArray< nsCOMPtr<nsIDOMNode> >& aNodeList);
459 
471  nsresult IsDeviceNodeDescendant(nsIDOMNode* aNode,
472  PRBool* aIsDeviceNodeDescendant);
473 
479  inline
480  void Log(const char * aFmt, ...);
481 
485  void LogIfFailed(nsresult aRV, const char * aPrintf, ...);
486 
490  void LogArgs(const char * aFmt, va_list aArgs);
491 };
492 
493 
494 #endif // _SB_DEVICE_XML_INFO_H_
495 
nsresult Read(const char *aDeviceXMLInfoSpecList, const char *aExtensionsList=nsnull)
nsresult GetStorageDeviceInfoList(nsIArray **aStorageDeviceInfoList)
nsresult GetDeviceInfoElement(nsIDOMElement **aDeviceInfoElement)
nsresult GetDeviceIcon(nsAString &aDeviceIconURL)
nsresult GetDeviceFolder(const nsAString &aFolderType, nsAString &aFolderURL)
sbDeviceXMLInfo(sbIDevice *aDevice=nsnull)
nsresult GetDefaultName(nsAString &aDefaultName)
nsresult GetDeviceInfoPresent(PRBool *aDeviceInfoPresent)
virtual ~sbDeviceXMLInfo()
static nsCString GetDeviceIdentifier(sbIDevice *aDevice)
nsresult GetOnlyMountMediaFolders(PRBool *aOnlyMountMediaFolders)
nsresult GetDoesDeviceSupportReformat(PRBool *aOutSupportsReformat)
nsresult GetMountTimeout(PRUint32 *aMountTimeout)
nsresult GetImportRules(nsIArray **aImportRules)
nsresult GetExcludedFolders(nsAString &aExcludedFolders)