Leaked source code of windows server 2003
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.

148 lines
4.7 KiB

  1. /*-----------------------------------------------------------------------------
  2. *
  3. * File: wiaitem.h
  4. * Author: Samuel Clement (samclem)
  5. * Date: Tue Aug 17 17:20:49 1999
  6. *
  7. * Copyright (c) 1999 Microsoft Corporation
  8. *
  9. * Description:
  10. * Contains the the dispatch interface to IWiaItems which represent devices
  11. * Images and other useful wia things.
  12. *
  13. * History:
  14. * 17 Aug 1999: Created.
  15. *----------------------------------------------------------------------------*/
  16. #ifndef _WIAITEM_H_
  17. #define _WIAITEM_H_
  18. #define CLIPBOARD_STR_W L"clipboard"
  19. /*-----------------------------------------------------------------------------
  20. *
  21. * Class: CWiaItem
  22. * Syniosis: Provides a scriptable interface to the IWiaItem which
  23. * corresponds to a particular device.
  24. *
  25. *--(samclem)-----------------------------------------------------------------*/
  26. class ATL_NO_VTABLE CWiaItem :
  27. public CComObjectRootEx<CComSingleThreadModel>,
  28. public IDispatchImpl<IWiaDispatchItem, &IID_IWiaDispatchItem, &LIBID_WIALib>,
  29. public IObjectSafetyImpl<CWiaDeviceInfo, INTERFACESAFE_FOR_UNTRUSTED_CALLER>
  30. {
  31. public:
  32. CWiaItem();
  33. DECLARE_TRACKED_OBJECT
  34. DECLARE_NO_REGISTRY()
  35. DECLARE_PROTECT_FINAL_CONSTRUCT()
  36. STDMETHOD_(void, FinalRelease)();
  37. BEGIN_COM_MAP(CWiaItem)
  38. COM_INTERFACE_ENTRY(IWiaDispatchItem)
  39. COM_INTERFACE_ENTRY(IDispatch)
  40. END_COM_MAP()
  41. // Non-interface methods for internal use
  42. HRESULT CacheProperties( IWiaPropertyStorage* pWiaStg );
  43. HRESULT AttachTo( CWia* pWia, IWiaItem* pWiaItem );
  44. void SendTransferComplete(BSTR bstrFilename );
  45. // IWiaDispatchItem
  46. STDMETHOD(GetItemsFromUI)( WiaFlag Flags, WiaIntent Intent, ICollection** ppCollection );
  47. STDMETHOD(GetPropById)( WiaItemPropertyId Id, VARIANT* pvaOut );
  48. STDMETHOD(Transfer)( BSTR bstrFilename, VARIANT_BOOL bAsyncTransfer);
  49. STDMETHOD(TakePicture)( IWiaDispatchItem** ppDispItem );
  50. STDMETHOD(get_Children)( ICollection** ppCollection );
  51. STDMETHOD(get_ItemType)( BSTR* pbstrType );
  52. // WIA_DPC_xxx
  53. STDMETHOD(get_ConnectStatus)( BSTR* pbstrStatus );
  54. STDMETHOD(get_Time)( BSTR* pbstrTime );
  55. STDMETHOD(get_FirmwareVersion)( BSTR* pbstrVersion );
  56. // WIA_IPA_xxx
  57. STDMETHOD(get_Name)( BSTR* pbstrName );
  58. STDMETHOD(get_FullName)( BSTR* pbstrFullName );
  59. STDMETHOD(get_Width)( long* plWidth );
  60. STDMETHOD(get_Height)( long* plHeight );
  61. // WIA_IPC_xxx
  62. STDMETHOD(get_ThumbWidth)( long* plWidth );
  63. STDMETHOD(get_ThumbHeight)( long* plHeight );
  64. STDMETHOD(get_Thumbnail)( BSTR* pbstrPath );
  65. STDMETHOD(get_PictureWidth)( long* plWidth );
  66. STDMETHOD(get_PictureHeight)( long* pdwHeight );
  67. // Static methods for transfering and caching a thumbnail
  68. // bitmap. Currently this only works for bitmaps.
  69. static HRESULT TransferThumbnailToCache( IWiaItem* pItem, BYTE** ppbThumb, DWORD* pcbThumb );
  70. protected:
  71. CWia* m_pWia;
  72. IWiaItem* m_pWiaItem;
  73. IWiaPropertyStorage* m_pWiaStorage;
  74. // Commonly used properties, prevent: Process -> WIA -> Device
  75. DWORD m_dwThumbWidth;
  76. DWORD m_dwThumbHeight;
  77. BSTR m_bstrThumbUrl;
  78. DWORD m_dwItemWidth;
  79. DWORD m_dwItemHeight;
  80. friend class CWiaDataTransfer;
  81. };
  82. /*-----------------------------------------------------------------------------
  83. *
  84. * Class: CWiaDataTransfer
  85. * Synopsis: This handles the async transfer of the data from WIA. this
  86. * object is only used from within this function object and
  87. * therefore doesn't need to be exposed anywhere else.
  88. *
  89. *--(samclem)-----------------------------------------------------------------*/
  90. class ATL_NO_VTABLE CWiaDataTransfer :
  91. public CComObjectRootEx<CComSingleThreadModel>,
  92. public IWiaDataCallback
  93. {
  94. public:
  95. // used in making the call to DoAsyncTransfer
  96. struct ASYNCTRANSFERPARAMS
  97. {
  98. // this is the stream which contians the marshalled interface
  99. IStream* pStream;
  100. // the file name that we want to transfer to
  101. BSTR bstrFilename;
  102. // the CWiaItem object that we are transferring from
  103. CWiaItem* pItem;
  104. };
  105. DECLARE_TRACKED_OBJECT
  106. BEGIN_COM_MAP(CWiaDataTransfer)
  107. COM_INTERFACE_ENTRY(IWiaDataCallback)
  108. END_COM_MAP()
  109. CWiaDataTransfer();
  110. STDMETHOD_(void, FinalRelease)();
  111. // this is called to do an async transfer. You must pass an
  112. // ASYNCTRANSFERPARAMS structure in for pvParams.
  113. static DWORD WINAPI DoAsyncTransfer( LPVOID pvParams );
  114. HRESULT TransferComplete();
  115. HRESULT Initialize( CWiaItem* pItem, BSTR bstrFilename );
  116. STDMETHOD(BandedDataCallback)( LONG lMessage, LONG lStatus, LONG lPercentComplete,
  117. LONG lOffset, LONG lLength, LONG lReserved, LONG lResLength, BYTE *pbBuffer );
  118. private:
  119. size_t m_sizeBuffer;
  120. BYTE* m_pbBuffer;
  121. CComBSTR m_bstrOutputFile;
  122. CWiaItem* m_pItem;
  123. };
  124. #endif //_WIAITEM_H_