-
Notifications
You must be signed in to change notification settings - Fork 0
/
WHOISDOC.CPP
204 lines (171 loc) · 4.1 KB
/
WHOISDOC.CPP
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// whoisdoc.cpp : implementation of the CWhoisDoc class
//
#include "stdafx.h"
#include "inetnav.h"
#include "whoisdoc.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWhoisDoc
IMPLEMENT_SERIAL(CWhoisDoc, CDocument, 1)
BEGIN_MESSAGE_MAP(CWhoisDoc, CDocument)
//{{AFX_MSG_MAP(CWhoisDoc)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE, OnUpdateFileSave)
ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_AS, OnUpdateFileSaveAs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWhoisDoc construction/destruction
CWhoisDoc::CWhoisDoc()
{
//{{AFX_DATA_INIT(CWhoisDoc)
m_strNIC = ""; // main Network Information Center (NIC)
m_strHost = "";
m_strOutput = "";
//}}AFX_DATA_INIT
m_pApp = (CInternetNavApp*)AfxGetApp();
}
/*
//{{AFX_DATA_MAP(CWhoisDoc)
//}}AFX_DATA_MAP
*/
CWhoisDoc::~CWhoisDoc()
{
}
BOOL CWhoisDoc::OnNewDocument()
{
// Load the Network Information Center text box with the address
// of DS.INTERNIC.NET, the main database of hosts on the Internet
m_strNIC.LoadString(IDS_DS_INTERNIC_NET);
CString strTitle = "InterNIC Site Information";
SetTitle(strTitle);
SetModifiedFlag(FALSE);
if (!CDocument::OnNewDocument())
return FALSE;
return TRUE;
}
BOOL CWhoisDoc::OnOpenDocument(const char* pszPathName)
{
if (!CDocument::OnOpenDocument(pszPathName))
{
AfxMessageBox(AFX_IDP_FAILED_TO_OPEN_DOC, MB_ICONSTOP|MB_OK);
return FALSE;
}
CString strTitle = "InterNIC Site Information: ";
strTitle += GetTitle();
SetTitle(strTitle);
return TRUE;
}
BOOL CWhoisDoc::SaveModified()
{
if (!IsModified())
return TRUE; // ok to continue
CString strName = "the information you have obtained from the InterNIC";
CString prompt = "";
AfxFormatString1(prompt, AFX_IDP_ASK_TO_SAVE, strName);
switch (AfxMessageBox(prompt, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE))
{
case IDCANCEL:
return FALSE; // don't continue
case IDYES:
// If so, either Save or Update, as appropriate
if (_access(m_strPathName, 6) != 0)
{
if (!CDocument::DoSave(NULL))
return FALSE; // don't continue
}
else
{
if (!CDocument::DoSave(m_strPathName))
return FALSE; // don't continue
}
break;
case IDNO:
// If not saving changes, revert the document
break;
default:
ASSERT(FALSE);
break;
}
return TRUE; // keep going
}
void CWhoisDoc::SetTitle(const char* /*pszTitle*/)
{
CString strTitle = "InterNIC Site Information";
if (m_strHost.IsEmpty() && m_strNIC.IsEmpty())
{
// set this window's (and document's) title to say,
// "InterNIC Site Information".
m_strTitle = strTitle;
UpdateFrameCounts();
return;
}
else if (m_strHost.IsEmpty() || m_strNIC.IsEmpty())
{
m_strTitle = strTitle;
UpdateFrameCounts();
return;
}
else if (!m_strHost.IsEmpty() && !m_strNIC.IsEmpty())
{
m_strTitle = strTitle;
m_strTitle += ": ";
m_strTitle += m_strHost;
UpdateFrameCounts();
return;
}
else
{
m_strTitle = strTitle;
UpdateFrameCounts();
return;
}
}
/////////////////////////////////////////////////////////////////////////////
// CWhoisDoc serialization
void CWhoisDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
ar << m_strNIC;
ar << m_strHost;
ar << m_strOutput;
}
else
{
ar >> m_strNIC;
ar >> m_strHost;
ar >> m_strOutput;
}
}
void CWhoisDoc::DeleteContents()
{
return;
}
/////////////////////////////////////////////////////////////////////////////
// CWhoisDoc diagnostics
#ifdef _DEBUG
void CWhoisDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CWhoisDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWhoisDoc commands
void CWhoisDoc::OnUpdateFileSave(CCmdUI* pCmdUI)
{
// Only enable the File, Save menu item if the document data has
// changed
pCmdUI->Enable(IsModified());
return;
}
void CWhoisDoc::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
}