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.

484 lines
15 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. wnprop.cxx
  7. This file contains the following symbols:
  8. WNetGetPropertyText
  9. WNetPropertyDialog
  10. FILE HISTORY:
  11. rustanl 29-Apr-1991 Created
  12. rustanl 24-May-1991 Added calls to permission test program
  13. terryk 22-May-1991 add parent class name to constructor
  14. Yi-HsinS 15-Aug-1991 Added calls to share dialogs
  15. Yi-HsinS 31-Dec-1991 Unicode Work
  16. */
  17. #include <ntstuff.hxx>
  18. #define INCL_WINDOWS
  19. #define INCL_WINDOWS_GDI
  20. #define INCL_DOSERRORS
  21. #define INCL_NETERRORS
  22. #define INCL_NETFILE
  23. #define _WINNETWK_
  24. #include <lmui.hxx>
  25. #undef _WINNETWK_
  26. extern "C"
  27. {
  28. #include <wnet1632.h>
  29. #include <winlocal.h>
  30. }
  31. #define INCL_BLT_WINDOW
  32. #define INCL_BLT_DIALOG
  33. #define INCL_BLT_CONTROL
  34. #define INCL_BLT_MSGPOPUP
  35. #define INCL_BLT_MISC
  36. #include <blt.hxx>
  37. #include <string.hxx>
  38. #include <opens.hxx>
  39. #include <sharedlg.h>
  40. #include <uitrace.hxx>
  41. #include <wnprop.hxx>
  42. #include <wnetdev.hxx>
  43. /* This array contains the button indices and the associated string IDs
  44. * for that button.
  45. */
  46. MSGID aidsButtonNames[] =
  47. {
  48. IDS_PROP_BUTTON_FILEOPENS,
  49. 0
  50. } ;
  51. RESOURCE_STR * PROPERTY_DIALOG::pnlsButtonName[] = { NULL, NULL } ;
  52. /*******************************************************************
  53. NAME: PROPERTY_DIALOG::Construct
  54. SYNOPSIS: Property Dialog pseudo constructor
  55. EXIT: Initializes the array of button names, should be called
  56. before the static QueryButtonName is called.
  57. NOTES:
  58. HISTORY:
  59. Johnl 04-Aug-1991 Created
  60. ********************************************************************/
  61. APIERR PROPERTY_DIALOG::Construct( void )
  62. {
  63. INT i = 0 ;
  64. while ( aidsButtonNames[i] != 0 )
  65. {
  66. pnlsButtonName[i] = new RESOURCE_STR( aidsButtonNames[i] ) ;
  67. if ( pnlsButtonName[i]->QueryError() != NERR_Success )
  68. {
  69. UIDEBUG( SZ("PROPERTY_DIALOG::Construct - Error loading button names")) ;
  70. return pnlsButtonName[i]->QueryError() ;
  71. }
  72. i++ ;
  73. }
  74. return NERR_Success ;
  75. }
  76. /*******************************************************************
  77. NAME: PROPERTY_DIALOG::Destruct
  78. SYNOPSIS: Pseudo Destructor.
  79. NOTES:
  80. HISTORY:
  81. Johnl 04-Aug-1991 Created
  82. ********************************************************************/
  83. void PROPERTY_DIALOG::Destruct()
  84. {
  85. INT i = 0 ;
  86. while ( aidsButtonNames[i] != 0 )
  87. {
  88. delete pnlsButtonName[i] ;
  89. pnlsButtonName[i] = NULL ;
  90. i++ ;
  91. }
  92. }
  93. /*******************************************************************
  94. NAME: PROPERTY_DIALOG::QueryButtonName
  95. SYNOPSIS: Returns the button name for a particular button
  96. ENTRY:
  97. EXIT:
  98. RETURNS:
  99. NOTES:
  100. The following notes described what *really* is to take place.
  101. The following table describes which buttons are used for
  102. which types of objects. F stands for File, and D for Directory.
  103. Note, no buttons are used for multiple selections.
  104. Permissions FD
  105. Auditing FD
  106. //Volume D
  107. Share D
  108. In use by F
  109. To check whether or not to display the Permission and Auditing
  110. buttons, the following is done. Call NetAccessGetInfo.
  111. If it returns success, more data, buf too small, or
  112. resource not found, display the button; otherwise, don't.
  113. //For Volume, call I_DfsCheckExitPoint. Display button iff
  114. //the directory is an exit point.
  115. For Share, use a DEVICE object on the drive letter. Then,
  116. call dev.IsRemote. If remote, then use dev.QueryRemoteName()
  117. and call NetShareGetInfo on that server and share. If return
  118. is success, more data, or buf too small, display the button;
  119. otherwise, don't.
  120. For In use by, call NetFileEnum2.
  121. To check whether a name is valid (maybe not in this function),
  122. use the following FSA:
  123. 0 1 2 3 4 5 6
  124. ^ 4 2 1 4 3 6 6
  125. " 1 5 1 6 3 6 6
  126. other 3 1 1 3 3 6 6
  127. where 0 is the initial state, and 3 and 5 are accepting
  128. states.
  129. HISTORY:
  130. rustanl 29-Apr-1991 Created
  131. rustanl 03-May-1991 Added notes
  132. Johnl 21-Jan-1992 Removed Permission/Auditting buttons
  133. ********************************************************************/
  134. APIERR PROPERTY_DIALOG::QueryButtonName( UINT iButton,
  135. UINT nPropSel,
  136. const NLS_STR * * ppnlsName )
  137. {
  138. INT i = -1;
  139. switch ( nPropSel )
  140. {
  141. case WNPS_FILE:
  142. {
  143. switch ( iButton )
  144. {
  145. /* Note: These numbers are the actual indices past to us by
  146. * the file manager (and not magic numbers).
  147. */
  148. case 0:
  149. i = PROP_ID_FILEOPENS ;
  150. break ;
  151. default:
  152. break;
  153. }
  154. }
  155. break;
  156. case WNPS_DIR:
  157. break;
  158. case WNPS_MULT:
  159. break;
  160. }
  161. /* We are being asked for a button that we don't support
  162. */
  163. if ( i == -1 )
  164. {
  165. return WN_NOT_SUPPORTED ;
  166. }
  167. *ppnlsName = pnlsButtonName[ i ] ;
  168. return NERR_Success;
  169. } // PROPERTY_DIALOG::QueryButtonName
  170. /*******************************************************************
  171. NAME: WNetGetPropertyText
  172. SYNOPSIS: This function is used to determine the names of
  173. buttons added to a property dialog for some particular
  174. resources. It is called everytime such a dialog is
  175. brought up, and prior to displaying the dialog.
  176. If the user clicks a button added through this API
  177. by the Winnet driver, WNetPropertyDialog will be called
  178. with the appropriate parameters.
  179. In Windows 3.1, only File Manager calls this API. File
  180. Manager then calls it on files and directories.
  181. ENTRY:
  182. iButton Indicates the index (starting at 0) of the
  183. button.
  184. The Windows 3.1 File Manager will support
  185. at most 6 buttons.
  186. nPropSel Specifies what items the property dialog
  187. focuses on.
  188. In Windows 3.1, it can be one of the
  189. following values:
  190. WNPS_FILE single file
  191. WNPS_DIR single directory
  192. WNPS_MULT multiple selection of
  193. files and/or directories
  194. lpszName Specifies the names of the item or items
  195. to be viewed or edited by the dialog.
  196. In Windows 3.1, the items are files (and
  197. directories), so the item names are file
  198. names. These will
  199. be unambiguous, contain no wildcard
  200. characters and will be fully qualified (e.g.,
  201. C:\LOCAL\FOO.BAR). Multiple filenames
  202. will be separated with spaces. Any filename
  203. may be quoted (e.g., "C:\My File") in which
  204. case it will be treated as a single name. The
  205. caret character '^' may also be used as the
  206. quotation mechanism for single characters
  207. (e.g., C:\My^"File, "C:\My^"File" both refer
  208. to the file C:\My"File).
  209. lpButtonName Points to a buffer where the Winnet driver
  210. should copy the name of the property button.
  211. cchButtonName Specifies the size of the lpButtonName
  212. buffer in count of characters for NT and
  213. is a byte count for Win 3.1.
  214. nType Specifies the item type.
  215. In Windows 3.1, only WNTYPE_FILE will be used.
  216. EXIT: On success, the buffer pointed to by lpButtonName will
  217. contain the name of the property button. If this buffer,
  218. on exit, contains the empty string, then the corresponding
  219. button and all succeeding buttons will be removed from the
  220. dialog box. The network driver cannot "skip" a button.
  221. RETURNS: A Winnet return code, including:
  222. WN_SUCCESS lpButtonName can be used. If it
  223. points to the empty string, no
  224. button corresponds to an index as
  225. high as iButton.
  226. WN_OUT_OF_MEMORY Couldn't load string from resources
  227. WN_MORE_DATA The given buffer is too small
  228. to fit the text of the button.
  229. WN_BAD_VALUE The lpszName parameter takes an
  230. unexpected form.
  231. WN_NOT_SUPPORTED Property dialogs are not supported
  232. for the given object type (nType).
  233. NOTES: The behavior, parameters, and return values of this
  234. function are specified in the Winnet 3.1 spec.
  235. HISTORY:
  236. rustanl 29-Apr-1991 Created
  237. Johnl 02-Sep-1991 Updated for real world.
  238. beng 06-Apr-1992 Unicode fixes
  239. ********************************************************************/
  240. UINT /* FAR PASCAL */ WNetGetPropertyText( UINT iButton,
  241. UINT nPropSel,
  242. LPTSTR lpszName,
  243. LPTSTR lpButtonName,
  244. UINT cchButtonName,
  245. UINT nType )
  246. {
  247. APIERR err ;
  248. if ( err = InitShellUI() )
  249. {
  250. return err ;
  251. }
  252. UNREFERENCED( lpszName );
  253. if ( nType != WNTYPE_FILE )
  254. {
  255. // Note. Only WNTYPE_FILE is used in Windows 3.1.
  256. UIDEBUG( SZ("WNetGetPropertyText received unexpected nType value\r\n"));
  257. return ERROR_NOT_SUPPORTED;
  258. }
  259. const NLS_STR * pnlsButtonName;
  260. err = PROPERTY_DIALOG::QueryButtonName( iButton,
  261. nPropSel,
  262. &pnlsButtonName );
  263. if ( err != NERR_Success )
  264. {
  265. return err;
  266. }
  267. UINT nButtonNameLen = pnlsButtonName->QueryTextLength()+1 ;
  268. if ( cchButtonName < nButtonNameLen ) // dialog name
  269. {
  270. UIDEBUG( SZ("WNetGetPropertyText given too small a buffer\r\n") );
  271. return ERROR_MORE_DATA;
  272. }
  273. /* Note: This is an NLS_STR strcpy.
  274. */
  275. ::strcpy( (TCHAR *) lpButtonName, *pnlsButtonName );
  276. return NERR_Success;
  277. } // WNetGetPropertyText
  278. /*******************************************************************
  279. NAME: WNetPropertyDialog
  280. SYNOPSIS: This function is called out to when the user clicks
  281. a button added through the WNetGetPropertyText API.
  282. In Windows 3.1, this will only be called for file and
  283. directory network properties.
  284. ENTRY:
  285. hwndParent Specifies the parent window which should own
  286. the file property dialog.
  287. iButton Indicates the index (starting at 0) of the
  288. button that was pressed.
  289. nPropSel Specifies what items the property dialog should
  290. act on.
  291. In Windows 3.1, it can be one of the
  292. following values:
  293. WNPS_FILE single file
  294. WNPS_DIR single directory
  295. WNPS_MULT multiple selection of
  296. files and/or directories
  297. lpszName Points to the names of the items that the
  298. property dialog should act on.
  299. See the WNetGetPropertyText API for a description
  300. of the format of what lpszName points to.
  301. nType Specifies the item type.
  302. For Windows 3.1, only WNTYPE_FILE will be used.
  303. RETURNS: A Winnet return code, including:
  304. WN_SUCCESS Success
  305. WN_BAD_VALUE Some parameter takes an unexpected
  306. form or value
  307. WN_OUT_OF_MEMORY Not enough memory to display the
  308. dialog
  309. WN_NET_ERROR Some other network error occurred
  310. NOTES: Note, this function is only called on sets of properties
  311. for which WNetGetPropertyText has assigned a button name.
  312. The behavior, parameters, and return values of this
  313. function are specified in the Winnet 3.1 spec.
  314. HISTORY:
  315. rustanl 29-Apr-1991 Created
  316. ********************************************************************/
  317. UINT /* FAR PASCAL */ WNetPropertyDialog( HWND hwndParent,
  318. UINT iButton,
  319. UINT nPropSel,
  320. LPTSTR lpszName,
  321. UINT nType )
  322. {
  323. APIERR err ;
  324. if ( err = InitShellUI() )
  325. {
  326. return err ;
  327. }
  328. if ( nType != WNTYPE_FILE )
  329. {
  330. // Note. Only WNTYPE_FILE is used in Windows 3.1.
  331. UIDEBUG( SZ("WNetPropertyDialog received unexpected nType value\r\n"));
  332. return ERROR_NOT_SUPPORTED;
  333. }
  334. const NLS_STR * pnlsButtonName;
  335. err = PROPERTY_DIALOG::QueryButtonName( iButton,
  336. nPropSel,
  337. &pnlsButtonName );
  338. if ( err != NERR_Success )
  339. {
  340. return err;
  341. }
  342. if ( *pnlsButtonName == *PROPERTY_DIALOG::QueryString( PROP_ID_FILEOPENS ) )
  343. {
  344. err = DisplayOpenFiles( hwndParent,
  345. (WORD)nPropSel,
  346. lpszName ) ;
  347. }
  348. return err;
  349. } // WNetPropertyDialog
  350. /* Standard Init and Uninit calls.
  351. */
  352. APIERR I_PropDialogInit( void )
  353. {
  354. APIERR err ;
  355. //if ( err = MapError( PROPERTY_DIALOG::Construct()))
  356. if ( err = PROPERTY_DIALOG::Construct())
  357. {
  358. return err ;
  359. }
  360. return NERR_Success ;
  361. }
  362. void I_PropDialogUnInit( void )
  363. {
  364. PROPERTY_DIALOG::Destruct() ;
  365. }