X-Git-Url: https://git.saurik.com/apple/mdnsresponder.git/blobdiff_plain/7cb34e5c3616917483a8e75510de0387e51833cc..ca3eca6bb9e566fa2f1db828ae1825ca099188fd:/mDNSWindows/ControlPanel/ThirdPage.cpp diff --git a/mDNSWindows/ControlPanel/ThirdPage.cpp b/mDNSWindows/ControlPanel/ThirdPage.cpp index bfb56bd..a483418 100755 --- a/mDNSWindows/ControlPanel/ThirdPage.cpp +++ b/mDNSWindows/ControlPanel/ThirdPage.cpp @@ -1,28 +1,28 @@ -/* +/* -*- Mode: C; tab-width: 4 -*- + * * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * http://www.apache.org/licenses/LICENSE-2.0 * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, - * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. - * - * @APPLE_LICENSE_HEADER_END@ Change History (most recent first): $Log: ThirdPage.cpp,v $ +Revision 1.5 2006/08/14 23:25:29 cheshire +Re-licensed mDNSResponder daemon source code under Apache License, Version 2.0 + +Revision 1.4 2005/10/05 20:46:50 herscher + Move Wide-Area preferences to another part of the registry so they don't removed during an update-install. + Revision 1.3 2005/03/07 18:27:42 shersche Fix problem when ControlPanel commits changes to the browse domain list @@ -40,7 +40,7 @@ Revision 1.2 2005/03/03 19:55:22 shersche #include -#define MAX_KEY_LENGTH 255 +#define MAX_KEY_LENGTH 255 IMPLEMENT_DYNCREATE(CThirdPage, CPropertyPage) @@ -79,16 +79,16 @@ void CThirdPage::DoDataExchange(CDataExchange* pDX) CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CThirdPage) //}}AFX_DATA_MAP - DDX_Control(pDX, IDC_BROWSE_LIST, m_browseListCtrl); - DDX_Control(pDX, IDC_REMOVE_BROWSE_DOMAIN, m_removeButton); + DDX_Control(pDX, IDC_BROWSE_LIST, m_browseListCtrl); + DDX_Control(pDX, IDC_REMOVE_BROWSE_DOMAIN, m_removeButton); } BEGIN_MESSAGE_MAP(CThirdPage, CPropertyPage) //{{AFX_MSG_MAP(CThirdPage) //}}AFX_MSG_MAP - ON_BN_CLICKED(IDC_ADD_BROWSE_DOMAIN, OnBnClickedAddBrowseDomain) - ON_BN_CLICKED(IDC_REMOVE_BROWSE_DOMAIN, OnBnClickedRemoveBrowseDomain) - ON_NOTIFY(LVN_ITEMCHANGED, IDC_BROWSE_LIST, OnLvnItemchangedBrowseList) + ON_BN_CLICKED(IDC_ADD_BROWSE_DOMAIN, OnBnClickedAddBrowseDomain) + ON_BN_CLICKED(IDC_REMOVE_BROWSE_DOMAIN, OnBnClickedRemoveBrowseDomain) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_BROWSE_LIST, OnLvnItemchangedBrowseList) END_MESSAGE_MAP() @@ -117,11 +117,11 @@ CThirdPage::OnSetActive() DWORD dwSize; DWORD enabled; DWORD err; - TCHAR subKeyName[MAX_KEY_LENGTH]; - DWORD cSubKeys = 0; - DWORD cbMaxSubKey; - DWORD cchMaxClass; - int nIndex; + TCHAR subKeyName[MAX_KEY_LENGTH]; + DWORD cSubKeys = 0; + DWORD cbMaxSubKey; + DWORD cchMaxClass; + int nIndex; DWORD i; BOOL b = CPropertyPage::OnSetActive(); @@ -148,39 +148,39 @@ CThirdPage::OnSetActive() // Now populate the browse domain box - err = RegCreateKey( HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L"\\Parameters\\DynDNS\\Setup\\" kServiceDynDNSBrowseDomains, &key ); + err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\DynDNS\\Setup\\" kServiceDynDNSBrowseDomains, &key ); require_noerr( err, exit ); - // Get information about this node - - err = RegQueryInfoKey( key, NULL, NULL, NULL, &cSubKeys, &cbMaxSubKey, &cchMaxClass, NULL, NULL, NULL, NULL, NULL ); + // Get information about this node + + err = RegQueryInfoKey( key, NULL, NULL, NULL, &cSubKeys, &cbMaxSubKey, &cchMaxClass, NULL, NULL, NULL, NULL, NULL ); require_noerr( err, exit ); - - for ( i = 0; i < cSubKeys; i++) - { - dwSize = MAX_KEY_LENGTH; - - err = RegEnumKeyEx( key, i, subKeyName, &dwSize, NULL, NULL, NULL, NULL ); - require_noerr( err, exit ); - - err = RegOpenKey( key, subKeyName, &subKey ); - require_noerr( err, exit ); - - dwSize = sizeof( DWORD ); - err = RegQueryValueEx( subKey, L"Enabled", NULL, NULL, (LPBYTE) &enabled, &dwSize ); - require_noerr( err, exit ); - + + for ( i = 0; i < cSubKeys; i++) + { + dwSize = MAX_KEY_LENGTH; + + err = RegEnumKeyEx( key, i, subKeyName, &dwSize, NULL, NULL, NULL, NULL ); + require_noerr( err, exit ); + + err = RegOpenKey( key, subKeyName, &subKey ); + require_noerr( err, exit ); + + dwSize = sizeof( DWORD ); + err = RegQueryValueEx( subKey, L"Enabled", NULL, NULL, (LPBYTE) &enabled, &dwSize ); + require_noerr( err, exit ); + nIndex = m_browseListCtrl.InsertItem( m_browseListCtrl.GetItemCount(), L""); - m_browseListCtrl.SetItemText( nIndex, 1, subKeyName ); - m_browseListCtrl.SetCheck( nIndex, enabled ); - - RegCloseKey( subKey ); - subKey = NULL; - } - - m_browseListCtrl.SortItems( SortFunc, (DWORD_PTR) this ); - - m_removeButton.EnableWindow( FALSE ); + m_browseListCtrl.SetItemText( nIndex, 1, subKeyName ); + m_browseListCtrl.SetCheck( nIndex, enabled ); + + RegCloseKey( subKey ); + subKey = NULL; + } + + m_browseListCtrl.SortItems( SortFunc, (DWORD_PTR) this ); + + m_removeButton.EnableWindow( FALSE ); exit: @@ -198,8 +198,8 @@ exit: return b; } - - + + //--------------------------------------------------------------------------------------------------------------------------- // CThirdPage::OnOK @@ -225,31 +225,31 @@ CThirdPage::Commit() { HKEY key = NULL; HKEY subKey = NULL; - TCHAR subKeyName[MAX_KEY_LENGTH]; - DWORD cSubKeys = 0; - DWORD cbMaxSubKey; + TCHAR subKeyName[MAX_KEY_LENGTH]; + DWORD cSubKeys = 0; + DWORD cbMaxSubKey; DWORD cchMaxClass; DWORD dwSize; int i; DWORD err; - err = RegCreateKey( HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\" kServiceName L"\\Parameters\\DynDNS\\Setup\\" kServiceDynDNSBrowseDomains, &key ); + err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\DynDNS\\Setup\\" kServiceDynDNSBrowseDomains, &key ); require_noerr( err, exit ); - // First, remove all the entries that are there - - err = RegQueryInfoKey( key, NULL, NULL, NULL, &cSubKeys, &cbMaxSubKey, &cchMaxClass, NULL, NULL, NULL, NULL, NULL ); + // First, remove all the entries that are there + + err = RegQueryInfoKey( key, NULL, NULL, NULL, &cSubKeys, &cbMaxSubKey, &cchMaxClass, NULL, NULL, NULL, NULL, NULL ); require_noerr( err, exit ); - - for ( i = 0; i < (int) cSubKeys; i++ ) - { - dwSize = MAX_KEY_LENGTH; - - err = RegEnumKeyEx( key, 0, subKeyName, &dwSize, NULL, NULL, NULL, NULL ); - require_noerr( err, exit ); - - err = RegDeleteKey( key, subKeyName ); - require_noerr( err, exit ); + + for ( i = 0; i < (int) cSubKeys; i++ ) + { + dwSize = MAX_KEY_LENGTH; + + err = RegEnumKeyEx( key, 0, subKeyName, &dwSize, NULL, NULL, NULL, NULL ); + require_noerr( err, exit ); + + err = RegDeleteKey( key, subKeyName ); + require_noerr( err, exit ); } // Now re-populate @@ -297,9 +297,9 @@ CThirdPage::OnBnClickedAddBrowseDomain() int nIndex; nIndex = m_browseListCtrl.InsertItem( m_browseListCtrl.GetItemCount(), L""); - m_browseListCtrl.SetItemText( nIndex, 1, dlg.m_text ); - m_browseListCtrl.SetCheck( nIndex, 1 ); - + m_browseListCtrl.SetItemText( nIndex, 1, dlg.m_text ); + m_browseListCtrl.SetCheck( nIndex, 1 ); + m_browseListCtrl.SortItems( SortFunc, (DWORD_PTR) this ); m_browseListCtrl.Invalidate(); @@ -316,141 +316,141 @@ CThirdPage::OnBnClickedAddBrowseDomain() void CThirdPage::OnBnClickedRemoveBrowseDomain() { - UINT selectedCount = m_browseListCtrl.GetSelectedCount(); - int nItem = -1; - UINT i; - - // Update all of the selected items. - - for ( i = 0; i < selectedCount; i++ ) - { - nItem = m_browseListCtrl.GetNextItem( -1, LVNI_SELECTED ); - check( nItem != -1 ); - - m_browseListCtrl.DeleteItem( nItem ); - - SetModified( TRUE ); - } - - m_removeButton.EnableWindow( FALSE ); + UINT selectedCount = m_browseListCtrl.GetSelectedCount(); + int nItem = -1; + UINT i; + + // Update all of the selected items. + + for ( i = 0; i < selectedCount; i++ ) + { + nItem = m_browseListCtrl.GetNextItem( -1, LVNI_SELECTED ); + check( nItem != -1 ); + + m_browseListCtrl.DeleteItem( nItem ); + + SetModified( TRUE ); + } + + m_removeButton.EnableWindow( FALSE ); } -void -CThirdPage::OnLvnItemchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult) -{ - if ( m_browseListCtrl.GetSelectedCount() ) - { - m_removeButton.EnableWindow( TRUE ); - } - - if ( m_initialized ) - { - NM_LISTVIEW * pNMListView = (NM_LISTVIEW*)pNMHDR; - - BOOL bPrevState = (BOOL) ( ( ( pNMListView->uOldState & LVIS_STATEIMAGEMASK ) >> 12 ) - 1 ); - - if ( bPrevState < 0 ) - { - bPrevState = 0; - } - - - BOOL bChecked = ( BOOL ) ( ( ( pNMListView->uNewState & LVIS_STATEIMAGEMASK ) >> 12) - 1 ); - - if ( bChecked < 0 ) - { - bChecked = 0; - } - - if ( bPrevState != bChecked ) - { - SetModified( TRUE ); - } - } - - *pResult = 0; +void +CThirdPage::OnLvnItemchangedBrowseList(NMHDR *pNMHDR, LRESULT *pResult) +{ + if ( m_browseListCtrl.GetSelectedCount() ) + { + m_removeButton.EnableWindow( TRUE ); + } + + if ( m_initialized ) + { + NM_LISTVIEW * pNMListView = (NM_LISTVIEW*)pNMHDR; + + BOOL bPrevState = (BOOL) ( ( ( pNMListView->uOldState & LVIS_STATEIMAGEMASK ) >> 12 ) - 1 ); + + if ( bPrevState < 0 ) + { + bPrevState = 0; + } + + + BOOL bChecked = ( BOOL ) ( ( ( pNMListView->uNewState & LVIS_STATEIMAGEMASK ) >> 12) - 1 ); + + if ( bChecked < 0 ) + { + bChecked = 0; + } + + if ( bPrevState != bChecked ) + { + SetModified( TRUE ); + } + } + + *pResult = 0; } -int CALLBACK -CThirdPage::SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) -{ - CString str1; - CString str2; - int ret = 0; - +int CALLBACK +CThirdPage::SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) +{ + CString str1; + CString str2; + int ret = 0; + CThirdPage * self = reinterpret_cast( lParamSort ); require_quiet( self, exit ); - - str1 = self->m_browseListCtrl.GetItemText( (int) lParam1, 1 ); - str2 = self->m_browseListCtrl.GetItemText( (int) lParam2, 1 ); - - ret = str1.Compare( str2 ); - -exit: - - return ret; + + str1 = self->m_browseListCtrl.GetItemText( (int) lParam1, 1 ); + str2 = self->m_browseListCtrl.GetItemText( (int) lParam2, 1 ); + + ret = str1.Compare( str2 ); + +exit: + + return ret; +} + + +// CAddBrowseDomain dialog + +IMPLEMENT_DYNAMIC(CAddBrowseDomain, CDialog) +CAddBrowseDomain::CAddBrowseDomain(CWnd* pParent /*=NULL*/) + : CDialog(CAddBrowseDomain::IDD, pParent) +{ } - - -// CAddBrowseDomain dialog - -IMPLEMENT_DYNAMIC(CAddBrowseDomain, CDialog) -CAddBrowseDomain::CAddBrowseDomain(CWnd* pParent /*=NULL*/) - : CDialog(CAddBrowseDomain::IDD, pParent) -{ -} - -CAddBrowseDomain::~CAddBrowseDomain() -{ -} - -void CAddBrowseDomain::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_COMBO1, m_comboBox); -} - - -BOOL -CAddBrowseDomain::OnInitDialog() -{ - CConfigPropertySheet * psheet; - CConfigPropertySheet::StringList::iterator it; - - BOOL b = CDialog::OnInitDialog(); - + +CAddBrowseDomain::~CAddBrowseDomain() +{ +} + +void CAddBrowseDomain::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + DDX_Control(pDX, IDC_COMBO1, m_comboBox); +} + + +BOOL +CAddBrowseDomain::OnInitDialog() +{ + CConfigPropertySheet * psheet; + CConfigPropertySheet::StringList::iterator it; + + BOOL b = CDialog::OnInitDialog(); + psheet = reinterpret_cast(GetParent()); - require_quiet( psheet, exit ); - - for ( it = psheet->m_browseDomains.begin(); it != psheet->m_browseDomains.end(); it++ ) - { - CString text = *it; - + require_quiet( psheet, exit ); + + for ( it = psheet->m_browseDomains.begin(); it != psheet->m_browseDomains.end(); it++ ) + { + CString text = *it; + if ( m_comboBox.FindStringExact( -1, *it ) == CB_ERR ) { m_comboBox.AddString( *it ); - } - } - -exit: - - return b; -} - - -void -CAddBrowseDomain::OnOK() -{ - m_comboBox.GetWindowText( m_text ); - - CDialog::OnOK(); -} - - - -BEGIN_MESSAGE_MAP(CAddBrowseDomain, CDialog) -END_MESSAGE_MAP() - + } + } + +exit: + + return b; +} + + +void +CAddBrowseDomain::OnOK() +{ + m_comboBox.GetWindowText( m_text ); + + CDialog::OnOK(); +} + + + +BEGIN_MESSAGE_MAP(CAddBrowseDomain, CDialog) +END_MESSAGE_MAP() +