]>
git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSWindows/ControlPanel/SharedSecret.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.
19 // SharedSecret.cpp : implementation file
25 #include "SharedSecret.h"
26 #include <WinServices.h>
28 #include <DebugServices.h>
31 // SharedSecret dialog
33 IMPLEMENT_DYNAMIC(CSharedSecret
, CDialog
)
36 //---------------------------------------------------------------------------------------------------------------------------
37 // CSharedSecret::CSharedSecret
38 //---------------------------------------------------------------------------------------------------------------------------
40 CSharedSecret::CSharedSecret(CWnd
* pParent
/*=NULL*/)
41 : CDialog(CSharedSecret::IDD
, pParent
)
48 //---------------------------------------------------------------------------------------------------------------------------
49 // CSharedSecret::~CSharedSecret
50 //---------------------------------------------------------------------------------------------------------------------------
52 CSharedSecret::~CSharedSecret()
57 //---------------------------------------------------------------------------------------------------------------------------
58 // CSharedSecret::DoDataExchange
59 //---------------------------------------------------------------------------------------------------------------------------
61 void CSharedSecret::DoDataExchange(CDataExchange
* pDX
)
63 CDialog::DoDataExchange(pDX
);
64 DDX_Text(pDX
, IDC_KEY
, m_key
);
65 DDX_Text(pDX
, IDC_SECRET
, m_secret
);
69 BEGIN_MESSAGE_MAP(CSharedSecret
, CDialog
)
73 //---------------------------------------------------------------------------------------------------------------------------
74 // CSharedSecret::Load
75 //---------------------------------------------------------------------------------------------------------------------------
78 CSharedSecret::Load( CString zone
)
81 char outDomain
[ 256 ];
83 char outSecret
[ 256 ];
85 StringObjectToUTF8String( zone
, zoneUTF8
, sizeof( zoneUTF8
) );
87 if ( LsaGetSecret( zoneUTF8
, outDomain
, sizeof( outDomain
) / sizeof( TCHAR
), outKey
, sizeof( outKey
) / sizeof( TCHAR
), outSecret
, sizeof( outSecret
) / sizeof( TCHAR
) ) )
99 //---------------------------------------------------------------------------------------------------------------------------
100 // CSharedSecret::Commit
101 //---------------------------------------------------------------------------------------------------------------------------
104 CSharedSecret::Commit( CString zone
)
106 char zoneUTF8
[ 256 ];
108 char secretUTF8
[ 256 ];
110 StringObjectToUTF8String( zone
, zoneUTF8
, sizeof( zoneUTF8
) );
111 StringObjectToUTF8String( m_key
, keyUTF8
, sizeof( keyUTF8
) );
112 StringObjectToUTF8String( m_secret
, secretUTF8
, sizeof( secretUTF8
) );
114 LsaSetSecret( zoneUTF8
, keyUTF8
, secretUTF8
);