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_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
);
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
);
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
);
79 StartTask (taskSET_RENAME_APPLY
, NULL
, psrp
);
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
))
92 static LPSET_RENAME_APPLY_PARAMS psrp
= NULL
;
93 if (msg
== WM_INITDIALOG
)
94 psrp
= (LPSET_RENAME_APPLY_PARAMS
)lp
;
101 Filesets_Rename_OnInitDialog (hDlg
, psrp
);
109 EndDialog (hDlg
, LOWORD(wp
));
113 Filesets_Rename_EnableOK (hDlg
, psrp
);
117 WinHelp (hDlg
, cszHELPFILENAME
, HELP_CONTEXT
, IDH_SVRMGR_RENAMEFILESET_OVERVIEW
);
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
);
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
);
167 if (!psrp
->szNewName
[0])
171 else if (!lstrcmpi (szOld
, psrp
->szNewName
))
176 EnableWindow (GetDlgItem (hDlg
, IDOK
), fEnable
);