Author: gedmurphy
Date: Sun Jul 5 08:49:54 2015
New Revision: 68344
URL:
http://svn.reactos.org/svn/reactos?rev=68344&view=rev
Log:
[DEVMGR]
- Implement very basic uninstall functionality
- Move device action code into the DeviceView class
Modified:
trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.cpp
trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.h
trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp
trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h
trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.cpp [iso-8859-1] Sun Jul 5 08:49:54
2015
@@ -344,6 +344,40 @@
return true;
}
+bool
+CDeviceNode::UninstallDevice()
+{
+
+ if (CanUninstall() == false)
+ return false;
+
+ SP_REMOVEDEVICE_PARAMS RemoveDevParams;
+ RemoveDevParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
+ RemoveDevParams.ClassInstallHeader.InstallFunction = DIF_REMOVE;
+ RemoveDevParams.Scope = DI_REMOVEDEVICE_GLOBAL;
+ RemoveDevParams.HwProfile = 0;
+
+ //
+ // We probably need to walk all the siblings of this
+ // device and ask if they're happy with the uninstall
+ //
+
+
+ // Remove it
+ SetupDiSetClassInstallParamsW(m_hDevInfo,
+ &m_DevinfoData,
+ &RemoveDevParams.ClassInstallHeader,
+ sizeof(SP_REMOVEDEVICE_PARAMS));
+ SetupDiCallClassInstaller(DIF_REMOVE, m_hDevInfo, &m_DevinfoData);
+
+ // Clear the install params
+ SetupDiSetClassInstallParamsW(m_hDevInfo,
+ &m_DevinfoData,
+ NULL,
+ 0);
+
+}
+
/* PRIVATE METHODS ******************************************************/
void
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceNode.h [iso-8859-1] Sun Jul 5 08:49:54
2015
@@ -38,6 +38,9 @@
_Out_ bool &NeedsReboot
);
+ bool UninstallDevice(
+ );
+
private:
void Cleanup(
);
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.cpp [iso-8859-1] Sun Jul 5 08:49:54
2015
@@ -229,6 +229,68 @@
if (hThread) CloseHandle(hThread);
}
+LRESULT
+CDeviceView::OnAction(
+ _In_ UINT Action
+)
+{
+ switch (Action)
+ {
+ case IDC_PROPERTIES:
+ {
+ DisplayPropertySheet();
+ break;
+ }
+
+ case IDC_SCAN_HARDWARE:
+ {
+ Refresh(GetCurrentView(),
+ true,
+ true,
+ NULL);
+ break;
+ }
+
+ case IDC_ENABLE_DRV:
+ {
+ bool NeedsReboot;
+ if (EnableSelectedDevice(true, NeedsReboot) &&
+ NeedsReboot)
+ {
+ MessageBox(m_hMainWnd, L"Rebooting", L"Enable",
MB_OK);
+ }
+ break;
+ }
+
+ case IDC_DISABLE_DRV:
+ {
+ bool NeedsReboot;
+ EnableSelectedDevice(false, NeedsReboot);
+ break;
+ }
+
+ case IDC_UPDATE_DRV:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Update
Driver", MB_OK);
+ break;
+ }
+
+ case IDC_UNINSTALL_DRV:
+ {
+ UninstallSelectedDevice();
+ break;
+ }
+
+ case IDC_ADD_HARDWARE:
+ {
+ MessageBox(m_hMainWnd, L"Not yet implemented", L"Add
Hardware", MB_OK);
+ break;
+ }
+ }
+
+ return 0;
+}
+
void
CDeviceView::DisplayPropertySheet()
{
@@ -286,77 +348,14 @@
return false;
}
-bool
-CDeviceView::HasProperties(
- _In_ LPTV_ITEMW TvItem
- )
-{
- CNode *Node = GetNode(TvItem);
- if (Node)
- {
- return Node->HasProperties();
- }
- return false;
-}
-
-bool
-CDeviceView::IsDisabled(
- _In_ LPTV_ITEMW TvItem
- )
-{
- CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetNode(TvItem));
- if (Node)
- {
- return Node->IsDisabled();
- }
- return false;
-}
-
-bool
-CDeviceView::CanDisable(
- _In_ LPTV_ITEMW TvItem
- )
-{
- CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetNode(TvItem));
- if (Node)
- {
- return Node->CanDisable();
- }
- return false;
-}
-
-bool
-CDeviceView::EnableSelectedDevice(
- _In_ bool Enable,
- _Out_ bool &NeedsReboot
- )
-{
- CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
- if (Node == nullptr) return false;
-
- if (Enable == false)
- {
- CAtlStringW str;
- if (str.LoadStringW(g_hInstance, IDS_CONFIRM_DISABLE))
- {
- if (MessageBoxW(m_hMainWnd,
- str,
- Node->GetDisplayName(),
- MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
- {
- return false;
- }
- }
- }
-
- if (Node->EnableDevice(Enable, NeedsReboot))
- {
- Refresh(m_ViewType, true, true, Node->GetDeviceId());
- return true;
- }
-
- return false;
-}
+CNode*
+CDeviceView::GetSelectedNode()
+{
+ TV_ITEM TvItem;
+ TvItem.hItem = TreeView_GetSelection(m_hTreeView);
+ return GetNode(&TvItem);
+}
+
// PRIVATE METHODS *******************************************/
@@ -710,6 +709,49 @@
}
bool
+CDeviceView::EnableSelectedDevice(
+ _In_ bool Enable,
+ _Out_ bool &NeedsReboot
+ )
+{
+ CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
+ if (Node == nullptr) return false;
+
+ if (Enable == false)
+ {
+ CAtlStringW str;
+ if (str.LoadStringW(g_hInstance, IDS_CONFIRM_DISABLE))
+ {
+ if (MessageBoxW(m_hMainWnd,
+ str,
+ Node->GetDisplayName(),
+ MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) != IDYES)
+ {
+ return false;
+ }
+ }
+ }
+
+ if (Node->EnableDevice(Enable, NeedsReboot))
+ {
+ Refresh(m_ViewType, true, true, Node->GetDeviceId());
+ return true;
+ }
+
+ return false;
+}
+
+bool
+CDeviceView::UninstallSelectedDevice(
+ )
+{
+ CDeviceNode *Node = dynamic_cast<CDeviceNode *>(GetSelectedNode());
+ if (Node == nullptr) return false;
+
+ return Node->UninstallDevice();
+}
+
+bool
CDeviceView::GetChildDevice(
_In_ DEVINST ParentDevInst,
_Out_ PDEVINST DevInst
@@ -1034,13 +1076,6 @@
return NULL;
}
-CNode* CDeviceView::GetSelectedNode()
-{
- TV_ITEM TvItem;
- TvItem.hItem = TreeView_GetSelection(m_hTreeView);
- return GetNode(&TvItem);
-}
-
void
CDeviceView::EmptyLists()
{
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/D…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/DeviceView.h [iso-8859-1] Sun Jul 5 08:49:54
2015
@@ -51,6 +51,10 @@
_In_ LPARAM lParam
);
+ LRESULT OnAction(
+ UINT Action
+ );
+
VOID Refresh(
_In_ ViewType Type,
_In_ bool ScanForChanges,
@@ -73,20 +77,7 @@
_In_ bool MainMenu
);
- bool HasProperties(
- _In_ LPTV_ITEMW TvItem
- );
- //bool SelDeviceIsHidden();
- bool CanDisable(
- _In_ LPTV_ITEMW TvItem
- );
- bool IsDisabled(
- _In_ LPTV_ITEMW TvItem
- );
-
- bool EnableSelectedDevice(
- _In_ bool Enable,
- _Out_ bool &NeedsReboot
+ CNode* GetSelectedNode(
);
bool SelDeviceIsStarted();
@@ -115,6 +106,14 @@
bool RecurseChildDevices(
_In_ DEVINST ParentDevice,
_In_ HTREEITEM hParentTreeItem
+ );
+
+ bool EnableSelectedDevice(
+ _In_ bool Enable,
+ _Out_ bool &NeedsReboot
+ );
+
+ bool UninstallSelectedDevice(
);
bool GetChildDevice(
@@ -153,7 +152,6 @@
CNode* GetNode(
_In_ LPTV_ITEMW TvItem
);
- CNode* GetSelectedNode();
CClassNode* GetClassNode(
_In_ LPGUID ClassGuid
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp [iso-8859-1] Sun Jul 5 08:49:54
2015
@@ -235,17 +235,6 @@
}
bool
-CMainWindow::ScanForHardwareChanges()
-{
- // Refresh the cache and and display
- m_DeviceView->Refresh(m_DeviceView->GetCurrentView(),
- true,
- true,
- NULL);
- return true;
-}
-
-bool
CMainWindow::CreateToolBar()
{
TBADDBITMAP TbAddBitmap;
@@ -323,12 +312,14 @@
return bRet;
}
-void CMainWindow::UpdateUiContext(_In_ LPTV_ITEMW TvItem)
+void CMainWindow::UpdateToolbar(_In_ LPTV_ITEMW TvItem)
{
WORD State;
+ CNode *Node = m_DeviceView->GetSelectedNode();
+
// properties button
- if (m_DeviceView->HasProperties(TvItem))
+ if (Node->HasProperties())
{
State = TBSTATE_ENABLED;
}
@@ -340,8 +331,11 @@
SendMessageW(m_hToolBar, TB_SETSTATE, IDC_UPDATE_DRV, MAKELPARAM(State, 0)); //hack
SendMessageW(m_hToolBar, TB_SETSTATE, IDC_UNINSTALL_DRV, MAKELPARAM(State, 0)); //
hack
+
+
// enable driver button
- if (m_DeviceView->IsDisabled(TvItem))
+ if (Node->GetNodeType() == DeviceNode &&
+ dynamic_cast<CDeviceNode *>(Node)->IsDisabled())
{
State = TBSTATE_ENABLED;
}
@@ -352,7 +346,9 @@
SendMessageW(m_hToolBar, TB_SETSTATE, IDC_ENABLE_DRV, MAKELPARAM(State, 0));
// disable driver button
- if (m_DeviceView->CanDisable(TvItem) &&
!m_DeviceView->IsDisabled(TvItem))
+ if (Node->GetNodeType() == DeviceNode &&
+ dynamic_cast<CDeviceNode *>(Node)->CanDisable() &&
+ !dynamic_cast<CDeviceNode *>(Node)->IsDisabled())
{
State = TBSTATE_ENABLED;
}
@@ -411,7 +407,10 @@
if (m_DeviceView->Initialize())
{
// Do the initial scan
- ScanForHardwareChanges();
+ m_DeviceView->Refresh(m_DeviceView->GetCurrentView(),
+ true,
+ true,
+ NULL);
// Display the window according to the user request
ShowWindow(hwnd, m_CmdShow);
@@ -468,7 +467,7 @@
case TVN_SELCHANGED:
{
LPNMTREEVIEW NmTreeView = (LPNMTREEVIEW)lParam;
- UpdateUiContext(&NmTreeView->itemNew);
+ UpdateToolbar(&NmTreeView->itemNew);
break;
}
@@ -543,50 +542,14 @@
switch (Msg)
{
case IDC_PROPERTIES:
- {
- m_DeviceView->DisplayPropertySheet();
- break;
- }
-
case IDC_SCAN_HARDWARE:
- {
- ScanForHardwareChanges();
- break;
- }
-
case IDC_ENABLE_DRV:
- {
- bool NeedsReboot;
- if (m_DeviceView->EnableSelectedDevice(true, NeedsReboot) &&
- NeedsReboot)
- {
- MessageBox(m_hMainWnd, L"Rebooting", L"Enable",
MB_OK);
- }
- break;
- }
-
case IDC_DISABLE_DRV:
- {
- bool NeedsReboot;
- m_DeviceView->EnableSelectedDevice(false, NeedsReboot);
- break;
- }
-
case IDC_UPDATE_DRV:
- {
- MessageBox(m_hMainWnd, L"Not yet implemented", L"Update
Driver", MB_OK);
- break;
- }
-
case IDC_UNINSTALL_DRV:
- {
- MessageBox(m_hMainWnd, L"Not yet implemented", L"Uninstall
Driver", MB_OK);
- break;
- }
-
case IDC_ADD_HARDWARE:
{
- MessageBox(m_hMainWnd, L"Not yet implemented", L"Add
Hardware", MB_OK);
+ m_DeviceView->OnAction(Msg);
break;
}
Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/M…
==============================================================================
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Sun Jul 5 08:49:54
2015
@@ -45,7 +45,9 @@
bool CreateToolBar();
bool CreateStatusBar();
- void UpdateUiContext(_In_ LPTV_ITEMW TvItem);
+ void UpdateToolbar(
+ _In_ LPTV_ITEMW TvItem
+ );
bool StatusBarLoadString(
HWND hStatusBar,
@@ -68,8 +70,5 @@
bool RefreshView(
ViewType Type
);
-
- bool ScanForHardwareChanges(
- );
};