1 | // PropAccess.cpp : implementation file |
---|
2 | // |
---|
3 | |
---|
4 | #include "PropAccess.h" |
---|
5 | |
---|
6 | #ifdef _DEBUG |
---|
7 | #define new DEBUG_NEW |
---|
8 | #undef THIS_FILE |
---|
9 | static char THIS_FILE[] = __FILE__; |
---|
10 | #endif |
---|
11 | |
---|
12 | ///////////////////////////////////////////////////////////////////////////// |
---|
13 | // CPropAccess dialog |
---|
14 | |
---|
15 | |
---|
16 | CPropAccess::CPropAccess() |
---|
17 | : CPropertyPage(CPropAccess::IDD) |
---|
18 | { |
---|
19 | |
---|
20 | //{{AFX_DATA_INIT(CPropAccess) |
---|
21 | //}}AFX_DATA_INIT |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | void CPropAccess::DoDataExchange(CDataExchange* pDX) |
---|
26 | { |
---|
27 | CDialog::DoDataExchange(pDX); |
---|
28 | //{{AFX_DATA_MAP(CPropAccess) |
---|
29 | DDX_Control(pDX, IDC_AUTH_REGISTERED, m_auth_registered); |
---|
30 | DDX_Control(pDX, IDC_AUTH_OPEN, m_auth_open); |
---|
31 | DDX_Control(pDX, IDC_AUTH_CLOSED, m_auth_closed); |
---|
32 | DDX_Control(pDX, IDC_PASSWORD, m_password); |
---|
33 | DDX_Control(pDX, IDC_PORT, m_port); |
---|
34 | DDX_Control(pDX, IDC_INTERFACE, m_interface); |
---|
35 | //}}AFX_DATA_MAP |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | BEGIN_MESSAGE_MAP(CPropAccess, CPropertyPage) |
---|
40 | //{{AFX_MSG_MAP(CPropAccess) |
---|
41 | ON_BN_CLICKED(IDC_AUTH_REGISTERED, OnAuthRegistered) |
---|
42 | ON_BN_CLICKED(IDC_AUTH_OPEN, OnAuthOpen) |
---|
43 | ON_BN_CLICKED(IDC_AUTH_CLOSED, OnAuthClosed) |
---|
44 | //}}AFX_MSG_MAP |
---|
45 | END_MESSAGE_MAP() |
---|
46 | |
---|
47 | ///////////////////////////////////////////////////////////////////////////// |
---|
48 | // CPropAccess message handlers |
---|
49 | |
---|
50 | void CPropAccess::OnOK() |
---|
51 | { |
---|
52 | CString iface; m_interface.GetWindowText(iface); |
---|
53 | WriteProfileString("interface", iface); |
---|
54 | |
---|
55 | CString port; m_port.GetWindowText(port); |
---|
56 | WriteProfileInt("port", port); |
---|
57 | |
---|
58 | CString password; m_password.GetWindowText(password); |
---|
59 | WriteProfileString("password", password); |
---|
60 | |
---|
61 | if(m_auth_closed.GetCheck() == 1) WriteProfileInt("auth_mode", 1); |
---|
62 | if(m_auth_open.GetCheck() == 1) WriteProfileInt("auth_mode", 0); |
---|
63 | if(m_auth_registered.GetCheck() == 1) WriteProfileInt("auth_mode", 2); |
---|
64 | |
---|
65 | CPropertyPage::OnOK(); |
---|
66 | } |
---|
67 | |
---|
68 | void CPropAccess::OnAuthRegistered() |
---|
69 | { |
---|
70 | m_password.EnableWindow(FALSE); |
---|
71 | m_auth_open.SetCheck(0); |
---|
72 | m_auth_registered.SetCheck(1); |
---|
73 | m_auth_closed.SetCheck(0); |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | void CPropAccess::OnAuthOpen() |
---|
78 | { |
---|
79 | m_password.EnableWindow(FALSE); |
---|
80 | m_auth_open.SetCheck(1); |
---|
81 | m_auth_registered.SetCheck(0); |
---|
82 | m_auth_closed.SetCheck(0); |
---|
83 | } |
---|
84 | |
---|
85 | void CPropAccess::OnAuthClosed() |
---|
86 | { |
---|
87 | m_password.EnableWindow(TRUE); |
---|
88 | m_auth_open.SetCheck(0); |
---|
89 | m_auth_registered.SetCheck(0); |
---|
90 | m_auth_closed.SetCheck(1); |
---|
91 | |
---|
92 | } |
---|
93 | |
---|
94 | BOOL CPropAccess::OnInitDialog() |
---|
95 | { |
---|
96 | CPropertyPage::OnInitDialog(); |
---|
97 | |
---|
98 | HKEY key; |
---|
99 | RegOpenKey(HKEY_LOCAL_MACHINE, BITLBEE_KEY, &key); |
---|
100 | |
---|
101 | m_interface.SetWindowText(GetProfileString("interface", "0.0.0.0")); |
---|
102 | m_password.SetWindowText(GetProfileString("password", "")); |
---|
103 | char tmp[20]; |
---|
104 | sprintf(tmp, "%d", GetProfileInt("port", 6667)); |
---|
105 | m_port.SetWindowText(tmp); |
---|
106 | |
---|
107 | switch(GetProfileInt("auth_mode", 1)) { |
---|
108 | case 0: OnAuthOpen();break; |
---|
109 | case 1: OnAuthClosed();break; |
---|
110 | case 2: OnAuthRegistered();break; |
---|
111 | } |
---|
112 | |
---|
113 | return TRUE; |
---|
114 | } |
---|