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_repprop.h"
20 #include "set_createrep.h"
21 #include "set_delete.h"
22 #include "set_release.h"
23 #include "propcache.h"
29 * DEFINITIONS ________________________________________________________________
38 } SET_REPPROP_PARAMS
, *LPSET_REPPROP_PARAMS
;
42 * PROTOTYPES _________________________________________________________________
46 BOOL CALLBACK
Filesets_RepSites_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
47 void Filesets_RepSites_OnInitDialog (HWND hDlg
, LPSET_REPPROP_PARAMS prp
);
48 void Filesets_RepSites_OnSelect (HWND hDlg
);
49 void Filesets_RepSites_OnDelete (HWND hDlg
);
53 * ROUTINES ___________________________________________________________________
57 void Filesets_ShowReplication (HWND hDlg
, LPIDENT lpiFileset
, LPIDENT lpiTarget
)
59 LPSET_REPPROP_INIT_PARAMS lpp
= New (SET_REPPROP_INIT_PARAMS
);
60 memset (lpp
, 0x00, sizeof(SET_REPPROP_INIT_PARAMS
));
61 lpp
->lpiReq
= lpiFileset
;
63 StartTask (taskSET_REPPROP_INIT
, g
.hMain
, lpp
);
66 void Filesets_OnEndTask_ShowReplication (LPTASKPACKET ptp
)
68 LPSET_REPPROP_INIT_PARAMS lpp
= (LPSET_REPPROP_INIT_PARAMS
)(ptp
->lpUser
);
70 TCHAR szSvrName
[ cchNAME
];
71 TCHAR szAggName
[ cchNAME
];
72 TCHAR szSetName
[ cchNAME
];
73 lpp
->lpiReq
->GetServerName (szSvrName
);
74 lpp
->lpiReq
->GetAggregateName (szAggName
);
75 lpp
->lpiReq
->GetFilesetName (szSetName
);
79 ErrorDialog (ptp
->status
, IDS_ERROR_REFRESH_FILESET_STATUS
, TEXT("%s%s%s"), szSvrName
, szAggName
, szSetName
);
81 else if (!lpp
->lpiRW
) // couldn't find RW fileset entry?
83 ErrorDialog (ptp
->status
, IDS_ERROR_NOT_REPLICATED
, TEXT("%s"), szSetName
);
88 if ((hCurrent
= PropCache_Search (pcSET_REP
, lpp
->lpiRW
)) != NULL
)
94 LPSET_REPPROP_PARAMS prp
= New (SET_REPPROP_PARAMS
);
95 prp
->lpiReq
= lpp
->lpiReq
;
96 prp
->lpiRW
= lpp
->lpiRW
;
97 memcpy (&prp
->fs
, &lpp
->fs
, sizeof(lpp
->fs
));
99 LPTSTR pszTitle
= FormatString (IDS_SET_REP_TITLE
, TEXT("%s"), szSetName
);
100 LPPROPSHEET psh
= PropSheet_Create (pszTitle
, FALSE
);
101 psh
->sh
.dwFlags
|= PSH_NOAPPLYNOW
;
102 psh
->fMadeCaption
= TRUE
;
104 if (PropSheet_AddTab (psh
, IDS_SET_REPSITES_TAB
, IDD_SET_REPSITES
, (DLGPROC
)Filesets_RepSites_DlgProc
, (LPARAM
)prp
, TRUE
, TRUE
))
106 PropSheet_ShowModeless (psh
);
115 BOOL CALLBACK
Filesets_RepSites_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
117 if (HandleColumnNotify (hDlg
, msg
, wp
, lp
, &gr
.viewRep
))
120 if (AfsAppLib_HandleHelp (IDD_SET_REPSITES
, hDlg
, msg
, wp
, lp
))
123 if (msg
== WM_INITDIALOG
)
124 SetWindowLongPtr (hDlg
, DWLP_USER
, ((LPPROPSHEETPAGE
)lp
)->lParam
);
126 if (msg
== WM_INITDIALOG_SHEET
)
128 PropCache_Add (pcSET_REP
, ((LPSET_REPPROP_PARAMS
)lp
)->lpiRW
, hDlg
);
130 else if (msg
== WM_DESTROY_SHEET
)
132 PropCache_Delete (hDlg
);
136 LPSET_REPPROP_PARAMS prp
;
137 if ((prp
= (LPSET_REPPROP_PARAMS
)GetWindowLongPtr (hDlg
, DWLP_USER
)) != NULL
)
142 FastList_SetTextCallback (GetDlgItem (hDlg
, IDC_SET_REP_LIST
), GetItemText
, &gr
.viewRep
);
143 Filesets_RepSites_OnInitDialog (hDlg
, prp
);
144 NotifyMe (WHEN_SETS_CHANGE
, NULL
, hDlg
, 0);
148 DontNotifyMeEver (hDlg
);
149 SetWindowLongPtr (hDlg
, DWLP_USER
, 0);
154 if ((HWND
)wp
== GetDlgItem (hDlg
, IDC_SET_REP_LIST
))
156 HWND hList
= GetDlgItem (hDlg
, IDC_SET_REP_LIST
);
159 ptScreen
.x
= LOWORD(lp
);
160 ptScreen
.y
= HIWORD(lp
);
164 ScreenToClient ((HWND
)wp
, &ptClient
);
166 if (FL_HitTestForHeaderBar (hList
, ptClient
))
168 HMENU hm
= TaLocale_LoadMenu (MENU_COLUMNS
);
169 DisplayContextMenu (hm
, ptScreen
, hList
);
174 case WM_COLUMNS_CHANGED
:
176 hList
= GetDlgItem (hDlg
, IDC_SET_REP_LIST
);
178 lpiSel
= (LPIDENT
)FL_GetSelectedData (hList
);
179 FL_RestoreView (hList
, &gr
.viewRep
);
180 UpdateDisplay_Replicas (FALSE
, hList
, prp
->lpiRW
, lpiSel
);
191 case IDC_SET_REPSITE_ADD
:
192 Filesets_CreateReplica (prp
->lpiRW
);
195 case IDC_SET_REPSITE_DELETE
:
196 Filesets_RepSites_OnDelete (hDlg
);
199 case IDC_SET_RELEASE
:
200 Filesets_Release (prp
->lpiRW
);
205 case WM_NOTIFY_FROM_DISPATCH
:
206 UpdateDisplay_Replicas (FALSE
, GetDlgItem (hDlg
, IDC_SET_REP_LIST
), prp
->lpiRW
, prp
->lpiReq
);
207 Delete ((LPNOTIFYSTRUCT
)lp
);
211 switch (((LPNMHDR
)lp
)->code
)
213 case FLN_COLUMNRESIZE
:
214 FL_StoreView (GetDlgItem (hDlg
, IDC_SET_REP_LIST
), &gr
.viewRep
);
218 Filesets_RepSites_OnSelect (hDlg
);
230 static LONG_PTR procRepSitesList
= 0;
232 LRESULT CALLBACK
Filesets_RepSites_SubclassListProc (HWND hList
, UINT msg
, WPARAM wp
, LPARAM lp
)
236 if (procRepSitesList
== 0)
237 rc
= DefWindowProc (hList
, msg
, wp
, lp
);
239 rc
= CallWindowProc ((WNDPROC
)procRepSitesList
, hList
, msg
, wp
, lp
);
244 if (procRepSitesList
!= 0)
245 SetWindowLongPtr (hList
, GWLP_WNDPROC
, procRepSitesList
);
252 ShowColumnsDialog (GetParent (hList
), &gr
.viewRep
);
262 void Filesets_RepSites_OnInitDialog (HWND hDlg
, LPSET_REPPROP_PARAMS prp
)
264 HWND hList
= GetDlgItem (hDlg
, IDC_SET_REP_LIST
);
265 if (procRepSitesList
== 0)
266 procRepSitesList
= GetWindowLongPtr (hList
, GWLP_WNDPROC
);
267 SetWindowLongPtr (hList
, GWLP_WNDPROC
, (LONG_PTR
)Filesets_RepSites_SubclassListProc
);
269 TCHAR szServer
[ cchNAME
];
270 TCHAR szFileset
[ cchNAME
];
271 TCHAR szAggregate
[ cchNAME
];
272 prp
->lpiRW
->GetServerName (szServer
);
273 prp
->lpiRW
->GetAggregateName (szAggregate
);
274 prp
->lpiRW
->GetFilesetName (szFileset
);
275 SetDlgItemText (hDlg
, IDC_SET_SERVER
, szServer
);
276 SetDlgItemText (hDlg
, IDC_SET_AGGREGATE
, szAggregate
);
277 SetDlgItemText (hDlg
, IDC_SET_NAME
, szFileset
);
279 FL_RestoreView (GetDlgItem (hDlg
, IDC_SET_REP_LIST
), &gr
.viewRep
);
280 UpdateDisplay_Replicas (FALSE
, GetDlgItem (hDlg
, IDC_SET_REP_LIST
), prp
->lpiRW
, prp
->lpiReq
);
284 void Filesets_RepSites_OnSelect (HWND hDlg
)
286 LPIDENT lpiSelected
= (LPIDENT
)FL_GetSelectedData (GetDlgItem (hDlg
, IDC_SET_REP_LIST
));
287 EnableWindow (GetDlgItem (hDlg
, IDC_SET_REPSITE_DELETE
), (lpiSelected
!= NULL
));
291 void Filesets_RepSites_OnDelete (HWND hDlg
)
293 LPIDENT lpiSelected
= (LPIDENT
)FL_GetSelectedData (GetDlgItem (hDlg
, IDC_SET_REP_LIST
));
295 Filesets_Delete (lpiSelected
);