Repository navigation
Expand file tree
/
Copy pathMibImportPropertyPage.cpp
More file actions
153 lines (132 loc) · 3.43 KB
/
Copy pathMibImportPropertyPage.cpp
File metadata and controls
153 lines (132 loc) · 3.43 KB
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
#include "stdafx.h"
#include "traprcvr.h"
#include "MibImportPropertyPage.h"
#include "Registry.h"
#include "MibFileBrowse.h"
#include "MibLoadStatus.h"
#include "MibUnloadStatus.h"
#include "MibDb.h"
extern MibDb gDb;
IMPLEMENT_DYNCREATE(MibImportPropertyPage, CPropertyPage)
MibImportPropertyPage::MibImportPropertyPage()
:CPropertyPage(MibImportPropertyPage::IDD)
{
//{{AFX_DATA_INIT(MibImportPropertyPage)
mTranslateOids = FALSE;
//}}AFX_DATA_INIT
}
MibImportPropertyPage::~MibImportPropertyPage()
{
}
void
MibImportPropertyPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(MibImportPropertyPage)
DDX_Control(pDX, IDC_BUTTONUNLOADMIB, mUnloadButton);
DDX_Control(pDX, IDC_LISTLOADEDMIBS, mList);
DDX_Check(pDX, IDC_CHECKTRANSLATEOIDS, mTranslateOids);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(MibImportPropertyPage, CPropertyPage)
//{{AFX_MSG_MAP(MibImportPropertyPage)
ON_BN_CLICKED(IDC_BUTTONIMPORTMIB, OnButtonImportMib)
ON_BN_CLICKED(IDC_BUTTONUNLOADMIB, OnButtonUnloadMib)
ON_LBN_SELCHANGE(IDC_LISTLOADEDMIBS, OnSelchangeListLoadedMibs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL
MibImportPropertyPage::OnApply()
{
Registry registry;
registry.translateOids(mTranslateOids);
return CPropertyPage::OnApply();
}
BOOL
MibImportPropertyPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
Registry registry;
try
{
mTranslateOids = registry.translateOids();
}
catch(...)
{
registry.translateOids(FALSE);
}
bool status = gDb.GetAllMIBs();
while (true == status)
{
mList.AddString(gDb.MibName().c_str());
status = gDb.Next(MIBDATASET);
}
#if 0
unsigned int numR = gTrapMap->NumberOfRecords();
for (unsigned int x = 0; x < numR; x++)
{
EbRecord* pRecord = gTrapMap->GetRecord(x);
if (mList.FindString(-1, pRecord->GetFieldString(1)) == LB_ERR)
mList.AddString(pRecord->GetFieldString(1));
}
numR = gOidMap->NumberOfRecords();
for (x = 0; x < numR; x++)
{
EbRecord* pRecord = gOidMap->GetRecord(x);
if (mList.FindString(-1, pRecord->GetFieldString(1)) == LB_ERR)
mList.AddString(pRecord->GetFieldString(1));
}
numR = gEnumMap->NumberOfRecords();
for (x = 0; x < numR; x++)
{
EbRecord* pRecord = gEnumMap->GetRecord(x);
if (mList.FindString(-1, pRecord->GetFieldString(1)) == LB_ERR)
mList.AddString(pRecord->GetFieldString(1));
}
#endif
mUnloadButton.EnableWindow(FALSE);
UpdateData(FALSE);
return TRUE;
}
void
MibImportPropertyPage::OnButtonImportMib()
{
MibFileBrowse dlg;
int result = dlg.DoModal();
if (result == IDOK)
{
CString fileName = dlg.mMibFilename;
if (fileName.GetLength() > 0)
{
MibLoadStatus mls(fileName, &mList);
// MibLoadStatus mls(fileName);
mls.DoModal();
if (mls.mStatus == TRUE)
if (mList.FindString(-1, mls.mMibName.GetBuffer(0)) == LB_ERR)
mList.AddString(mls.mMibName.GetBuffer(0));
}
}
}
void
MibImportPropertyPage::OnButtonUnloadMib()
{
CString mib;
int index = mList.GetCurSel();
mList.GetText(index, mib);
if (mib.GetLength() > 0)
{
MibUnloadStatus mus(mib, &mList);
// MibUnloadStatus mus(mib);
mus.DoModal();
if (mus.mStatus == TRUE)
mList.DeleteString(index);
}
}
void
MibImportPropertyPage::OnSelchangeListLoadedMibs()
{
if (mList.GetCurSel() == -1)
mUnloadButton.EnableWindow(FALSE);
else
mUnloadButton.EnableWindow(TRUE);
}