sbWindowsDeviceUtils.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_WINDOWS_DEVICE_UTILS_H_
28 #define SB_WINDOWS_DEVICE_UTILS_H_
29 
30 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 //
33 // Songbird Windows device utilities defs.
34 //
35 //------------------------------------------------------------------------------
36 //------------------------------------------------------------------------------
37 
43 //------------------------------------------------------------------------------
44 //
45 // Songbird Windows device utilities imported services.
46 //
47 //------------------------------------------------------------------------------
48 
49 // Songbird imports.
50 #include <sbMemoryUtils.h>
51 
52 // Mozilla imports.
53 #include <nsStringGlue.h>
54 
55 // Windows imports.
56 #include <objbase.h>
57 
58 #include <cfgmgr32.h>
59 #include <setupapi.h>
60 
61 
62 //------------------------------------------------------------------------------
63 //
64 // Songbird Windows device file services.
65 //
66 //------------------------------------------------------------------------------
67 
68 nsresult sbWinCreateDeviceFile(HANDLE* aDevFile,
69  DEVINST aDevInst,
70  const GUID* aGUID,
71  DWORD aDesiredAccess,
72  DWORD aShareMode,
73  LPSECURITY_ATTRIBUTES aSecurityAttributes,
74  DWORD aCreationDisposition,
75  DWORD aFlagsAndAttributes,
76  HANDLE aTemplateFile);
77 
79  (HANDLE* aDevFile,
80  DEVINST aDevInst,
81  const GUID* aGUID,
82  DWORD aDesiredAccess,
83  DWORD aShareMode,
84  LPSECURITY_ATTRIBUTES aSecurityAttributes,
85  DWORD aCreationDisposition,
86  DWORD aFlagsAndAttributes,
87  HANDLE aTemplateFile);
88 
89 nsresult sbWinDeviceHasInterface(DEVINST aDevInst,
90  const GUID* aGUID,
91  PRBool* aHasInterface);
92 
93 nsresult sbWinGetDevicePath(DEVINST aDevInst,
94  const GUID* aGUID,
95  nsAString& aDevicePath);
96 
97 
98 //------------------------------------------------------------------------------
99 //
100 // Songbird Windows device utilities services.
101 //
102 //------------------------------------------------------------------------------
103 
105  (nsTArray<DEVINST>& aDevInstList,
106  DEVINST aRootDevInst,
107  const GUID* aGUID,
108  PRBool aSearchAncestors = PR_FALSE);
109 
110 nsresult sbWinFindDeviceByClass(DEVINST* aDevInst,
111  PRBool* aFound,
112  DEVINST aRootDevInst,
113  const nsAString& aClass);
114 
115 nsresult sbWinGetDevInfoData(DEVINST aDevInst,
116  HDEVINFO aDevInfo,
117  PSP_DEVINFO_DATA aDevInfoData);
118 
119 nsresult sbWinGetDevDetail(PSP_DEVICE_INTERFACE_DETAIL_DATA* aDevIfDetailData,
120  SP_DEVINFO_DATA* aDevInfoData,
121  HDEVINFO aDevInfo,
122  const GUID* aGUID,
123  DWORD aDevIndex);
124 
126  (PSP_DEVICE_INTERFACE_DETAIL_DATA* aDevIfDetailData,
127  HDEVINFO aDevInfo,
128  SP_DEVINFO_DATA* aDevInfoData,
129  const GUID* aGUID);
130 
132  (nsAString& aDeviceInterfaceName,
133  nsAString& aDeviceInstanceID);
134 
135 nsresult sbWinGetDeviceInstanceID(DEVINST aDevInst,
136  nsAString& aDeviceInstanceID);
137 
138 nsresult sbWinDeviceEject(DEVINST aDevInst);
139 nsresult sbWinDeviceEject(nsAString const & aMountPath);
140 
141 nsresult sbWinDeviceIsDescendantOf(DEVINST aDevInst,
142  DEVINST aDescendantDevInst,
143  PRBool* aIsDescendant);
144 
145 nsresult sbWinRegisterDeviceHandleNotification(HDEVNOTIFY* aDeviceNotification,
146  HWND aEventWindow,
147  DEVINST aDevInst,
148  const GUID& aGUID);
149 
150 
151 //------------------------------------------------------------------------------
152 //
153 // Songbird Windows device utilities classes.
154 //
155 // These classes may depend upon function prototypes.
156 //
157 //------------------------------------------------------------------------------
158 
159 //
160 // Auto-disposal class wrappers.
161 //
162 // sbAutoHDEVINFO Wrapper to auto-destroy Win32 device info lists.
163 //
164 
165 SB_AUTO_CLASS(sbAutoHDEVINFO,
166  HDEVINFO,
167  mValue != INVALID_HANDLE_VALUE,
168  SetupDiDestroyDeviceInfoList(mValue),
169  mValue = INVALID_HANDLE_VALUE);
170 
171 #endif // SB_WINDOWS_DEVICE_UTILS_H_
172 
nsresult sbWinRegisterDeviceHandleNotification(HDEVNOTIFY *aDeviceNotification, HWND aEventWindow, DEVINST aDevInst, const GUID &aGUID)
nsresult sbWinGetDevInterfaceDetail(PSP_DEVICE_INTERFACE_DETAIL_DATA *aDevIfDetailData, HDEVINFO aDevInfo, SP_DEVINFO_DATA *aDevInfoData, const GUID *aGUID)
SB_AUTO_CLASS(sbAutoHDEVINFO, HDEVINFO, mValue!=INVALID_HANDLE_VALUE, SetupDiDestroyDeviceInfoList(mValue), mValue=INVALID_HANDLE_VALUE)
nsresult sbWinGetDevDetail(PSP_DEVICE_INTERFACE_DETAIL_DATA *aDevIfDetailData, SP_DEVINFO_DATA *aDevInfoData, HDEVINFO aDevInfo, const GUID *aGUID, DWORD aDevIndex)
nsresult sbWinGetDevicePath(DEVINST aDevInst, const GUID *aGUID, nsAString &aDevicePath)
nsresult sbWinGetDevInfoData(DEVINST aDevInst, HDEVINFO aDevInfo, PSP_DEVINFO_DATA aDevInfoData)
nsresult sbWinCreateAncestorDeviceFile(HANDLE *aDevFile, DEVINST aDevInst, const GUID *aGUID, DWORD aDesiredAccess, DWORD aShareMode, LPSECURITY_ATTRIBUTES aSecurityAttributes, DWORD aCreationDisposition, DWORD aFlagsAndAttributes, HANDLE aTemplateFile)
nsresult sbWinGetDeviceInstanceIDFromDeviceInterfaceName(nsAString &aDeviceInterfaceName, nsAString &aDeviceInstanceID)
nsresult sbWinGetDeviceInstanceID(DEVINST aDevInst, nsAString &aDeviceInstanceID)
nsresult sbWinDeviceIsDescendantOf(DEVINST aDevInst, DEVINST aDescendantDevInst, PRBool *aIsDescendant)
nsresult sbWinFindDevicesByInterface(nsTArray< DEVINST > &aDevInstList, DEVINST aRootDevInst, const GUID *aGUID, PRBool aSearchAncestors=PR_FALSE)
nsresult sbWinFindDeviceByClass(DEVINST *aDevInst, PRBool *aFound, DEVINST aRootDevInst, const nsAString &aClass)
nsresult sbWinCreateDeviceFile(HANDLE *aDevFile, DEVINST aDevInst, const GUID *aGUID, DWORD aDesiredAccess, DWORD aShareMode, LPSECURITY_ATTRIBUTES aSecurityAttributes, DWORD aCreationDisposition, DWORD aFlagsAndAttributes, HANDLE aTemplateFile)
nsresult sbWinDeviceEject(DEVINST aDevInst)
nsresult sbWinDeviceHasInterface(DEVINST aDevInst, const GUID *aGUID, PRBool *aHasInterface)