2 * Copyright 2000, International Business Machines Corporation and others.
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
11 #include <afs/param.h>
16 #include "set_delete.h"
17 #include "propcache.h"
21 * PROTOTYPES _________________________________________________________________
25 BOOL CALLBACK Filesets_Delete_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
26 void Filesets_Delete_OnInitDialog (HWND hDlg, LPIDENT lpi);
27 void Filesets_Delete_OnCheckBoxes (HWND hDlg);
28 void Filesets_Delete_OnEndTask_FindGhost (HWND hDlg, LPTASKPACKET ptp, LPSET_DELETE_PARAMS psdp);
29 void Filesets_Delete_ShrinkWindow (HWND hDlg);
33 * ROUTINES ___________________________________________________________________
37 void Filesets_Delete (LPIDENT lpiFileset)
40 if ((hCurrent = PropCache_Search (pcSET_DELETE, lpiFileset)) != NULL)
46 LPSET_DELETE_PARAMS psdp = New (SET_DELETE_PARAMS);
47 memset (psdp, 0x00, sizeof(SET_DELETE_PARAMS));
48 psdp->lpiFileset = lpiFileset;
49 psdp->iddHelp = IDD_SET_DELETE;
51 ModelessDialogParam (IDD_SET_DELETE, NULL, (DLGPROC)Filesets_Delete_DlgProc, (LPARAM)psdp);
52 // NOTE: Don't show window!
58 BOOL CALLBACK Filesets_Delete_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
60 LPSET_DELETE_PARAMS psdp;
61 if (msg == WM_INITDIALOG)
62 SetWindowLongPtr (hDlg, DWLP_USER, lp);
63 if ((psdp = (LPSET_DELETE_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
65 if (AfsAppLib_HandleHelp (psdp->iddHelp, hDlg, msg, wp, lp))
71 PropCache_Add (pcSET_DELETE, psdp->lpiFileset, hDlg);
72 Filesets_Delete_OnInitDialog (hDlg, psdp->lpiFileset);
73 StartTask (taskSET_FIND_GHOST, hDlg, psdp->lpiFileset);
78 if ((ptp = (LPTASKPACKET)lp) != NULL)
80 if (ptp->idTask == taskSET_FIND_GHOST)
81 Filesets_Delete_OnEndTask_FindGhost (hDlg, ptp, psdp);
90 psdp->fVLDB = IsDlgButtonChecked (hDlg, IDC_DELSET_VLDB);
91 psdp->fServer = IsDlgButtonChecked (hDlg, IDC_DELSET_SERVER);
93 if (psdp->fVLDB || psdp->fServer)
94 StartTask (taskSET_DELETE, NULL, psdp);
102 DestroyWindow (hDlg);
105 case IDC_DELSET_VLDB:
106 case IDC_DELSET_SERVER:
107 Filesets_Delete_OnCheckBoxes (hDlg);
113 PropCache_Delete (hDlg);
114 SetWindowLongPtr (hDlg, DWLP_USER, 0);
124 void Filesets_Delete_OnInitDialog (HWND hDlg, LPIDENT lpi)
126 TCHAR szServer[ cchNAME ];
127 TCHAR szAggregate[ cchNAME ];
128 TCHAR szFileset[ cchNAME ];
130 lpi->GetServerName (szServer);
131 lpi->GetAggregateName (szAggregate);
132 lpi->GetFilesetName (szFileset);
134 TCHAR szOld[ cchRESOURCE ];
136 GetDlgItemText (hDlg, IDC_DELSET_DESC, szOld, cchRESOURCE);
137 LPTSTR pszNew = FormatString (szOld, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
138 SetDlgItemText (hDlg, IDC_DELSET_DESC, pszNew);
141 GetDlgItemText (hDlg, IDC_DELSET_SERVER, szOld, cchRESOURCE);
142 pszNew = FormatString (szOld, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
143 SetDlgItemText (hDlg, IDC_DELSET_SERVER, pszNew);
146 GetDlgItemText (hDlg, IDC_DELSET_VLDB, szOld, cchRESOURCE);
147 pszNew = FormatString (szOld, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
148 SetDlgItemText (hDlg, IDC_DELSET_VLDB, pszNew);
151 EnableWindow (GetDlgItem (hDlg, IDOK), FALSE);
155 void Filesets_Delete_OnEndTask_FindGhost (HWND hDlg, LPTASKPACKET ptp, LPSET_DELETE_PARAMS psdp)
157 TCHAR szServer[ cchNAME ];
158 TCHAR szAggregate[ cchNAME ];
159 TCHAR szFileset[ cchNAME ];
160 psdp->lpiFileset->GetServerName (szServer);
161 psdp->lpiFileset->GetAggregateName (szAggregate);
162 psdp->lpiFileset->GetFilesetName (szFileset);
166 ErrorDialog (ptp->status, IDS_ERROR_REFRESH_FILESET_STATUS, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
167 DestroyWindow (hDlg);
169 else if ( (TASKDATA(ptp)->fs.Type == ftREADWRITE) && (TASKDATA(ptp)->fHasReplicas) )
171 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_REPLICATED_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
172 DestroyWindow (hDlg);
176 if (TASKDATA(ptp)->fs.Type == ftREPLICA)
177 psdp->wGhost = GHOST_HAS_SERVER_ENTRY;
178 else if (TASKDATA(ptp)->fs.Type == ftCLONE)
179 psdp->wGhost = GHOST_HAS_SERVER_ENTRY;
181 psdp->wGhost = TASKDATA(ptp)->wGhost;
183 psdp->fVLDB = (psdp->wGhost & GHOST_HAS_VLDB_ENTRY) ? TRUE : FALSE;
184 psdp->fServer = (psdp->wGhost & GHOST_HAS_SERVER_ENTRY) ? TRUE : FALSE;
186 CheckDlgButton (hDlg, IDC_DELSET_VLDB, psdp->fVLDB);
187 CheckDlgButton (hDlg, IDC_DELSET_SERVER, psdp->fServer);
189 if (TASKDATA(ptp)->fs.Type == ftREPLICA)
191 psdp->iddHelp = IDD_SET_DELREP;
193 LPTSTR pszNew = FormatString (IDS_DELSET_REPLICA_DESC, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
194 SetDlgItemText (hDlg, IDC_DELSET_DESC, pszNew);
197 Filesets_Delete_ShrinkWindow (hDlg);
199 else if (TASKDATA(ptp)->fs.Type == ftCLONE)
201 psdp->iddHelp = IDD_SET_DELCLONE;
203 LPTSTR pszNew = FormatString (IDS_DELSET_CLONE_DESC, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
204 SetDlgItemText (hDlg, IDC_DELSET_DESC, pszNew);
207 Filesets_Delete_ShrinkWindow (hDlg);
210 if (!(psdp->wGhost & GHOST_HAS_SERVER_ENTRY))
211 EnableWindow (GetDlgItem (hDlg, IDC_DELSET_SERVER), FALSE);
213 if (!(psdp->wGhost & GHOST_HAS_VLDB_ENTRY))
214 EnableWindow (GetDlgItem (hDlg, IDC_DELSET_VLDB), FALSE);
216 Filesets_Delete_OnCheckBoxes (hDlg);
218 ShowWindow (hDlg, SW_SHOW);
223 void Filesets_Delete_OnCheckBoxes (HWND hDlg)
225 BOOL fEnableOK = TRUE;
226 if ( !IsDlgButtonChecked (hDlg, IDC_DELSET_VLDB) &&
227 !IsDlgButtonChecked (hDlg, IDC_DELSET_SERVER) )
230 EnableWindow (GetDlgItem (hDlg, IDOK), fEnableOK);
234 void Filesets_Delete_ShrinkWindow (HWND hDlg)
237 GetWindowRect (hDlg, &rDialog);
240 GetRectInParent (GetDlgItem (hDlg, IDC_DELSET_VLDB), &rCheckbox);
243 GetRectInParent (GetDlgItem (hDlg, IDOK), &rButton);
245 LONG cy = rButton.top -rCheckbox.top; // shrink window by this much
247 EnableWindow (GetDlgItem (hDlg, IDC_DELSET_SERVER), FALSE);
248 ShowWindow (GetDlgItem (hDlg, IDC_DELSET_SERVER), SW_HIDE);
250 EnableWindow (GetDlgItem (hDlg, IDC_DELSET_VLDB), FALSE);
251 ShowWindow (GetDlgItem (hDlg, IDC_DELSET_VLDB), SW_HIDE);
253 GetRectInParent (GetDlgItem (hDlg, IDOK), &rButton);
254 SetWindowPos (GetDlgItem (hDlg, IDOK), NULL,
255 rButton.left, rButton.top -cy, 0, 0,
256 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
258 GetRectInParent (GetDlgItem (hDlg, IDCANCEL), &rButton);
259 SetWindowPos (GetDlgItem (hDlg, IDCANCEL), NULL,
260 rButton.left, rButton.top -cy, 0, 0,
261 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
263 GetRectInParent (GetDlgItem (hDlg, IDHELP), &rButton);
264 SetWindowPos (GetDlgItem (hDlg, IDHELP), NULL,
265 rButton.left, rButton.top -cy, 0, 0,
266 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
268 SetWindowPos (hDlg, NULL,
269 0, 0, cxRECT(rDialog), cyRECT(rDialog) -cy,
270 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);