]>
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.5 2005/10/05 20:46:50 herscher
27 <rdar://problem/4192011> Move Wide-Area preferences to another part of the registry so they don't removed during an update-install.
29 Revision 1.4 2005/04/05 03:52:14 shersche
30 <rdar://problem/4066485> Registering with shared secret key doesn't work. Additionally, mDNSResponder wasn't dynamically re-reading it's DynDNS setup after setting a shared secret key.
32 Revision 1.3 2005/03/07 18:27:42 shersche
33 <rdar://problem/4037940> Fix problem when ControlPanel commits changes to the browse domain list
35 Revision 1.2 2005/03/03 19:55:22 shersche
36 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
41 #include "FirstPage.h"
44 #include "ConfigPropertySheet.h"
45 #include "SharedSecret.h"
47 #define MAX_KEY_LENGTH 255
50 IMPLEMENT_DYNCREATE(CFirstPage
, CPropertyPage
)
52 //---------------------------------------------------------------------------------------------------------------------------
53 // CFirstPage::CFirstPage
54 //---------------------------------------------------------------------------------------------------------------------------
56 CFirstPage::CFirstPage()
58 CPropertyPage(CFirstPage::IDD
),
59 m_ignoreHostnameChange( false ),
63 //{{AFX_DATA_INIT(CFirstPage)
68 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, kServiceParametersNode L
"\\DynDNS\\State\\Hostnames", &m_statusKey
);
71 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, kServiceParametersNode L
"\\DynDNS\\Setup\\Hostnames", &m_setupKey
);
75 CFirstPage::~CFirstPage()
79 RegCloseKey( m_statusKey
);
85 RegCloseKey( m_setupKey
);
91 //---------------------------------------------------------------------------------------------------------------------------
92 // CFirstPage::DoDataExchange
93 //---------------------------------------------------------------------------------------------------------------------------
95 void CFirstPage::DoDataExchange(CDataExchange
* pDX
)
97 CPropertyPage::DoDataExchange(pDX
);
98 //{{AFX_DATA_MAP(CFirstPage)
100 DDX_Control(pDX
, IDC_EDIT1
, m_hostnameControl
);
101 DDX_Control(pDX
, IDC_FAILURE
, m_failureIcon
);
102 DDX_Control(pDX
, IDC_SUCCESS
, m_successIcon
);
105 BEGIN_MESSAGE_MAP(CFirstPage
, CPropertyPage
)
106 //{{AFX_MSG_MAP(CFirstPage)
108 ON_BN_CLICKED(IDC_BUTTON1
, OnBnClickedSharedSecret
)
109 ON_EN_CHANGE(IDC_EDIT1
, OnEnChangeHostname
)
113 //---------------------------------------------------------------------------------------------------------------------------
114 // CFirstPage::OnEnChangedHostname
115 //---------------------------------------------------------------------------------------------------------------------------
117 void CFirstPage::OnEnChangeHostname()
119 if ( !m_ignoreHostnameChange
)
126 //---------------------------------------------------------------------------------------------------------------------------
127 // CFirstPage::OnBnClickedSharedSecret
128 //---------------------------------------------------------------------------------------------------------------------------
130 void CFirstPage::OnBnClickedSharedSecret()
134 m_hostnameControl
.GetWindowText( name
);
140 if ( dlg
.DoModal() == IDOK
)
143 DWORD dwSize
= sizeof( DWORD
);
148 // We have now updated the secret, however the system service
149 // doesn't know about it yet. So we're going to update the
150 // registry with a dummy value which will cause the system
151 // service to re-initialize it's DynDNS setup
154 RegQueryValueEx( m_setupKey
, L
"Wakeup", NULL
, NULL
, (LPBYTE
) &wakeup
, &dwSize
);
158 err
= RegSetValueEx( m_setupKey
, L
"Wakeup", 0, REG_DWORD
, (LPBYTE
) &wakeup
, sizeof( DWORD
) );
159 require_noerr( err
, exit
);
168 //---------------------------------------------------------------------------------------------------------------------------
169 // CFirstPage::SetModified
170 //---------------------------------------------------------------------------------------------------------------------------
172 void CFirstPage::SetModified( BOOL bChanged
)
174 m_modified
= bChanged
? true : false;
176 CPropertyPage::SetModified( bChanged
);
180 //---------------------------------------------------------------------------------------------------------------------------
181 // CFirstPage::OnSetActive
182 //---------------------------------------------------------------------------------------------------------------------------
185 CFirstPage::OnSetActive()
187 TCHAR name
[kDNSServiceMaxDomainName
+ 1];
188 DWORD nameLen
= ( kDNSServiceMaxDomainName
+ 1 ) * sizeof( TCHAR
);
191 BOOL b
= CPropertyPage::OnSetActive();
197 err
= RegQueryValueEx( m_setupKey
, L
"", NULL
, NULL
, (LPBYTE
) name
, &nameLen
);
201 m_ignoreHostnameChange
= true;
202 m_hostnameControl
.SetWindowText( name
);
203 m_ignoreHostnameChange
= false;
207 // Check the status of this hostname
216 //---------------------------------------------------------------------------------------------------------------------------
218 //---------------------------------------------------------------------------------------------------------------------------
230 //---------------------------------------------------------------------------------------------------------------------------
231 // CFirstPage::Commit
232 //---------------------------------------------------------------------------------------------------------------------------
241 m_hostnameControl
.GetWindowText( name
);
243 // Convert to lower case
247 // Remove trailing dot
249 name
.TrimRight( '.' );
251 err
= RegSetValueEx( m_setupKey
, L
"", 0, REG_SZ
, (LPBYTE
) (LPCTSTR
) name
, ( name
.GetLength() + 1 ) * sizeof( TCHAR
) );
252 require_noerr( err
, exit
);
254 err
= RegSetValueEx( m_setupKey
, L
"Enabled", 0, REG_DWORD
, (LPBYTE
) &enabled
, sizeof( DWORD
) );
255 require_noerr( err
, exit
);
263 //---------------------------------------------------------------------------------------------------------------------------
264 // CFirstPage::CheckStatus
265 //---------------------------------------------------------------------------------------------------------------------------
268 CFirstPage::CheckStatus()
271 DWORD dwSize
= sizeof( DWORD
);
274 // Get the status field
276 err
= RegQueryValueEx( m_statusKey
, L
"Status", NULL
, NULL
, (LPBYTE
) &status
, &dwSize
);
277 require_noerr( err
, exit
);
279 ShowStatus( status
);
287 //---------------------------------------------------------------------------------------------------------------------------
288 // CFirstPage::ShowStatus
289 //---------------------------------------------------------------------------------------------------------------------------
292 CFirstPage::ShowStatus( DWORD status
)
296 m_failureIcon
.ShowWindow( SW_HIDE
);
297 m_successIcon
.ShowWindow( SW_SHOW
);
301 m_failureIcon
.ShowWindow( SW_SHOW
);
302 m_successIcon
.ShowWindow( SW_HIDE
);
307 //---------------------------------------------------------------------------------------------------------------------------
308 // CFirstPage::OnRegistryChanged
309 //---------------------------------------------------------------------------------------------------------------------------
312 CFirstPage::OnRegistryChanged()