<rdar://problem/7252936> Add a new Services tab to control panel that lets you enable...
authorsherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Mon, 28 Sep 2009 20:13:31 +0000 (20:13 +0000)
committersherscher@apple.com <sherscher@apple.com@214c2c4a-bf3b-4dcf-9390-e4dd3010487d>
Mon, 28 Sep 2009 20:13:31 +0000 (20:13 +0000)
git-svn-id: http://svn.macosforge.org/repository/mDNSResponder/trunk@6707 214c2c4a-bf3b-4dcf-9390-e4dd3010487d

mDNSWindows/ControlPanel/ConfigPropertySheet.cpp
mDNSWindows/ControlPanel/ConfigPropertySheet.h
mDNSWindows/ControlPanel/ControlPanel.rc
mDNSWindows/ControlPanel/ControlPanel.vcproj
mDNSWindows/ControlPanel/ControlPanelExe.vcproj
mDNSWindows/ControlPanel/FifthPage.cpp [new file with mode: 0755]
mDNSWindows/ControlPanel/FifthPage.h [new file with mode: 0755]
mDNSWindows/ControlPanel/resource.h

index 81ea8f3..e6e091c 100755 (executable)
@@ -43,6 +43,7 @@ CConfigPropertySheet::CConfigPropertySheet()
        AddPage(&m_firstPage);
        AddPage(&m_secondPage);
        AddPage(&m_thirdPage);
+       AddPage(&m_fifthPage );
        AddPage(&m_fourthPage );
 
        InitializeCriticalSection( &m_lock );
index 6b327af..e7d5ecb 100755 (executable)
@@ -23,6 +23,7 @@
 #include "SecondPage.h"
 #include "ThirdPage.h"
 #include "FourthPage.h"
+#include "FifthPage.h"
 
 #include <RegNames.h>
 #include <dns_sd.h>
@@ -51,6 +52,7 @@ protected:
        CSecondPage     m_secondPage;
        CThirdPage m_thirdPage;
        CFourthPage m_fourthPage;
+       CFifthPage m_fifthPage;
 
        //{{AFX_VIRTUAL(CConfigPropertySheet)
        //}}AFX_VIRTUAL
index 035b0d1..0508e87 100644 (file)
@@ -146,6 +146,15 @@ BEGIN
     LTEXT           "Warning: Allowing Bonjour to bring the computer out of standby may cause this computer to periodically wakeup to refresh its network state.",IDC_STATIC,13,41,227,20
 END
 
+IDR_APPLET_PAGE5 DIALOGEX 0, 0, 262, 140
+STYLE DS_SETFONT | WS_CHILD | WS_CAPTION
+CAPTION "Services"
+FONT 8, "MS Sans Serif", 0, 0, 0x0
+BEGIN
+    CONTROL         "Advertise shared folders and printers using Bonjour.",IDC_ADVERTISE_SMB,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,19,199,8
+END
+
 IDR_ADD_BROWSE_DOMAIN DIALOGEX 0, 0, 230, 95
 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | 
     WS_SYSMENU
index ffdb6ff..4902532 100755 (executable)
                                RelativePath="ControlPanel.def"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\FifthPage.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="FirstPage.cpp"\r
                                >\r
                                RelativePath="ControlPanel.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\FifthPage.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="FirstPage.h"\r
                                >\r
index c97f430..8bc0b29 100755 (executable)
                                RelativePath=".\ControlPanelExe.cpp"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\FifthPage.cpp"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="FirstPage.cpp"\r
                                >\r
                                RelativePath=".\ControlPanelExe.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\FifthPage.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="FirstPage.h"\r
                                >\r
diff --git a/mDNSWindows/ControlPanel/FifthPage.cpp b/mDNSWindows/ControlPanel/FifthPage.cpp
new file mode 100755 (executable)
index 0000000..4d4d123
--- /dev/null
@@ -0,0 +1,179 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+ */
+
+#include "FifthPage.h"
+#include "resource.h"
+
+#include "ConfigPropertySheet.h"
+#include "SharedSecret.h"
+
+#include <WinServices.h>
+    
+#define MAX_KEY_LENGTH 255
+
+
+IMPLEMENT_DYNCREATE(CFifthPage, CPropertyPage)
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::CFifthPage
+//---------------------------------------------------------------------------------------------------------------------------
+
+CFifthPage::CFifthPage()
+:
+       CPropertyPage(CFifthPage::IDD)
+{
+       //{{AFX_DATA_INIT(CFifthPage)
+       //}}AFX_DATA_INIT
+}
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::~CFifthPage
+//---------------------------------------------------------------------------------------------------------------------------
+
+CFifthPage::~CFifthPage()
+{
+}
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::DoDataExchange
+//---------------------------------------------------------------------------------------------------------------------------
+
+void CFifthPage::DoDataExchange(CDataExchange* pDX)
+{
+       CPropertyPage::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CFifthPage)
+       //}}AFX_DATA_MAP
+       DDX_Control(pDX, IDC_ADVERTISE_SMB, m_checkBox);
+}
+
+BEGIN_MESSAGE_MAP(CFifthPage, CPropertyPage)
+       //{{AFX_MSG_MAP(CFifthPage)
+       //}}AFX_MSG_MAP
+
+       ON_BN_CLICKED(IDC_ADVERTISE_SMB, &CFifthPage::OnBnClickedAdvertiseSMB)
+
+END_MESSAGE_MAP()
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::SetModified
+//---------------------------------------------------------------------------------------------------------------------------
+
+void CFifthPage::SetModified( BOOL bChanged )
+{
+       m_modified = bChanged;
+
+       CPropertyPage::SetModified( bChanged );
+}
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::OnSetActive
+//---------------------------------------------------------------------------------------------------------------------------
+
+BOOL
+CFifthPage::OnSetActive()
+{
+       CConfigPropertySheet    *       psheet;
+       HKEY                                            key = NULL;
+       DWORD                                           dwSize;
+       DWORD                                           enabled;
+       DWORD                                           err;
+       BOOL                                            b = CPropertyPage::OnSetActive();
+
+       psheet = reinterpret_cast<CConfigPropertySheet*>(GetParent());
+       require_quiet( psheet, exit );
+
+       m_checkBox.SetCheck( 0 );
+
+       // Now populate the browse domain box
+
+       err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\Services\\SMB", &key );
+       require_noerr( err, exit );
+
+       dwSize = sizeof( DWORD );
+       err = RegQueryValueEx( key, L"Advertise", NULL, NULL, (LPBYTE) &enabled, &dwSize );
+       require_noerr( err, exit );
+
+       m_checkBox.SetCheck( enabled );
+exit:
+
+       if ( key )
+       {
+               RegCloseKey( key );
+       }
+
+       return b;
+}
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::OnOK
+//---------------------------------------------------------------------------------------------------------------------------
+
+void
+CFifthPage::OnOK()
+{
+       if ( m_modified )
+       {
+               Commit();
+       }
+}
+
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::Commit
+//---------------------------------------------------------------------------------------------------------------------------
+
+void
+CFifthPage::Commit()
+{
+       HKEY            key             = NULL;
+       DWORD           enabled;
+       DWORD           err;
+
+       err = RegCreateKey( HKEY_LOCAL_MACHINE, kServiceParametersNode L"\\Services\\SMB", &key );
+       require_noerr( err, exit );
+
+       enabled = m_checkBox.GetCheck();
+       err = RegSetValueEx( key, L"Advertise", NULL, REG_DWORD, (LPBYTE) &enabled, sizeof( enabled ) );
+       require_noerr( err, exit );
+       
+exit:
+
+       if ( key )
+       {
+               RegCloseKey( key );
+       }
+}
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage::OnBnClickedRemoveBrowseDomain
+//---------------------------------------------------------------------------------------------------------------------------
+
+
+void CFifthPage::OnBnClickedAdvertiseSMB()
+{
+       SetModified( TRUE );
+}
+
diff --git a/mDNSWindows/ControlPanel/FifthPage.h b/mDNSWindows/ControlPanel/FifthPage.h
new file mode 100755 (executable)
index 0000000..ce8f489
--- /dev/null
@@ -0,0 +1,87 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
+ *
+ * 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
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * 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.
+ */
+
+#pragma once
+
+#include "stdafx.h"
+#include "resource.h"
+
+#include <DebugServices.h>
+#include <list>
+#include "afxcmn.h"
+
+#include "afxwin.h"
+
+
+
+
+
+//---------------------------------------------------------------------------------------------------------------------------
+//     CFifthPage
+//---------------------------------------------------------------------------------------------------------------------------
+
+class CFifthPage : public CPropertyPage
+{
+public:
+       CFifthPage();
+       ~CFifthPage();
+
+protected:
+
+       //{{AFX_DATA(CFifthPage)
+       enum { IDD = IDR_APPLET_PAGE5 };
+       //}}AFX_DATA
+
+       //{{AFX_VIRTUAL(CFifthPage)
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+       DECLARE_DYNCREATE(CFifthPage)
+
+       //{{AFX_MSG(CFifthPage)
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+       
+private:
+       
+       typedef std::list<CString> StringList;
+
+       afx_msg BOOL
+       OnSetActive();
+       
+       afx_msg void
+       OnOK();
+       
+       void
+       SetModified( BOOL bChanged = TRUE );
+       
+       void
+       Commit();
+
+       BOOL                    m_modified;
+
+public:
+private:
+
+       CButton m_checkBox;
+
+public:
+
+
+       afx_msg void OnBnClickedAdvertiseSMB();
+
+};
index e82d604..f0b01e9 100644 (file)
@@ -9,6 +9,7 @@
 #define IDR_SECRET                      133
 #define IDR_APPLET_PAGE3                134
 #define IDR_APPLET_PAGE4                135
+#define IDR_APPLET_PAGE5                136
 #define IDI_FAILURE                     140
 #define IDI_SUCCESS                     141
 #define IDD_ADD_BROWSE_DOMAIN           142
@@ -32,6 +33,7 @@
 #define IDC_REMOVE_BROWSE_DOMAIN        1012
 #define IDC_ADD_BROWSE_DOMAIN           1013
 #define IDC_POWER_MANAGEMENT            1014
+#define IDC_ADVERTISE_SMB                  1015
 
 // Next default values for new objects
 // 
@@ -39,7 +41,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        143
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1015
+#define _APS_NEXT_CONTROL_VALUE         1016
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif