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
11 #include <afs/param.h>
15 #include "TaAfsUsrMgr.h"
16 #include "grp_rename.h"
21 * DEFINITIONS ________________________________________________________________
27 * PROTOTYPES _________________________________________________________________
31 BOOL CALLBACK
Group_Rename_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
32 void Group_Rename_OnInitDialog (HWND hDlg
);
33 void Group_Rename_OnDestroy (HWND hDlg
);
34 void Group_Rename_OnNewName (HWND hDlg
);
35 void Group_Rename_OnChangeOwner (HWND hDlg
);
36 void Group_Rename_OnOK (HWND hDlg
);
37 void Group_Rename_UpdateDialog (HWND hDlg
);
41 * ROUTINES ___________________________________________________________________
45 void Group_ShowRename (HWND hParent
, ASID idGroup
)
47 ModalDialogParam (IDD_GROUP_RENAME
, hParent
, (DLGPROC
)Group_Rename_DlgProc
, (LPARAM
)idGroup
);
51 BOOL CALLBACK
Group_Rename_DlgProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
53 if (AfsAppLib_HandleHelp (IDD_GROUP_RENAME
, hDlg
, msg
, wp
, lp
))
59 SetWindowLongPtr (hDlg
, DWLP_USER
, lp
);
60 Group_Rename_OnInitDialog (hDlg
);
64 Group_Rename_OnDestroy (hDlg
);
67 case WM_ASC_NOTIFY_OBJECT
:
68 Group_Rename_UpdateDialog (hDlg
);
75 Group_Rename_OnOK (hDlg
);
76 EndDialog (hDlg
, IDOK
);
80 EndDialog (hDlg
, IDCANCEL
);
83 case IDC_RENAME_NEWNAME
:
84 Group_Rename_OnNewName (hDlg
);
87 case IDC_RENAME_CHOWN
:
88 Group_Rename_OnChangeOwner (hDlg
);
98 void Group_Rename_OnInitDialog (HWND hDlg
)
100 ASID idGroup
= (ASID
)GetWindowLongPtr (hDlg
, DWLP_USER
);
102 // Indicate we want to know if anything changes with this group
104 LPOBJECT_LISTEN_PARAMS pTask
= New (OBJECT_LISTEN_PARAMS
);
105 memset (pTask
, 0x00, sizeof(OBJECT_LISTEN_PARAMS
));
106 pTask
->hNotify
= hDlg
;
107 asc_AsidListCreate (&pTask
->pAsidList
);
108 asc_AsidListAddEntry (&pTask
->pAsidList
, idGroup
, 0);
109 StartTask (taskOBJECT_LISTEN
, NULL
, pTask
);
111 // Update the dialog's information
113 SetDlgItemText (hDlg
, IDC_RENAME_NEWNAME
, TEXT(""));
114 Group_Rename_UpdateDialog (hDlg
);
118 void Group_Rename_OnDestroy (HWND hDlg
)
120 // Indicate we no longer care if anything changes with this group
122 LPOBJECT_LISTEN_PARAMS pTask
= New (OBJECT_LISTEN_PARAMS
);
123 memset (pTask
, 0x00, sizeof(OBJECT_LISTEN_PARAMS
));
124 pTask
->hNotify
= hDlg
;
125 StartTask (taskOBJECT_LISTEN
, NULL
, pTask
);
129 void Group_Rename_OnNewName (HWND hDlg
)
131 TCHAR szOldName
[ cchNAME
];
132 GetDlgItemText (hDlg
, IDC_RENAME_OLDNAME
, szOldName
, cchNAME
);
134 TCHAR szNewName
[ cchNAME
];
135 GetDlgItemText (hDlg
, IDC_RENAME_NEWNAME
, szNewName
, cchNAME
);
140 if (!lstrcmp (szOldName
, szNewName
))
143 EnableWindow (GetDlgItem (hDlg
, IDOK
), fEnable
);
147 void Group_Rename_OnChangeOwner (HWND hDlg
)
149 ASID idGroup
= (ASID
)GetWindowLongPtr (hDlg
, DWLP_USER
);
152 memset (&pp
, 0x00, sizeof(pp
));
154 pp
.iddForHelp
= IDD_BROWSE_OWNER
;
155 pp
.idsTitle
= IDS_GROUP_CHANGEOWNER_TITLE
;
156 pp
.idsPrompt
= IDS_GROUP_CHANGEOWNER_PROMPT
;
158 pp
.TypeToShow
= (ASOBJTYPE
)( (ULONG
)TYPE_USER
| (ULONG
)TYPE_GROUP
);
159 pp
.fAllowMultiple
= FALSE
;
162 ASOBJPROP Properties
;
163 if (asc_ObjectPropertiesGet_Fast (g
.idClient
, g
.idCell
, idGroup
, &Properties
, &status
))
165 lstrcpy (pp
.szName
, Properties
.u
.GroupProperties
.szOwner
);
167 if (ShowBrowseDialog (&pp
))
169 LPGROUP_CHANGE_PARAMS pTask
= New (GROUP_CHANGE_PARAMS
);
170 pTask
->idGroup
= idGroup
;
171 pTask
->NewProperties
.aaListStatus
= Properties
.u
.GroupProperties
.aaListStatus
;
172 pTask
->NewProperties
.aaListGroupsOwned
= Properties
.u
.GroupProperties
.aaListGroupsOwned
;
173 pTask
->NewProperties
.aaListMembers
= Properties
.u
.GroupProperties
.aaListMembers
;
174 pTask
->NewProperties
.aaAddMember
= Properties
.u
.GroupProperties
.aaAddMember
;
175 pTask
->NewProperties
.aaDeleteMember
= Properties
.u
.GroupProperties
.aaDeleteMember
;
176 lstrcpy (pTask
->NewProperties
.szOwner
, pp
.szName
);
177 StartTask (taskGROUP_CHANGE
, NULL
, pTask
);
181 if (pp
.pObjectsSelected
)
182 asc_AsidListFree (&pp
.pObjectsSelected
);
186 void Group_Rename_OnOK (HWND hDlg
)
188 ASID idGroup
= (ASID
)GetWindowLongPtr (hDlg
, DWLP_USER
);
190 LPGROUP_RENAME_PARAMS lpp
= New (GROUP_RENAME_PARAMS
);
191 memset (lpp
, 0x00, sizeof(GROUP_RENAME_PARAMS
));
192 lpp
->idGroup
= idGroup
;
193 GetDlgItemText (hDlg
, IDC_RENAME_NEWNAME
, lpp
->szNewName
, cchNAME
);
195 StartTask (taskGROUP_RENAME
, NULL
, lpp
);
199 void Group_Rename_UpdateDialog (HWND hDlg
)
201 ASID idGroup
= (ASID
)GetWindowLongPtr (hDlg
, DWLP_USER
);
203 // Get the current properties for this group
206 TCHAR szName
[ cchNAME
];
207 asc_ObjectNameGet_Fast (g
.idClient
, g
.idCell
, idGroup
, szName
, &status
);
209 ASOBJPROP Properties
;
210 if (!asc_ObjectPropertiesGet_Fast (g
.idClient
, g
.idCell
, idGroup
, &Properties
, &status
))
211 GetString (Properties
.u
.GroupProperties
.szOwner
, IDS_UNKNOWN_NAME
);
212 SetDlgItemText (hDlg
, IDC_RENAME_OWNER
, Properties
.u
.GroupProperties
.szOwner
);
214 // Fill in the text at the top of the dialog
216 LPTSTR pszText
= FormatString (IDS_RENAME_TITLE
, TEXT("%s"), szName
);
217 SetDlgItemText (hDlg
, IDC_RENAME_TITLE
, pszText
);
218 FreeString (pszText
);
220 // Prepare the New Name control and disable the OK button
222 SetDlgItemText (hDlg
, IDC_RENAME_OLDNAME
, szName
);
223 Group_Rename_OnNewName (hDlg
);