Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / set_repprop.cpp
blob4ad49fb3e32a43a861bbf9d2e1366870ab21ecf4
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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
8 */
10 #include <winsock2.h>
11 #include <ws2tcpip.h>
13 extern "C" {
14 #include <afs/param.h>
15 #include <afs/stds.h>
18 #include "svrmgr.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"
24 #include "display.h"
25 #include "columns.h"
29 * DEFINITIONS ________________________________________________________________
33 typedef struct
35 LPIDENT lpiReq;
36 LPIDENT lpiRW;
37 FILESETSTATUS fs;
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);
77 if (!ptp->rc)
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);
85 else
87 HWND hCurrent;
88 if ((hCurrent = PropCache_Search (pcSET_REP, lpp->lpiRW)) != NULL)
90 SetFocus (hCurrent);
92 else
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);
111 Delete (lpp);
115 BOOL CALLBACK Filesets_RepSites_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
117 if (HandleColumnNotify (hDlg, msg, wp, lp, &gr.viewRep))
118 return FALSE;
120 if (AfsAppLib_HandleHelp (IDD_SET_REPSITES, hDlg, msg, wp, lp))
121 return TRUE;
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);
134 else
136 LPSET_REPPROP_PARAMS prp;
137 if ((prp = (LPSET_REPPROP_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL)
139 switch (msg)
141 case WM_INITDIALOG:
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);
145 break;
147 case WM_DESTROY:
148 DontNotifyMeEver (hDlg);
149 SetWindowLongPtr (hDlg, DWLP_USER, 0);
150 Delete (prp);
151 break;
153 case WM_CONTEXTMENU:
154 if ((HWND)wp == GetDlgItem (hDlg, IDC_SET_REP_LIST))
156 HWND hList = GetDlgItem (hDlg, IDC_SET_REP_LIST);
158 POINT ptScreen;
159 ptScreen.x = LOWORD(lp);
160 ptScreen.y = HIWORD(lp);
162 POINT ptClient;
163 ptClient = ptScreen;
164 ScreenToClient ((HWND)wp, &ptClient);
166 if (FL_HitTestForHeaderBar (hList, ptClient))
168 HMENU hm = TaLocale_LoadMenu (MENU_COLUMNS);
169 DisplayContextMenu (hm, ptScreen, hList);
172 break;
174 case WM_COLUMNS_CHANGED:
175 HWND hList;
176 hList = GetDlgItem (hDlg, IDC_SET_REP_LIST);
177 LPIDENT lpiSel;
178 lpiSel = (LPIDENT)FL_GetSelectedData (hList);
179 FL_RestoreView (hList, &gr.viewRep);
180 UpdateDisplay_Replicas (FALSE, hList, prp->lpiRW, lpiSel);
181 break;
183 case WM_COMMAND:
184 switch (LOWORD(wp))
186 case IDOK:
187 case IDCANCEL:
188 case IDAPPLY:
189 break;
191 case IDC_SET_REPSITE_ADD:
192 Filesets_CreateReplica (prp->lpiRW);
193 break;
195 case IDC_SET_REPSITE_DELETE:
196 Filesets_RepSites_OnDelete (hDlg);
197 break;
199 case IDC_SET_RELEASE:
200 Filesets_Release (prp->lpiRW);
201 break;
203 break;
205 case WM_NOTIFY_FROM_DISPATCH:
206 UpdateDisplay_Replicas (FALSE, GetDlgItem (hDlg, IDC_SET_REP_LIST), prp->lpiRW, prp->lpiReq);
207 Delete ((LPNOTIFYSTRUCT)lp);
208 break;
210 case WM_NOTIFY:
211 switch (((LPNMHDR)lp)->code)
213 case FLN_COLUMNRESIZE:
214 FL_StoreView (GetDlgItem (hDlg, IDC_SET_REP_LIST), &gr.viewRep);
215 break;
217 case FLN_ITEMSELECT:
218 Filesets_RepSites_OnSelect (hDlg);
219 break;
221 break;
226 return FALSE;
230 static LONG_PTR procRepSitesList = 0;
232 LRESULT CALLBACK Filesets_RepSites_SubclassListProc (HWND hList, UINT msg, WPARAM wp, LPARAM lp)
234 LRESULT rc;
236 if (procRepSitesList == 0)
237 rc = DefWindowProc (hList, msg, wp, lp);
238 else
239 rc = CallWindowProc ((WNDPROC)procRepSitesList, hList, msg, wp, lp);
241 switch (msg)
243 case WM_DESTROY:
244 if (procRepSitesList != 0)
245 SetWindowLongPtr (hList, GWLP_WNDPROC, procRepSitesList);
246 break;
248 case WM_COMMAND:
249 switch (LOWORD(wp))
251 case M_COLUMNS:
252 ShowColumnsDialog (GetParent (hList), &gr.viewRep);
253 break;
255 break;
258 return rc;
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));
294 if (lpiSelected)
295 Filesets_Delete (lpiSelected);