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 
54 // Mozilla imports.
55 #include <nsAutoLock.h>
56 #include <nsIClassInfo.h>
57 #include <nsInterfaceHashtable.h>
58 
59 // Win32 imports.
60 #include <windows.h>
61 
62 
63 //------------------------------------------------------------------------------
64 //
65 // iPod device marshall definitions.
66 //
67 //------------------------------------------------------------------------------
68 
69 //
70 // iPod device marshall XPCOM component definitions.
71 //XXXeps should move out of platform specific file
72 //
73 
74 #define SB_IPDMARSHALL_CONTRACTID "@songbirdnest.com/Songbird/IPDMarshall;1"
75 #define SB_IPDMARSHALL_CLASSNAME "iPod Device Marshall"
76 #define SB_IPDMARSHALL_DESCRIPTION "iPod Device Marshall"
77 #define SB_IPDMARSHALL_CID \
78 { \
79  0xbbca0e8c, \
80  0x78a3, \
81  0x4f13, \
82  { 0xae, 0x2b, 0x0f, 0xed, 0xb9, 0x47, 0xdf, 0x37 } \
83 }
84 
85 
86 //------------------------------------------------------------------------------
87 //
88 // iPod device marshall classes.
89 //
90 //------------------------------------------------------------------------------
91 
97 class sbIPDMarshall : public sbBaseDeviceMarshall,
98  public nsIClassInfo
99 {
100  //----------------------------------------------------------------------------
101  //
102  // Public interface.
103  //
104  //----------------------------------------------------------------------------
105 
106 public:
107 
108  //
109  // Inherited interfaces.
110  //
111 
113  NS_DECL_SBIDEVICEMARSHALL
114  NS_DECL_NSICLASSINFO
115 
116 
117  //
118  // Constructors/destructors.
119  //
120 
121  sbIPDMarshall();
122 
123  virtual ~sbIPDMarshall();
124 
125 
126  //----------------------------------------------------------------------------
127  //
128  // Private interface.
129  //
130  //----------------------------------------------------------------------------
131 
132 private:
133 
134  //
135  // Event services fields.
136  //
137  // mEventWindow Window used for receiving device events.
138  // mEventWindowClass Event window class.
139  //
140 
141  HWND mEventWindow;
142  ATOM mEventWindowClass;
143 
144 
145  //
146  // Event services.
147  //
148 
149  nsresult EventInitialize();
150 
151  void EventFinalize();
152 
153  static LRESULT CALLBACK WindowEventHandler(HWND hwnd,
154  UINT msg,
155  WPARAM param1,
156  LPARAM param2);
157 
158  void _WindowEventHandler(HWND hwnd,
159  UINT msg,
160  WPARAM param1,
161  LPARAM param2);
162 
163  void HandleAddedEvent(char aDriveLetter);
164 
165  void HandleRemovedEvent(char aDriveLetter);
166 
167 
168  //
169  // Internal services fields.
170  //
171  // mMonitor Marshall services monitor.
172  // mDeviceManager Device manager.
173  // mDeviceRegistrar Device registrar.
174  // mDeviceList List of devices.
175  //
176 
177  PRMonitor *mMonitor;
178  nsCOMPtr<sbIDeviceManager2> mDeviceManager;
179  nsCOMPtr<sbIDeviceRegistrar> mDeviceRegistrar;
180  nsInterfaceHashtable<nsUint32HashKey, nsISupports>
181  mDeviceList;
182 
183 
184  //
185  // Internal services.
186  //
187 
188  nsresult Initialize();
189 
190  void Finalize();
191 
192  nsresult ScanForConnectedDevices();
193 
194  PRBool IsIPod(char aDriveLetter);
195 };
196 
197 
198 #endif /* __SB_IPD_MARSHALL_H__ */
199 
NS_DECL_ISUPPORTS NS_DECL_SBIDEVICEMARSHALL NS_DECL_NSICLASSINFO sbIPDMarshall()
virtual ~sbIPDMarshall()
function msg