source: win32/PropConn.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// PropConn.cpp : implementation file
2//
3
4#define BITLBEE_CORE
5#include "bitlbeewin.h"
6#include "PropConn.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPropConn dialog
16
17
18CPropConn::CPropConn(CWnd* pParent /*=NULL*/)
19        : CPropertyPage(CPropConn::IDD)
20{
21        //{{AFX_DATA_INIT(CPropConn)
22        //}}AFX_DATA_INIT
23}
24
25
26void CPropConn::DoDataExchange(CDataExchange* pDX)
27{
28        CDialog::DoDataExchange(pDX);
29        //{{AFX_DATA_MAP(CPropConn)
30        DDX_Control(pDX, IDC_PROXYPORT, m_proxyport);
31        DDX_Control(pDX, IDC_PROXYTYPE, m_proxytype);
32        DDX_Control(pDX, IDC_PROXY_ENABLED, m_proxy_enabled);
33        DDX_Control(pDX, IDC_PROXY_AUTH_ENABLED, m_proxy_auth_enabled);
34        DDX_Control(pDX, IDC_PROXYPASS, m_proxypass);
35        DDX_Control(pDX, IDC_PROXYHOST, m_proxyhost);
36        DDX_Control(pDX, IDC_PROXYUSER, m_proxyuser);
37        //}}AFX_DATA_MAP
38}
39
40
41BEGIN_MESSAGE_MAP(CPropConn, CPropertyPage)
42        //{{AFX_MSG_MAP(CPropConn)
43        ON_BN_CLICKED(IDC_PROXY_AUTH_ENABLED, OnProxyAuthEnabled)
44        ON_BN_CLICKED(IDC_PROXY_ENABLED, OnProxyEnabled)
45        //}}AFX_MSG_MAP
46END_MESSAGE_MAP()
47
48/////////////////////////////////////////////////////////////////////////////
49// CPropConn message handlers
50
51void CPropConn::OnProxyAuthEnabled() 
52{
53        m_proxyuser.EnableWindow(m_proxy_enabled.GetCheck() && m_proxy_auth_enabled.GetCheck());
54        m_proxypass.EnableWindow(m_proxy_enabled.GetCheck() && m_proxy_auth_enabled.GetCheck());
55}
56
57void CPropConn::OnProxyEnabled() 
58{
59        // TODO: Add your control notification handler code here
60        m_proxyhost.EnableWindow(m_proxy_enabled.GetCheck());
61        m_proxytype.EnableWindow(m_proxy_enabled.GetCheck());
62        m_proxyport.EnableWindow(m_proxy_enabled.GetCheck());
63        m_proxy_auth_enabled.EnableWindow(m_proxy_enabled.GetCheck());
64
65        if(m_proxy_enabled.GetCheck() && (m_proxytype.GetCurSel() < 0 || m_proxytype.GetCurSel() > 2)) 
66        {
67                m_proxytype.SetCurSel(0);
68        }
69
70        OnProxyAuthEnabled();
71}
72
73void CPropConn::OnOK() 
74{
75        if(!m_proxy_enabled.GetCheck()) {
76                proxytype = PROXY_NONE;
77                return;
78        }
79
80        CString tmp;
81        m_proxyhost.GetWindowText(tmp);
82        strcpy(proxyhost, tmp);
83
84        m_proxyport.GetWindowText(tmp);
85        proxyport = atoi(tmp);
86
87        proxytype = m_proxytype.GetCurSel()+1;
88
89        if(!m_proxy_auth_enabled.GetCheck()) {
90                strcpy(proxyuser, "");
91                strcpy(proxypass, "");
92                return;
93        }
94
95        m_proxyuser.GetWindowText(tmp);
96        strcpy(proxyuser, tmp);
97        m_proxypass.GetWindowText(tmp);
98        strcpy(proxypass, tmp);
99       
100        CPropertyPage::OnOK();
101}
102
103BOOL CPropConn::OnInitDialog() 
104{
105        char pp[20];
106        CPropertyPage::OnInitDialog();
107
108        m_proxyhost.SetWindowText(proxyhost);
109        m_proxyuser.SetWindowText(proxyuser);
110        m_proxypass.SetWindowText(proxypass);
111        g_snprintf(pp, 20, "%d", proxyport);
112        m_proxyport.SetWindowText(pp);
113
114        m_proxytype.AddString("SOCKS 4");
115        m_proxytype.AddString("SOCKS 5");
116        m_proxytype.AddString("HTTP");
117        m_proxytype.SetCurSel(proxytype-1);
118
119        m_proxy_enabled.SetCheck(proxytype == PROXY_NONE?0:1); 
120        m_proxy_auth_enabled.SetCheck(strcmp(proxyuser, "")?1:0);
121
122        OnProxyEnabled();
123       
124        return TRUE; 
125}
Note: See TracBrowser for help on using the repository browser.