]>
Commit | Line | Data |
---|---|---|
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 |
20 | static 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" |
36 | extern ThreeBarProgressPage Progress; | |
37 | ||
23c9e63c DD |
38 | static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 }; |
39 | ||
b7301c43 RC |
40 | void |
41 | NetPage::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 | ||
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); | |
23c9e63c DD |
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); | |
23c9e63c DD |
84 | } |
85 | ||
ab57ceaa RC |
86 | bool |
87 | NetPage::Create () | |
23c9e63c | 88 | { |
b7301c43 | 89 | return PropertyPage::Create (IDD_NET); |
23c9e63c DD |
90 | } |
91 | ||
92 | void | |
ab57ceaa | 93 | NetPage::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 | ||
111 | long | |
112 | NetPage::OnNext () | |
113 | { | |
114 | save_dialog (GetHWND ()); | |
89b1a15b | 115 | |
1ac649ed RC |
116 | log (LOG_PLAIN, String ("net: ") + |
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 | ||
f2ff9838 RC |
124 | long |
125 | NetPage::OnUnattended() | |
126 | { | |
127 | return OnNext (); | |
128 | } | |
129 | ||
ab57ceaa RC |
130 | long |
131 | NetPage::OnBack () | |
132 | { | |
133 | save_dialog (GetHWND ()); | |
134 | return 0; | |
23c9e63c | 135 | } |
b7301c43 RC |
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 | } |