]>
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 | /* This handles the "other URL" option from the mirror site | |
17 | selection. */ | |
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 <shlobj.h> | |
26 | #include <stdio.h> | |
27 | #include <stdlib.h> | |
28 | #include "dialog.h" | |
29 | #include "resource.h" | |
30 | #include "state.h" | |
31 | #include "msg.h" | |
89b1a15b | 32 | #include "log.h" |
de6a1a64 | 33 | #include "site.h" |
23c9e63c | 34 | |
de6a1a64 RC |
35 | static char * other_url = 0; |
36 | ||
23c9e63c DD |
37 | static void |
38 | check_if_enable_next (HWND h) | |
39 | { | |
40 | EnableWindow (GetDlgItem (h, IDOK), other_url ? 1 : 0); | |
41 | } | |
42 | ||
43 | static void | |
44 | load_dialog (HWND h) | |
45 | { | |
46 | eset (h, IDC_OTHER_URL, other_url); | |
47 | check_if_enable_next (h); | |
48 | } | |
49 | ||
50 | static void | |
51 | save_dialog (HWND h) | |
52 | { | |
53 | other_url = eget (h, IDC_OTHER_URL, other_url); | |
de6a1a64 RC |
54 | site_list_type *newsite = new site_list_type (other_url); |
55 | site_list_type &listobj = all_site_list.registerbyobject (*newsite); | |
56 | if (&listobj != newsite) | |
57 | /* That site was already registered */ | |
58 | delete newsite; | |
59 | site_list.registerbyobject (listobj); | |
23c9e63c DD |
60 | } |
61 | ||
62 | static BOOL | |
63 | dialog_cmd (HWND h, int id, HWND hwndctl, UINT code) | |
64 | { | |
65 | switch (id) | |
66 | { | |
67 | ||
68 | case IDC_OTHER_URL: | |
de6a1a64 | 69 | other_url = eget (h, IDC_OTHER_URL, other_url); |
23c9e63c DD |
70 | check_if_enable_next (h); |
71 | break; | |
72 | ||
73 | case IDOK: | |
1fd6d0a2 | 74 | save_dialog (h); |
ed3e8b9b | 75 | save_site_url (); |
1fd6d0a2 | 76 | NEXT (IDD_S_LOAD_INI); |
23c9e63c DD |
77 | break; |
78 | ||
79 | case IDC_BACK: | |
1fd6d0a2 DD |
80 | save_dialog (h); |
81 | NEXT (IDD_SITE); | |
23c9e63c DD |
82 | break; |
83 | ||
84 | case IDCANCEL: | |
1fd6d0a2 | 85 | NEXT (0); |
23c9e63c DD |
86 | break; |
87 | } | |
b24c88b3 | 88 | return 0; |
23c9e63c DD |
89 | } |
90 | ||
91 | static BOOL CALLBACK | |
92 | dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam) | |
93 | { | |
94 | switch (message) | |
95 | { | |
96 | case WM_INITDIALOG: | |
1fd6d0a2 | 97 | load_dialog (h); |
23c9e63c DD |
98 | return FALSE; |
99 | case WM_COMMAND: | |
1fd6d0a2 | 100 | return HANDLE_WM_COMMAND (h, wParam, lParam, dialog_cmd); |
23c9e63c DD |
101 | } |
102 | return FALSE; | |
103 | } | |
104 | ||
105 | void | |
ab57ceaa | 106 | do_other (HINSTANCE h, HWND owner) |
23c9e63c DD |
107 | { |
108 | int rv = 0; | |
ab57ceaa | 109 | rv = DialogBox (h, MAKEINTRESOURCE (IDD_OTHER_URL), owner, dialog_proc); |
23c9e63c | 110 | if (rv == -1) |
ab57ceaa | 111 | fatal (owner, IDS_DIALOG_FAILED); |
89b1a15b DD |
112 | |
113 | log (0, "site: %s", other_url); | |
23c9e63c | 114 | } |