sbCDDeviceMarshall.h
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2009 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
27 #ifndef sbCDDeviceMarshall_h_
28 #define sbCDDeviceMarshall_h_
29 
30 #include "sbCDDeviceDefines.h"
31 
32 #include <sbBaseDeviceMarshall.h>
33 #include <sbIDeviceRegistrar.h>
34 #include <sbICDDeviceService.h>
35 
36 #include <nsIClassInfo.h>
37 #include <nsStringAPI.h>
38 #include <nsIWritablePropertyBag.h>
39 #include <nsInterfaceHashtable.h>
40 #include <nsAutoLock.h>
41 #include <nsIThread.h>
42 
43 
45  public sbICDDeviceListener,
46  public nsIClassInfo
47 {
48 public:
50  virtual ~sbCDDeviceMarshall();
51 
53  NS_DECL_NSICLASSINFO
54  NS_DECL_SBIDEVICEMARSHALL
55  NS_DECL_SBICDDEVICELISTENER
56 
57  NS_DECLARE_STATIC_IID_ACCESSOR(SB_CDDEVICE_MARSHALL_IID)
58 
59  nsresult Init();
60 
61 protected:
62  //
63  // @brief Add and register a device to the list of known devices.
64  //
65  nsresult AddDevice(sbICDDevice *aCDDevice);
66  nsresult AddDevice2(nsAString const & aName, sbIDevice *aDevice);
67 
68  //
69  // @brief Remove a device from the list of known devices.
70  //
71  nsresult RemoveDevice(nsAString const & aName);
72 
73  //
74  // @brief Get a device from a given device ID.
75  //
76  nsresult GetDevice(nsAString const & aName, sbIDevice **aOutDevice);
77 
78  //
79  // @brief Find out if a device is already in the device hash.
80  //
81  nsresult GetHasDevice(nsAString const & aName, PRBool *aOutHasDevice);
82 
83  //
84  // @brief Find and add all the devices that have media already.
85  //
86  nsresult DiscoverDevices();
87 
88  //
89  // @brief Event dispatching utility method
90  //
91  nsresult CreateAndDispatchDeviceManagerEvent(PRUint32 aType,
92  nsIVariant *aData = nsnull,
93  nsISupports *aOrigin = nsnull,
94  PRBool aAsync = PR_FALSE);
95 
96  //
97  // @brief Internal method for discovering plugged in devices on a
98  // background thread.
99  //
100  void RunDiscoverDevices();
101 
102  //
103  // @brief Internal method for sending the device start scan event.
104  //
106 
107  //
108  // @brief Internal method for sending the device stop scan event.
109  //
111 
112 private:
113  nsInterfaceHashtableMT<nsStringHashKey, nsISupports> mKnownDevices;
114  PRMonitor *mKnownDevicesLock;
115 
116  // The CD device service to use
117  nsCOMPtr<sbICDDeviceService> mCDDeviceService;
118 
119  // Threading
120  nsCOMPtr<nsIThread> mOwnerContextThread;
121 
122  // Prevent copying and assignment
124  sbCDDeviceMarshall & operator= (sbCDDeviceMarshall const &);
125 };
126 
127 #endif // sbCDDeviceMarshall_h_
128 
nsresult AddDevice(sbICDDevice *aCDDevice)
nsresult GetHasDevice(nsAString const &aName, PRBool *aOutHasDevice)
nsresult RemoveDevice(nsAString const &aName)
#define SB_CDDEVICE_MARSHALL_IID
nsresult AddDevice2(nsAString const &aName, sbIDevice *aDevice)
NS_DECL_ISUPPORTS NS_DECL_NSICLASSINFO NS_DECL_SBIDEVICEMARSHALL NS_DECL_SBICDDEVICELISTENER nsresult Init()
_updateCookies aName
nsresult GetDevice(nsAString const &aName, sbIDevice **aOutDevice)
nsresult CreateAndDispatchDeviceManagerEvent(PRUint32 aType, nsIVariant *aData=nsnull, nsISupports *aOrigin=nsnull, PRBool aAsync=PR_FALSE)
_updateTextAndScrollDataForFrame aData