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.

257 lines
11 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. RmsCartg.h
  5. Abstract:
  6. Declaration of the CRmsCartridge class
  7. Author:
  8. Brian Dodd [brian] 15-Nov-1996
  9. Revision History:
  10. --*/
  11. #ifndef _RMSCARTG_
  12. #define _RMSCARTG_
  13. #include "resource.h" // resource symbols
  14. #include "RmsSInfo.h" // CRmsStorageInfo
  15. #include "RmsLocat.h" // CRmsLocator
  16. /*++
  17. Class Name:
  18. CRmsCartridge
  19. Class Description:
  20. A CRmsCartridge represents a unit of removalble media. This can be a tape
  21. cartridge, removable hard disk, optical platter (of various formats),
  22. Compact Disk, or DVD Optical Disc. A Cartridge is normally designated as
  23. either scratch or private. The Cartrige name or GUID is used by an
  24. application when referencing a particular unit of removable media.
  25. Cartridge information is maintained by the Removable Media Service, and
  26. the Cartriges's properties are recreated or updated by auditing the contents of
  27. the Library.
  28. --*/
  29. class CRmsCartridge :
  30. public CComDualImpl<IRmsCartridge, &IID_IRmsCartridge, &LIBID_RMSLib>,
  31. public CRmsStorageInfo, // inherits CRmsComObject
  32. public CWsbObject, // inherits CComObjectRoot
  33. public CComCoClass<CRmsCartridge,&CLSID_CRmsCartridge>
  34. {
  35. public:
  36. CRmsCartridge() {}
  37. BEGIN_COM_MAP(CRmsCartridge)
  38. COM_INTERFACE_ENTRY2(IDispatch, IRmsCartridge)
  39. COM_INTERFACE_ENTRY(IRmsCartridge)
  40. COM_INTERFACE_ENTRY(IRmsComObject)
  41. COM_INTERFACE_ENTRY(IRmsStorageInfo)
  42. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  43. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  44. COM_INTERFACE_ENTRY(IPersistStream)
  45. COM_INTERFACE_ENTRY(IWsbCollectable)
  46. COM_INTERFACE_ENTRY(IWsbPersistStream)
  47. COM_INTERFACE_ENTRY(IWsbTestable)
  48. END_COM_MAP()
  49. DECLARE_REGISTRY_RESOURCEID(IDR_RmsCartridge)
  50. // CComObjectRoot
  51. public:
  52. STDMETHOD(FinalConstruct)(void);
  53. STDMETHOD(FinalRelease)(void);
  54. // IPersist
  55. public:
  56. STDMETHOD(GetClassID)(CLSID *pClsid);
  57. // IPersistStream
  58. public:
  59. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
  60. STDMETHOD(Load)(IStream* pStream);
  61. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  62. // IWsbCollectable
  63. public:
  64. STDMETHOD(CompareTo)( IN IUnknown *pCollectable, OUT SHORT *pResult);
  65. WSB_FROM_CWSBOBJECT;
  66. // IWsbTestable
  67. public:
  68. STDMETHOD(Test)(USHORT *pPassed, USHORT *pFailed);
  69. // IRmsCartridge
  70. public:
  71. STDMETHOD(GetCartridgeId)(GUID *pCartId);
  72. STDMETHOD(SetCartridgeId)(GUID cartId);
  73. STDMETHOD(GetMediaSetId)(GUID *pMediaSetId);
  74. STDMETHOD(SetMediaSetId)(GUID mediaSetId);
  75. STDMETHOD(GetName)(BSTR *pName);
  76. STDMETHOD(SetName)(BSTR name);
  77. STDMETHOD(GetDescription)(BSTR *pDescription);
  78. STDMETHOD(SetDescription)(BSTR description);
  79. STDMETHOD(GetTagAndNumber)(BSTR *pTag, LONG *pNumber);
  80. STDMETHOD(SetTagAndNumber)(BSTR tag, LONG number);
  81. STDMETHOD(GetBarcode)(BSTR *pBarcode); // Same as Tag
  82. // OnMediaIdentifier is used by DataMover
  83. STDMETHOD(GetOnMediaIdentifier)(BYTE *pIdentifier, LONG *pSize, LONG *pType);
  84. STDMETHOD(SetOnMediaIdentifier)(BYTE *pIdentifier, LONG size, LONG type);
  85. // OnMediaLabel is used by DataMover
  86. STDMETHOD(GetOnMediaLabel)(BSTR *pLabel);
  87. STDMETHOD(SetOnMediaLabel)(BSTR label);
  88. STDMETHOD(GetStatus)(LONG *pStatus);
  89. STDMETHOD(SetStatus)(LONG status);
  90. STDMETHOD(GetType)(LONG *pType);
  91. STDMETHOD(SetType)(LONG type);
  92. STDMETHOD(GetBlockSize)(LONG *pBlockSize);
  93. STDMETHOD(SetBlockSize)(LONG blockSize);
  94. STDMETHOD(IsTwoSided)(void);
  95. STDMETHOD(SetIsTwoSided)(BOOL flag);
  96. STDMETHOD(IsMounted)(void);
  97. STDMETHOD(SetIsMounted)(BOOL flag);
  98. STDMETHOD(IsAvailable)(void);
  99. STDMETHOD(SetIsAvailable)(BOOL flag);
  100. STDMETHOD(GetHome)(LONG *pType, GUID *pLibId, GUID *pMediaSetId, LONG *pPos, LONG *pAlt1, LONG *pAlt2, LONG *pAlt3, BOOL *pInvert);
  101. STDMETHOD(SetHome)(LONG type, GUID libId, GUID mediaSetId, LONG pos, LONG alt1, LONG alt2, LONG alt3, BOOL invert);
  102. STDMETHOD(GetLocation)(LONG *pType, GUID *pLibId, GUID *pMediaSetId, LONG *pPos, LONG *pAlt1, LONG *pAlt2, LONG *pAlt3, BOOL *pInvert);
  103. STDMETHOD(SetLocation)(LONG type, GUID libId, GUID mediaSetId, LONG pos, LONG alt1, LONG alt2, LONG alt3, BOOL invert);
  104. STDMETHOD(GetMailStop)(BSTR *pMailStop);
  105. STDMETHOD(SetMailStop)(BSTR mailStop);
  106. STDMETHOD(GetDrive)(IRmsDrive **ptr);
  107. STDMETHOD(SetDrive)(IRmsDrive *ptr);
  108. STDMETHOD(GetInfo)(UCHAR *pInfo, SHORT *pSize);
  109. STDMETHOD(SetInfo)(UCHAR *pInfo, SHORT size);
  110. STDMETHOD(GetOwnerClassId)(CLSID *pClassId);
  111. STDMETHOD(SetOwnerClassId)(CLSID classId);
  112. STDMETHOD(GetPartitions)(IWsbIndexedCollection **ptr);
  113. STDMETHOD(GetVerifierClass)(CLSID *pClassId);
  114. STDMETHOD(SetVerifierClass)(CLSID classId);
  115. STDMETHOD(GetPortalClass)(CLSID *pClassId);
  116. STDMETHOD(SetPortalClass)(CLSID classId);
  117. STDMETHOD( Mount )( OUT IRmsDrive **ppDrive, IN DWORD dwOptions = RMS_NONE, IN DWORD threadId = 0);
  118. STDMETHOD( Dismount )( IN DWORD dwOptions = RMS_NONE );
  119. STDMETHOD( Home )( IN DWORD dwOptions = RMS_NONE );
  120. STDMETHOD( CreateDataMover )( /*[out]*/ IDataMover **ptr );
  121. STDMETHOD( ReleaseDataMover )( IN IDataMover *ptr );
  122. STDMETHOD( LoadDataCache )(OUT BYTE *pCache, IN OUT ULONG *pSize, OUT ULONG *pUsed, OUT ULARGE_INTEGER *pStartPBA);
  123. STDMETHOD( SaveDataCache )(IN BYTE *pCache, IN ULONG size, IN ULONG used, IN ULARGE_INTEGER startPBA);
  124. STDMETHOD( GetManagedBy )(OUT LONG *pManagedBy);
  125. STDMETHOD( SetManagedBy )(IN LONG managedBy);
  126. STDMETHOD(IsFixedBlockSize)(void);
  127. // CRmsCartridge
  128. private:
  129. HRESULT updateMountStats( IN BOOL bRead, IN BOOL bWrite );
  130. private:
  131. enum { // Class specific constants:
  132. //
  133. Version = 1, // Class version, this should be
  134. // incremented each time the
  135. // the class definition changes.
  136. MaxInfo = RMS_STR_MAX_CARTRIDGE_INFO // Size of the application specific
  137. // information buffer. Currently
  138. // fixed in size.
  139. };
  140. CWsbBstrPtr m_externalLabel; // A string representing bar code or
  141. // SCSI volume-tag information.
  142. LONG m_externalNumber; // A numeric value representing
  143. // SCSI volume-tag sequence number.
  144. LONG m_sizeofOnMediaId; // The size of the on media identification buffer.
  145. LONG m_typeofOnMediaId; // The type of the on media identification.
  146. BYTE *m_pOnMediaId; // Raw on media identification buffer.
  147. //
  148. CWsbBstrPtr m_onMediaLabel; // The UNICODE label written on the media.
  149. //
  150. RmsStatus m_status; // Cartridge status (see RmsStatus).
  151. RmsMedia m_type; // The type of Cartridge (see RmsMedia).
  152. LONG m_BlockSize; // Media block size.
  153. BOOL m_isTwoSided; // TRUE if the Cartridge represents two-sided media
  154. // Note: Currently nobody sets this value -
  155. // this should be fixed if found to be important
  156. BOOL m_isMounted; // TRUE if the Cartridge is mounted in a drive.
  157. BOOL m_isInTransit; // TRUE if the Cartridge is in transit between locations.
  158. BOOL m_isAvailable; // TRUE if the Cartridge is not in use by any application
  159. // (Note: Available here does not ensure online)
  160. BOOL m_isMountedSerialized; // TRUE if the cartridge has been mounted as serialized
  161. CRmsLocator m_home; // The preferred storage location
  162. // for the Cartridge (see CRmsLocator).
  163. CRmsLocator m_location; // The current location of the
  164. // Cartridge (see CRmsLocator).
  165. CRmsLocator m_destination; // The target destination location of the
  166. // Cartridge (see CRmsLocator). Valid when
  167. // m_isInTransit bit is set.
  168. CWsbBstrPtr m_mailStop; // A string describing the shelf (local)
  169. // or off-site location of a Cartridge.
  170. // This is displayed when the Cartridge
  171. // needs to be mounted with human
  172. // intervention. [This field is
  173. // created by the Import/Export dialog.]
  174. CComPtr<IRmsDrive> m_pDrive; // The drive in which the cartridge is mounted.
  175. SHORT m_sizeofInfo; // The size of valid data in the application
  176. // specific information buffer.
  177. UCHAR m_info[MaxInfo]; // Application specific information.
  178. CLSID m_ownerClassId; // The Class ID for the application that
  179. // owns/created the cartridge resource.
  180. CComPtr<IWsbIndexedCollection> m_pParts; // A collection of Partitions. These
  181. // represent the partitions on a tape
  182. // or sides of an optical platter.
  183. CLSID m_verifierClass; // The interface to the on-media
  184. // ID verification function.
  185. CLSID m_portalClass; // The interface to a site specific import
  186. // and export storage location
  187. // specification dialog.
  188. BYTE * m_pDataCache; // Cache used to handle I/O for block boudary conditions
  189. ULONG m_DataCacheSize; // Max size of the cache
  190. ULONG m_DataCacheUsed; // The number of bytes of the cache containing valid data
  191. ULARGE_INTEGER m_DataCacheStartPBA; // The corresponding starting PBA for the cache
  192. RmsMode m_MountMode; // The mount mode specified for the cartridge.
  193. RmsMediaManager m_ManagedBy; // The media manager that controls the cartridge.
  194. static int s_InstanceCount; // Counter of the number of object instances.
  195. };
  196. #endif // _RMSCARTG_