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.

292 lines
8.1 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. RmsServr.h
  5. Abstract:
  6. Declaration of the CRmsServer class
  7. Author:
  8. Brian Dodd [brian] 15-Nov-1996
  9. Revision History:
  10. --*/
  11. #ifndef _RMSSERVR_
  12. #define _RMSSERVR_
  13. #include "resource.h" // resource symbols
  14. #include "RmsObjct.h" // CRmsComObject
  15. //
  16. // Registry entry
  17. //
  18. class CRmsServer :
  19. public CComDualImpl<IRmsServer, &IID_IRmsServer, &LIBID_RMSLib>,
  20. public IHsmSystemState,
  21. public CRmsComObject,
  22. public CWsbPersistStream,
  23. public IConnectionPointContainerImpl<CRmsServer>,
  24. public IConnectionPointImpl<CRmsServer, &IID_IRmsSinkEveryEvent, CComDynamicUnkArray>,
  25. public CComCoClass<CRmsServer,&CLSID_CRmsServer>
  26. {
  27. public:
  28. CRmsServer() {}
  29. BEGIN_COM_MAP(CRmsServer)
  30. COM_INTERFACE_ENTRY2(IDispatch, IRmsServer)
  31. COM_INTERFACE_ENTRY(IRmsServer)
  32. COM_INTERFACE_ENTRY(IHsmSystemState)
  33. COM_INTERFACE_ENTRY(IRmsComObject)
  34. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  35. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  36. COM_INTERFACE_ENTRY(IPersistStream)
  37. COM_INTERFACE_ENTRY(IWsbPersistStream)
  38. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  39. END_COM_MAP()
  40. DECLARE_NOT_AGGREGATABLE(CRmsServer)
  41. DECLARE_REGISTRY_RESOURCEID(IDR_RmsServer)
  42. DECLARE_PROTECT_FINAL_CONSTRUCT()
  43. BEGIN_CONNECTION_POINT_MAP(CRmsServer)
  44. CONNECTION_POINT_ENTRY(IID_IRmsSinkEveryEvent)
  45. END_CONNECTION_POINT_MAP()
  46. // CComObjectRoot
  47. public:
  48. STDMETHOD(FinalConstruct)(void);
  49. STDMETHOD(FinalRelease)(void);
  50. // IPersist
  51. public:
  52. STDMETHOD(GetClassID)(
  53. OUT CLSID *pClsid);
  54. // IPersistStream
  55. public:
  56. STDMETHOD(GetSizeMax)(
  57. OUT ULARGE_INTEGER* pSize);
  58. STDMETHOD(Load)(
  59. IN IStream* pStream);
  60. STDMETHOD(Save)(
  61. IN IStream* pStream,
  62. IN BOOL clearDirty);
  63. // IHsmSystemState
  64. public:
  65. STDMETHOD( ChangeSysState )( HSM_SYSTEM_STATE* pSysState );
  66. // IRmsServer
  67. public:
  68. STDMETHOD( InitializeInAnotherThread )(void);
  69. STDMETHOD( Initialize )(void);
  70. STDMETHOD( SaveAll )(void);
  71. STDMETHOD( Unload )(void);
  72. STDMETHOD( GetServerName )(
  73. OUT BSTR *pName);
  74. STDMETHOD( GetCartridges )(
  75. OUT IWsbIndexedCollection **ptr);
  76. STDMETHOD( GetActiveCartridges )(
  77. OUT IWsbIndexedCollection **ptr);
  78. STDMETHOD( GetDataMovers )(
  79. OUT IWsbIndexedCollection **ptr);
  80. STDMETHOD( SetActiveCartridge )(
  81. IN IRmsCartridge *ptr);
  82. STDMETHOD( GetLibraries )(
  83. OUT IWsbIndexedCollection **ptr);
  84. STDMETHOD( GetMediaSets )(
  85. OUT IWsbIndexedCollection **ptr);
  86. STDMETHOD( GetRequests )(
  87. OUT IWsbIndexedCollection **ptr);
  88. STDMETHOD( GetClients )(
  89. OUT IWsbIndexedCollection **ptr);
  90. STDMETHOD( GetUnconfiguredDevices )(
  91. OUT IWsbIndexedCollection **ptr);
  92. STDMETHOD( ScanForDevices )(void);
  93. STDMETHOD( ScanForDrives )(void);
  94. STDMETHOD( MountScratchCartridge )(
  95. OUT GUID *pCartId,
  96. IN REFGUID fromMediaSet,
  97. IN REFGUID prevSideId,
  98. IN OUT LONGLONG *pFreeSpace,
  99. IN LONG blockingFactor,
  100. IN BSTR displayName,
  101. IN OUT IRmsDrive **ppDrive,
  102. OUT IRmsCartridge **ppCartridge,
  103. OUT IDataMover **ppDataMover,
  104. IN DWORD dwOptions = RMS_NONE);
  105. STDMETHOD( MountCartridge )(
  106. IN REFGUID cartId,
  107. IN OUT IRmsDrive **ppDrive,
  108. OUT IRmsCartridge **ppCartridge,
  109. OUT IDataMover **ppDataMover,
  110. IN DWORD dwOptions = RMS_NONE,
  111. IN DWORD threadId = 0);
  112. STDMETHOD( DismountCartridge )(
  113. IN REFGUID cartId,
  114. IN DWORD dwOptions = RMS_NONE);
  115. STDMETHOD( DuplicateCartridge )(
  116. IN REFGUID cartId,
  117. IN REFGUID firstSideId,
  118. IN OUT GUID *pCopyCartId,
  119. IN REFGUID copySetId,
  120. IN BSTR copyName,
  121. OUT LONGLONG *pFreeSpace,
  122. OUT LONGLONG *pCapacity,
  123. IN DWORD options);
  124. STDMETHOD( RecycleCartridge )(
  125. IN REFGUID cartId,
  126. IN DWORD options);
  127. STDMETHOD( FindLibraryById )(
  128. IN REFGUID libId,
  129. OUT IRmsLibrary **ptr);
  130. STDMETHOD( FindCartridgeById )(
  131. IN REFGUID cartId,
  132. OUT IRmsCartridge **ptr);
  133. STDMETHOD( CreateObject )(
  134. IN REFGUID objectId,
  135. IN REFCLSID rclsid,
  136. IN REFIID riid,
  137. IN DWORD dwCreate,
  138. OUT void **ppvObj);
  139. STDMETHOD( IsNTMSInstalled )(void);
  140. STDMETHOD( GetNTMS )(
  141. OUT IRmsNTMS **ptr);
  142. STDMETHOD( IsReady )(void);
  143. STDMETHOD( ChangeState )(
  144. IN LONG newState);
  145. STDMETHOD( GetNofAvailableDrives ) (
  146. IN REFGUID fromMediaSet,
  147. OUT DWORD *pdwNofDrives);
  148. STDMETHOD( FindCartridgeStatusById )(
  149. IN REFGUID cartId,
  150. OUT DWORD *dwStatus);
  151. STDMETHOD( IsMultipleSidedMedia )(
  152. IN REFGUID mediaSetId);
  153. STDMETHOD( CheckSecondSide )(
  154. IN REFGUID firstSideId,
  155. OUT BOOL *pbValid,
  156. OUT GUID *pSecondSideId);
  157. // CRmsServer
  158. private:
  159. HRESULT resolveUnconfiguredDevices(void);
  160. HRESULT autoConfigureDevices(void);
  161. HRESULT processInquiryData(
  162. IN int portNumber,
  163. IN UCHAR *pPortScanData);
  164. HRESULT findDriveLetter(
  165. IN UCHAR portNo,
  166. IN UCHAR pathNo,
  167. IN UCHAR id,
  168. IN UCHAR lun,
  169. OUT OLECHAR *driveString);
  170. HRESULT getDeviceName(
  171. IN UCHAR portNo,
  172. IN UCHAR pathNo,
  173. IN UCHAR id,
  174. IN UCHAR lun,
  175. OUT OLECHAR *deviceName);
  176. HRESULT getHardDrivesToUseFromRegistry(
  177. OUT OLECHAR *pDrivesToUse, OUT DWORD *pLen);
  178. HRESULT enableAsBackupOperator(void);
  179. private:
  180. enum { // Class specific constants:
  181. //
  182. Version = 1, // Class version, this should be
  183. // incremented each time the
  184. // the class definition changes.
  185. MaxActive = 8 // Max number of active cartridges.
  186. };
  187. CWsbStringPtr m_dbPath; // The directory where databases are stored.
  188. LONG m_LockReference;// The server lock used for blocking normal access during synchornized operations.
  189. CWsbBstrPtr m_ServerName; // The name of the computer running the server.
  190. CComPtr<IWsbIndexedCollection> m_pCartridges; // The cartridges known to the server.
  191. CComPtr<IWsbIndexedCollection> m_pLibraries; // The libraries managed by the server.
  192. CComPtr<IWsbIndexedCollection> m_pMediaSets; // The media sets known to the server.
  193. CComPtr<IWsbIndexedCollection> m_pRequests; // The requests associated with the server.
  194. CComPtr<IWsbIndexedCollection> m_pClients; // The clients associated with the server.
  195. CComPtr<IWsbIndexedCollection> m_pUnconfiguredDevices; // The unconfigured devices associated with the server.
  196. CComPtr<IRmsNTMS> m_pNTMS; // NTMS support.
  197. ULONG m_HardDrivesUsed; // the number of hard drives in use by RMS.
  198. //typedef List<int> LISTINT;
  199. //LISTINT::iterator i;
  200. //LISTINT test;
  201. //List<IRmsCartridge *> m_ListOfActiveCartridges; // The cartridges already mounted into a drive.
  202. //List<IRmsCartridge *>::iterator m_IteratorForListOfActiveCartridges; // The cartridges already mounted into a drive.
  203. CComPtr<IWsbIndexedCollection> m_pActiveCartridges; // The cartridges already mounted into a drive.
  204. CComPtr<IWsbIndexedCollection> m_pDataMovers; // The active data movers.
  205. CComPtr<IRmsCartridge> m_pActiveCartridge ; // The cartridges already mounted into a drive.
  206. // Thread routines
  207. public:
  208. static DWORD WINAPI InitializationThread(
  209. IN LPVOID pv);
  210. };
  211. /////////////////////////////////////////////////////////////////////////////
  212. //
  213. // g_pServer
  214. //
  215. // This is made global so that anybody in the context of Rms has
  216. // quick access to it
  217. //
  218. extern IRmsServer *g_pServer;
  219. extern CRITICAL_SECTION g_CriticalSection;
  220. #endif // _RMSSERVR_