comparison netinstall/net.cc @ 448:3078fd1074e8 r21-2-39

Import from CVS: tag r21-2-39
author cvs
date Mon, 13 Aug 2007 11:38:25 +0200
parents
children 685b588e92d8
comparison
equal deleted inserted replaced
447:4fc5f13f3bd3 448:3078fd1074e8
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 #include "win32.h"
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include "dialog.h"
23 #include "resource.h"
24 #include "state.h"
25 #include "msg.h"
26 #include "log.h"
27
28 static int rb[] = { IDC_NET_IE5, IDC_NET_DIRECT, IDC_NET_PROXY, 0 };
29
30 static void
31 check_if_enable_next (HWND h)
32 {
33 int e = 0, p = 0, pu = 0;
34 if (net_method == IDC_NET_IE5)
35 pu = 1;
36 if (net_method == IDC_NET_IE5 || net_method == IDC_NET_DIRECT)
37 e = 1;
38 else if (net_method == IDC_NET_PROXY)
39 {
40 p = pu = 1;
41 if (net_proxy_host && net_proxy_port)
42 e = 1;
43 }
44 EnableWindow (GetDlgItem (h, IDOK), e);
45 EnableWindow (GetDlgItem (h, IDC_PROXY_HOST), p);
46 EnableWindow (GetDlgItem (h, IDC_PROXY_PORT), p);
47 }
48
49 static void
50 load_dialog (HWND h)
51 {
52 rbset (h, rb, net_method);
53 eset (h, IDC_PROXY_HOST, net_proxy_host);
54 if (net_proxy_port == 0)
55 net_proxy_port = 80;
56 eset (h, IDC_PROXY_PORT, net_proxy_port);
57 check_if_enable_next (h);
58 }
59
60 static void
61 save_dialog (HWND h)
62 {
63 net_method = rbget (h, rb);
64 net_proxy_host = eget (h, IDC_PROXY_HOST, net_proxy_host);
65 net_proxy_port = eget (h, IDC_PROXY_PORT);
66 }
67
68 static BOOL
69 dialog_cmd (HWND h, int id, HWND hwndctl, UINT code)
70 {
71 switch (id)
72 {
73
74 case IDC_NET_IE5:
75 case IDC_NET_DIRECT:
76 case IDC_NET_PROXY:
77 case IDC_PROXY_HOST:
78 case IDC_PROXY_PORT:
79 save_dialog (h);
80 check_if_enable_next (h);
81 break;
82
83 case IDOK:
84 save_dialog (h);
85 switch (source)
86 {
87 case IDC_SOURCE_NETINST:
88 case IDC_SOURCE_DOWNLOAD:
89 NEXT (IDD_SITE);
90 break;
91 case IDC_SOURCE_CWD:
92 NEXT (0);
93 break;
94 default:
95 msg ("source is default? %d\n", source);
96 NEXT (0);
97 }
98 break;
99
100 case IDC_BACK:
101 save_dialog (h);
102 switch (source)
103 {
104 case IDC_SOURCE_DOWNLOAD:
105 NEXT (IDD_LOCAL_DIR);
106 break;
107 case IDC_SOURCE_NETINST:
108 case IDC_SOURCE_CWD:
109 NEXT (IDD_ROOT);
110 break;
111 }
112 break;
113
114 case IDCANCEL:
115 NEXT (0);
116 break;
117 }
118 return FALSE;
119 }
120
121 static BOOL CALLBACK
122 dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
123 {
124 switch (message)
125 {
126 case WM_INITDIALOG:
127 load_dialog (h);
128 return FALSE;
129 case WM_COMMAND:
130 return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd);
131 }
132 return FALSE;
133 }
134
135 void
136 do_net (HINSTANCE h)
137 {
138 int rv = 0;
139
140 rv = DialogBox (h, MAKEINTRESOURCE (IDD_NET), 0, dialog_proc);
141 if (rv == -1)
142 fatal (IDS_DIALOG_FAILED);
143
144 log (0, "net: %s",
145 (net_method == IDC_NET_IE5) ? "IE5" :
146 (net_method == IDC_NET_DIRECT) ? "Direct" : "Proxy");
147 }
148