]> cygwin.com Git - cygwin-apps/setup.git/blob - net.cc
2003-10-23 Jerry D. Hedden <jerry@hedden.us>
[cygwin-apps/setup.git] / net.cc
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
19 #if 0
20 static const char *cvsid =
21 "\n%%% $Id$\n";
22 #endif
23
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"
31 #include "log.h"
32
33 #include "net.h"
34 #include "propsheet.h"
35 #include "threebar.h"
36 #include "ConnectionSetting.h"
37 extern ThreeBarProgressPage Progress;
38
39 static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
40 static ConnectionSetting theSetting;
41
42 void
43 NetPage::CheckIfEnableNext ()
44 {
45 int e = 0, p = 0, pu = 0;
46 DWORD ButtonFlags = PSWIZB_BACK;
47
48 if (net_method == IDC_NET_IE5)
49 pu = 1;
50 if (net_method == IDC_NET_IE5 || net_method == IDC_NET_DIRECT)
51 e = 1;
52 else if (net_method == IDC_NET_PROXY)
53 {
54 p = pu = 1;
55 if (net_proxy_host && net_proxy_port)
56 e = 1;
57 }
58 if (e)
59 {
60 // There's something in the proxy and port boxes, enable "Next".
61 ButtonFlags |= PSWIZB_NEXT;
62 }
63
64 GetOwner ()->SetButtons (ButtonFlags);
65
66 EnableWindow (GetDlgItem (IDC_PROXY_HOST), p);
67 EnableWindow (GetDlgItem (IDC_PROXY_PORT), p);
68 }
69
70 static void
71 load_dialog (HWND h)
72 {
73 rbset (h, rb, net_method);
74 eset (h, IDC_PROXY_HOST, net_proxy_host);
75 if (net_proxy_port == 0)
76 net_proxy_port = 80;
77 eset (h, IDC_PROXY_PORT, net_proxy_port);
78 }
79
80 static void
81 save_dialog (HWND h)
82 {
83 net_method = rbget (h, rb);
84 net_proxy_host = eget (h, IDC_PROXY_HOST, net_proxy_host);
85 net_proxy_port = eget (h, IDC_PROXY_PORT);
86 }
87
88 bool
89 NetPage::Create ()
90 {
91 return PropertyPage::Create (IDD_NET);
92 }
93
94 void
95 NetPage::OnInit ()
96 {
97 HWND h = GetHWND ();
98
99 if (!net_method)
100 net_method = IDC_NET_DIRECT;
101 load_dialog (h);
102 CheckIfEnableNext();
103
104 // Check to see if any radio buttons are selected. If not, select a default.
105 if ((!SendMessage (GetDlgItem (IDC_NET_IE5), BM_GETCHECK, 0, 0) ==
106 BST_CHECKED)
107 && (!SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0)
108 == BST_CHECKED))
109 {
110 SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_CLICK, 0, 0);
111 }
112 }
113
114 long
115 NetPage::OnNext ()
116 {
117 save_dialog (GetHWND ());
118
119 log (LOG_PLAIN, String ("net: ") +
120 ((net_method == IDC_NET_IE5) ? "IE5" :
121 (net_method == IDC_NET_DIRECT) ? "Direct" : "Proxy"));
122
123 Progress.SetActivateTask (WM_APP_START_SITE_INFO_DOWNLOAD);
124 return IDD_INSTATUS;
125 }
126
127 long
128 NetPage::OnUnattended()
129 {
130 return OnNext ();
131 }
132
133 long
134 NetPage::OnBack ()
135 {
136 save_dialog (GetHWND ());
137 return 0;
138 }
139
140 bool
141 NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
142 {
143 switch (id)
144 {
145 case IDC_NET_IE5:
146 case IDC_NET_DIRECT:
147 case IDC_NET_PROXY:
148 case IDC_PROXY_HOST:
149 case IDC_PROXY_PORT:
150 save_dialog (GetHWND());
151 CheckIfEnableNext ();
152 break;
153
154 default:
155 // Wasn't recognized or handled.
156 return false;
157 }
158
159 // Was handled since we never got to default above.
160 return true;
161 }
This page took 0.041667 seconds and 5 git commands to generate.