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_createrep.h"
21 #include "svr_window.h"
26 * PROTOTYPES _________________________________________________________________
30 BOOL CALLBACK
Filesets_CreateReplica_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
31 void Filesets_CreateReplica_OnInitDialog (HWND hDlg
, LPSET_CREATEREP_PARAMS pscp
);
32 void Filesets_CreateReplica_OnSelectServer (HWND hDlg
, LPIDENT
*plpiTarget
);
33 void Filesets_CreateReplica_OnEndTask_EnumAggregates (HWND hDlg
, LPSET_CREATEREP_PARAMS pscp
);
34 void Filesets_CreateReplica_EnableOK (HWND hDlg
, LPSET_CREATEREP_PARAMS pscp
);
35 void Filesets_CreateReplica_StartDisplay_Aggregates (HWND hDlg
, LPIDENT lpiTarget
);
39 * ROUTINES ___________________________________________________________________
43 void Filesets_CreateReplica (LPIDENT lpiSource
, LPIDENT lpiTarget
)
45 LPSET_CREATEREP_PARAMS pscp
= New (SET_CREATEREP_PARAMS
);
46 pscp
->lpiSource
= lpiSource
;
47 pscp
->lpiTarget
= lpiTarget
;
49 INT_PTR rc
= ModalDialogParam (IDD_SET_CREATEREP
, NULL
, (DLGPROC
)Filesets_CreateReplica_DlgProc
, (LPARAM
)pscp
);
54 else if (!ASSERT( pscp
->lpiTarget
&& pscp
->lpiTarget
->fIsAggregate() ))
60 StartTask (taskSET_CREATEREP
, NULL
, pscp
);
65 BOOL CALLBACK
Filesets_CreateReplica_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
67 static LPSET_CREATEREP_PARAMS pscp
= NULL
;
68 if (msg
== WM_INITDIALOG
)
69 pscp
= (LPSET_CREATEREP_PARAMS
)lp
;
71 if (HandleColumnNotify (hDlg
, msg
, wp
, lp
, &gr
.viewAggMove
))
74 if (AfsAppLib_HandleHelp (IDD_SET_CREATEREP
, hDlg
, msg
, wp
, lp
))
82 FastList_SetTextCallback (GetDlgItem (hDlg
, IDC_AGG_LIST
), GetItemText
, &gr
.viewAggMove
);
83 Filesets_CreateReplica_OnInitDialog (hDlg
, pscp
);
88 if ((ptp
= (LPTASKPACKET
)lp
) != NULL
)
90 if (ptp
->idTask
== taskAGG_ENUM_TO_LISTVIEW
)
91 Filesets_CreateReplica_OnEndTask_EnumAggregates (hDlg
, pscp
);
92 else if (ptp
->idTask
== taskSVR_ENUM_TO_COMBOBOX
)
94 EnableWindow (GetDlgItem (hDlg
, IDC_SET_SERVER
), TRUE
);
95 Filesets_CreateReplica_OnSelectServer (hDlg
, &pscp
->lpiTarget
);
103 hList
= GetDlgItem (hDlg
, IDC_AGG_LIST
);
107 ptScreen
.x
= LOWORD(lp
);
108 ptScreen
.y
= HIWORD(lp
);
111 ScreenToClient (hList
, &ptClient
);
113 if (FL_HitTestForHeaderBar (hList
, ptClient
))
115 HMENU hm
= TaLocale_LoadMenu (MENU_COLUMNS
);
116 DisplayContextMenu (hm
, ptScreen
, hList
);
120 case WM_COLUMNS_CHANGED
:
122 lpSel
= FL_GetSelectedData (GetDlgItem (hDlg
, IDC_AGG_LIST
));
123 FL_RestoreView (GetDlgItem (hDlg
, IDC_AGG_LIST
), &gr
.viewAggMove
);
124 Filesets_CreateReplica_OnSelectServer (hDlg
, (LPIDENT
*)&lpSel
);
132 EndDialog (hDlg
, LOWORD(wp
));
136 EndDialog (hDlg
, LOWORD(wp
));
140 if (HIWORD(wp
) == CBN_SELCHANGE
)
141 Filesets_CreateReplica_OnSelectServer (hDlg
, &pscp
->lpiTarget
);
147 FL_StoreView (GetDlgItem (hDlg
, IDC_AGG_LIST
), &gr
.viewAggMove
);
152 switch (((LPNMHDR
)lp
)->code
)
156 if ((lpi
= (LPIDENT
)FL_GetSelectedData (GetDlgItem (hDlg
, IDC_AGG_LIST
))) != NULL
)
158 pscp
->lpiTarget
= lpi
;
159 Filesets_CreateReplica_EnableOK (hDlg
, pscp
);
171 static LONG_PTR procFilesetsCreateReplicaList
= 0;
173 LRESULT CALLBACK
Filesets_CreateReplica_SubclassListProc (HWND hList
, UINT msg
, WPARAM wp
, LPARAM lp
)
177 if (procFilesetsCreateReplicaList
== 0)
178 rc
= DefWindowProc (hList
, msg
, wp
, lp
);
180 rc
= (LRESULT
) CallWindowProc ((WNDPROC
)procFilesetsCreateReplicaList
, hList
, msg
, wp
, lp
);
185 if (procFilesetsCreateReplicaList
!= 0)
186 SetWindowLongPtr (hList
, GWLP_WNDPROC
, (LONG_PTR
)procFilesetsCreateReplicaList
);
193 ShowColumnsDialog (GetParent (hList
), &gr
.viewAggMove
);
203 void Filesets_CreateReplica_OnInitDialog (HWND hDlg
, LPSET_CREATEREP_PARAMS pscp
)
205 TCHAR szServer
[ cchNAME
];
206 TCHAR szAggregate
[ cchNAME
];
207 TCHAR szFileset
[ cchNAME
];
208 pscp
->lpiSource
->GetServerName (szServer
);
209 pscp
->lpiSource
->GetAggregateName (szAggregate
);
210 pscp
->lpiSource
->GetFilesetName (szFileset
);
212 TCHAR szText
[ cchRESOURCE
];
213 GetDlgItemText (hDlg
, IDC_SET_NAME
, szText
, cchRESOURCE
);
214 LPTSTR pszText
= FormatString (szText
, TEXT("%s%s%s"), szServer
, szAggregate
, szFileset
);
215 SetDlgItemText (hDlg
, IDC_SET_NAME
, pszText
);
216 FreeString (pszText
);
218 HWND hList
= GetDlgItem (hDlg
, IDC_AGG_LIST
);
219 if (procFilesetsCreateReplicaList
== 0)
220 procFilesetsCreateReplicaList
= GetWindowLongPtr (hList
, GWLP_WNDPROC
);
221 SetWindowLongPtr (hList
, GWLP_WNDPROC
, (LONG_PTR
)Filesets_CreateReplica_SubclassListProc
);
223 if (gr
.viewAggMove
.lvsView
== 0) // never initialized this?
225 if (gr
.viewAggCreate
.lvsView
== 0)
226 memcpy (&gr
.viewAggMove
, &gr
.viewAgg
, sizeof(VIEWINFO
));
228 memcpy (&gr
.viewAggMove
, &gr
.viewAggCreate
, sizeof(VIEWINFO
));
230 FL_RestoreView (GetDlgItem (hDlg
, IDC_AGG_LIST
), &gr
.viewAggMove
);
232 EnableWindow (GetDlgItem (hDlg
, IDOK
), FALSE
);
233 EnableWindow (GetDlgItem (hDlg
, IDC_SET_SERVER
), FALSE
);
234 EnableWindow (GetDlgItem (hDlg
, IDC_AGG_LIST
), FALSE
);
236 // Fill in the Servers combobox, and select the default server
237 // (if one was specified).
239 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp
= New (SVR_ENUM_TO_COMBOBOX_PACKET
);
240 lpp
->hCombo
= GetDlgItem (hDlg
, IDC_SET_SERVER
);
241 lpp
->lpiSelect
= (pscp
->lpiTarget
) ? pscp
->lpiTarget
->GetServer() : NULL
;
242 StartTask (taskSVR_ENUM_TO_COMBOBOX
, hDlg
, lpp
);
246 void Filesets_CreateReplica_OnSelectServer (HWND hDlg
, LPIDENT
*plpiTarget
)
248 LPIDENT lpiServerNew
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_SET_SERVER
));
250 SetWindowLongPtr (hDlg
, DWLP_USER
, (LONG_PTR
)lpiServerNew
);
252 if (*plpiTarget
&& (*plpiTarget
)->fIsServer())
254 if (*plpiTarget
&& ((*plpiTarget
)->GetServer() != lpiServerNew
))
257 Filesets_CreateReplica_StartDisplay_Aggregates (hDlg
, *plpiTarget
);
261 void Filesets_CreateReplica_OnEndTask_EnumAggregates (HWND hDlg
, LPSET_CREATEREP_PARAMS pscp
)
263 EnableWindow (GetDlgItem (hDlg
, IDC_AGG_LIST
), TRUE
);
264 Filesets_CreateReplica_EnableOK (hDlg
, pscp
);
268 void Filesets_CreateReplica_EnableOK (HWND hDlg
, LPSET_CREATEREP_PARAMS pscp
)
270 EnableWindow (GetDlgItem (hDlg
, IDOK
), (pscp
->lpiTarget
) ? TRUE
: FALSE
);
274 void Filesets_CreateReplica_StartDisplay_Aggregates (HWND hDlg
, LPIDENT lpiTarget
)
276 LPIDENT lpiServerNew
= (LPIDENT
)CB_GetSelectedData (GetDlgItem (hDlg
, IDC_SET_SERVER
));
278 EnableWindow (GetDlgItem (hDlg
, IDOK
), FALSE
);
280 LPAGG_ENUM_TO_LISTVIEW_PACKET lpp
= New (AGG_ENUM_TO_LISTVIEW_PACKET
);
281 lpp
->hList
= GetDlgItem (hDlg
, IDC_AGG_LIST
);
282 lpp
->lpiServer
= lpiServerNew
;
283 lpp
->lpiSelect
= lpiTarget
;
284 lpp
->lpvi
= &gr
.viewAggMove
;
285 StartTask (taskAGG_ENUM_TO_LISTVIEW
, hDlg
, lpp
);