source: win32/PropAccess.cpp @ d1d6776

Last change on this file since d1d6776 was d1d6776, checked in by Jelmer Vernooij <jelmer@…>, at 2005-11-07T16:20:37Z

Import win32 branch

  • Property mode set to 100644
File size: 3.1 KB
Line 
1// PropAccess.cpp : implementation file
2//
3
4#define BITLBEE_CORE
5#include "bitlbeewin.h"
6#include "PropAccess.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPropAccess dialog
16
17
18CPropAccess::CPropAccess()
19        : CPropertyPage(CPropAccess::IDD)
20{
21
22        //{{AFX_DATA_INIT(CPropAccess)
23        //}}AFX_DATA_INIT
24}
25
26
27void CPropAccess::DoDataExchange(CDataExchange* pDX)
28{
29        CDialog::DoDataExchange(pDX);
30        //{{AFX_DATA_MAP(CPropAccess)
31        DDX_Control(pDX, IDC_AUTH_REGISTERED, m_auth_registered);
32        DDX_Control(pDX, IDC_AUTH_OPEN, m_auth_open);
33        DDX_Control(pDX, IDC_AUTH_CLOSED, m_auth_closed);
34        DDX_Control(pDX, IDC_PASSWORD, m_password);
35        DDX_Control(pDX, IDC_PORT, m_port);
36        DDX_Control(pDX, IDC_INTERFACE, m_interface);
37        //}}AFX_DATA_MAP
38}
39
40
41BEGIN_MESSAGE_MAP(CPropAccess, CPropertyPage)
42        //{{AFX_MSG_MAP(CPropAccess)
43        ON_BN_CLICKED(IDC_AUTH_REGISTERED, OnAuthRegistered)
44        ON_BN_CLICKED(IDC_AUTH_OPEN, OnAuthOpen)
45        ON_BN_CLICKED(IDC_AUTH_CLOSED, OnAuthClosed)
46        //}}AFX_MSG_MAP
47END_MESSAGE_MAP()
48
49/////////////////////////////////////////////////////////////////////////////
50// CPropAccess message handlers
51
52void CPropAccess::OnOK() 
53{
54        CString iface; m_interface.GetWindowText(iface);
55        CString port; m_port.GetWindowText(port);
56
57        CString password; m_password.GetWindowText(password);
58        g_free((void *)global.conf->password);
59        global.conf->password = g_strdup(password);
60
61        if(m_auth_closed.GetCheck() == 1) global.conf->authmode = AUTHMODE_CLOSED;
62        if(m_auth_open.GetCheck() == 1) global.conf->authmode = AUTHMODE_OPEN;
63        if(m_auth_registered.GetCheck() == 1) global.conf->authmode = AUTHMODE_REGISTERED;
64
65        if(strcmp(iface, global.conf->iface) || atol(port) != global.conf->port) {
66                global.conf->port = atoi(port);
67                g_free((void *)global.conf->iface);
68                global.conf->iface = g_strdup(iface);
69                closesocket(global.listen_socket);
70                bitlbee_daemon_init();
71        }
72
73       
74        CPropertyPage::OnOK();
75}
76
77void CPropAccess::OnAuthRegistered() 
78{
79        m_password.EnableWindow(FALSE);
80        m_auth_open.SetCheck(0);
81        m_auth_registered.SetCheck(1);
82        m_auth_closed.SetCheck(0);
83       
84}
85
86void CPropAccess::OnAuthOpen() 
87{
88        m_password.EnableWindow(FALSE);
89        m_auth_open.SetCheck(1);
90        m_auth_registered.SetCheck(0);
91        m_auth_closed.SetCheck(0);
92}
93
94void CPropAccess::OnAuthClosed() 
95{
96        m_password.EnableWindow(TRUE);
97        m_auth_open.SetCheck(0);
98        m_auth_registered.SetCheck(0);
99        m_auth_closed.SetCheck(1);
100       
101}
102
103BOOL CPropAccess::OnInitDialog() 
104{
105        CPropertyPage::OnInitDialog();
106
107        m_interface.SetWindowText(global.conf->iface);
108        m_password.SetWindowText(global.conf->password);
109        char tmp[20];
110        g_snprintf(tmp, sizeof(tmp), "%d", global.conf->port);
111        m_port.SetWindowText(tmp);
112        m_auth_open.SetCheck(0);
113        m_auth_closed.SetCheck(0);
114        m_auth_registered.SetCheck(0);
115
116        switch(global.conf->authmode) {
117        case AUTHMODE_OPEN: m_auth_open.SetCheck(1); m_password.EnableWindow(FALSE);break;
118        case AUTHMODE_CLOSED: m_auth_closed.SetCheck(1); m_password.EnableWindow(TRUE);break;
119        case AUTHMODE_REGISTERED: m_auth_registered.SetCheck(1);m_password.EnableWindow(FALSE);break;
120        }
121       
122        return TRUE;
123}
Note: See TracBrowser for help on using the repository browser.