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_clone.h"
20 #include "propcache.h"
24 * DEFINITIONS ________________________________________________________________
30 * PROTOTYPES _________________________________________________________________
34 BOOL CALLBACK
Filesets_Clone_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
35 void Filesets_Clone_OnInitDialog (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
37 BOOL CALLBACK
Filesets_Clonesys_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
38 void Filesets_Clonesys_OnInitDialog (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
39 void Filesets_Clonesys_OnOK (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
40 void Filesets_Clonesys_OnSelect (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
41 void Filesets_Clonesys_OnSelectServer (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
42 void Filesets_Clonesys_OnEndTask_EnumServers (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
43 void Filesets_Clonesys_OnEndTask_EnumAggregs (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
);
47 * ROUTINES ___________________________________________________________________
51 void Filesets_Clone (LPIDENT lpi
)
53 LPSET_CLONESYS_PARAMS pcsp
= New (SET_CLONESYS_PARAMS
);
54 memset (pcsp
, 0x00, sizeof(SET_CLONESYS_PARAMS
));
55 pcsp
->lpi
= (lpi
== NULL
) ? g
.lpiCell
: lpi
;
58 if (pcsp
->lpi
&& pcsp
->lpi
->fIsFileset())
59 rc
= ModalDialogParam (IDD_SET_CLONE
, NULL
, (DLGPROC
)Filesets_Clone_DlgProc
, (LPARAM
)pcsp
);
61 rc
= ModalDialogParam (IDD_SET_CLONESYS
, NULL
, (DLGPROC
)Filesets_Clonesys_DlgProc
, (LPARAM
)pcsp
);
63 if ((rc
!= IDOK
) || (!pcsp
->lpi
))
67 else if (pcsp
->lpi
->fIsFileset()) // clone one fileset?
69 StartTask (taskSET_CLONE
, NULL
, pcsp
->lpi
);
72 else // or clone lots of filesets?
74 StartTask (taskSET_CLONESYS
, NULL
, pcsp
);
75 // don't delete pcsp--it'll be freed by the StartTask handler
81 BOOL CALLBACK
Filesets_Clone_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
83 if (AfsAppLib_HandleHelp (IDD_SET_CLONE
, hDlg
, msg
, wp
, lp
))
86 if (msg
== WM_INITDIALOG
)
87 SetWindowLongPtr (hDlg
, DWLP_USER
, lp
);
89 LPSET_CLONESYS_PARAMS pcsp
= (LPSET_CLONESYS_PARAMS
)GetWindowLongPtr (hDlg
, DWLP_USER
);
96 PropCache_Add (pcSET_CLONE
, NULL
, hDlg
);
97 Filesets_Clone_OnInitDialog (hDlg
, pcsp
);
105 EndDialog (hDlg
, LOWORD(wp
));
111 PropCache_Delete (pcSET_CLONE
, NULL
);
120 void Filesets_Clone_OnInitDialog (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
122 TCHAR szServer
[ cchNAME
];
123 TCHAR szAggregate
[ cchNAME
];
124 TCHAR szFileset
[ cchNAME
];
125 pcsp
->lpi
->GetServerName (szServer
);
126 pcsp
->lpi
->GetAggregateName (szAggregate
);
127 pcsp
->lpi
->GetFilesetName (szFileset
);
129 TCHAR szText
[ cchRESOURCE
];
130 GetDlgItemText (hDlg
, IDC_CLONE_DESC
, szText
, cchRESOURCE
);
132 LPTSTR pszText
= FormatString (szText
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
133 SetDlgItemText (hDlg
, IDC_CLONE_DESC
, pszText
);
134 FreeString (pszText
);
138 BOOL CALLBACK
Filesets_Clonesys_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
140 if (AfsAppLib_HandleHelp (IDD_SET_CLONESYS
, hDlg
, msg
, wp
, lp
))
143 if (msg
== WM_INITDIALOG
)
144 SetWindowLongPtr (hDlg
, DWLP_USER
, lp
);
146 LPSET_CLONESYS_PARAMS pcsp
= (LPSET_CLONESYS_PARAMS
)GetWindowLongPtr (hDlg
, DWLP_USER
);
153 PropCache_Add (pcSET_CLONE
, NULL
, hDlg
);
154 Filesets_Clonesys_OnInitDialog (hDlg
, pcsp
);
159 if ((ptp
= (LPTASKPACKET
)lp
) != NULL
)
161 if (ptp
->idTask
== taskSVR_ENUM_TO_COMBOBOX
)
163 Filesets_Clonesys_OnEndTask_EnumServers (hDlg
, pcsp
);
165 else if (ptp
->idTask
== taskAGG_ENUM_TO_COMBOBOX
)
167 Filesets_Clonesys_OnEndTask_EnumAggregs (hDlg
, pcsp
);
169 FreeTaskPacket (ptp
);
177 Filesets_Clonesys_OnOK (hDlg
, pcsp
);
178 EndDialog (hDlg
, IDOK
);
182 EndDialog (hDlg
, IDCANCEL
);
187 case IDC_CLONE_SVR_LIMIT
:
188 case IDC_CLONE_AGG_LIMIT
:
189 case IDC_CLONE_PREFIX_LIMIT
:
190 Filesets_Clonesys_OnSelect (hDlg
, pcsp
);
194 if (HIWORD(wp
) == CBN_SELCHANGE
)
196 Filesets_Clonesys_OnSelectServer (hDlg
, pcsp
);
203 PropCache_Delete (pcSET_CLONE
, NULL
);
212 void Filesets_Clonesys_OnInitDialog (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
214 CheckDlgButton (hDlg
, IDC_CLONE_ALL
, pcsp
->lpi
->fIsCell());
215 CheckDlgButton (hDlg
, IDC_CLONE_SOME
, !pcsp
->lpi
->fIsCell());
216 CheckDlgButton (hDlg
, IDC_CLONE_SVR_LIMIT
, !pcsp
->lpi
->fIsCell());
217 CheckDlgButton (hDlg
, IDC_CLONE_AGG_LIMIT
, pcsp
->lpi
->fIsAggregate());
219 pcsp
->fEnumedServers
= FALSE
;
220 pcsp
->fEnumedAggregs
= FALSE
;
221 Filesets_Clonesys_OnSelect (hDlg
, pcsp
);
223 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp
= New (SVR_ENUM_TO_COMBOBOX_PACKET
);
224 lpp
->hCombo
= GetDlgItem (hDlg
, IDC_CLONE_SVR
);
225 lpp
->lpiSelect
= (pcsp
->lpi
&& !pcsp
->lpi
->fIsCell()) ? pcsp
->lpi
->GetServer() : NULL
;
226 StartTask (taskSVR_ENUM_TO_COMBOBOX
, hDlg
, lpp
);
230 void Filesets_Clonesys_OnOK (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
232 if (IsDlgButtonChecked (hDlg
, IDC_CLONE_ALL
))
234 pcsp
->lpi
= g
.lpiCell
;
235 pcsp
->fUsePrefix
= FALSE
;
236 pcsp
->szPrefix
[0] = TEXT('\0');
238 else // (IsDlgButtonChecked (hDlg, IDC_CLONE_SOME))
240 if (IsDlgButtonChecked (hDlg
, IDC_CLONE_AGG_LIMIT
))
241 pcsp
->lpi
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_CLONE_AGG
));
242 else if (IsDlgButtonChecked (hDlg
, IDC_CLONE_SVR_LIMIT
))
243 pcsp
->lpi
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_CLONE_SVR
));
245 pcsp
->lpi
= g
.lpiCell
;
247 pcsp
->fUsePrefix
= IsDlgButtonChecked (hDlg
, IDC_CLONE_PREFIX_LIMIT
);
248 GetDlgItemText (hDlg
, IDC_CLONE_PREFIX
, pcsp
->szPrefix
, MAX_PATH
);
250 if (pcsp
->fUsePrefix
&& (pcsp
->szPrefix
[0] == TEXT('!')))
252 TCHAR szPrefixNoBang
[ cchRESOURCE
];
253 lstrcpy (szPrefixNoBang
, &pcsp
->szPrefix
[1]);
254 lstrcpy (pcsp
->szPrefix
, szPrefixNoBang
);
255 pcsp
->fExcludePrefix
= TRUE
;
261 void Filesets_Clonesys_OnSelect (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
263 BOOL fCloneAll
= (IsDlgButtonChecked (hDlg
, IDC_CLONE_ALL
)) ? TRUE
: FALSE
;
265 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_SVR_LIMIT
), !fCloneAll
);
266 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_AGG_LIMIT
), !fCloneAll
);
267 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_PREFIX_LIMIT
), !fCloneAll
);
271 CheckDlgButton (hDlg
, IDC_CLONE_SVR_LIMIT
, FALSE
);
272 CheckDlgButton (hDlg
, IDC_CLONE_AGG_LIMIT
, FALSE
);
273 CheckDlgButton (hDlg
, IDC_CLONE_PREFIX_LIMIT
, FALSE
);
278 fEnable
= IsDlgButtonChecked (hDlg
, IDC_CLONE_SVR_LIMIT
) && pcsp
->fEnumedServers
;
279 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_SVR
), fEnable
);
281 fEnable
= IsDlgButtonChecked (hDlg
, IDC_CLONE_SVR_LIMIT
);
282 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_AGG_LIMIT
), fEnable
);
284 CheckDlgButton (hDlg
, IDC_CLONE_AGG_LIMIT
, FALSE
);
286 fEnable
= fEnable
&& IsDlgButtonChecked (hDlg
, IDC_CLONE_AGG_LIMIT
) && pcsp
->fEnumedAggregs
;
287 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_AGG
), fEnable
);
289 fEnable
= IsDlgButtonChecked (hDlg
, IDC_CLONE_PREFIX_LIMIT
);
290 EnableWindow (GetDlgItem (hDlg
, IDC_CLONE_PREFIX
), fEnable
);
293 if (IsDlgButtonChecked (hDlg
, IDC_CLONE_SVR_LIMIT
) && !pcsp
->fEnumedServers
)
295 if (IsDlgButtonChecked (hDlg
, IDC_CLONE_AGG_LIMIT
) && !pcsp
->fEnumedAggregs
)
297 EnableWindow (GetDlgItem (hDlg
, IDOK
), fEnable
);
301 void Filesets_Clonesys_OnSelectServer (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
303 pcsp
->fEnumedAggregs
= FALSE
;
304 Filesets_Clonesys_OnSelect (hDlg
, pcsp
);
306 LPAGG_ENUM_TO_COMBOBOX_PACKET lpp
= New (AGG_ENUM_TO_COMBOBOX_PACKET
);
307 lpp
->hCombo
= GetDlgItem (hDlg
, IDC_CLONE_AGG
);
308 lpp
->lpiServer
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_CLONE_SVR
));
309 lpp
->lpiSelect
= (pcsp
->lpi
->fIsAggregate() && (pcsp
->lpi
->GetServer() == lpp
->lpiServer
)) ? pcsp
->lpi
: NULL
;
310 StartTask (taskAGG_ENUM_TO_COMBOBOX
, hDlg
, lpp
);
314 void Filesets_Clonesys_OnEndTask_EnumServers (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
316 pcsp
->fEnumedServers
= TRUE
;
317 Filesets_Clonesys_OnSelectServer (hDlg
, pcsp
);
321 void Filesets_Clonesys_OnEndTask_EnumAggregs (HWND hDlg
, LPSET_CLONESYS_PARAMS pcsp
)
323 pcsp
->fEnumedAggregs
= TRUE
;
324 Filesets_Clonesys_OnSelect (hDlg
, pcsp
);