]>
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.4 2005/04/05 03:52:14 shersche
27 <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.
29 Revision 1.3 2005/03/07 18:27:42 shersche
30 <rdar://problem/4037940> Fix problem when ControlPanel commits changes to the browse domain list
32 Revision 1.2 2005/03/03 19:55:22 shersche
33 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
38 #include "FirstPage.h"
41 #include "ConfigPropertySheet.h"
42 #include "SharedSecret.h"
44 #define MAX_KEY_LENGTH 255
47 IMPLEMENT_DYNCREATE(CFirstPage
, CPropertyPage
)
49 //---------------------------------------------------------------------------------------------------------------------------
50 // CFirstPage::CFirstPage
51 //---------------------------------------------------------------------------------------------------------------------------
53 CFirstPage::CFirstPage()
55 CPropertyPage(CFirstPage::IDD
),
56 m_ignoreHostnameChange( false ),
60 //{{AFX_DATA_INIT(CFirstPage)
65 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L
"\\Parameters\\DynDNS\\State\\Hostnames", &m_statusKey
);
68 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, L
"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L
"\\Parameters\\DynDNS\\Setup\\Hostnames", &m_setupKey
);
72 CFirstPage::~CFirstPage()
76 RegCloseKey( m_statusKey
);
82 RegCloseKey( m_setupKey
);
88 //---------------------------------------------------------------------------------------------------------------------------
89 // CFirstPage::DoDataExchange
90 //---------------------------------------------------------------------------------------------------------------------------
92 void CFirstPage::DoDataExchange(CDataExchange
* pDX
)
94 CPropertyPage::DoDataExchange(pDX
);
95 //{{AFX_DATA_MAP(CFirstPage)
97 DDX_Control(pDX
, IDC_EDIT1
, m_hostnameControl
);
98 DDX_Control(pDX
, IDC_FAILURE
, m_failureIcon
);
99 DDX_Control(pDX
, IDC_SUCCESS
, m_successIcon
);
102 BEGIN_MESSAGE_MAP(CFirstPage
, CPropertyPage
)
103 //{{AFX_MSG_MAP(CFirstPage)
105 ON_BN_CLICKED(IDC_BUTTON1
, OnBnClickedSharedSecret
)
106 ON_EN_CHANGE(IDC_EDIT1
, OnEnChangeHostname
)
110 //---------------------------------------------------------------------------------------------------------------------------
111 // CFirstPage::OnEnChangedHostname
112 //---------------------------------------------------------------------------------------------------------------------------
114 void CFirstPage::OnEnChangeHostname()
116 if ( !m_ignoreHostnameChange
)
123 //---------------------------------------------------------------------------------------------------------------------------
124 // CFirstPage::OnBnClickedSharedSecret
125 //---------------------------------------------------------------------------------------------------------------------------
127 void CFirstPage::OnBnClickedSharedSecret()
131 m_hostnameControl
.GetWindowText( name
);
137 if ( dlg
.DoModal() == IDOK
)
140 DWORD dwSize
= sizeof( DWORD
);
145 // We have now updated the secret, however the system service
146 // doesn't know about it yet. So we're going to update the
147 // registry with a dummy value which will cause the system
148 // service to re-initialize it's DynDNS setup
151 RegQueryValueEx( m_setupKey
, L
"Wakeup", NULL
, NULL
, (LPBYTE
) &wakeup
, &dwSize
);
155 err
= RegSetValueEx( m_setupKey
, L
"Wakeup", 0, REG_DWORD
, (LPBYTE
) &wakeup
, sizeof( DWORD
) );
156 require_noerr( err
, exit
);
165 //---------------------------------------------------------------------------------------------------------------------------
166 // CFirstPage::SetModified
167 //---------------------------------------------------------------------------------------------------------------------------
169 void CFirstPage::SetModified( BOOL bChanged
)
171 m_modified
= bChanged
? true : false;
173 CPropertyPage::SetModified( bChanged
);
177 //---------------------------------------------------------------------------------------------------------------------------
178 // CFirstPage::OnSetActive
179 //---------------------------------------------------------------------------------------------------------------------------
182 CFirstPage::OnSetActive()
184 TCHAR name
[kDNSServiceMaxDomainName
+ 1];
185 DWORD nameLen
= ( kDNSServiceMaxDomainName
+ 1 ) * sizeof( TCHAR
);
188 BOOL b
= CPropertyPage::OnSetActive();
194 err
= RegQueryValueEx( m_setupKey
, L
"", NULL
, NULL
, (LPBYTE
) name
, &nameLen
);
198 m_ignoreHostnameChange
= true;
199 m_hostnameControl
.SetWindowText( name
);
200 m_ignoreHostnameChange
= false;
204 // Check the status of this hostname
213 //---------------------------------------------------------------------------------------------------------------------------
215 //---------------------------------------------------------------------------------------------------------------------------
227 //---------------------------------------------------------------------------------------------------------------------------
228 // CFirstPage::Commit
229 //---------------------------------------------------------------------------------------------------------------------------
238 m_hostnameControl
.GetWindowText( name
);
240 // Convert to lower case
244 // Remove trailing dot
246 name
.TrimRight( '.' );
248 err
= RegSetValueEx( m_setupKey
, L
"", 0, REG_SZ
, (LPBYTE
) (LPCTSTR
) name
, ( name
.GetLength() + 1 ) * sizeof( TCHAR
) );
249 require_noerr( err
, exit
);
251 err
= RegSetValueEx( m_setupKey
, L
"Enabled", 0, REG_DWORD
, (LPBYTE
) &enabled
, sizeof( DWORD
) );
252 require_noerr( err
, exit
);
260 //---------------------------------------------------------------------------------------------------------------------------
261 // CFirstPage::CheckStatus
262 //---------------------------------------------------------------------------------------------------------------------------
265 CFirstPage::CheckStatus()
268 DWORD dwSize
= sizeof( DWORD
);
271 // Get the status field
273 err
= RegQueryValueEx( m_statusKey
, L
"Status", NULL
, NULL
, (LPBYTE
) &status
, &dwSize
);
274 require_noerr( err
, exit
);
276 ShowStatus( status
);
284 //---------------------------------------------------------------------------------------------------------------------------
285 // CFirstPage::ShowStatus
286 //---------------------------------------------------------------------------------------------------------------------------
289 CFirstPage::ShowStatus( DWORD status
)
293 m_failureIcon
.ShowWindow( SW_HIDE
);
294 m_successIcon
.ShowWindow( SW_SHOW
);
298 m_failureIcon
.ShowWindow( SW_SHOW
);
299 m_successIcon
.ShowWindow( SW_HIDE
);
304 //---------------------------------------------------------------------------------------------------------------------------
305 // CFirstPage::OnRegistryChanged
306 //---------------------------------------------------------------------------------------------------------------------------
309 CFirstPage::OnRegistryChanged()