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.

404 lines
9.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. cpl.cxx
  7. This module contains entry points for the Afp Manager Control Panel Applet.
  8. It contains "CplApplet" function.
  9. FILE HISTORY:
  10. NarenG 1-Oct-1991 Stole from srvmgr.cpl.
  11. */
  12. #define INCL_NET
  13. #define INCL_NETLIB
  14. #define INCL_NETSERVICE
  15. #define INCL_WINDOWS
  16. #define INCL_WINDOWS_GDI
  17. #define INCL_NETERRORS
  18. #define INCL_DOSERRORS
  19. #include <lmui.hxx>
  20. #if defined(DEBUG)
  21. static const CHAR szFileName[] = __FILE__;
  22. #define _FILENAME_DEFINED_ONCE szFileName
  23. #endif
  24. #include <uiassert.hxx>
  25. #include <uitrace.hxx>
  26. #define INCL_BLT_WINDOW
  27. #define INCL_BLT_DIALOG
  28. #define INCL_BLT_CONTROL
  29. #define INCL_BLT_CLIENT
  30. #define INCL_BLT_MSGPOPUP
  31. #define INCL_BLT_EVENT
  32. #define INCL_BLT_MISC
  33. #define INCL_BLT_TIMER
  34. #define INCL_BLT_CC
  35. #include <blt.hxx>
  36. #include <dbgstr.hxx>
  37. #include <lmoloc.hxx>
  38. extern "C"
  39. {
  40. #include <cpl.h> // Multimedia CPL defs
  41. #include <afpmgr.h>
  42. #include <macfile.h>
  43. }
  44. #include <srvprop.hxx>
  45. #include <startafp.hxx>
  46. extern "C"
  47. {
  48. //
  49. // Control Panel Applet entry point.
  50. //
  51. LONG FAR PASCAL CPlApplet( HWND hwndCPl,
  52. WORD nMsg,
  53. LPARAM lParam1,
  54. LPARAM lparam2 );
  55. //
  56. // Globals.
  57. //
  58. extern HINSTANCE _hInstance; // Exported by the afpmgr.cxx module.
  59. } // extern "C"
  60. /*******************************************************************
  61. NAME: GetLocalServerName
  62. SYNOPSIS: Returns the name of the current server (\\server).
  63. ENTRY: nlsServerName - Will receive the server name.
  64. RETURNS: APIERR - Any error encountered.
  65. HISTORY:
  66. NarenG 1-Oct-1992 Stole from original.
  67. ********************************************************************/
  68. APIERR GetLocalServerName( NLS_STR * nlsServerName )
  69. {
  70. LOCATION loc( LOC_TYPE_LOCAL );
  71. APIERR err = loc.QueryError();
  72. if( err == NERR_Success )
  73. {
  74. err = loc.QueryDisplayName( nlsServerName );
  75. }
  76. return err;
  77. } // GetLocalServerName
  78. /*******************************************************************
  79. NAME: RunAfpMgr
  80. SYNOPSIS: Invoke the main dialog of the AFP Server Manager Control
  81. Panel Applet.
  82. ENTRY: hWnd - Window handle of parent window.
  83. RETURNS: APIERR
  84. HISTORY:
  85. NarenG 1-Oct-1992 Stole from original.
  86. ********************************************************************/
  87. APIERR RunAfpMgr( HWND hWnd )
  88. {
  89. NLS_STR nlsServerName;
  90. BOOL fAFPRunning;
  91. APIERR err;
  92. AFP_SERVER_HANDLE hServer = NULL;
  93. //
  94. // This is not a loop
  95. //
  96. do {
  97. if ( ( err = nlsServerName.QueryError() ) != NERR_Success )
  98. break;
  99. //
  100. // Try to get the Local Server Name
  101. //
  102. err = GetLocalServerName( &nlsServerName );
  103. if ( err != NERR_Success )
  104. break;
  105. err = IsAfpServiceRunning( nlsServerName.QueryPch(), &fAFPRunning );
  106. if ( err != NERR_Success )
  107. break;
  108. //
  109. // The server is not started.
  110. //
  111. if( !fAFPRunning )
  112. {
  113. //
  114. // Ask the user if he/she wants to start it.
  115. //
  116. if ( ::MsgPopup( hWnd,
  117. IDS_START_AFPSERVER_NOW,
  118. MPSEV_WARNING,
  119. MP_YESNO,
  120. MP_YES ) == IDYES )
  121. {
  122. //
  123. // Start the AFP Service
  124. //
  125. err = StartAfpService( hWnd, nlsServerName.QueryPch());
  126. if ( err != NERR_Success )
  127. break;
  128. }
  129. else
  130. {
  131. break;
  132. }
  133. }
  134. //
  135. // Set up an RPC conenction with the server
  136. //
  137. if ( ( err = ::AfpAdminConnect( (LPWSTR)(nlsServerName.QueryPch()),
  138. &hServer ) ) != NO_ERROR )
  139. {
  140. break;
  141. }
  142. //
  143. // Invoke the Main Property Dialog.
  144. //
  145. SERVER_PROPERTIES * pDlg = new SERVER_PROPERTIES(
  146. hWnd,
  147. hServer,
  148. nlsServerName.QueryPch() );
  149. err = ( pDlg == NULL ) ? ERROR_NOT_ENOUGH_MEMORY : pDlg->Process();
  150. delete pDlg;
  151. if ( hServer != NULL )
  152. {
  153. ::AfpAdminDisconnect( hServer );
  154. }
  155. } while( FALSE );
  156. if( err != NERR_Success )
  157. {
  158. if ( err == IDS_MACFILE_NOT_INSTALLED )
  159. {
  160. ::MsgPopup( hWnd,
  161. err,
  162. MPSEV_ERROR,
  163. MP_OKCANCEL,
  164. nlsServerName.QueryPch(),
  165. MP_OK );
  166. }
  167. else
  168. {
  169. ::MsgPopup( hWnd, AFPERR_TO_STRINGID(err) );
  170. }
  171. }
  172. return err;
  173. } // RunAfpMgr
  174. /*******************************************************************
  175. NAME: CPlApplet
  176. SYNOPSIS: Exported function to start the Server Manager Control
  177. Panel Applet.
  178. ENTRY: hwndCPl - Window handle of parent.
  179. nMsg - CPL user message (see CPL.H
  180. in WINDOWS\SHELL\CONTROL\H).
  181. lParam1 - Message-specific pointer.
  182. lParam2 - Message-specific pointer.
  183. RETURNS: LONG
  184. HISTORY:
  185. NarenG 1-Oct-1992 Stole from original.
  186. ********************************************************************/
  187. LONG FAR PASCAL CPlApplet( HWND hwndCPl,
  188. WORD nMsg,
  189. LPARAM lParam1,
  190. LPARAM lParam2 )
  191. {
  192. LPCPLINFO pCplInfo;
  193. LONG nResult = 0;
  194. UNREFERENCED( lParam1 );
  195. switch( nMsg )
  196. {
  197. case CPL_INIT:
  198. //
  199. // This message is sent to indicate that CPlApplet() was found.
  200. //
  201. // lParam1 and lParam2 are not used.
  202. //
  203. // Return TRUE if applet should be installed, FALSE otherwise.
  204. //
  205. return (LONG)TRUE;
  206. case CPL_GETCOUNT:
  207. //
  208. // This message is set to determine the number of applets contained
  209. // in this DLL.
  210. //
  211. // lParam1 and lParam2 are not used.
  212. //
  213. // Return the number of applets contained in this DLL.
  214. //
  215. return 1;
  216. case CPL_INQUIRE:
  217. //
  218. // This message is sent once per applet to retrieve information
  219. // about each applet.
  220. //
  221. // lParam1 is the applet number to register.
  222. //
  223. // lParam2 is a pointer to a CPLINFO structure. The CPLINFO
  224. // structure's idIcon, idName, idInfo, and lData fields should
  225. // be initialized as appropriate for the applet.
  226. //
  227. // There is no return value.
  228. //
  229. pCplInfo = (LPCPLINFO)lParam2;
  230. pCplInfo->idIcon = IDI_AFPMCPA_ICON;
  231. pCplInfo->idName = IDS_AFPMCPA_NAME_STRING;
  232. pCplInfo->idInfo = IDS_AFPMCPA_INFO_STRING;
  233. pCplInfo->lData = 0L;
  234. break;
  235. case CPL_SELECT:
  236. //
  237. // This message is sent when the applet's icon has been
  238. // selected.
  239. //
  240. // lParam1 is the applet number that was selected.
  241. //
  242. // lParam2 is the applet's lData value.
  243. //
  244. // There is no return value.
  245. //
  246. break;
  247. case CPL_DBLCLK:
  248. //
  249. // This message is sent when the applet's icon has been
  250. // double-clicked. This message should initiate the
  251. // applet's dialog box.
  252. //
  253. // lParam1 is the applet number that was selected.
  254. //
  255. // lParam2 is the applet's lData value.
  256. //
  257. // There is no return value.
  258. //
  259. RunAfpMgr( hwndCPl );
  260. break;
  261. case CPL_STOP:
  262. //
  263. // This message is sent once for each applet when the
  264. // control panel is shutting down. This message should
  265. // initiate applet specific cleanup.
  266. //
  267. // lParam1 is the applet number being stopped.
  268. //
  269. // lParam2 is the applet's lData value.
  270. //
  271. // There is no return value.
  272. //
  273. break;
  274. case CPL_EXIT:
  275. //
  276. // This message is sent just before the control panel calls
  277. // FreeLibrary.
  278. //
  279. // lParam1 and lParam2 are not used.
  280. //
  281. // There is no return value.
  282. //
  283. break;
  284. case CPL_NEWINQUIRE:
  285. //
  286. // This message is basically the same as CPL_INQUIRE, except
  287. // lParam2 points to a NEWCPLINFO structure. This message will
  288. // be sent *before* CPL_INQUIRE. If the applet returns a non
  289. // zero value, then CPL_INQUIRE will not be sent.
  290. //
  291. // lParam1 is the applet number to register.
  292. //
  293. // lParam2 is a pointer to a NEWCPLINFO structure.
  294. //
  295. // There is no return value.
  296. //
  297. return FALSE;
  298. default:
  299. //
  300. // Who knows. Ignore it.
  301. //
  302. break;
  303. }
  304. return nResult;
  305. } // CPlApplet