]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/ControlPanel/FourthPage.cpp
mDNSResponder-212.1.tar.gz
[apple/mdnsresponder.git] / mDNSWindows / ControlPanel / FourthPage.cpp
1 /* -*- Mode: C; tab-width: 4 -*-
2 *
3 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16
17 Change History (most recent first):
18
19 $Log: FourthPage.cpp,v $
20 Revision 1.1 2009/07/01 19:20:37 herscher
21 <rdar://problem/6713286> UI changes for configuring sleep proxy settings.
22
23
24
25 */
26
27 #include "FourthPage.h"
28 #include "resource.h"
29
30 #include "ConfigPropertySheet.h"
31 #include "SharedSecret.h"
32
33 #include <WinServices.h>
34
35 #define MAX_KEY_LENGTH 255
36
37
38 IMPLEMENT_DYNCREATE(CFourthPage, CPropertyPage)
39
40
41 //---------------------------------------------------------------------------------------------------------------------------
42 // CFourthPage::CFourthPage
43 //---------------------------------------------------------------------------------------------------------------------------
44
45 CFourthPage::CFourthPage()
46 :
47 CPropertyPage(CFourthPage::IDD)
48 {
49 //{{AFX_DATA_INIT(CFourthPage)
50 //}}AFX_DATA_INIT
51 }
52
53
54 //---------------------------------------------------------------------------------------------------------------------------
55 // CFourthPage::~CFourthPage
56 //---------------------------------------------------------------------------------------------------------------------------
57
58 CFourthPage::~CFourthPage()
59 {
60 }
61
62
63 //---------------------------------------------------------------------------------------------------------------------------
64 // CFourthPage::DoDataExchange
65 //---------------------------------------------------------------------------------------------------------------------------
66
67 void CFourthPage::DoDataExchange(CDataExchange* pDX)
68 {
69 CPropertyPage::DoDataExchange(pDX);
70 //{{AFX_DATA_MAP(CFourthPage)
71 //}}AFX_DATA_MAP
72 DDX_Control(pDX, IDC_POWER_MANAGEMENT, m_checkBox);
73 }
74
75 BEGIN_MESSAGE_MAP(CFourthPage, CPropertyPage)
76 //{{AFX_MSG_MAP(CFourthPage)
77 //}}AFX_MSG_MAP
78 ON_BN_CLICKED(IDC_POWER_MANAGEMENT, &CFourthPage::OnBnClickedPowerManagement)
79 END_MESSAGE_MAP()
80
81
82 //---------------------------------------------------------------------------------------------------------------------------
83 // CFourthPage::SetModified
84 //---------------------------------------------------------------------------------------------------------------------------
85
86 void CFourthPage::SetModified( BOOL bChanged )
87 {
88 m_modified = bChanged;
89
90 CPropertyPage::SetModified( bChanged );
91 }
92
93
94 //---------------------------------------------------------------------------------------------------------------------------
95 // CFourthPage::OnSetActive
96 //---------------------------------------------------------------------------------------------------------------------------
97
98 BOOL
99 CFourthPage::OnSetActive()
100 {
101 CConfigPropertySheet * psheet;
102 HKEY key = NULL;
103 DWORD dwSize;
104 DWORD enabled;
105 DWORD err;
106 BOOL b = CPropertyPage::OnSetActive();
107
108 psheet = reinterpret_cast<CConfigPropertySheet*>(GetParent());
109 require_quiet( psheet, exit );
110
111 m_checkBox.SetCheck( 0 );
112
113 // Now populate the browse domain box
114
115 err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\Power Management", &key );
116 require_noerr( err, exit );
117
118 dwSize = sizeof( DWORD );
119 err = RegQueryValueEx( key, L"Enabled", NULL, NULL, (LPBYTE) &enabled, &dwSize );
120 require_noerr( err, exit );
121
122 m_checkBox.SetCheck( enabled );
123
124 exit:
125
126 if ( key )
127 {
128 RegCloseKey( key );
129 }
130
131 return b;
132 }
133
134
135 //---------------------------------------------------------------------------------------------------------------------------
136 // CFourthPage::OnOK
137 //---------------------------------------------------------------------------------------------------------------------------
138
139 void
140 CFourthPage::OnOK()
141 {
142 if ( m_modified )
143 {
144 Commit();
145 }
146 }
147
148
149
150 //---------------------------------------------------------------------------------------------------------------------------
151 // CFourthPage::Commit
152 //---------------------------------------------------------------------------------------------------------------------------
153
154 void
155 CFourthPage::Commit()
156 {
157 HKEY key = NULL;
158 DWORD enabled;
159 DWORD err;
160
161 err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\Power Management", &key );
162 require_noerr( err, exit );
163
164 enabled = m_checkBox.GetCheck();
165 err = RegSetValueEx( key, L"Enabled", NULL, REG_DWORD, (LPBYTE) &enabled, sizeof( enabled ) );
166 require_noerr( err, exit );
167
168 exit:
169
170 if ( key )
171 {
172 RegCloseKey( key );
173 }
174 }
175
176
177 //---------------------------------------------------------------------------------------------------------------------------
178 // CFourthPage::OnBnClickedRemoveBrowseDomain
179 //---------------------------------------------------------------------------------------------------------------------------
180
181
182 void CFourthPage::OnBnClickedPowerManagement()
183 {
184 char buf[ 256 ];
185
186 sprintf( buf, "check box: %d", m_checkBox.GetCheck() );
187 OutputDebugStringA( buf );
188 // TODO: Add your control notification handler code here
189
190 SetModified( TRUE );
191 }