Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / set_dump.cpp
blob8f335b404950b9851add458e1f1f766ac7069276
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
18 #include "svrmgr.h"
19 #include "set_dump.h"
20 #include "columns.h"
21 #include "svr_window.h"
22 #include "display.h"
26 * PROTOTYPES _________________________________________________________________
30 BOOL CALLBACK Filesets_Dump_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
31 void Filesets_Dump_OnInitDialog (HWND hDlg, LPSET_DUMP_PARAMS psdp);
32 void Filesets_Dump_OnSelect (HWND hDlg);
33 void Filesets_Dump_EnableOK (HWND hDlg);
34 void Filesets_Dump_OnOK (HWND hDlg, LPSET_DUMP_PARAMS psdp);
35 void Filesets_Dump_OnBrowse (HWND hDlg, LPSET_DUMP_PARAMS psdp);
39 * ROUTINES ___________________________________________________________________
43 void Filesets_Dump (LPIDENT lpi)
45 LPSET_DUMP_PARAMS psdp = New (SET_DUMP_PARAMS);
46 memset (psdp, 0x00, sizeof(SET_DUMP_PARAMS));
47 psdp->lpi = lpi;
49 INT_PTR rc = ModalDialogParam (IDD_SET_DUMP, NULL, (DLGPROC)Filesets_Dump_DlgProc, (LPARAM)psdp);
51 if (rc != IDOK)
53 Delete (psdp);
55 else
57 StartTask (taskSET_DUMP, NULL, psdp);
62 BOOL CALLBACK Filesets_Dump_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
64 if (AfsAppLib_HandleHelp (IDD_SET_DUMP, hDlg, msg, wp, lp))
65 return TRUE;
67 static LPSET_DUMP_PARAMS psdp = NULL;
68 if (msg == WM_INITDIALOG)
69 psdp = (LPSET_DUMP_PARAMS)lp;
71 if (psdp != NULL)
73 switch (msg)
75 case WM_INITDIALOG:
76 Filesets_Dump_OnInitDialog (hDlg, psdp);
77 break;
79 case WM_COMMAND:
80 switch (LOWORD(wp))
82 case IDOK:
83 Filesets_Dump_OnOK (hDlg, psdp);
84 EndDialog (hDlg, LOWORD(wp));
85 break;
87 case IDCANCEL:
88 EndDialog (hDlg, LOWORD(wp));
89 break;
91 case IDC_DUMP_FULL:
92 case IDC_DUMP_LIMIT_TIME:
93 Filesets_Dump_OnSelect (hDlg);
94 break;
96 case IDC_DUMP_FILENAME:
97 Filesets_Dump_EnableOK (hDlg);
98 break;
100 case IDC_DUMP_BROWSE:
101 Filesets_Dump_OnBrowse (hDlg, psdp);
102 break;
104 break;
106 case WM_DESTROY:
107 psdp = NULL;
108 break;
112 return FALSE;
116 void Filesets_Dump_OnInitDialog (HWND hDlg, LPSET_DUMP_PARAMS psdp)
118 TCHAR szServer[ cchNAME ];
119 TCHAR szAggregate[ cchNAME ];
120 TCHAR szFileset[ cchNAME ];
121 psdp->lpi->GetServerName (szServer);
122 psdp->lpi->GetAggregateName (szAggregate);
123 psdp->lpi->GetFilesetName (szFileset);
125 TCHAR szText[ cchRESOURCE ];
126 GetDlgItemText (hDlg, IDC_DUMP_FULL, szText, cchRESOURCE);
128 LPTSTR pszText = FormatString (szText, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
129 SetDlgItemText (hDlg, IDC_DUMP_FULL, pszText);
130 FreeString (pszText);
132 pszText = FormatString (IDS_SET_DUMP_NAME, TEXT("%s"), szFileset);
133 SetDlgItemText (hDlg, IDC_DUMP_FILENAME, pszText);
134 FreeString (pszText);
136 // Get the local system time
137 SYSTEMTIME st;
138 GetSystemTime (&st);
139 FILETIME ft;
140 SystemTimeToFileTime (&st, &ft);
141 FILETIME lft;
142 FileTimeToLocalFileTime (&ft, &lft);
143 FileTimeToSystemTime (&lft, &st);
145 DA_SetDate (GetDlgItem (hDlg, IDC_DUMP_DATE), &st);
146 TI_SetTime (GetDlgItem (hDlg, IDC_DUMP_TIME), &st);
148 CheckDlgButton (hDlg, IDC_DUMP_FULL, TRUE);
149 Filesets_Dump_OnSelect (hDlg);
150 Filesets_Dump_EnableOK (hDlg);
154 void Filesets_Dump_OnSelect (HWND hDlg)
156 BOOL fEnable;
158 fEnable = IsDlgButtonChecked (hDlg, IDC_DUMP_LIMIT_TIME);
159 EnableWindow (GetDlgItem (hDlg, IDC_DUMP_DATE), fEnable);
160 EnableWindow (GetDlgItem (hDlg, IDC_DUMP_TIME), fEnable);
164 void Filesets_Dump_EnableOK (HWND hDlg)
166 TCHAR szText[ MAX_PATH ];
167 GetDlgItemText (hDlg, IDC_DUMP_FILENAME, szText, MAX_PATH);
169 EnableWindow (GetDlgItem (hDlg, IDOK), (szText[0] == TEXT('\0')) ? FALSE : TRUE);
173 void Filesets_Dump_OnOK (HWND hDlg, LPSET_DUMP_PARAMS psdp)
175 GetDlgItemText (hDlg, IDC_DUMP_FILENAME, psdp->szFilename, MAX_PATH);
177 psdp->fDumpByDate = IsDlgButtonChecked (hDlg, IDC_DUMP_LIMIT_TIME);
178 memset (&psdp->stDump, 0x00, sizeof(SYSTEMTIME));
179 DA_GetDate (GetDlgItem (hDlg, IDC_DUMP_DATE), &psdp->stDump);
180 TI_GetTime (GetDlgItem (hDlg, IDC_DUMP_TIME), &psdp->stDump);
184 void Filesets_Dump_OnBrowse (HWND hDlg, LPSET_DUMP_PARAMS psdp)
186 TCHAR szFilter[ cchRESOURCE ];
187 GetString (szFilter, IDS_RESTORE_FILTER);
188 TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ];
189 for (LPTSTR pszFilter = szFilter;
190 (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL);
191 ++pszFilter)
193 *pszFilter = TEXT('\0');
196 TCHAR szFilename[ MAX_PATH ];
197 GetDlgItemText (hDlg, IDC_DUMP_FILENAME, szFilename, MAX_PATH);
199 OPENFILENAME sfn;
200 memset (&sfn, 0x00, sizeof(sfn));
201 sfn.lStructSize = sizeof(sfn);
202 sfn.hwndOwner = hDlg;
203 sfn.hInstance = THIS_HINST;
204 sfn.lpstrFilter = szFilter;
205 sfn.nFilterIndex = 1;
206 sfn.lpstrFile = szFilename;
207 sfn.nMaxFile = MAX_PATH;
208 sfn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
209 sfn.lpstrDefExt = TEXT("dmp");
211 if (GetSaveFileName (&sfn))
213 SetDlgItemText (hDlg, IDC_DUMP_FILENAME, szFilename);
214 Filesets_Dump_EnableOK (hDlg);