sbDeviceManager.h
Go to the documentation of this file.
1 /* vim: set sw=2 :miv */
2 /*
3 //
4 // BEGIN SONGBIRD GPL
5 //
6 // This file is part of the Songbird web player.
7 //
8 // Copyright(c) 2005-2008 POTI, Inc.
9 // http://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 
28 #include "sbIDeviceManager.h"
29 #include "sbIDeviceControllerRegistrar.h"
30 #include "sbIDeviceRegistrar.h"
31 #include "sbIDeviceEventTarget.h"
33 
34 #include <prmon.h>
35 #include <nsHashKeys.h>
36 #include <nsIClassInfo.h>
37 #include <nsInterfaceHashtable.h>
38 #include <nsIObserver.h>
39 
40 #include <sbWeakReference.h>
41 
42 #include "sbIDevice.h"
43 #include "sbIDeviceController.h"
44 #include "sbIDeviceMarshall.h"
45 
47  public sbIDeviceManager2,
49  public sbIDeviceRegistrar,
50  public nsIClassInfo,
51  public nsIObserver,
53 {
54 public:
56  NS_DECL_SBIDEVICEMANAGER2
57  NS_DECL_SBIDEVICECONTROLLERREGISTRAR
58  NS_DECL_SBIDEVICEREGISTRAR
59  NS_DECL_NSICLASSINFO
60  NS_DECL_NSIOBSERVER
62 
63 private:
64  ~sbDeviceManager();
65 
66 protected:
67  // copies the given hash table into the given mutable array
68  template<class T>
69  static NS_HIDDEN_(PLDHashOperator) EnumerateIntoArray(const nsID& aKey,
70  T* aData,
71  void* aArray);
72 
73  // helpers
74  nsresult Init();
75  nsresult BeginMarshallMonitoring();
76  nsresult PrepareShutdown();
77  nsresult FinalShutdown();
78  nsresult QuitApplicationRequested(PRBool *aShouldQuit);
79  nsresult QuitApplicationGranted();
80  nsresult RemoveAllDevices();
81 
82 protected:
83  PRMonitor* mMonitor;
84  nsInterfaceHashtableMT<nsIDHashKey, sbIDeviceController> mControllers;
85  nsInterfaceHashtableMT<nsIDHashKey, sbIDevice> mDevices;
86  nsInterfaceHashtableMT<nsIDHashKey, sbIDeviceMarshall> mMarshalls;
88 };
89 
90 #define SONGBIRD_DEVICEMANAGER2_DESCRIPTION \
91  "Songbird DeviceManager2 Service"
92 #define SONGBIRD_DEVICEMANAGER2_CONTRACTID \
93  "@songbirdnest.com/Songbird/DeviceManager;2"
94 #define SONGBIRD_DEVICEMANAGER2_CLASSNAME \
95  "Songbird Device Manager 2"
96 #define SONGBIRD_DEVICEMANAGER2_CID \
97 { /* {F1B2417E-2515-481d-B03A-DA3D5B7F62FA} */ \
98  0xf1b2417e, 0x2515, 0x481d, \
99  { 0xb0, 0x3a, 0xda, 0x3d, 0x5b, 0x7f, 0x62, 0xfa } }
nsresult RemoveAllDevices()
nsresult QuitApplicationGranted()
static NS_HIDDEN_(PLDHashOperator) EnumerateIntoArray(const nsID &aKey
PRMonitor * mMonitor
static T * aData
PRBool mHasAllowedShutdown
nsInterfaceHashtableMT< nsIDHashKey, sbIDeviceController > mControllers
nsInterfaceHashtableMT< nsIDHashKey, sbIDevice > mDevices
static T void * aArray
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICEMANAGER2 NS_DECL_SBIDEVICECONTROLLERREGISTRAR NS_DECL_SBIDEVICEREGISTRAR NS_DECL_NSICLASSINFO NS_DECL_NSIOBSERVER sbDeviceManager()
[UNIMPLEMENTED UNTIL AFTER 0.3]
nsresult BeginMarshallMonitoring()
nsresult QuitApplicationRequested(PRBool *aShouldQuit)
nsInterfaceHashtableMT< nsIDHashKey, sbIDeviceMarshall > mMarshalls
nsresult PrepareShutdown()
[UNIMPLEMENTED UNTIL AFTER 0.3]
nsresult FinalShutdown()