Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afssvrmgr / set_rename.cpp
blob1eefafbb32ebc8dbd5042884f11158f4614ff9e5
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_rename.h"
23 * PROTOTYPES _________________________________________________________________
27 BOOL CALLBACK Filesets_Rename_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
28 void Filesets_Rename_OnInitDialog (HWND hDlg, LPSET_RENAME_APPLY_PARAMS psrp);
29 void Filesets_Rename_EnableOK (HWND hDlg, LPSET_RENAME_APPLY_PARAMS psrp);
33 * ROUTINES ___________________________________________________________________
37 void Filesets_ShowRename (LPIDENT lpiFileset)
39 LPSET_RENAME_INIT_PARAMS lpp = New (SET_RENAME_INIT_PARAMS);
40 memset (lpp, 0x00, sizeof(SET_RENAME_INIT_PARAMS));
41 lpp->lpiReq = lpiFileset;
43 StartTask (taskSET_RENAME_INIT, g.hMain, lpp);
47 void Filesets_OnEndTask_ShowRename (LPTASKPACKET ptp)
49 LPSET_RENAME_INIT_PARAMS lpp = (LPSET_RENAME_INIT_PARAMS)(ptp->lpUser);
51 TCHAR szSvrName[ cchNAME ];
52 TCHAR szAggName[ cchNAME ];
53 TCHAR szSetName[ cchNAME ];
54 lpp->lpiReq->GetServerName (szSvrName);
55 lpp->lpiReq->GetAggregateName (szAggName);
56 lpp->lpiReq->GetFilesetName (szSetName);
58 if (!ptp->rc)
60 ErrorDialog (ptp->status, IDS_ERROR_REFRESH_FILESET_STATUS, TEXT("%s%s%s"), szSvrName, szAggName, szSetName);
62 else if (!lpp->lpiRW) // couldn't find RW fileset entry?
64 ErrorDialog (ptp->status, IDS_ERROR_NOT_REPLICATED, TEXT("%s"), szSetName);
66 else
68 LPSET_RENAME_APPLY_PARAMS psrp = New (SET_RENAME_APPLY_PARAMS);
69 memset (psrp, 0x00, sizeof(SET_RENAME_APPLY_PARAMS));
70 psrp->lpiFileset = lpp->lpiRW;
72 INT_PTR rc = ModalDialogParam (IDD_SET_RENAME, GetActiveWindow(), (DLGPROC)Filesets_Rename_DlgProc, (LPARAM)psrp);
73 if (rc != IDOK)
75 Delete (psrp);
77 else
79 StartTask (taskSET_RENAME_APPLY, NULL, psrp);
83 Delete (lpp);
87 BOOL CALLBACK Filesets_Rename_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
89 if (AfsAppLib_HandleHelp (IDD_SET_RENAME, hDlg, msg, wp, lp))
90 return TRUE;
92 static LPSET_RENAME_APPLY_PARAMS psrp = NULL;
93 if (msg == WM_INITDIALOG)
94 psrp = (LPSET_RENAME_APPLY_PARAMS)lp;
96 if (psrp != NULL)
98 switch (msg)
100 case WM_INITDIALOG:
101 Filesets_Rename_OnInitDialog (hDlg, psrp);
102 break;
104 case WM_COMMAND:
105 switch (LOWORD(wp))
107 case IDOK:
108 case IDCANCEL:
109 EndDialog (hDlg, LOWORD(wp));
110 break;
112 case IDC_RENSET_NEW:
113 Filesets_Rename_EnableOK (hDlg, psrp);
114 break;
116 case IDHELP:
117 WinHelp (hDlg, cszHELPFILENAME, HELP_CONTEXT, IDH_SVRMGR_RENAMEFILESET_OVERVIEW);
118 break;
120 break;
122 case WM_DESTROY:
123 psrp = NULL;
124 break;
128 return FALSE;
132 void Filesets_Rename_OnInitDialog (HWND hDlg, LPSET_RENAME_APPLY_PARAMS psrp)
134 TCHAR szServer[ cchNAME ];
135 TCHAR szAggregate[ cchNAME ];
136 TCHAR szFileset[ cchNAME ];
138 psrp->lpiFileset->GetServerName (szServer);
139 psrp->lpiFileset->GetAggregateName (szAggregate);
140 psrp->lpiFileset->GetFilesetName (szFileset);
142 TCHAR szOld[ cchRESOURCE ];
144 GetDlgItemText (hDlg, IDC_RENSET_DESC, szOld, cchRESOURCE);
145 LPTSTR pszNew = FormatString (szOld, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
146 SetDlgItemText (hDlg, IDC_RENSET_DESC, pszNew);
147 FreeString (pszNew);
149 SetDlgItemText (hDlg, IDC_RENSET_OLD, szFileset);
150 SetDlgItemText (hDlg, IDC_RENSET_NEW, szFileset);
152 PostMessage (hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg,IDC_RENSET_NEW), TRUE);
154 Filesets_Rename_EnableOK (hDlg, psrp);
158 void Filesets_Rename_EnableOK (HWND hDlg, LPSET_RENAME_APPLY_PARAMS psrp)
160 TCHAR szOld[ cchNAME ];
162 GetDlgItemText (hDlg, IDC_RENSET_OLD, szOld, cchNAME);
163 GetDlgItemText (hDlg, IDC_RENSET_NEW, psrp->szNewName, cchNAME);
165 BOOL fEnable = TRUE;
167 if (!psrp->szNewName[0])
169 fEnable = FALSE;
171 else if (!lstrcmpi (szOld, psrp->szNewName))
173 fEnable = FALSE;
176 EnableWindow (GetDlgItem (hDlg, IDOK), fEnable);