]>
git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/ControlPanel/FirstPage.cpp
2 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 Change History (most recent first):
25 $Log: FirstPage.cpp,v $
26 Revision 1.3 2005/03/07 18:27:42 shersche
27 <rdar://problem/4037940> Fix problem when ControlPanel commits changes to the browse domain list
29 Revision 1.2 2005/03/03 19:55:22 shersche
30 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
35 #include "FirstPage.h"
38 #include "ConfigPropertySheet.h"
39 #include "SharedSecret.h"
41 #define MAX_KEY_LENGTH 255
44 IMPLEMENT_DYNCREATE(CFirstPage
, CPropertyPage
)
46 //---------------------------------------------------------------------------------------------------------------------------
47 // CFirstPage::CFirstPage
48 //---------------------------------------------------------------------------------------------------------------------------
50 CFirstPage::CFirstPage()
52 CPropertyPage(CFirstPage::IDD
),
53 m_ignoreHostnameChange( false ),
56 //{{AFX_DATA_INIT(CFirstPage)
61 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L
"\\Parameters\\DynDNS\\State\\Hostnames", &m_statusKey
);
64 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L
"\\Parameters\\DynDNS\\Setup\\Hostnames", &m_setupKey
);
68 CFirstPage::~CFirstPage()
72 RegCloseKey( m_statusKey
);
78 RegCloseKey( m_setupKey
);
84 //---------------------------------------------------------------------------------------------------------------------------
85 // CFirstPage::DoDataExchange
86 //---------------------------------------------------------------------------------------------------------------------------
88 void CFirstPage::DoDataExchange(CDataExchange
* pDX
)
90 CPropertyPage::DoDataExchange(pDX
);
91 //{{AFX_DATA_MAP(CFirstPage)
93 DDX_Control(pDX
, IDC_EDIT1
, m_hostnameControl
);
94 DDX_Control(pDX
, IDC_FAILURE
, m_failureIcon
);
95 DDX_Control(pDX
, IDC_SUCCESS
, m_successIcon
);
98 BEGIN_MESSAGE_MAP(CFirstPage
, CPropertyPage
)
99 //{{AFX_MSG_MAP(CFirstPage)
101 ON_BN_CLICKED(IDC_BUTTON1
, OnBnClickedSharedSecret
)
102 ON_EN_CHANGE(IDC_EDIT1
, OnEnChangeHostname
)
106 //---------------------------------------------------------------------------------------------------------------------------
107 // CFirstPage::OnEnChangedHostname
108 //---------------------------------------------------------------------------------------------------------------------------
110 void CFirstPage::OnEnChangeHostname()
112 if ( !m_ignoreHostnameChange
)
119 //---------------------------------------------------------------------------------------------------------------------------
120 // CFirstPage::OnBnClickedSharedSecret
121 //---------------------------------------------------------------------------------------------------------------------------
123 void CFirstPage::OnBnClickedSharedSecret()
127 m_hostnameControl
.GetWindowText( name
);
131 dlg
.m_secretName
= name
;
133 if ( dlg
.DoModal() == IDOK
)
140 //---------------------------------------------------------------------------------------------------------------------------
141 // CFirstPage::SetModified
142 //---------------------------------------------------------------------------------------------------------------------------
144 void CFirstPage::SetModified( BOOL bChanged
)
146 m_modified
= bChanged
? true : false;
148 CPropertyPage::SetModified( bChanged
);
152 //---------------------------------------------------------------------------------------------------------------------------
153 // CFirstPage::OnSetActive
154 //---------------------------------------------------------------------------------------------------------------------------
157 CFirstPage::OnSetActive()
159 TCHAR name
[kDNSServiceMaxDomainName
+ 1];
160 DWORD nameLen
= ( kDNSServiceMaxDomainName
+ 1 ) * sizeof( TCHAR
);
163 BOOL b
= CPropertyPage::OnSetActive();
169 err
= RegQueryValueEx( m_setupKey
, L
"", NULL
, NULL
, (LPBYTE
) name
, &nameLen
);
173 m_ignoreHostnameChange
= true;
174 m_hostnameControl
.SetWindowText( name
);
175 m_ignoreHostnameChange
= false;
179 // Check the status of this hostname
188 //---------------------------------------------------------------------------------------------------------------------------
190 //---------------------------------------------------------------------------------------------------------------------------
202 //---------------------------------------------------------------------------------------------------------------------------
203 // CFirstPage::Commit
204 //---------------------------------------------------------------------------------------------------------------------------
213 m_hostnameControl
.GetWindowText( name
);
215 // Convert to lower case
219 // Remove trailing dot
221 name
.TrimRight( '.' );
223 err
= RegSetValueEx( m_setupKey
, L
"", 0, REG_SZ
, (LPBYTE
) (LPCTSTR
) name
, ( name
.GetLength() + 1 ) * sizeof( TCHAR
) );
224 require_noerr( err
, exit
);
226 err
= RegSetValueEx( m_setupKey
, L
"Enabled", 0, REG_DWORD
, (LPBYTE
) &enabled
, sizeof( DWORD
) );
227 require_noerr( err
, exit
);
235 //---------------------------------------------------------------------------------------------------------------------------
236 // CFirstPage::CheckStatus
237 //---------------------------------------------------------------------------------------------------------------------------
240 CFirstPage::CheckStatus()
243 DWORD dwSize
= sizeof( DWORD
);
246 // Get the status field
248 err
= RegQueryValueEx( m_statusKey
, L
"Status", NULL
, NULL
, (LPBYTE
) &status
, &dwSize
);
249 require_noerr( err
, exit
);
251 ShowStatus( status
);
259 //---------------------------------------------------------------------------------------------------------------------------
260 // CFirstPage::ShowStatus
261 //---------------------------------------------------------------------------------------------------------------------------
264 CFirstPage::ShowStatus( DWORD status
)
268 m_failureIcon
.ShowWindow( SW_HIDE
);
269 m_successIcon
.ShowWindow( SW_SHOW
);
273 m_failureIcon
.ShowWindow( SW_SHOW
);
274 m_successIcon
.ShowWindow( SW_HIDE
);
279 //---------------------------------------------------------------------------------------------------------------------------
280 // CFirstPage::OnRegistryChanged
281 //---------------------------------------------------------------------------------------------------------------------------
284 CFirstPage::OnRegistryChanged()