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
14 #include <afs/param.h>
19 #include "set_delete.h"
20 #include "propcache.h"
24 * PROTOTYPES _________________________________________________________________
28 BOOL CALLBACK
Filesets_Delete_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
29 void Filesets_Delete_OnInitDialog (HWND hDlg
, LPIDENT lpi
);
30 void Filesets_Delete_OnCheckBoxes (HWND hDlg
);
31 void Filesets_Delete_OnEndTask_FindGhost (HWND hDlg
, LPTASKPACKET ptp
, LPSET_DELETE_PARAMS psdp
);
32 void Filesets_Delete_ShrinkWindow (HWND hDlg
);
36 * ROUTINES ___________________________________________________________________
40 void Filesets_Delete (LPIDENT lpiFileset
)
43 if ((hCurrent
= PropCache_Search (pcSET_DELETE
, lpiFileset
)) != NULL
)
49 LPSET_DELETE_PARAMS psdp
= New (SET_DELETE_PARAMS
);
50 memset (psdp
, 0x00, sizeof(SET_DELETE_PARAMS
));
51 psdp
->lpiFileset
= lpiFileset
;
52 psdp
->iddHelp
= IDD_SET_DELETE
;
54 ModelessDialogParam (IDD_SET_DELETE
, NULL
, (DLGPROC
)Filesets_Delete_DlgProc
, (LPARAM
)psdp
);
55 // NOTE: Don't show window!
61 BOOL CALLBACK
Filesets_Delete_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
63 LPSET_DELETE_PARAMS psdp
;
64 if (msg
== WM_INITDIALOG
)
65 SetWindowLongPtr (hDlg
, DWLP_USER
, lp
);
66 if ((psdp
= (LPSET_DELETE_PARAMS
)GetWindowLongPtr (hDlg
, DWLP_USER
)) != NULL
)
68 if (AfsAppLib_HandleHelp (psdp
->iddHelp
, hDlg
, msg
, wp
, lp
))
74 PropCache_Add (pcSET_DELETE
, psdp
->lpiFileset
, hDlg
);
75 Filesets_Delete_OnInitDialog (hDlg
, psdp
->lpiFileset
);
76 StartTask (taskSET_FIND_GHOST
, hDlg
, psdp
->lpiFileset
);
81 if ((ptp
= (LPTASKPACKET
)lp
) != NULL
)
83 if (ptp
->idTask
== taskSET_FIND_GHOST
)
84 Filesets_Delete_OnEndTask_FindGhost (hDlg
, ptp
, psdp
);
93 psdp
->fVLDB
= IsDlgButtonChecked (hDlg
, IDC_DELSET_VLDB
);
94 psdp
->fServer
= IsDlgButtonChecked (hDlg
, IDC_DELSET_SERVER
);
96 if (psdp
->fVLDB
|| psdp
->fServer
)
97 StartTask (taskSET_DELETE
, NULL
, psdp
);
100 DestroyWindow (hDlg
);
105 DestroyWindow (hDlg
);
108 case IDC_DELSET_VLDB
:
109 case IDC_DELSET_SERVER
:
110 Filesets_Delete_OnCheckBoxes (hDlg
);
116 PropCache_Delete (hDlg
);
117 SetWindowLongPtr (hDlg
, DWLP_USER
, 0);
127 void Filesets_Delete_OnInitDialog (HWND hDlg
, LPIDENT lpi
)
129 TCHAR szServer
[ cchNAME
];
130 TCHAR szAggregate
[ cchNAME
];
131 TCHAR szFileset
[ cchNAME
];
133 lpi
->GetServerName (szServer
);
134 lpi
->GetAggregateName (szAggregate
);
135 lpi
->GetFilesetName (szFileset
);
137 TCHAR szOld
[ cchRESOURCE
];
139 GetDlgItemText (hDlg
, IDC_DELSET_DESC
, szOld
, cchRESOURCE
);
140 LPTSTR pszNew
= FormatString (szOld
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
141 SetDlgItemText (hDlg
, IDC_DELSET_DESC
, pszNew
);
144 GetDlgItemText (hDlg
, IDC_DELSET_SERVER
, szOld
, cchRESOURCE
);
145 pszNew
= FormatString (szOld
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
146 SetDlgItemText (hDlg
, IDC_DELSET_SERVER
, pszNew
);
149 GetDlgItemText (hDlg
, IDC_DELSET_VLDB
, szOld
, cchRESOURCE
);
150 pszNew
= FormatString (szOld
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
151 SetDlgItemText (hDlg
, IDC_DELSET_VLDB
, pszNew
);
154 EnableWindow (GetDlgItem (hDlg
, IDOK
), FALSE
);
158 void Filesets_Delete_OnEndTask_FindGhost (HWND hDlg
, LPTASKPACKET ptp
, LPSET_DELETE_PARAMS psdp
)
160 TCHAR szServer
[ cchNAME
];
161 TCHAR szAggregate
[ cchNAME
];
162 TCHAR szFileset
[ cchNAME
];
163 psdp
->lpiFileset
->GetServerName (szServer
);
164 psdp
->lpiFileset
->GetAggregateName (szAggregate
);
165 psdp
->lpiFileset
->GetFilesetName (szFileset
);
169 ErrorDialog (ptp
->status
, IDS_ERROR_REFRESH_FILESET_STATUS
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
170 DestroyWindow (hDlg
);
172 else if ( (TASKDATA(ptp
)->fs
.Type
== ftREADWRITE
) && (TASKDATA(ptp
)->fHasReplicas
) )
174 ErrorDialog (ptp
->status
, IDS_ERROR_CANT_DELETE_REPLICATED_FILESET
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
175 DestroyWindow (hDlg
);
179 if (TASKDATA(ptp
)->fs
.Type
== ftREPLICA
)
180 psdp
->wGhost
= GHOST_HAS_SERVER_ENTRY
;
181 else if (TASKDATA(ptp
)->fs
.Type
== ftCLONE
)
182 psdp
->wGhost
= GHOST_HAS_SERVER_ENTRY
;
184 psdp
->wGhost
= TASKDATA(ptp
)->wGhost
;
186 psdp
->fVLDB
= (psdp
->wGhost
& GHOST_HAS_VLDB_ENTRY
) ? TRUE
: FALSE
;
187 psdp
->fServer
= (psdp
->wGhost
& GHOST_HAS_SERVER_ENTRY
) ? TRUE
: FALSE
;
189 CheckDlgButton (hDlg
, IDC_DELSET_VLDB
, psdp
->fVLDB
);
190 CheckDlgButton (hDlg
, IDC_DELSET_SERVER
, psdp
->fServer
);
192 if (TASKDATA(ptp
)->fs
.Type
== ftREPLICA
)
194 psdp
->iddHelp
= IDD_SET_DELREP
;
196 LPTSTR pszNew
= FormatString (IDS_DELSET_REPLICA_DESC
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
197 SetDlgItemText (hDlg
, IDC_DELSET_DESC
, pszNew
);
200 Filesets_Delete_ShrinkWindow (hDlg
);
202 else if (TASKDATA(ptp
)->fs
.Type
== ftCLONE
)
204 psdp
->iddHelp
= IDD_SET_DELCLONE
;
206 LPTSTR pszNew
= FormatString (IDS_DELSET_CLONE_DESC
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
207 SetDlgItemText (hDlg
, IDC_DELSET_DESC
, pszNew
);
210 Filesets_Delete_ShrinkWindow (hDlg
);
213 if (!(psdp
->wGhost
& GHOST_HAS_SERVER_ENTRY
))
214 EnableWindow (GetDlgItem (hDlg
, IDC_DELSET_SERVER
), FALSE
);
216 if (!(psdp
->wGhost
& GHOST_HAS_VLDB_ENTRY
))
217 EnableWindow (GetDlgItem (hDlg
, IDC_DELSET_VLDB
), FALSE
);
219 Filesets_Delete_OnCheckBoxes (hDlg
);
221 ShowWindow (hDlg
, SW_SHOW
);
226 void Filesets_Delete_OnCheckBoxes (HWND hDlg
)
228 BOOL fEnableOK
= TRUE
;
229 if ( !IsDlgButtonChecked (hDlg
, IDC_DELSET_VLDB
) &&
230 !IsDlgButtonChecked (hDlg
, IDC_DELSET_SERVER
) )
233 EnableWindow (GetDlgItem (hDlg
, IDOK
), fEnableOK
);
237 void Filesets_Delete_ShrinkWindow (HWND hDlg
)
240 GetWindowRect (hDlg
, &rDialog
);
243 GetRectInParent (GetDlgItem (hDlg
, IDC_DELSET_VLDB
), &rCheckbox
);
246 GetRectInParent (GetDlgItem (hDlg
, IDOK
), &rButton
);
248 LONG cy
= rButton
.top
-rCheckbox
.top
; // shrink window by this much
250 EnableWindow (GetDlgItem (hDlg
, IDC_DELSET_SERVER
), FALSE
);
251 ShowWindow (GetDlgItem (hDlg
, IDC_DELSET_SERVER
), SW_HIDE
);
253 EnableWindow (GetDlgItem (hDlg
, IDC_DELSET_VLDB
), FALSE
);
254 ShowWindow (GetDlgItem (hDlg
, IDC_DELSET_VLDB
), SW_HIDE
);
256 GetRectInParent (GetDlgItem (hDlg
, IDOK
), &rButton
);
257 SetWindowPos (GetDlgItem (hDlg
, IDOK
), NULL
,
258 rButton
.left
, rButton
.top
-cy
, 0, 0,
259 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
261 GetRectInParent (GetDlgItem (hDlg
, IDCANCEL
), &rButton
);
262 SetWindowPos (GetDlgItem (hDlg
, IDCANCEL
), NULL
,
263 rButton
.left
, rButton
.top
-cy
, 0, 0,
264 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
266 GetRectInParent (GetDlgItem (hDlg
, IDHELP
), &rButton
);
267 SetWindowPos (GetDlgItem (hDlg
, IDHELP
), NULL
,
268 rButton
.left
, rButton
.top
-cy
, 0, 0,
269 SWP_NOSIZE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
271 SetWindowPos (hDlg
, NULL
,
272 0, 0, cxRECT(rDialog
), cyRECT(rDialog
) -cy
,
273 SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);