sbIPDMarshall.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-2009 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_IPD_MARSHALL_H__
28 #define __SB_IPD_MARSHALL_H__
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // iPod device marshall defs.
34 //
35 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 
43 //------------------------------------------------------------------------------
44 //
45 // iPod device marshall imported services.
46 //
47 //------------------------------------------------------------------------------
48 
49 // Songbird imports.
50 #include <sbBaseDeviceMarshall.h>
51 #include <sbIDeviceManager.h>
52 #include <sbIDeviceRegistrar.h>
53 #include "sbLibHal.h"
54 
55 // Mozilla imports.
56 #include <nsAutoLock.h>
57 #include <nsAutoPtr.h>
58 #include <nsClassHashtable.h>
59 #include <nsIClassInfo.h>
60 #include <nsInterfaceHashtable.h>
61 
62 //------------------------------------------------------------------------------
63 //
64 // iPod device marshall definitions.
65 //
66 //------------------------------------------------------------------------------
67 
68 //
69 // iPod device marshall XPCOM component definitions.
70 //XXXeps should move out of platform specific file
71 //
72 
73 #define SB_IPDMARSHALL_CONTRACTID "@songbirdnest.com/Songbird/IPDMarshall;1"
74 #define SB_IPDMARSHALL_CLASSNAME "iPod Device Marshall"
75 #define SB_IPDMARSHALL_DESCRIPTION "iPod Device Marshall"
76 #define SB_IPDMARSHALL_CID \
77 { \
78  0xbbca0e8c, \
79  0x78a3, \
80  0x4f13, \
81  { 0xae, 0x2b, 0x0f, 0xed, 0xb9, 0x47, 0xdf, 0x37 } \
82 }
83 
84 
85 //------------------------------------------------------------------------------
86 //
87 // iPod device marshall classes.
88 //
89 //------------------------------------------------------------------------------
90 
97  public nsIClassInfo
98 {
99  //----------------------------------------------------------------------------
100  //
101  // Public interface.
102  //
103  //----------------------------------------------------------------------------
104 
105 public:
106 
107  //
108  // Inherited interfaces.
109  //
110 
112  NS_DECL_SBIDEVICEMARSHALL
113  NS_DECL_NSICLASSINFO
114 
115 
116  //
117  // Constructors/destructors.
118  //
119 
120  sbIPDMarshall();
121 
122  virtual ~sbIPDMarshall();
123 
124 
125  //----------------------------------------------------------------------------
126  //
127  // Private interface.
128  //
129  //----------------------------------------------------------------------------
130 
131 private:
132 
133  //
134  // Internal services fields.
135  //
136  // mMonitor Marshall services monitor.
137  // mDeviceManager Device manager.
138  // mDeviceRegistrar Device registrar.
139  // mDeviceList List of devices.
140  // mDeviceMediaPartitionTable
141  // Table mapping media partitions to devices.
142  // mSBLibHalCtx HAL library API context.
143  //
144 
145  PRMonitor *mMonitor;
146  nsCOMPtr<sbIDeviceManager2> mDeviceManager;
147  nsCOMPtr<sbIDeviceRegistrar> mDeviceRegistrar;
148  nsInterfaceHashtable<nsCStringHashKey, nsISupports>
149  mDeviceList;
150  nsClassHashtable<nsCStringHashKey, nsCString>
151  mDeviceMediaPartitionTable;
152  sbLibHalCtx* mSBLibHalCtx;
153 
154 
155  //
156  // Event services.
157  //
158 
159  nsresult EventInitialize();
160 
161  void EventFinalize();
162 
163  static void HandleLibHalDevicePropertyModified(LibHalContext* aLibHalCtx,
164  const char* aDeviceUDI,
165  const char* aKey,
166  dbus_bool_t aIsRemoved,
167  dbus_bool_t aIsAdded);
168 
169  void HandleLibHalDevicePropertyModified(nsACString& aDeviceUDI,
170  const char* aKey,
171  dbus_bool_t aIsRemoved,
172  dbus_bool_t aIsAdded);
173 
174  static void HandleLibHalDeviceRemoved(LibHalContext* aLibHalCtx,
175  const char* aDeviceUDI);
176 
177  void HandleLibHalDeviceRemoved(nsACString& aDeviceUDI);
178 
179  void HandleAddedEvent(const nsACString& aDeviceUDI,
180  const nsACString& aMediaPartitionUDI);
181 
182  void HandleRemovedEvent(const nsACString& aDeviceUDI,
183  const nsACString& aMediaPartitionUDI);
184 
185 
186  //
187  // Internal services.
188  //
189 
190  nsresult Initialize();
191 
192  void Finalize();
193 
194  nsresult ScanForConnectedDevices();
195 
196  nsresult ProbeDev(nsACString &aDeviceUDI);
197 
198  PRBool IsIPod(nsACString& aDeviceUDI);
199 
200  PRBool IsMediaPartition(nsACString& aDeviceUDI);
201 };
202 
203 
204 #endif /* __SB_IPD_MARSHALL_H__ */
205 
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICEMARSHALL NS_DECL_NSICLASSINFO sbIPDMarshall()
virtual ~sbIPDMarshall()