]>
git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/ControlPanel/FirstPage.cpp
1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 Change History (most recent first):
19 $Log: FirstPage.cpp,v $
20 Revision 1.7 2009/06/22 23:25:10 herscher
21 <rdar://problem/5265747> ControlPanel doesn't display key and password in dialog box. Refactor Lsa calls into Secret.h and Secret.c, which is used by both the ControlPanel and mDNSResponder system service.
23 Revision 1.6 2006/08/14 23:25:28 cheshire
24 Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0
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 ()