MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / DeviceChange

Method DeviceChange

cppcryptfs/ui/MountPropertyPage.cpp:634–694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632}
633
634void CMountPropertyPage::DeviceChange()
635{
636
637 CListCtrl *pList = (CListCtrl*)GetDlgItem(IDC_DRIVE_LETTERS);
638
639 if (!pList)
640 return;
641
642
643 int nItems = pList->GetItemCount();
644 int i;
645 bool selected_was_visible = false;
646 CString selected;
647 CString cmp, cpath;
648 for (i = 0; i < nItems; i++) {
649 cmp = pList->GetItemText(i, 0);
650 if (pList->GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED) {
651 selected = cmp;
652 if (pList->IsItemVisible(i))
653 selected_was_visible = true;
654 }
655 }
656
657 pList->DeleteAllItems();
658
659
660 i = 0;
661 bool selected_something = false;
662 int new_selected_index = -1;
663
664 CStringArray mountPoints;
665 GetMountPoints(mountPoints);
666
667 for (i = 0; i < mountPoints.GetCount(); i++) {
668
669 CString dls = mountPoints.GetAt(i);
670
671 if (!lstrcmpi(dls, selected)) {
672 selected_something = true;
673 new_selected_index = i;
674 }
675
676 pList->InsertItem(LVIF_TEXT | (m_imageIndex >= 0 ? LVIF_IMAGE : 0) | LVIF_STATE, i, dls,
677 !lstrcmpi(dls, selected) ? LVIS_SELECTED : 0, LVIS_SELECTED, m_imageIndex >= 0 ? m_imageIndex : 0, 0);
678
679 wstring pathstr;
680 if (MountPointManager::getInstance().get_path(dls, pathstr)) {
681 pList->SetItemText(i, 1, pathstr.c_str());
682 }
683
684 }
685 if (pList->GetItemCount() > 0) {
686 if (!selected_something) {
687 pList->SetItemState(-1, 0, LVIS_SELECTED);
688 pList->SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
689 } else if (selected_was_visible && !pList->IsItemVisible(new_selected_index)) {
690 pList->EnsureVisible(new_selected_index, FALSE);
691 }

Callers 1

OnDeviceChangeMethod · 0.45

Calls 1

get_pathMethod · 0.80

Tested by

no test coverage detected