Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DelDeadLetter.cpp « Ext2Mgr - github.com/matt-wu/Ext3Fsd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d89d91c81f40ed730a319c7976fff690b5d9a978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// DelDeadLetter.cpp : implementation file
//

#include "stdafx.h"
#include "ext2mgr.h"
#include "DelDeadLetter.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDelDeadLetter dialog


CDelDeadLetter::CDelDeadLetter(CWnd* pParent /*=NULL*/)
	: CDialog(CDelDeadLetter::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDelDeadLetter)
	m_sDrvLetter = _T("");
	m_bAutoRemoval = g_bAutoRemoveDeadLetters;
	m_bKeepIt = TRUE;
	//}}AFX_DATA_INIT
}


void CDelDeadLetter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDelDeadLetter)
    DDX_CBString(pDX, IDC_DEAD_LETTER_LIST, m_sDrvLetter);
	DDX_Check(pDX, IDC_AUTO_REMOVAL, m_bAutoRemoval);
	DDX_Check(pDX, IDC_REMOVAL_CURRENT, m_bKeepIt);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDelDeadLetter, CDialog)
	//{{AFX_MSG_MAP(CDelDeadLetter)
	ON_BN_CLICKED(ID_RELOAD_DL, OnReloadDl)
	ON_BN_CLICKED(IDC_AUTO_REMOVAL, OnAutoRemoval)
	ON_BN_CLICKED(IDC_AUTOREMOVALTEXT, OnAutoremovaltext)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDelDeadLetter message handlers

void CDelDeadLetter::OnOK() 
{
    CHAR            drvChar;
    PEXT2_LETTER    drvLetter = NULL;
    UpdateData(TRUE);

    drvChar = m_sDrvLetter.GetAt(0);

    if ((drvChar >= '0') && (drvChar <= '9')) {
        drvLetter = &drvDigits[drvChar - '0'];
    }

    if ((drvChar >= 'A') && (drvChar <= 'Z')) {
        drvLetter = &drvLetters[drvChar - 'A'];
    }

    if (drvLetter) {
        if (AfxMessageBox("Warning: the driver letter might be still used. Are you\r\n"
                          "         sure that make it's a real dead driver letter ?", MB_YESNO) == IDYES) {

            Ext2RemoveMountPoint(drvLetter, !m_bKeepIt);
            Ext2RemoveDosSymLink(drvLetter->Letter);
            UpdateDeadLetterList();
        }
    }
}

BOOL CDelDeadLetter::OnInitDialog() 
{
	CDialog::OnInitDialog();

    UpdateDeadLetterList();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

VOID
CDelDeadLetter::UpdateDeadLetterList()
{
    ULONGLONG   LetterMask = -1;
    DWORD       i, j;
    PEXT2_VOLUME    volume;
    PEXT2_DISK      disk;
    PEXT2_PARTITION part;
    PEXT2_CDROM     cdrom;
    CString         str;

    CComboBox *cbList = (CComboBox *)GetDlgItem(IDC_DEAD_LETTER_LIST);

    cbList->ResetContent();

    for (volume = gVols; volume != NULL; volume = volume->Next) {
        LetterMask &= ~(volume->DrvLetters);
    }

    for (i = 0; i < g_nDisks; i++) {
        disk = &gDisks[i];
        if (disk->DataParts == NULL) {
            continue;
        }
        for (j=0; j < disk->NumParts; j++) {
            part = &disk->DataParts[j];
            if (part) {
                 LetterMask &= ~(part->DrvLetters);
            }
        }
    }

    for (i = 0; i < g_nCdroms; i++) {
        cdrom = &gCdroms[i];
        LetterMask &= ~(cdrom->DrvLetters);
    }

    for (i=0; i < 10; i++) {
        if (drvDigits[i].bUsed && (drvDigits[i].Extent == NULL) &&
            (LetterMask & (((ULONGLONG) 1) << (i + 32)) ) ) {
            str.Format("%c: ", drvDigits[i].Letter);
            str += drvDigits[i].SymLink;
            cbList->AddString(str);
        }
    }

    for (i=0; i <26; i++) {
        if (drvLetters[i].bUsed && (drvLetters[i].Extent == NULL) &&
            (LetterMask & (((ULONGLONG) 1) << i)) ) {
            str.Format("%c: ", drvLetters[i].Letter);
            str += drvLetters[i].SymLink;
            cbList->AddString(str);
        }
    }

#if 0
    if (cbList->GetCount() == 0) {
        AfxMessageBox("No dead driver letters exist :)", MB_OK|MB_ICONINFORMATION);
        EndDialog(TRUE);
    }
#endif

    cbList->SetCurSel(0);
}

void CDelDeadLetter::OnReloadDl() 
{
	// TODO: Add your control notification handler code here
	UpdateDeadLetterList();
}

void CDelDeadLetter::OnAutoRemoval() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
    g_bAutoRemoveDeadLetters = m_bAutoRemoval;	
}

void CDelDeadLetter::OnAutoremovaltext() 
{
}