Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

345 lines
7.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. voldel.cxx
  7. Contains the dialog for managing volumes in the server manager
  8. VOLUME_DELETE_DIALOG
  9. FILE HISTORY:
  10. NarenG 11/11/92 Modified sharemgt.cxx for AFPMGR
  11. */
  12. #define INCL_WINDOWS_GDI
  13. #define INCL_WINDOWS
  14. #define INCL_DOSERRORS
  15. #define INCL_NETERRORS
  16. #define INCL_NETSERVER
  17. #define INCL_NETSHARE
  18. #define INCL_NETCONS
  19. #define INCL_NETLIB
  20. #include <lmui.hxx>
  21. #define INCL_BLT_WINDOW
  22. #define INCL_BLT_DIALOG
  23. #define INCL_BLT_CONTROL
  24. #define INCL_BLT_MISC
  25. #define INCL_BLT_CLIENT
  26. #define INCL_BLT_MSGPOPUP
  27. #define INCL_BLT_SPIN_GROUP
  28. #define INCL_BLT_GROUP
  29. #include <blt.hxx>
  30. extern "C"
  31. {
  32. #include <afpmgr.h>
  33. #include <macfile.h>
  34. }
  35. #include <lmoloc.hxx>
  36. #include <string.hxx>
  37. #include <uitrace.hxx>
  38. #include "voldel.hxx"
  39. /*******************************************************************
  40. NAME: VOLUME_DELETE_DIALOG::VOLUME_DELETE_DIALOG
  41. SYNOPSIS: Constructor
  42. ENTRY: hwndParent - hwnd of the parent window
  43. hServer - handle to the target server
  44. pszServerName - name of the selected computer
  45. EXIT:
  46. RETURNS:
  47. NOTES:
  48. HISTORY:
  49. NarenG 11/18/92 Modified for AFPMGR
  50. ********************************************************************/
  51. VOLUME_DELETE_DIALOG::VOLUME_DELETE_DIALOG(
  52. HWND hwndOwner,
  53. AFP_SERVER_HANDLE hServer,
  54. const TCHAR *pszServerName,
  55. const TCHAR *pszPath,
  56. BOOL fIsFile )
  57. : VIEW_VOLUMES_DIALOG_BASE( MAKEINTRESOURCE(IDD_VOLUME_DELETE_DLG),
  58. hwndOwner,
  59. hServer,
  60. pszServerName,
  61. TRUE,
  62. IDDV_SLT_VOLUME_TITLE,
  63. IDDV_LB_VOLUMES),
  64. _pbOK( this, IDOK ),
  65. _pbCancel( this, IDCANCEL ),
  66. _hServer( hServer ),
  67. _sltVolumeTitle( this, IDDV_SLT_VOLUME_TITLE )
  68. {
  69. AUTO_CURSOR Cursor;
  70. //
  71. // Make sure everything constructed OK
  72. //
  73. if ( QueryError() != NERR_Success )
  74. return;
  75. //
  76. // Set the text of the list box title
  77. //
  78. DWORD err;
  79. NLS_STR nlsServer;
  80. LOCATION Loc( pszServerName );
  81. RESOURCE_STR nlsTitle( IDS_VOLUMES_LB_TITLE_TEXT );
  82. if ( ((err = nlsTitle.QueryError()) != NERR_Success ) ||
  83. ((err = _sltVolumeTitle.QueryError()) != NERR_Success ) ||
  84. ((err = nlsServer.QueryError()) != NERR_Success ) ||
  85. ((err = Loc.QueryDisplayName( &nlsServer )) != NERR_Success ) ||
  86. ((err = nlsTitle.InsertParams( nlsServer )) != NERR_Success ))
  87. {
  88. ReportError( err );
  89. return;
  90. }
  91. _sltVolumeTitle.SetText( nlsTitle );
  92. err = Refresh();
  93. if ( err != NO_ERROR )
  94. {
  95. ReportError( err );
  96. return;
  97. }
  98. //
  99. // If there are not items then tell the user that there are no
  100. // items to delete
  101. //
  102. if ( QueryLBVolumes()->QueryCount() == 0 )
  103. {
  104. ::MsgPopup( this, IDS_NO_VOLUMES, MPSEV_INFO );
  105. ReportError( ERROR_ALREADY_REPORTED );
  106. return;
  107. }
  108. //
  109. // If a directory was selected then select the volume item that has a
  110. // matching path.
  111. //
  112. if ( !fIsFile )
  113. {
  114. err = SelectVolumeItem( pszPath );
  115. if ( err != NO_ERROR )
  116. {
  117. ReportError( err );
  118. return;
  119. }
  120. }
  121. }
  122. /*******************************************************************
  123. NAME: VOLUME_DELETE_DIALOG::OnOK
  124. SYNOPSIS: Gather information and delete the volumes selected
  125. in the listbox.
  126. ENTRY:
  127. EXIT:
  128. RETURNS:
  129. NOTES:
  130. HISTORY:
  131. NarenG 11/18/92 Modified for AFPMGR
  132. ********************************************************************/
  133. BOOL VOLUME_DELETE_DIALOG::OnOK( VOID )
  134. {
  135. AUTO_CURSOR AutoCursor;
  136. APIERR err = NERR_Success;
  137. VIEW_VOLUMES_LISTBOX *plbVolume = QueryLBVolumes();
  138. INT ciMax = plbVolume->QuerySelCount();
  139. //
  140. // If there are no items selected in the listbox,
  141. // just dismiss the dialog.
  142. //
  143. if ( ciMax == 0 )
  144. {
  145. Dismiss( FALSE );
  146. return TRUE;
  147. }
  148. //
  149. // Warn the user.
  150. //
  151. if ( ::MsgPopup( this,
  152. IDS_DELETE_VOLUME_CONFIRM,
  153. MPSEV_WARNING,
  154. MP_YESNO,
  155. MP_YES ) == IDNO )
  156. {
  157. Dismiss( FALSE );
  158. return TRUE;
  159. }
  160. //
  161. // Get all the items selected in the listbox
  162. //
  163. INT *paSelItems = (INT *) new BYTE[ sizeof(INT) * ciMax ];
  164. if ( paSelItems == NULL )
  165. {
  166. ::MsgPopup( this, ERROR_NOT_ENOUGH_MEMORY);
  167. return TRUE;
  168. }
  169. err = plbVolume->QuerySelItems( paSelItems, ciMax );
  170. UIASSERT( err == NERR_Success );
  171. //
  172. // Loop through each volume that the user selects in the listbox
  173. // and delete the volume. We will break out of the loop
  174. // if any error occurred in deleting a volume or if the user
  175. // decides not to delete a volume that some user is connected to.
  176. //
  177. BOOL fCancel;
  178. VIEW_VOLUMES_LBI *pvlbi = NULL;
  179. for ( INT i = 0; i < ciMax; i++ )
  180. {
  181. pvlbi = plbVolume->QueryItem( paSelItems[i] );
  182. err = VolumeDelete( pvlbi, &fCancel );
  183. if ( fCancel || ( err != NO_ERROR ))
  184. break;
  185. }
  186. delete paSelItems;
  187. paSelItems = NULL;
  188. //
  189. // Dismiss the dialog only if everything went on smoothly.
  190. //
  191. if ( err != NO_ERROR )
  192. {
  193. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  194. }
  195. else if ( !fCancel )
  196. {
  197. Dismiss( TRUE );
  198. return TRUE;
  199. }
  200. //
  201. // Refresh the listbox.
  202. //
  203. err = Refresh();
  204. if ( err != NO_ERROR )
  205. {
  206. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  207. Dismiss( FALSE );
  208. }
  209. else
  210. {
  211. if ( plbVolume->QueryCount() > 0 )
  212. {
  213. plbVolume->SelectItem( 0 );
  214. plbVolume->ClaimFocus();
  215. }
  216. else
  217. {
  218. _pbOK.Enable( FALSE );
  219. _pbCancel.ClaimFocus();
  220. }
  221. }
  222. return TRUE;
  223. }
  224. /*******************************************************************
  225. NAME: VOLUME_DELETE_DIALOG::OnVolumeLbDblClk
  226. SYNOPSIS: This is called when the user double clicks on a share
  227. in the listbox.
  228. ENTRY:
  229. EXIT:
  230. RETURNS:
  231. NOTES:
  232. HISTORY:
  233. NarenG 11/18/92 Modified for AFPMGR
  234. ********************************************************************/
  235. BOOL VOLUME_DELETE_DIALOG::OnVolumeLbDblClk( VOID )
  236. {
  237. return OnOK();
  238. }
  239. /*******************************************************************
  240. NAME: VOLUME_DELETE_DIALOG::QueryHelpContext
  241. SYNOPSIS: Query the help context of the dialog
  242. ENTRY:
  243. EXIT:
  244. RETURNS: Return the help context of the dialog
  245. NOTES:
  246. HISTORY:
  247. NarenG 11/18/92 Modified for AFPMGR
  248. ********************************************************************/
  249. ULONG VOLUME_DELETE_DIALOG::QueryHelpContext( VOID )
  250. {
  251. return HC_VOLUME_DELETE_DIALOG;
  252. }