]> cygwin.com Git - cygwin-apps/setup.git/blob - net.cc
2002-09-21 Robert Collins <rbtcollins@hotmail.com>
[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 extern ThreeBarProgressPage Progress;
37
38 static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
39
40 void
41 NetPage::CheckIfEnableNext ()
42 {
43 int e = 0, p = 0, pu = 0;
44 DWORD ButtonFlags = PSWIZB_BACK;
45
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 }
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);
66 }
67
68 static void
69 load_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);
76 }
77
78 static void
79 save_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);
84 }
85
86 bool
87 NetPage::Create ()
88 {
89 return PropertyPage::Create (IDD_NET);
90 }
91
92 void
93 NetPage::OnInit ()
94 {
95 HWND h = GetHWND ();
96
97 net_method = IDC_NET_DIRECT;
98 load_dialog (h);
99 CheckIfEnableNext();
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
111 long
112 NetPage::OnNext ()
113 {
114 save_dialog (GetHWND ());
115
116 log (LOG_PLAIN, String ("net: ") +
117 ((net_method == IDC_NET_IE5) ? "IE5" :
118 (net_method == IDC_NET_DIRECT) ? "Direct" : "Proxy"));
119
120 Progress.SetActivateTask (WM_APP_START_SITE_INFO_DOWNLOAD);
121 return IDD_INSTATUS;
122 }
123
124 long
125 NetPage::OnUnattended()
126 {
127 return OnNext ();
128 }
129
130 long
131 NetPage::OnBack ()
132 {
133 save_dialog (GetHWND ());
134 return 0;
135 }
136
137 bool
138 NetPage::OnMessageCmd (int id, HWND hwndctl, UINT code)
139 {
140 switch (id)
141 {
142 case IDC_NET_IE5:
143 case IDC_NET_DIRECT:
144 case IDC_NET_PROXY:
145 case IDC_PROXY_HOST:
146 case IDC_PROXY_PORT:
147 save_dialog (GetHWND());
148 CheckIfEnableNext ();
149 break;
150
151 default:
152 // Wasn't recognized or handled.
153 return false;
154 }
155
156 // Was handled since we never got to default above.
157 return true;
158 }
This page took 0.039351 seconds and 5 git commands to generate.