]> cygwin.com Git - cygwin-apps/setup.git/blame - net.cc
2001-01-04 Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
[cygwin-apps/setup.git] / net.cc
CommitLineData
23c9e63c
DD
1/*
2 * Copyright (c) 2000, Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16/* The purpose of this file is to get the network configuration
17 information from the user. */
18
b24c88b3
RC
19#if 0
20static const char *cvsid =
21 "\n%%% $Id$\n";
22#endif
8507f105 23
23c9e63c
DD
24#include "win32.h"
25#include <stdio.h>
26#include <stdlib.h>
27#include "dialog.h"
28#include "resource.h"
29#include "state.h"
30#include "msg.h"
89b1a15b 31#include "log.h"
23c9e63c 32
ab57ceaa 33#include "net.h"
b7301c43 34#include "propsheet.h"
ab57ceaa
RC
35#include "threebar.h"
36extern ThreeBarProgressPage Progress;
37
23c9e63c
DD
38static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
39
b7301c43
RC
40void
41NetPage::CheckIfEnableNext ()
23c9e63c
DD
42{
43 int e = 0, p = 0, pu = 0;
b7301c43
RC
44 DWORD ButtonFlags = PSWIZB_BACK;
45
23c9e63c
DD
46 if (net_method == IDC_NET_IE5)
47 pu = 1;
48 if (net_method == IDC_NET_IE5 || net_method == IDC_NET_DIRECT)
49 e = 1;
50 else if (net_method == IDC_NET_PROXY)
51 {
52 p = pu = 1;
53 if (net_proxy_host && net_proxy_port)
54 e = 1;
55 }
b7301c43
RC
56 if (e)
57 {
58 // There's something in the proxy and port boxes, enable "Next".
59 ButtonFlags |= PSWIZB_NEXT;
60 }
61
62 GetOwner ()->SetButtons (ButtonFlags);
63
64 EnableWindow (GetDlgItem (IDC_PROXY_HOST), p);
65 EnableWindow (GetDlgItem (IDC_PROXY_PORT), p);
23c9e63c
DD
66}
67
68static void
69load_dialog (HWND h)
70{
71 rbset (h, rb, net_method);
72 eset (h, IDC_PROXY_HOST, net_proxy_host);
73 if (net_proxy_port == 0)
74 net_proxy_port = 80;
75 eset (h, IDC_PROXY_PORT, net_proxy_port);
23c9e63c
DD
76}
77
78static void
79save_dialog (HWND h)
80{
81 net_method = rbget (h, rb);
82 net_proxy_host = eget (h, IDC_PROXY_HOST, net_proxy_host);
83 net_proxy_port = eget (h, IDC_PROXY_PORT);
23c9e63c
DD
84}
85
ab57ceaa
RC
86bool
87NetPage::Create ()
23c9e63c 88{
b7301c43 89 return PropertyPage::Create (IDD_NET);
23c9e63c
DD
90}
91
92void
ab57ceaa 93NetPage::OnInit ()
23c9e63c 94{
ab57ceaa 95 HWND h = GetHWND ();
b5b282c4 96
8293fc16 97 net_method = IDC_NET_DIRECT;
ab57ceaa 98 load_dialog (h);
b7301c43 99 CheckIfEnableNext();
ab57ceaa
RC
100
101 // Check to see if any radio buttons are selected. If not, select a default.
102 if ((!SendMessage (GetDlgItem (IDC_NET_IE5), BM_GETCHECK, 0, 0) ==
103 BST_CHECKED)
104 && (!SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0)
105 == BST_CHECKED))
106 {
107 SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_CLICK, 0, 0);
108 }
109}
110
111long
112NetPage::OnNext ()
113{
114 save_dialog (GetHWND ());
89b1a15b
DD
115
116 log (0, "net: %s",
117 (net_method == IDC_NET_IE5) ? "IE5" :
118 (net_method == IDC_NET_DIRECT) ? "Direct" : "Proxy");
ab57ceaa
RC
119
120 Progress.SetActivateTask (WM_APP_START_SITE_INFO_DOWNLOAD);
121 return IDD_INSTATUS;
122}
123
124long
125NetPage::OnBack ()
126{
127 save_dialog (GetHWND ());
128 return 0;
23c9e63c 129}
b7301c43
RC
130
131bool
132NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
133{
134 switch (id)
135 {
136 case IDC_NET_IE5:
137 case IDC_NET_DIRECT:
138 case IDC_NET_PROXY:
139 case IDC_PROXY_HOST:
140 case IDC_PROXY_PORT:
141 save_dialog (GetHWND());
142 CheckIfEnableNext ();
143 break;
144
145 default:
146 // Wasn't recognized or handled.
147 return false;
148 }
149
150 // Was handled since we never got to default above.
151 return true;
152}
This page took 0.044799 seconds and 5 git commands to generate.