Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
9.3 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1993-1995
  4. * TITLE: USBPOPUP.H
  5. * VERSION: 1.0
  6. * AUTHOR: jsenior
  7. * DATE: 10/28/1998
  8. *
  9. ********************************************************************************
  10. *
  11. * CHANGE LOG:
  12. *
  13. * DATE REV DESCRIPTION
  14. * ---------- ------- ----------------------------------------------------------
  15. * 10/28/1998 jsenior Original implementation.
  16. *
  17. *******************************************************************************/
  18. #ifndef _USBPOPUP_H
  19. #define _USBPOPUP_H
  20. #include <objbase.h>
  21. #pragma warning(disable : 4200)
  22. #include <usbioctl.h>
  23. #include <setupapi.h>
  24. #include <tchar.h>
  25. #include <shellapi.h>
  26. #include <shlobj.h>
  27. #include <shlwapi.h>
  28. #include <shlwapip.h>
  29. #include <dbt.h>
  30. #include "UsbItem.h"
  31. #include <wmium.h>
  32. //#include "ItemFind.h"
  33. #include "debug.h"
  34. #include "resource.h"
  35. #ifndef IID_PPV_ARG
  36. #define IID_PPV_ARG(IType, ppType) IID_##IType, reinterpret_cast<void**>(static_cast<IType**>(ppType))
  37. #endif
  38. extern HINSTANCE gHInst;
  39. enum ProblemDeviceState {
  40. DeviceAttachedError = 1,
  41. DeviceDetachedError,
  42. DeviceReattached,
  43. DeviceAttachedProblemSolved
  44. };
  45. class UsbPopup : public IQueryContinue {
  46. public:
  47. UsbPopup() : hTreeDevices(0), ConnectionNotification(0), WmiHandle(0),
  48. ImageList(), RegisterForDeviceReattach(FALSE)
  49. {rootItem = NULL; HubAcquireInfo = NULL;
  50. deviceState = DeviceAttachedError; ConfigInfo = NULL;
  51. hNotifyArrival = NULL;}
  52. ~UsbPopup() { if (rootItem) { DeleteChunk(rootItem); delete rootItem; }
  53. if (HubAcquireInfo) { LocalFree(HubAcquireInfo); }
  54. if (ConfigInfo) { DeleteChunk(ConfigInfo); delete ConfigInfo;
  55. if (hNotifyArrival) { UnregisterDeviceNotification(hNotifyArrival); }}}
  56. void Make(PUSB_CONNECTION_NOTIFICATION UsbConnectionNotification,
  57. LPTSTR strInstanceName);
  58. static USBINT_PTR APIENTRY StaticDialogProc(IN HWND hDlg,
  59. IN UINT uMessage,
  60. IN WPARAM wParam,
  61. IN LPARAM lParam);
  62. // IUnknown
  63. STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
  64. STDMETHODIMP_(ULONG) AddRef();
  65. STDMETHODIMP_(ULONG) Release();
  66. // IQueryContinue
  67. STDMETHODIMP QueryContinue();
  68. protected:
  69. static UINT CALLBACK StaticDialogCallback(HWND Hwnd,
  70. UINT Msg,
  71. LPPROPSHEETPAGE Page);
  72. virtual INT_PTR APIENTRY ActualDialogProc(IN HWND hDlg,
  73. IN UINT uMessage,
  74. IN WPARAM wParam,
  75. IN LPARAM lParam)
  76. { return FALSE; } // DefDlgProc(hDlg, uMessage, wParam, lParam); }
  77. virtual BOOL OnCommand(INT wNotifyCode, INT wID, HWND hCtl);
  78. virtual BOOL OnInitDialog(HWND hDlg);
  79. virtual BOOL OnNotify(HWND hDlg, int nID, LPNMHDR pnmh);
  80. virtual BOOL CustomDialogWrap() { return FALSE; }
  81. virtual BOOL IsPopupStillValid() { return TRUE; }
  82. USBINT_PTR OnTimer() { return 0; }
  83. BOOL CustomDialog(DWORD DialogBoxId,
  84. DWORD IconId,
  85. DWORD FormatStringId,
  86. DWORD TitleStringId);
  87. virtual BOOL GetToolTip(LPNMTVGETINFOTIP lParam) { return TRUE; }
  88. virtual BOOL Refresh() { return FALSE; }
  89. PUSB_ACQUIRE_INFO GetControllerName(WMIHANDLE WmiHandle,
  90. UsbString InstanceName);
  91. BOOLEAN GetBusNotification(WMIHANDLE WmiHandle,
  92. PUSB_BUS_NOTIFICATION UsbBusNotification);
  93. PUSB_ACQUIRE_INFO GetHubName(WMIHANDLE WmiHandle,
  94. UsbString InstanceName,
  95. PUSB_CONNECTION_NOTIFICATION ConnectionNotification);
  96. BOOL InsertTreeItem(HWND hWndTree,
  97. UsbItem *usbItem,
  98. HTREEITEM hParent,
  99. LPTV_INSERTSTRUCT item,
  100. PUsbItemActionIsValid IsValid,
  101. PUsbItemActionIsValid IsBold,
  102. PUsbItemActionIsValid IsExpanded) {
  103. return UsbItem::InsertTreeItem(hWndTree,
  104. usbItem,
  105. hParent,
  106. item,
  107. IsValid,
  108. IsBold,
  109. IsExpanded);
  110. }
  111. HRESULT RegisterForReAttach();
  112. BOOL OnDeviceChange(HWND hDlg,
  113. WPARAM wParam,
  114. PDEV_BROADCAST_HDR devHdr);
  115. PUSB_CONNECTION_NOTIFICATION ConnectionNotification;
  116. UsbImageList ImageList;
  117. WMIHANDLE WmiHandle;
  118. HWND hWnd;
  119. HWND hTreeDevices;
  120. HWND hListDevices;
  121. UsbItem *rootItem;
  122. UsbString InstanceName;
  123. LONG RefCount;
  124. PUSB_ACQUIRE_INFO HubAcquireInfo;
  125. IUserNotification *pun;
  126. UsbItem deviceItem;
  127. BOOLEAN RegisterForDeviceReattach;
  128. UsbConfigInfo *ConfigInfo;
  129. HDEVNOTIFY hNotifyArrival;
  130. enum ProblemDeviceState deviceState;
  131. };
  132. class UsbBandwidthPopup : public UsbPopup {
  133. public:
  134. UsbBandwidthPopup() : UsbPopup() {;}
  135. protected:
  136. BOOL Refresh();
  137. BOOL OnInitDialog(HWND HWnd);
  138. BOOL CustomDialogWrap() { return CustomDialog(IDD_INSUFFICIENT_BANDWIDTH,
  139. NIIF_WARNING | NIIF_NOSOUND,
  140. IDS_BANDWIDTH_INITIAL,
  141. IDS_CONTROLLER_BW_EXCEEDED); }
  142. BOOL OnCommand(INT wNotifyCode, INT wID, HWND hCtl);
  143. void AddIsoDevicesToListView(UsbItem *controller, int iIndent);
  144. BOOL IsPopupStillValid();
  145. private:
  146. static UsbString LastDeviceName;
  147. static ULONG LastBandwidthRequested;
  148. static ULONG LastBandwidthConsumed;
  149. };
  150. class UsbPowerPopup : public UsbPopup {
  151. public:
  152. UsbPowerPopup() : UsbPopup() {;}
  153. protected:
  154. USBINT_PTR OnTimer();
  155. BOOL Refresh();
  156. BOOL CustomDialogWrap() { //RegisterForDeviceReattach = TRUE;
  157. return CustomDialog(IDD_INSUFFICIENT_POWER,
  158. NIIF_ERROR,
  159. IDS_POWER_INITIAL,
  160. IDS_POWER_EXCEEDED); }
  161. BOOL AssembleDialog(UsbItem* RootItem,
  162. LPTV_INSERTSTRUCT LvItem,
  163. LPCTSTR DeviceName,
  164. UINT Explanation,
  165. UINT Recommendation,
  166. PUsbItemActionIsValid IsValid,
  167. PUsbItemActionIsValid IsBold,
  168. PUsbItemActionIsValid IsExpanded);
  169. };
  170. class UsbLegacyPopup : public UsbPopup {
  171. public:
  172. UsbLegacyPopup() : UsbPopup() {;}
  173. protected:
  174. USBINT_PTR OnTimer();
  175. BOOL Refresh();
  176. BOOL CustomDialogWrap() {
  177. return CustomDialog(IDD_MODERN_DEVICE_IN_LEGACY_HUB,
  178. NIIF_WARNING,
  179. IDS_LEGACY_INITIAL,
  180. IDS_USB2_DEVICE_IN_USB1_HUB);
  181. }
  182. BOOL AssembleDialog(UsbItem* RootItem,
  183. LPTV_INSERTSTRUCT LvItem,
  184. LPCTSTR DeviceName,
  185. UINT Explanation,
  186. UINT Recommendation,
  187. PUsbItemActionIsValid IsValid,
  188. PUsbItemActionIsValid IsBold,
  189. PUsbItemActionIsValid IsExpanded);
  190. };
  191. class UsbEnumFailPopup : public UsbPopup {
  192. public:
  193. UsbEnumFailPopup() : UsbPopup() {;}
  194. protected:
  195. BOOL Refresh();
  196. BOOL CustomDialogWrap() { return CustomDialog(IDD_INSUFFICIENT_POWER,
  197. NIIF_WARNING,
  198. IDS_ENUMFAIL_INITIAL,
  199. IDS_ENUMERATION_FAILURE); }
  200. };
  201. class UsbOvercurrentPopup : public UsbPopup {
  202. public:
  203. UsbOvercurrentPopup() : UsbPopup() {;}
  204. protected:
  205. BOOL OnCommand(INT wNotifyCode, INT wID, HWND hCtl);
  206. BOOL Refresh();
  207. BOOL CustomDialogWrap();
  208. };
  209. class UsbNestedHubPopup : public UsbPopup {
  210. public:
  211. UsbNestedHubPopup() : UsbPopup() {;}
  212. protected:
  213. BOOL Refresh();
  214. BOOL CustomDialogWrap() {
  215. return CustomDialog(IDD_NESTED_HUB,
  216. NIIF_ERROR,
  217. IDS_NESTED_HUB_INITIAL,
  218. IDS_HUB_NESTED_TOO_DEEPLY); }
  219. BOOL AssembleDialog(UsbItem* RootItem,
  220. LPTV_INSERTSTRUCT LvItem,
  221. LPCTSTR DeviceName,
  222. UINT Explanation,
  223. UINT Recommendation,
  224. PUsbItemActionIsValid IsValid,
  225. PUsbItemActionIsValid IsBold,
  226. PUsbItemActionIsValid IsExpanded);
  227. };
  228. #endif // _USBPOPUP_H