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.

512 lines
14 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. srvprop.cxx
  7. Class definitions for the SERVER_PROPERTIES class.
  8. This file contains the class declarations for the SERVER_PROPERTIES.
  9. The SERVER_PROPERTIES class implements the Server Manager main property
  10. sheet.
  11. FILE HISTORY:
  12. NarenG 1-Oct-1992 Stole from NETUI server manager.
  13. Removed LM specific stuff and put AFP
  14. specific stuff
  15. */
  16. #define INCL_NET
  17. #define INCL_WINDOWS
  18. #define INCL_WINDOWS_GDI
  19. #define INCL_NETERRORS
  20. #define INCL_DOSERRORS
  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. #if defined(DEBUG)
  33. static const CHAR szFileName[] = __FILE__;
  34. #define _FILENAME_DEFINED_ONCE szFileName
  35. #endif // DEBUG
  36. #include <uiassert.hxx>
  37. #include <dbgstr.hxx>
  38. #include <lmsrvres.hxx>
  39. extern "C"
  40. {
  41. #include <afpmgr.h>
  42. #include <macfile.h>
  43. } // extern "C"
  44. #include <srvprop.hxx>
  45. #include <volumes.hxx>
  46. #include <sessions.hxx>
  47. #include <openfile.hxx>
  48. #include <util.hxx>
  49. #include <server.hxx>
  50. #define PATH_SEPARATOR TCH('\\')
  51. //
  52. // This macro is used in the SERVER_PROPERTIES::OnCommand() method to
  53. // invoke the appropriate dialog when one of the graphical buttons is
  54. // pressed. If DIALOG_WINDOW's destructor were virtual, we could do
  55. // all of this in a common worker function, thus reducing code size.
  56. //
  57. // NOTE: This macro assumes that the dialog constructor takes an HWND
  58. // and a AFP_SERVER_HANDLE. This macro further assumes that there
  59. // is a variable named _hserver of type AFP_SERVER_HANDLE in some
  60. // visible scope.
  61. //
  62. #define SUBPROPERTY( DlgClass ) \
  63. if( TRUE ) \
  64. { \
  65. DlgClass * pDlg = new DlgClass( QueryHwnd(), \
  66. _hServer, \
  67. _pszServerName ); \
  68. \
  69. DWORD err = ( pDlg == NULL ) ? ERROR_NOT_ENOUGH_MEMORY \
  70. : pDlg->Process(); \
  71. \
  72. if( err != NERR_Success ) \
  73. { \
  74. MsgPopup( this, err ); \
  75. } \
  76. \
  77. delete pDlg; \
  78. \
  79. RepaintNow(); \
  80. Refresh(); \
  81. \
  82. return TRUE; \
  83. } \
  84. else
  85. //
  86. // SERVER_PROPERTIES methods.
  87. //
  88. /*******************************************************************
  89. NAME: SERVER_PROPERTIES :: SERVER_PROPERTIES
  90. SYNOPSIS: SERVER_PROPERTIES class constructor.
  91. ENTRY: hWndOwner - Handle to the "owning" window.
  92. pszServerName - Name of the target server.
  93. EXIT: The object is constructed.
  94. RETURNS: No return value.
  95. NOTES: All SERVER_PROPERTIES methods assume that the current
  96. user has sufficient privilege to adminster the target
  97. server.
  98. HISTORY:
  99. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  100. ********************************************************************/
  101. SERVER_PROPERTIES :: SERVER_PROPERTIES( HWND hWndOwner,
  102. AFP_SERVER_HANDLE hServer,
  103. const TCHAR * pszServerName )
  104. : DIALOG_WINDOW( IDD_SERVER_PROPERTIES, hWndOwner ),
  105. _pszServerName( pszServerName ),
  106. _sltCurrentActiveSessions( this, IDSP_DT_CURRENT_SESSIONS ),
  107. _sltCurrentOpenFiles( this, IDSP_DT_CURRENT_OPENFILES ),
  108. _sltCurrentFileLocks( this, IDSP_DT_CURRENT_FILELOCKS ),
  109. _hServer( hServer ),
  110. /* MSKK NaotoN Appended for Localizing into Japanese 8/24/93 */
  111. #ifdef JAPAN
  112. _fontHelv( (TCHAR *)"�l�r �S�V�b�N", FIXED_PITCH | FF_MODERN, 8, FONT_ATT_DEFAULT ),
  113. #else
  114. _fontHelv( FONT_DEFAULT ),
  115. #endif
  116. /* end */
  117. _gbUsers( this,
  118. IDSP_GB_USERS,
  119. MAKEINTRESOURCE( IDBM_USERS )),
  120. _gbVolumes( this,
  121. IDSP_GB_VOLUMES,
  122. MAKEINTRESOURCE(IDBM_FILES) ),
  123. _gbOpenFiles( this,
  124. IDSP_GB_OPENFILES,
  125. MAKEINTRESOURCE(IDBM_OPENRES) ),
  126. _gbServerParms( this,
  127. IDSP_GB_SERVERPARMS,
  128. MAKEINTRESOURCE(IDBM_SERVERPARMS) )
  129. {
  130. AUTO_CURSOR Cursor;
  131. //
  132. // Let's make sure everything constructed OK.
  133. //
  134. if( QueryError() != NERR_Success )
  135. {
  136. return;
  137. }
  138. if( !_fontHelv )
  139. {
  140. ReportError( _fontHelv.QueryError() );
  141. return;
  142. }
  143. //
  144. // Display the dynamic server data.
  145. //
  146. DWORD err = Refresh();
  147. if ( err != NO_ERROR )
  148. {
  149. ReportError( err );
  150. return;
  151. }
  152. //
  153. // Initialize our magic button bar.
  154. //
  155. err = SetupButtonBar();
  156. if( err != NERR_Success )
  157. {
  158. ReportError( err );
  159. return;
  160. }
  161. //
  162. // Set the dialog caption.
  163. //
  164. err = ::SetCaption( this, IDS_CAPTION_PROPERTIES, _pszServerName );
  165. if( err != NERR_Success )
  166. {
  167. ReportError( err );
  168. return;
  169. }
  170. } // SERVER_PROPERTIES :: SERVER_PROPERTIES
  171. /*******************************************************************
  172. NAME: SERVER_PROPERTIES :: ~SERVER_PROPERTIES
  173. SYNOPSIS: SERVER_PROPERTIES class destructor.
  174. ENTRY: None.
  175. EXIT: The object is destroyed.
  176. RETURNS: No return value.
  177. NOTES:
  178. HISTORY:
  179. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  180. ********************************************************************/
  181. SERVER_PROPERTIES :: ~SERVER_PROPERTIES()
  182. {
  183. //
  184. // This space intentionally left blank
  185. //
  186. } // SERVER_PROPERTIES :: ~SERVER_PROPERTIES
  187. /*******************************************************************
  188. NAME: SERVER_PROPERTIES :: OnCommand
  189. SYNOPSIS: This method is called whenever a WM_COMMAND message
  190. is sent to the dialog procedure. In this case, we're
  191. only interested in commands sent as a result of the
  192. user clicking one of the graphical buttons.
  193. ENTRY: cid - The control ID from the
  194. generating control.
  195. lParam - Varies.
  196. EXIT: The command has been handled.
  197. RETURNS: BOOL - TRUE if we handled the command.
  198. FALSE if we did not handle
  199. the command.
  200. NOTES:
  201. HISTORY:
  202. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  203. ********************************************************************/
  204. BOOL SERVER_PROPERTIES :: OnCommand( const CONTROL_EVENT & event )
  205. {
  206. AUTO_CURSOR Cursor;
  207. switch ( event.QueryCid() )
  208. {
  209. case IDSP_GB_USERS:
  210. //
  211. // The Users dialog.
  212. //
  213. SUBPROPERTY( SESSIONS_DIALOG );
  214. break;
  215. case IDSP_GB_VOLUMES:
  216. //
  217. // The Files dialog.
  218. //
  219. SUBPROPERTY( VOLUMES_DIALOG );
  220. break;
  221. case IDSP_GB_OPENFILES:
  222. //
  223. // The In Use dialog.
  224. //
  225. SUBPROPERTY( OPENS_DIALOG );
  226. break;
  227. case IDSP_GB_SERVERPARMS:
  228. //
  229. // The Server Parameters dialog
  230. //
  231. SUBPROPERTY( SERVER_PARAMETERS_DIALOG );
  232. break;
  233. default:
  234. //
  235. // If we made it this far, then we're not interested
  236. // in the command.
  237. //
  238. return FALSE;
  239. }
  240. } // SERVER_PROPERTIES :: OnCommand
  241. /*******************************************************************
  242. NAME: SERVER_PROPERTIES :: QueryHelpContext
  243. SYNOPSIS: This function returns the appropriate help context
  244. value (HC_*) for this particular dialog.
  245. ENTRY: None.
  246. EXIT: None.
  247. RETURNS: ULONG - The help context for this
  248. dialog.
  249. NOTES:
  250. HISTORY:
  251. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  252. ********************************************************************/
  253. ULONG SERVER_PROPERTIES :: QueryHelpContext( void )
  254. {
  255. return HC_SERVER_PROPERTIES;
  256. } // SERVER_PROPERITES :: QueryHelpContext
  257. /*******************************************************************
  258. NAME: SERVER_PROPERTIES :: Refresh
  259. SYNOPSIS: This method will display any server data which may
  260. need to be refreshed during the lifetime of the
  261. properties dialog. This includes the number of
  262. active sessions, open files, etc.
  263. ENTRY: None.
  264. EXIT: The dynamic server data has been displayed.
  265. RETURNS: No return value.
  266. NOTES:
  267. HISTORY:
  268. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  269. ********************************************************************/
  270. DWORD SERVER_PROPERTIES :: Refresh( VOID )
  271. {
  272. //
  273. // This may take a while...
  274. //
  275. AUTO_CURSOR Cursor;
  276. //
  277. // This string will contain our "??" string.
  278. //
  279. const TCHAR * pszNotAvail = SZ("??");
  280. //
  281. // Retrieve the statitistics server info.
  282. //
  283. PAFP_STATISTICS_INFO pAfpStats;
  284. DWORD err = ::AfpAdminStatisticsGet( _hServer, (LPBYTE*)&pAfpStats );
  285. if( err == NO_ERROR )
  286. {
  287. _sltCurrentActiveSessions.Enable( TRUE );
  288. _sltCurrentActiveSessions.SetValue( pAfpStats->stat_CurrentSessions);
  289. _sltCurrentOpenFiles.Enable( TRUE );
  290. _sltCurrentOpenFiles.SetValue( pAfpStats->stat_CurrentFilesOpen );
  291. _sltCurrentFileLocks.Enable( TRUE );
  292. _sltCurrentFileLocks.SetValue( pAfpStats->stat_CurrentFileLocks );
  293. ::AfpAdminBufferFree( pAfpStats );
  294. }
  295. else
  296. {
  297. _sltCurrentActiveSessions.SetText( pszNotAvail );
  298. _sltCurrentActiveSessions.Enable( FALSE );
  299. _sltCurrentOpenFiles.SetText( pszNotAvail );
  300. _sltCurrentOpenFiles.Enable( FALSE );
  301. _sltCurrentFileLocks.SetText( pszNotAvail );
  302. _sltCurrentFileLocks.Enable( FALSE );
  303. }
  304. return err;
  305. } // SERVER_PROPERTIES :: Refresh
  306. /*******************************************************************
  307. NAME: SERVER_PROPERTIES :: SetupButtonBar
  308. SYNOPSIS: The method initializes the magic scrolling button bar.
  309. ENTRY: None.
  310. EXIT: The button bar has been initialized.
  311. RETURNS: APIERR - Any errors encountered.
  312. NOTES:
  313. HISTORY:
  314. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  315. ********************************************************************/
  316. APIERR SERVER_PROPERTIES :: SetupButtonBar( VOID )
  317. {
  318. //
  319. // Setup the graphical buttons.
  320. //
  321. InitializeButton( &_gbUsers, IDS_BUTTON_USERS, NULL );
  322. InitializeButton( &_gbVolumes, IDS_BUTTON_VOLUMES, NULL );
  323. InitializeButton( &_gbOpenFiles, IDS_BUTTON_OPENFILES, NULL );
  324. InitializeButton( &_gbServerParms,IDS_BUTTON_SERVERPARMS,NULL );
  325. //
  326. // Success!
  327. //
  328. return NO_ERROR;
  329. } // SERVER_PROPERTIES :: SetupButtonBar
  330. /*******************************************************************
  331. NAME: SERVER_PROPERTIES :: InitializeButton
  332. SYNOPSIS: Initialize a single graphical button for use in
  333. the graphical button bar.
  334. ENTRY: pgb - Pointer to a GRAPHICAL_BUTTON.
  335. msg - The resource ID of the string
  336. to be used as button text.
  337. bmid - The bitmap ID for the button
  338. status bitmap. This is the
  339. tiny bitmap displayed in the
  340. upper left corner of the button.
  341. EXIT: The button has been initialized.
  342. RETURNS: No return value.
  343. NOTES:
  344. HISTORY:
  345. NarenG 1-Oct-1992 Replaced LM stuff with AFP stuff
  346. ********************************************************************/
  347. VOID SERVER_PROPERTIES :: InitializeButton( GRAPHICAL_BUTTON * pgb,
  348. MSGID msg,
  349. BMID bmid )
  350. {
  351. //
  352. // This NLS_STR is used to retrieve strings
  353. // from the resource string table.
  354. //
  355. STACK_NLS_STR( nlsButtonText, MAX_RES_STR_LEN );
  356. nlsButtonText.Load( msg );
  357. UIASSERT( nlsButtonText.QueryError() == NERR_Success );
  358. pgb->SetFont( _fontHelv );
  359. pgb->SetStatus( bmid );
  360. pgb->SetText( nlsButtonText.QueryPch() );
  361. } // SERVER_PROPERTIES :: InitializeButton