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.

521 lines
10 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1992 **/
  4. /**********************************************************************/
  5. /*
  6. * volmgt.cxx
  7. * Contains the dialog for managing volumes in the server manager
  8. * VOLUME_MANAGEMENT_DIALOG
  9. *
  10. * FILE HISTORY:
  11. * NarenG 11/11/92 Modified sharemgt.cxx for AFPMGR
  12. *
  13. */
  14. #define INCL_WINDOWS_GDI
  15. #define INCL_WINDOWS
  16. #define INCL_DOSERRORS
  17. #define INCL_NETERRORS
  18. #define INCL_NETSERVER
  19. #define INCL_NETSHARE
  20. #define INCL_NETCONS
  21. #define INCL_NETLIB
  22. #include <lmui.hxx>
  23. #define INCL_BLT_WINDOW
  24. #define INCL_BLT_DIALOG
  25. #define INCL_BLT_CONTROL
  26. #define INCL_BLT_MISC
  27. #define INCL_BLT_CLIENT
  28. #define INCL_BLT_MSGPOPUP
  29. #define INCL_BLT_SPIN_GROUP
  30. #define INCL_BLT_GROUP
  31. #include <blt.hxx>
  32. extern "C"
  33. {
  34. #include <afpmgr.h>
  35. #include <macfile.h>
  36. }
  37. #include <string.hxx>
  38. #include <uitrace.hxx>
  39. #include <newvol.hxx>
  40. #include <volprop.hxx>
  41. #include "util.hxx"
  42. #include "volmgt.hxx"
  43. /*******************************************************************
  44. NAME: VOLUME_MANAGEMENT_DIALOG::VOLUME_MANAGEMENT_DIALOG
  45. SYNOPSIS: Constructor
  46. ENTRY: hwndParent - hwnd of the parent window
  47. hServer - handle to the target server
  48. pszServerName - name of the selected computer
  49. EXIT:
  50. RETURNS:
  51. NOTES:
  52. HISTORY:
  53. NarenG 11/18/92 Modified for AFPMGR
  54. ********************************************************************/
  55. VOLUME_MANAGEMENT_DIALOG::VOLUME_MANAGEMENT_DIALOG(
  56. HWND hwndOwner,
  57. AFP_SERVER_HANDLE hServer,
  58. const TCHAR *pszServerName )
  59. : VIEW_VOLUMES_DIALOG_BASE( MAKEINTRESOURCE(IDD_VOLUME_MANAGEMENT_DLG),
  60. hwndOwner,
  61. hServer,
  62. pszServerName,
  63. TRUE,
  64. IDVM_SLT_VOLUME_TITLE,
  65. IDVM_LB_VOLUMES),
  66. _pbVolumeDelete( this, IDVM_PB_DELETE_VOL ),
  67. _pbVolumeInfo( this, IDVM_PB_VOL_INFO ),
  68. _hServer( hServer ),
  69. _nlsServerName( pszServerName ),
  70. _pbClose( this, IDOK )
  71. {
  72. //
  73. // Just to be cool
  74. //
  75. AUTO_CURSOR Cursor;
  76. //
  77. // Make sure everything constructed OK
  78. //
  79. if ( QueryError() != NERR_Success )
  80. return;
  81. DWORD err;
  82. if ( ( err = _nlsServerName.QueryError() ) != NERR_Success )
  83. {
  84. ReportError( err );
  85. return;
  86. }
  87. //
  88. // Set the caption to "Volumes on Server".
  89. //
  90. err = ::SetCaption( this, IDS_CAPTION_VOLUMES, pszServerName );
  91. if ( err != NO_ERROR )
  92. {
  93. ReportError( err );
  94. return;
  95. }
  96. err = Refresh();
  97. if ( err != NO_ERROR )
  98. {
  99. ReportError( err );
  100. return;
  101. }
  102. ResetControls();
  103. }
  104. /*******************************************************************
  105. NAME: VOLUME_MANAGEMENT_DIALOG::Refresh
  106. SYNOPSIS: Refresh the volume listbox
  107. ENTRY:
  108. EXIT:
  109. RETURNS:
  110. NOTES:
  111. HISTORY:
  112. NarenG 11/18/92 Modified for AFPMGR
  113. ********************************************************************/
  114. DWORD VOLUME_MANAGEMENT_DIALOG::Refresh( VOID )
  115. {
  116. //
  117. // Just to be cool
  118. //
  119. AUTO_CURSOR Cursor;
  120. DWORD err = VIEW_VOLUMES_DIALOG_BASE::Refresh();
  121. ResetControls();
  122. return err;
  123. }
  124. /*******************************************************************
  125. NAME: VOLUME_MANAGEMENT_DIALOG::ResetControls
  126. SYNOPSIS: Enable/Disable/MakeDefault the push buttons according
  127. to whether there are items in the listbox
  128. ENTRY:
  129. EXIT:
  130. RETURNS:
  131. NOTES:
  132. HISTORY:
  133. NarenG 11/18/92 Modified for AFPMGR
  134. ********************************************************************/
  135. VOID VOLUME_MANAGEMENT_DIALOG::ResetControls( VOID )
  136. {
  137. INT nCount = QueryLBVolumes()->QueryCount();
  138. //
  139. // If there are items in the listbox, select the first one
  140. // and set focus to the listbox.
  141. //
  142. if ( nCount > 0 )
  143. {
  144. QueryLBVolumes()->SelectItem( 0 );
  145. QueryLBVolumes()->ClaimFocus();
  146. _pbVolumeDelete.Enable( TRUE );
  147. _pbVolumeInfo.Enable( IsFocusOnGoodVolume() );
  148. }
  149. else
  150. {
  151. //
  152. // Else set focus to the Close button
  153. //
  154. _pbClose.MakeDefault();
  155. _pbClose.ClaimFocus();
  156. _pbVolumeDelete.Enable( FALSE );
  157. _pbVolumeInfo.Enable( FALSE );
  158. }
  159. }
  160. /*******************************************************************
  161. NAME: VOLUME_MANAGEMENT_DIALOG::OnCommand
  162. SYNOPSIS: Handle all push buttons commands
  163. ENTRY: event - the CONTROL_EVENT that occurred
  164. EXIT:
  165. RETURNS:
  166. NOTES:
  167. HISTORY:
  168. NarenG 11/18/92 Modified for AFPMGR
  169. ********************************************************************/
  170. BOOL VOLUME_MANAGEMENT_DIALOG::OnCommand( const CONTROL_EVENT &event )
  171. {
  172. switch ( event.QueryCid() )
  173. {
  174. case IDVM_PB_DELETE_VOL:
  175. return( OnVolumeDelete() );
  176. case IDVM_PB_VOL_INFO:
  177. return( OnVolumeInfo() );
  178. break;
  179. case IDVM_PB_ADD_VOLUME:
  180. return( OnVolumeAdd() );
  181. break;
  182. case IDVM_LB_VOLUMES:
  183. _pbVolumeInfo.Enable( IsFocusOnGoodVolume() );
  184. break;
  185. default:
  186. break;
  187. }
  188. return( VIEW_VOLUMES_DIALOG_BASE::OnCommand( event ) );
  189. }
  190. /*******************************************************************
  191. NAME: VOLUME_MANAGEMENT_DIALOG::OnVolumeDelete
  192. SYNOPSIS: Called when the "Stop Sharing" button is pressed.
  193. Delete the selected share and pop up any warning
  194. message if there are users connected to the share.
  195. ENTRY:
  196. EXIT:
  197. RETURNS:
  198. NOTES:
  199. HISTORY:
  200. NarenG 11/18/92 Modified for AFPMGR
  201. ********************************************************************/
  202. BOOL VOLUME_MANAGEMENT_DIALOG::OnVolumeDelete( VOID )
  203. {
  204. //
  205. // First warn the user.
  206. //
  207. if ( ::MsgPopup( this,
  208. IDS_DELETE_VOLUME_CONFIRM,
  209. MPSEV_WARNING,
  210. MP_YESNO,
  211. MP_YES ) == IDNO )
  212. {
  213. return NO_ERROR;
  214. }
  215. //
  216. // Just to be cool
  217. //
  218. AUTO_CURSOR Cursor;
  219. VIEW_VOLUMES_LISTBOX *plbVolume = QueryLBVolumes();
  220. VIEW_VOLUMES_LBI *pvlbi = plbVolume->QueryItem();
  221. BOOL fCancel;
  222. //
  223. // Delete the selected item in the listbox
  224. //
  225. DWORD err = VolumeDelete( pvlbi, &fCancel );
  226. if ( err != NO_ERROR )
  227. {
  228. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  229. }
  230. if ( ( err = Refresh() ) != NO_ERROR )
  231. {
  232. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  233. return FALSE;
  234. }
  235. return TRUE;
  236. }
  237. /*******************************************************************
  238. NAME: VOLUME_MANAGEMENT_DIALOG::OnVolumeAdd
  239. SYNOPSIS: Called when the "New Volume" button is pressed.
  240. ENTRY:
  241. EXIT:
  242. RETURNS:
  243. NOTES:
  244. HISTORY:
  245. NarenG 11/18/92 Modified for AFPMGR
  246. ********************************************************************/
  247. BOOL VOLUME_MANAGEMENT_DIALOG::OnVolumeAdd( VOID )
  248. {
  249. //
  250. // Just to be cool
  251. //
  252. AUTO_CURSOR Cursor;
  253. DWORD err = NO_ERROR;
  254. NEW_VOLUME_SRVMGR_DIALOG *pDlg = new NEW_VOLUME_SRVMGR_DIALOG(
  255. QueryHwnd(),
  256. _hServer,
  257. _nlsServerName.QueryPch() );
  258. if ( ( pDlg == NULL )
  259. || ((err = pDlg->QueryError()) != NERR_Success )
  260. || ((err = pDlg->Process()) != NERR_Success )
  261. )
  262. {
  263. err = err ? err : ERROR_NOT_ENOUGH_MEMORY;
  264. }
  265. delete pDlg;
  266. pDlg = NULL;
  267. if ( err != NO_ERROR )
  268. {
  269. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  270. }
  271. if ( ( err = Refresh() ) != NO_ERROR )
  272. {
  273. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  274. return FALSE;
  275. }
  276. return TRUE;
  277. }
  278. /*******************************************************************
  279. NAME: VOLUME_MANAGEMENT_DIALOG::OnVolumeInfo
  280. SYNOPSIS: Called when the "Properties" button is pressed.
  281. Will pop up a dialog showing the properties of the
  282. selected share.
  283. ENTRY:
  284. EXIT:
  285. RETURNS:
  286. NOTES:
  287. HISTORY:
  288. NarenG 11/18/92 Modified for AFPMGR
  289. ********************************************************************/
  290. BOOL VOLUME_MANAGEMENT_DIALOG::OnVolumeInfo( VOID )
  291. {
  292. if ( !IsFocusOnGoodVolume() )
  293. {
  294. return FALSE;
  295. }
  296. //
  297. // Just to be cool
  298. //
  299. AUTO_CURSOR Cursor;
  300. DWORD err = NO_ERROR;
  301. VIEW_VOLUMES_LISTBOX *plbVolume = QueryLBVolumes();
  302. VIEW_VOLUMES_LBI *pvlbi = plbVolume->QueryItem();
  303. VOLUME_PROPERTIES_DIALOG *pDlg = new VOLUME_PROPERTIES_DIALOG(
  304. QueryHwnd(),
  305. _hServer,
  306. pvlbi->QueryVolumeName(),
  307. _nlsServerName.QueryPch(),
  308. TRUE );
  309. if ( ( pDlg == NULL )
  310. || ((err = pDlg->QueryError()) != NERR_Success )
  311. || ((err = pDlg->Process()) != NERR_Success )
  312. )
  313. {
  314. err = err ? err : ERROR_NOT_ENOUGH_MEMORY;
  315. }
  316. delete pDlg;
  317. pDlg = NULL;
  318. if ( err != NO_ERROR )
  319. {
  320. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  321. if ( ( err = Refresh() ) != NO_ERROR )
  322. {
  323. ::MsgPopup( this, AFPERR_TO_STRINGID( err ) );
  324. }
  325. return FALSE;
  326. }
  327. return TRUE;
  328. }
  329. /*******************************************************************
  330. NAME: VOLUME_MANAGEMENT_DIALOG::OnVolumeLbDblClk
  331. SYNOPSIS: This is called when the user double clicks on a volume
  332. in the listbox. Will pop up a dialog showing the
  333. properties of the selected volume if is valid.
  334. ENTRY:
  335. EXIT:
  336. RETURNS:
  337. NOTES:
  338. HISTORY:
  339. NarenG 11/18/92 Modified for AFPMGR
  340. ********************************************************************/
  341. BOOL VOLUME_MANAGEMENT_DIALOG::OnVolumeLbDblClk( VOID )
  342. {
  343. return( OnVolumeInfo() );
  344. }
  345. /*******************************************************************
  346. NAME: VOLUME_MANAGEMENT_DIALOG::QueryHelpContext
  347. SYNOPSIS: Query the help context of the dialog
  348. ENTRY:
  349. EXIT:
  350. RETURNS: Return the help context of the dialog
  351. NOTES:
  352. HISTORY:
  353. NarenG 11/18/92 Modified for AFPMGR
  354. ********************************************************************/
  355. ULONG VOLUME_MANAGEMENT_DIALOG::QueryHelpContext( VOID )
  356. {
  357. return HC_VOLUME_MANAGEMENT_DIALOG;
  358. }