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.

1060 lines
24 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1998
  4. *
  5. * TITLE: MiniItem.Cpp
  6. *
  7. * VERSION: 2.0
  8. *
  9. * AUTHOR: marke
  10. *
  11. * DATE: 30 Aug, 1998
  12. *
  13. * DESCRIPTION:
  14. * Implementation of the WIA test camera item methods.
  15. *
  16. *******************************************************************************/
  17. #include <stdio.h>
  18. #include <objbase.h>
  19. #include <sti.h>
  20. #ifdef TEST_PER_USER_DATA
  21. #ifdef UNICODE
  22. #include <userenv.h>
  23. #endif
  24. #endif
  25. #include "testusd.h"
  26. #include "defprop.h"
  27. extern HINSTANCE g_hInst; // Global hInstance
  28. /*******************************************************************************
  29. *
  30. * ValidateDataTransferContext
  31. *
  32. * DESCRIPTION:
  33. * Validate the data transfer context.
  34. *
  35. * PARAMETERS:
  36. *
  37. *******************************************************************************/
  38. HRESULT
  39. ValidateDataTransferContext(
  40. PMINIDRV_TRANSFER_CONTEXT pDataTransferContext)
  41. {
  42. if (pDataTransferContext->lSize != sizeof(MINIDRV_TRANSFER_CONTEXT)) {
  43. WIAS_ERROR((g_hInst,"ValidateDataTransferContext, invalid data transfer context"));
  44. return E_INVALIDARG;;
  45. }
  46. //
  47. // for tymed file or hglobal, only WiaImgFmt_MEMORYBMP is allowed
  48. //
  49. if ((pDataTransferContext->tymed == TYMED_FILE) ||
  50. (pDataTransferContext->tymed == TYMED_HGLOBAL)) {
  51. if (pDataTransferContext->guidFormatID != WiaImgFmt_BMP && pDataTransferContext->guidFormatID != WiaAudFmt_WAV) {
  52. WIAS_ERROR((g_hInst,"ValidateDataTransferContext, invalid format"));
  53. return E_INVALIDARG;;
  54. }
  55. }
  56. //
  57. // for tymed CALLBACK, only WiaImgFmt_MEMORYBMP is allowed
  58. //
  59. if (pDataTransferContext->tymed == TYMED_CALLBACK) {
  60. if ((pDataTransferContext->guidFormatID != WiaImgFmt_BMP) &&
  61. (pDataTransferContext->guidFormatID != WiaImgFmt_MEMORYBMP)) {
  62. WIAS_ERROR((g_hInst,"AcquireDeviceData, invalid format"));
  63. return E_INVALIDARG;;
  64. }
  65. }
  66. //
  67. // callback is always double buffered, non-callback never is
  68. //
  69. if (pDataTransferContext->pTransferBuffer == NULL) {
  70. WIAS_ERROR((g_hInst, "AcquireDeviceData, invalid transfer buffer"));
  71. return E_INVALIDARG;
  72. }
  73. return S_OK;
  74. }
  75. /**************************************************************************\
  76. * SendBitmapHeader
  77. *
  78. *
  79. *
  80. * Arguments:
  81. *
  82. *
  83. *
  84. * Return Value:
  85. *
  86. * Status
  87. *
  88. * History:
  89. *
  90. * 11/17/1998 Original Version
  91. *
  92. \**************************************************************************/
  93. HRESULT SendBitmapHeader(
  94. IWiaDrvItem *pDrvItem,
  95. PMINIDRV_TRANSFER_CONTEXT pTranCtx)
  96. {
  97. HRESULT hr;
  98. WIAS_ASSERT(g_hInst, pDrvItem != NULL);
  99. WIAS_ASSERT(g_hInst, pTranCtx != NULL);
  100. WIAS_ASSERT(g_hInst, pTranCtx->tymed == TYMED_CALLBACK);
  101. //
  102. // driver is sending TOPDOWN data, must swap biHeight
  103. //
  104. // this routine assumes pTranCtx->pHeader points to a
  105. // BITMAPINFO header (TYMED_FILE doesn't use this path
  106. // and DIB is the only format supported now)
  107. //
  108. PBITMAPINFO pbmi = (PBITMAPINFO)pTranCtx->pTransferBuffer;
  109. if (pTranCtx->guidFormatID == WiaImgFmt_MEMORYBMP) {
  110. pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight;
  111. }
  112. hr = pTranCtx->
  113. pIWiaMiniDrvCallBack->
  114. MiniDrvCallback(
  115. IT_MSG_DATA,
  116. IT_STATUS_TRANSFER_TO_CLIENT,
  117. 0,
  118. 0,
  119. pTranCtx->lHeaderSize,
  120. pTranCtx,
  121. 0);
  122. if (hr == S_OK) {
  123. //
  124. // advance offset for destination copy
  125. //
  126. pTranCtx->cbOffset += pTranCtx->lHeaderSize;
  127. }
  128. return hr;
  129. }
  130. /**************************************************************************\
  131. * TestUsdDevice::drvDeleteItem
  132. *
  133. * Try to delete a device item. Device items for the test scanner may
  134. * not be modified.
  135. *
  136. * Arguments:
  137. *
  138. * pWiasContext - The context of the item to delete
  139. * lFlags - unused
  140. * plDevErrVal - unused
  141. *
  142. * Return Value:
  143. *
  144. * Status
  145. *
  146. * History:
  147. *
  148. * 10/15/1998 Original Version
  149. *
  150. \**************************************************************************/
  151. HRESULT _stdcall TestUsdDevice::drvDeleteItem(
  152. BYTE* pWiasContext,
  153. LONG lFlags,
  154. LONG* plDevErrVal)
  155. {
  156. *plDevErrVal = 0;
  157. return STG_E_ACCESSDENIED;
  158. }
  159. /**************************************************************************\
  160. * TestUsdDevice::drvAcquireItemData
  161. *
  162. * Scan data into buffer. This routine scans the entire contents into
  163. * the destination buffer in one call. Status will be sent back if
  164. * the callback routine is provided
  165. *
  166. * Arguments:
  167. *
  168. * pWiasContext - identifies ITEM context
  169. * lFlags - unused
  170. * pTranCtx - buffer and callback information
  171. * plDevErrVal - error value
  172. *
  173. * Return Value:
  174. *
  175. * Status
  176. *
  177. * History:
  178. *
  179. * 11/17/1998 Original Version
  180. *
  181. \**************************************************************************/
  182. HRESULT _stdcall TestUsdDevice::drvAcquireItemData(
  183. BYTE *pWiasContext,
  184. LONG lFlags,
  185. PMINIDRV_TRANSFER_CONTEXT pTranCtx,
  186. LONG *plDevErrVal)
  187. {
  188. HRESULT hr;
  189. // #define TEST_PER_USER_DATA 1
  190. #ifdef TEST_PER_USER_DATA
  191. #ifdef UNICODE
  192. BOOL bRet;
  193. TCHAR tszUserName[MAX_PATH];
  194. DWORD dwBufSize;
  195. HANDLE hToken;
  196. PROFILEINFO profileInfo;
  197. LONG lRet;
  198. HKEY hKeyCurUser;
  199. #endif
  200. #endif
  201. *plDevErrVal = 0;
  202. //
  203. // How to access per user setting in the USD
  204. //
  205. #ifdef TEST_PER_USER_DATA
  206. #ifdef UNICODE
  207. #ifdef DEBUG
  208. dwBufSize = MAX_PATH;
  209. bRet = GetUserName(tszUserName, &dwBufSize);
  210. #endif
  211. #endif
  212. #endif
  213. #ifdef TEST_PER_USER_DATA
  214. #ifdef UNICODE
  215. hToken = NULL;
  216. __try {
  217. hr = CoImpersonateClient();
  218. if (FAILED(hr)) {
  219. __leave;
  220. }
  221. #ifdef NEED_USER_PROFILE
  222. bRet = OpenThreadToken(
  223. GetCurrentThread(),
  224. TOKEN_ALL_ACCESS,
  225. TRUE,
  226. &hToken);
  227. if (! bRet) {
  228. __leave;
  229. }
  230. //
  231. // Get the client's user name
  232. //
  233. dwBufSize = MAX_PATH;
  234. bRet = GetUserName(tszUserName, &dwBufSize);
  235. //
  236. // Revert to system account
  237. //
  238. hr = CoRevertToSelf();
  239. if (FAILED(hr)) {
  240. __leave;
  241. }
  242. hr = S_FALSE;
  243. //
  244. // Load the user profile
  245. //
  246. ZeroMemory(&profileInfo, sizeof(profileInfo));
  247. profileInfo.dwSize = sizeof(profileInfo);
  248. profileInfo.dwFlags = PI_NOUI;
  249. profileInfo.lpUserName = tszUserName;
  250. bRet = LoadUserProfile(hToken, &profileInfo);
  251. if (! bRet) {
  252. __leave;
  253. }
  254. //
  255. // Access user portion of the registry
  256. //
  257. // Use profileInfo.hProfile instead of HKEY_CURRENT_USER
  258. //
  259. //
  260. hKeyCurUser = (HKEY)profileInfo.hProfile;
  261. #else
  262. lRet = RegOpenCurrentUser(KEY_ALL_ACCESS, &hKeyCurUser);
  263. if (lRet != ERROR_SUCCESS) {
  264. __leave;
  265. }
  266. #endif
  267. HKEY hKeyEnv;
  268. lRet = RegOpenKey(
  269. hKeyCurUser,
  270. TEXT("Environment"),
  271. &hKeyEnv);
  272. if (lRet == ERROR_SUCCESS) {
  273. RegCloseKey(hKeyEnv);
  274. }
  275. }
  276. __finally {
  277. if (hr == S_OK) {
  278. CoRevertToSelf();
  279. }
  280. #ifdef NEED_USER_PROFILE
  281. if (bRet) {
  282. UnloadUserProfile(hToken, profileInfo.hProfile);
  283. }
  284. if (hToken) {
  285. CloseHandle(hToken);
  286. }
  287. #else
  288. if (hKeyCurUser) {
  289. RegCloseKey(hKeyCurUser);
  290. }
  291. #endif
  292. }
  293. #endif
  294. #endif
  295. //
  296. // Get a pointer to the associated driver item.
  297. //
  298. IWiaDrvItem* pDrvItem;
  299. hr = wiasGetDrvItem(pWiasContext, &pDrvItem);
  300. if (FAILED(hr)) {
  301. return hr;
  302. }
  303. //
  304. // Validate the data transfer context.
  305. //
  306. hr = ValidateDataTransferContext(pTranCtx);
  307. if (FAILED(hr)) {
  308. return hr;
  309. }
  310. //
  311. // get item specific driver data
  312. //
  313. MEMCAM_IMAGE_CONTEXT *pMCamContext;
  314. pDrvItem->GetDeviceSpecContext((BYTE **)&pMCamContext);
  315. if (!pMCamContext) {
  316. WIAS_ERROR((g_hInst,"drvAcquireItemData, NULL item context"));
  317. return E_POINTER;
  318. }
  319. //
  320. // Use WIA services to fetch format specific info.
  321. //
  322. if (!IsEqualGUID (pTranCtx->guidFormatID, WiaAudFmt_WAV) )
  323. {
  324. hr = wiasGetImageInformation(pWiasContext,
  325. 0,
  326. pTranCtx);
  327. }
  328. else
  329. {
  330. WIN32_FILE_ATTRIBUTE_DATA wfd;
  331. GetFileAttributesEx (pMCamContext->pszCameraImagePath,GetFileExInfoStandard, &wfd);
  332. pTranCtx->lItemSize = (LONG)wfd.nFileSizeLow;
  333. }
  334. if (hr != S_OK) {
  335. return hr;
  336. }
  337. //
  338. // determine if this is a callback or buffered transfer
  339. //
  340. if (pTranCtx->tymed == TYMED_CALLBACK) {
  341. //
  342. // For formats that have a data header, send it to the client
  343. //
  344. if (pTranCtx->lHeaderSize > 0) {
  345. hr = SendBitmapHeader(
  346. pDrvItem,
  347. pTranCtx);
  348. }
  349. if (hr == S_OK) {
  350. hr = CamLoadPictureCB(
  351. pMCamContext,
  352. pTranCtx,
  353. plDevErrVal);
  354. }
  355. } else {
  356. //
  357. // inc past header
  358. //
  359. pTranCtx->cbOffset += pTranCtx->lHeaderSize;
  360. hr = CamLoadPicture(
  361. pMCamContext,
  362. pTranCtx,
  363. plDevErrVal);
  364. }
  365. return hr;
  366. }
  367. /**************************************************************************\
  368. * TestUsdDevice::drvInitItemProperties
  369. *
  370. * Initialize the device item properties.
  371. *
  372. * Arguments:
  373. *
  374. * pWiasContext - Pointer to WIA item context.
  375. * lFLags - unused
  376. * plDevErrVal - pointer to hardware error value.
  377. *
  378. *
  379. * Return Value:
  380. *
  381. * Status
  382. *
  383. * History:
  384. *
  385. * 10/29/1998 Original Version
  386. *
  387. \**************************************************************************/
  388. HRESULT _stdcall TestUsdDevice::drvInitItemProperties(
  389. BYTE *pWiasContext,
  390. LONG lFlags,
  391. LONG *plDevErrVal)
  392. {
  393. HRESULT hr;
  394. LONG lItemType;
  395. PMEMCAM_IMAGE_CONTEXT pContext;
  396. //
  397. // This device doesn't touch hardware to initialize the
  398. // device item properties.
  399. //
  400. *plDevErrVal = 0;
  401. //
  402. // Parameter validation.
  403. //
  404. if (!pWiasContext) {
  405. WIAS_ERROR((g_hInst,"drvInitItemProperties, invalid input pointers"));
  406. return (E_INVALIDARG);
  407. }
  408. //
  409. // Get a pointer to the associated driver item.
  410. //
  411. IWiaDrvItem* pDrvItem;
  412. hr = wiasGetDrvItem(pWiasContext, &pDrvItem);
  413. if (FAILED(hr)) {
  414. return hr;
  415. }
  416. //
  417. // Root item has the all the device properties
  418. //
  419. hr = pDrvItem->GetItemFlags(&lItemType);
  420. if (FAILED(hr)) {
  421. return (hr);
  422. }
  423. if (lItemType & WiaItemTypeRoot) {
  424. // Root item property init finishes here
  425. return (InitDeviceProperties(pWiasContext,
  426. plDevErrVal));
  427. }
  428. //
  429. // If this is a file, init the properties
  430. //
  431. if (lItemType & WiaItemTypeImage) {
  432. //
  433. // Add the item property names.
  434. //
  435. hr = wiasSetItemPropNames(pWiasContext,
  436. NUM_CAM_ITEM_PROPS,
  437. gItemPropIDs,
  438. gItemPropNames);
  439. if (FAILED(hr)) {
  440. WIAS_ERROR((g_hInst,"drvInitItemProperties, wiasSetItemPropNames() failed"));
  441. return (hr);
  442. }
  443. //
  444. // Use WIA services to set the defaul item properties.
  445. //
  446. hr = wiasWriteMultiple(pWiasContext,
  447. NUM_CAM_ITEM_PROPS,
  448. gPropSpecDefaults,
  449. (PROPVARIANT*)gPropVarDefaults);
  450. if (FAILED(hr)) {
  451. return (hr);
  452. }
  453. hr = pDrvItem->GetDeviceSpecContext((BYTE **)&pContext);
  454. if (FAILED(hr)) {
  455. WIAS_ERROR((g_hInst,"drvInitItemProperties, GetDeviceSpecContext failed"));
  456. return (hr);
  457. }
  458. hr = InitImageInformation(pWiasContext,
  459. pContext,
  460. plDevErrVal);
  461. if (FAILED(hr)) {
  462. WIAS_ERROR((g_hInst,"drvInitItemProperties InitImageInformation() failed"));
  463. return (hr);
  464. }
  465. }
  466. else if (lItemType & WiaItemTypeAudio)
  467. {
  468. //
  469. // Add the item property names.
  470. //
  471. hr = wiasSetItemPropNames(pWiasContext,
  472. NUM_AUDIO_PROPS,
  473. gAudioPropIDs,
  474. gAudioPropNames);
  475. if (FAILED(hr)) {
  476. WIAS_ERROR((g_hInst,"drvInitItemProperties, wiasSetItemPropNames() failed"));
  477. return (hr);
  478. }
  479. //
  480. // Use WIA services to set the defaul item properties.
  481. //
  482. hr = wiasWriteMultiple(pWiasContext,
  483. NUM_AUDIO_PROPS,
  484. gAudioPropDefaults,
  485. (PROPVARIANT*)gAudioDefaults);
  486. if (FAILED(hr)) {
  487. return (hr);
  488. }
  489. hr = pDrvItem->GetDeviceSpecContext((BYTE **)&pContext);
  490. if (FAILED(hr)) {
  491. WIAS_ERROR((g_hInst,"drvInitItemProperties, GetDeviceSpecContext failed"));
  492. return (hr);
  493. }
  494. hr = InitAudioInformation (pWiasContext,
  495. pContext,
  496. plDevErrVal);
  497. }
  498. return (S_OK);
  499. }
  500. /**************************************************************************\
  501. * TestUsdDevice::drvValidateItemProperties
  502. *
  503. * Validate the device item properties.
  504. *
  505. * Arguments:
  506. *
  507. * pWiasContext - wia item context
  508. * lFlags - unused
  509. * nPropSpec -
  510. * pPropSpec -
  511. * plDevErrVal - device error value
  512. *
  513. * Return Value:
  514. *
  515. * Status
  516. *
  517. * History:
  518. *
  519. * 10/29/1998 Original Version
  520. *
  521. \**************************************************************************/
  522. HRESULT _stdcall TestUsdDevice::drvValidateItemProperties(
  523. BYTE *pWiasContext,
  524. LONG lFlags,
  525. ULONG nPropSpec,
  526. const PROPSPEC *pPropSpec,
  527. LONG *plDevErrVal)
  528. {
  529. //
  530. // This device doesn't touch hardware to validate the device item properties.
  531. //
  532. *plDevErrVal = 0;
  533. //
  534. // Parameter validation.
  535. //
  536. if (!pWiasContext || !pPropSpec) {
  537. WIAS_ERROR((g_hInst,"drvValidateItemProperties, invalid input pointers"));
  538. return E_POINTER;
  539. }
  540. //
  541. // validate size
  542. //
  543. HRESULT hr = S_OK;
  544. IWiaDrvItem* pDrvItem;
  545. hr = wiasGetDrvItem(pWiasContext, &pDrvItem);
  546. if (FAILED(hr)) {
  547. return hr;
  548. }
  549. LONG lItemType;
  550. hr = pDrvItem->GetItemFlags(&lItemType);
  551. if (hr == S_OK) {
  552. if (lItemType & WiaItemTypeImage) {
  553. //
  554. // calc item size
  555. //
  556. hr = SetItemSize(pWiasContext);
  557. //
  558. // Change MinBufferSize property. Need to get Tymed and
  559. // ItemSize first, since MinBufferSize in dependant on these
  560. // properties.
  561. //
  562. LONG lTymed;
  563. LONG lItemSize;
  564. LONG lMinBufSize = 0;
  565. HRESULT hr = S_OK;
  566. hr = wiasReadPropLong(pWiasContext, WIA_IPA_TYMED, &lTymed, NULL, TRUE);
  567. if (FAILED(hr)) {
  568. WIAS_ERROR((g_hInst,"drvValidateItemProperties, could not read TYMED property"));
  569. return hr;
  570. }
  571. hr = wiasReadPropLong(pWiasContext, WIA_IPA_ITEM_SIZE, &lItemSize, NULL, TRUE);
  572. if (SUCCEEDED(hr)) {
  573. //
  574. // Update the MinBufferSize property.
  575. //
  576. switch (lTymed) {
  577. case TYMED_CALLBACK:
  578. lMinBufSize = 65535;
  579. break;
  580. default:
  581. lMinBufSize = lItemSize;
  582. }
  583. if (lMinBufSize) {
  584. hr = wiasWritePropLong(pWiasContext, WIA_IPA_MIN_BUFFER_SIZE, lMinBufSize);
  585. if (FAILED(hr)) {
  586. WIAS_ERROR((g_hInst, "drvValidateItemProperties, could not write value for WIA_IPA_MIN_BUFFER_SIZE"));
  587. }
  588. }
  589. } else {
  590. WIAS_ERROR((g_hInst, "drvValidateItemProperties, could not read value for ItemSize"));
  591. }
  592. } else if (lItemType & WiaItemTypeRoot) {
  593. //
  594. // Find out whether the Root Path property is changed
  595. //
  596. for (ULONG i = 0; i < nPropSpec; i++) {
  597. if (((pPropSpec[i].ulKind == PRSPEC_PROPID) &&
  598. (pPropSpec[i].propid == WIA_DPP_TCAM_ROOT_PATH)) ||
  599. ((pPropSpec[i].ulKind == PRSPEC_LPWSTR) &&
  600. (wcscmp(pPropSpec[i].lpwstr, WIA_DPP_TCAM_ROOT_PATH_STR) == 0))) {
  601. BSTR bstrRootPath;
  602. //
  603. // Retrieve the new value for Root Path property
  604. //
  605. hr = wiasReadPropStr(
  606. pWiasContext,
  607. WIA_DPP_TCAM_ROOT_PATH,
  608. &bstrRootPath,
  609. NULL,
  610. TRUE);
  611. if (FAILED(hr)) {
  612. return (hr);
  613. }
  614. #ifdef UNICODE
  615. wcscpy(gpszPath, bstrRootPath);
  616. #else
  617. wcstombs(gpszPath, bstrRootPath, MAX_PATH);
  618. #endif
  619. //
  620. // Release the Root Path bstr
  621. //
  622. SysFreeString(bstrRootPath);
  623. //
  624. // Rebuild the item tree and send event notification
  625. //
  626. hr = DeleteDeviceItemTree(plDevErrVal);
  627. if (FAILED(hr)) {
  628. break;
  629. }
  630. hr = BuildDeviceItemTree(plDevErrVal);
  631. if (FAILED(hr)) {
  632. break;
  633. }
  634. m_guidLastEvent = WIA_EVENT_DEVICE_CONNECTED;
  635. SetEvent(m_hSignalEvent);
  636. break;
  637. }
  638. }
  639. }
  640. }
  641. return (hr);
  642. }
  643. /**************************************************************************\
  644. * TestUsdDevice::drvWriteItemProperties
  645. *
  646. * Write the device item properties to the hardware.
  647. *
  648. * Arguments:
  649. *
  650. * pWiasContext - the corresponding wia item context
  651. * pmdtc - pointer to mini driver context
  652. * pFlags - unused
  653. * plDevErrVal - the device error value
  654. *
  655. * Return Value:
  656. *
  657. * Status
  658. *
  659. * History:
  660. *
  661. * 10/29/1998 Original Version
  662. *
  663. \**************************************************************************/
  664. HRESULT _stdcall TestUsdDevice::drvWriteItemProperties(
  665. BYTE *pWiasContext,
  666. LONG lFlags,
  667. PMINIDRV_TRANSFER_CONTEXT pmdtc,
  668. LONG *plDevErrVal)
  669. {
  670. //
  671. // Assume no device hardware errors.
  672. //
  673. *plDevErrVal = 0;
  674. //
  675. // Parameter validation.
  676. //
  677. if ((! pWiasContext) || (! pmdtc)) {
  678. WIAS_ERROR((g_hInst,"drvWriteItemProperties, invalid input pointers"));
  679. return E_POINTER;
  680. }
  681. //
  682. // Get a pointer to the associated driver item.
  683. //
  684. IWiaDrvItem* pDrvItem;
  685. HRESULT hr = wiasGetDrvItem(pWiasContext, &pDrvItem);
  686. if (FAILED(hr)) {
  687. return hr;
  688. }
  689. PMEMCAM_IMAGE_CONTEXT pItemContext;
  690. hr = pDrvItem->GetDeviceSpecContext((BYTE**)&pItemContext);
  691. if (FAILED(hr)) {
  692. WIAS_ERROR((g_hInst,"drvWriteItemProperties, NULL item context"));
  693. return E_POINTER;
  694. }
  695. //
  696. // Write the device item properties to the hardware here.
  697. //
  698. return hr;
  699. }
  700. /**************************************************************************\
  701. * TestUsdDevice::drvReadItemProperties
  702. *
  703. * Read the device item properties from the hardware.
  704. *
  705. * Arguments:
  706. *
  707. * pWiasContext - wia item context
  708. * lFlags - unused
  709. * nPropSpec -
  710. * pPropSpec -
  711. * plDevErrVal - device error value
  712. *
  713. * Return Value:
  714. *
  715. * Status
  716. *
  717. * History:
  718. *
  719. * 10/29/1998 Original Version
  720. *
  721. \**************************************************************************/
  722. HRESULT _stdcall TestUsdDevice::drvReadItemProperties(
  723. BYTE *pWiasContext,
  724. LONG lFlags,
  725. ULONG nPropSpec,
  726. const PROPSPEC *pPropSpec,
  727. LONG *plDevErrVal)
  728. {
  729. // For most scanner devices, item properties are stored in the driver
  730. // and written out at acquire image time. Some devices support properties
  731. // which should be updated on every property read. This can be done here.
  732. *plDevErrVal = 0;
  733. return S_OK;
  734. }
  735. /**************************************************************************\
  736. * TestUsdDevice::drvLockWiaDevice
  737. *
  738. * Lock access to the device.
  739. *
  740. * Arguments:
  741. *
  742. * pWiasContext - unused,
  743. * lFlags - unused
  744. * plDevErrVal - device error value
  745. *
  746. *
  747. * Return Value:
  748. *
  749. * Status
  750. *
  751. * History:
  752. *
  753. * 9/11/1998 Original Version
  754. *
  755. \**************************************************************************/
  756. HRESULT TestUsdDevice::drvLockWiaDevice(
  757. BYTE *pWiasContext,
  758. LONG lFlags,
  759. LONG *plDevErrVal)
  760. {
  761. *plDevErrVal = 0;
  762. if (m_pStiDevice)
  763. {
  764. return m_pStiDevice->LockDevice(100);
  765. }
  766. return S_OK;
  767. }
  768. /**************************************************************************\
  769. * TestUsdDevice::drvUnLockWiaDevice
  770. *
  771. * Unlock access to the device.
  772. *
  773. * Arguments:
  774. *
  775. * pWiasContext - unused
  776. * lFlags - unused
  777. * plDevErrVal - device error value
  778. *
  779. *
  780. * Return Value:
  781. *
  782. * Status
  783. *
  784. * History:
  785. *
  786. * 9/11/1998 Original Version
  787. *
  788. \**************************************************************************/
  789. HRESULT TestUsdDevice::drvUnLockWiaDevice(
  790. BYTE *pWiasContext,
  791. LONG lFlags,
  792. LONG *plDevErrVal)
  793. {
  794. plDevErrVal = 0;
  795. return m_pStiDevice->UnLockDevice();
  796. }
  797. /**************************************************************************\
  798. * TestUsdDevice::drvAnalyzeItem
  799. *
  800. * The test camera does not support imag analysis.
  801. *
  802. * Arguments:
  803. *
  804. * pWiasContext - Pointer to the device item context to be analyzed.
  805. * lFlags - Operation flags.
  806. * plDevErrVal - device error value
  807. *
  808. * Return Value:
  809. *
  810. * Status
  811. *
  812. * History:
  813. *
  814. * 10/15/1998 Original Version
  815. *
  816. \**************************************************************************/
  817. HRESULT _stdcall TestUsdDevice::drvAnalyzeItem(
  818. BYTE *pWiasContext,
  819. LONG lFlags,
  820. LONG *plDevErrVal)
  821. {
  822. *plDevErrVal = 0;
  823. return E_NOTIMPL;
  824. }
  825. /**************************************************************************\
  826. * TestUsdDevice::drvFreeDrvItemContext
  827. *
  828. * The test scanner does not support imag analysis.
  829. *
  830. * Arguments:
  831. *
  832. * lFlags - unused
  833. * pSpecContext - Pointer to item specific context.
  834. * plDevErrVal - device error value
  835. *
  836. * Return Value:
  837. *
  838. * Status
  839. *
  840. * History:
  841. *
  842. * 10/15/1998 Original Version
  843. *
  844. \**************************************************************************/
  845. HRESULT _stdcall TestUsdDevice::drvFreeDrvItemContext(
  846. LONG lFlags,
  847. BYTE *pSpecContext,
  848. LONG *plDevErrVal)
  849. {
  850. PMEMCAM_IMAGE_CONTEXT pContext = (PMEMCAM_IMAGE_CONTEXT)pSpecContext;
  851. if (pContext != NULL) {
  852. if (pContext->pszCameraImagePath != NULL) {
  853. free(pContext->pszCameraImagePath);
  854. pContext->pszCameraImagePath = NULL;
  855. }
  856. }
  857. return S_OK;
  858. }