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.

276 lines
7.9 KiB

  1. // sfm.h: SFM shares, sessions and open resources
  2. #ifndef __SFM_H_INCLUDED__
  3. #define __SFM_H_INCLUDED__
  4. #include "FileSvc.h" // FileServiceProvider
  5. class DynamicDLL;
  6. class CSFMPropertySheet;
  7. typedef enum _SfmApiIndex
  8. {
  9. AFP_VOLUME_ENUM = 0,
  10. AFP_SESSION_ENUM,
  11. AFP_FILE_ENUM,
  12. AFP_BUFFER_FREE,
  13. AFP_VOLUME_DEL,
  14. AFP_CONNECTION_ENUM,
  15. AFP_CONNECTION_CLOSE,
  16. AFP_SESSION_CLOSE,
  17. AFP_FILE_CLOSE,
  18. AFP_CONNECT,
  19. AFP_DISCONNECT,
  20. AFP_VOLUME_GET_INFO,
  21. AFP_VOLUME_SET_INFO,
  22. AFP_DIRECTORY_GET_INFO,
  23. AFP_DIRECTORY_SET_INFO,
  24. AFP_SERVER_GET_INFO,
  25. AFP_SERVER_SET_INFO,
  26. AFP_ETC_MAP_ASSOCIATE,
  27. AFP_ETC_MAP_ADD,
  28. AFP_ETC_MAP_DELETE,
  29. AFP_ETC_MAP_GET_INFO,
  30. AFP_ETC_MAP_SET_INFO,
  31. AFP_MESSAGE_SEND,
  32. AFP_STATISTICS_GET
  33. };
  34. // not subject to localization
  35. static LPCSTR g_apchFunctionNames[] = {
  36. "AfpAdminVolumeEnum",
  37. "AfpAdminSessionEnum",
  38. "AfpAdminFileEnum",
  39. "AfpAdminBufferFree",
  40. "AfpAdminVolumeDelete",
  41. "AfpAdminConnectionEnum",
  42. "AfpAdminConnectionClose",
  43. "AfpAdminSessionClose",
  44. "AfpAdminFileClose",
  45. "AfpAdminConnect",
  46. "AfpAdminDisconnect",
  47. "AfpAdminVolumeGetInfo",
  48. "AfpAdminVolumeSetInfo",
  49. "AfpAdminDirectoryGetInfo",
  50. "AfpAdminDirectorySetInfo",
  51. "AfpAdminServerGetInfo",
  52. "AfpAdminServerSetInfo",
  53. "AfpAdminETCMapAssociate",
  54. "AfpAdminETCMapAdd",
  55. "AfpAdminETCMapDelete",
  56. "AfpAdminETCMapGetInfo",
  57. "AfpAdminETCMapSetInfo",
  58. "AfpAdminMessageSend",
  59. "AfpAdminStatisticsGet",
  60. NULL
  61. };
  62. // not subject to localization
  63. extern DynamicDLL g_SfmDLL;
  64. // forward declarations
  65. class CSfmCookieBlock;
  66. class SfmFileServiceProvider : public FileServiceProvider
  67. {
  68. public:
  69. SfmFileServiceProvider( CFileMgmtComponentData* pFileMgmtData );
  70. ~SfmFileServiceProvider();
  71. virtual DWORD OpenShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName) { return NERR_Success; }
  72. virtual HRESULT ConfirmDeleteShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  73. virtual DWORD DeleteShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  74. virtual DWORD CloseSession(CFileMgmtResultCookie* pcookie);
  75. virtual DWORD CloseResource(CFileMgmtResultCookie* pcookie);
  76. virtual VOID DisplayShareProperties(
  77. LPPROPERTYSHEETCALLBACK pCallBack,
  78. LPDATAOBJECT pDataObject,
  79. LONG_PTR handle);
  80. virtual DWORD ReadShareProperties(
  81. LPCTSTR ptchServerName,
  82. LPCTSTR ptchShareName,
  83. OUT PVOID* ppvPropertyBlock,
  84. OUT CString& strDescription,
  85. OUT CString& strPath,
  86. OUT BOOL* pfEditDescription,
  87. OUT BOOL* pfEditPath,
  88. OUT DWORD* pdwShareType);
  89. virtual DWORD WriteShareProperties(LPCTSTR ptchServerName, LPCTSTR ptchShareName,
  90. PVOID pvPropertyBlock, LPCTSTR ptchDescription, LPCTSTR ptchPath);
  91. virtual VOID FreeShareProperties(PVOID pvPropertyBlock);
  92. virtual DWORD QueryMaxUsers(PVOID pvPropertyBlock);
  93. virtual VOID SetMaxUsers( PVOID pvPropertyBlock, DWORD dwMaxUsers);
  94. virtual VOID FreeData(PVOID pv);
  95. virtual HRESULT PopulateShares(
  96. IResultData* pResultData,
  97. CFileMgmtCookie* pcookie);
  98. // if pResultData is not NULL, add sessions/resources to the listbox
  99. // if pResultData is NULL, delete all sessions/resources
  100. // if pResultData is NULL, return SUCCEEDED(hr) to continue or
  101. // FAILED(hr) to abort
  102. virtual HRESULT EnumerateSessions(
  103. IResultData* pResultData,
  104. CFileMgmtCookie* pcookie,
  105. bool bAddToResultPane);
  106. virtual HRESULT EnumerateResources(
  107. IResultData* pResultData,
  108. CFileMgmtCookie* pcookie);
  109. virtual LPCTSTR QueryTransportString();
  110. HRESULT AddSFMShareItems(
  111. IResultData* pResultData,
  112. CFileMgmtCookie* pParentCookie,
  113. PVOID pinfo,
  114. DWORD nItems);
  115. HRESULT HandleSFMSessionItems(
  116. IResultData* pResultData,
  117. CFileMgmtCookie* pParentCookie,
  118. PVOID pinfo,
  119. DWORD nItems,
  120. BOOL bAddToResultPane);
  121. HRESULT HandleSFMResourceItems(
  122. IResultData* pResultData,
  123. CFileMgmtCookie* pParentCookie,
  124. PVOID pinfo,
  125. DWORD nItems);
  126. DWORD GetDirectoryInfo(
  127. LPCTSTR ptchServerName,
  128. LPCWSTR pszPath,
  129. DWORD* pdwPerms,
  130. CString& strOwner,
  131. CString& strGroup );
  132. DWORD SetDirectoryInfo(
  133. LPCTSTR ptchServerName,
  134. LPCWSTR pszPath,
  135. DWORD dwPerms,
  136. LPCWSTR pszOwner,
  137. LPCWSTR pszGroup );
  138. // functions added for SFM configuration - EricDav
  139. BOOL DisplaySfmProperties(
  140. LPDATAOBJECT pDataObject,
  141. CFileMgmtCookie* pCookie);
  142. void CleanupSfmProperties();
  143. void SetSfmPropSheet(CSFMPropertySheet * pSfmPropSheet);
  144. DWORD UserHasAccess(LPCWSTR pwchServerName);
  145. BOOL FSFMInstalled(LPCWSTR pwchServerName);
  146. BOOL StartSFM(HWND hwndParent, SC_HANDLE hScManager, LPCWSTR pwchServerName);
  147. // This is public, but be careful to use it promptly after SFMConnect().
  148. AFP_SERVER_HANDLE m_ulSFMServerConnection;
  149. BOOL SFMConnect(LPCWSTR pwchServer, BOOL fDisplayError = FALSE);
  150. void SFMDisconnect();
  151. private:
  152. CString m_ulSFMServerConnectionMachine;
  153. CString m_strTransportSFM;
  154. CSFMPropertySheet * m_pSfmPropSheet;
  155. };
  156. class CSfmCookie : public CFileMgmtResultCookie
  157. {
  158. public:
  159. CSfmCookie( FileMgmtObjectType objecttype )
  160. : CFileMgmtResultCookie( objecttype )
  161. {}
  162. virtual HRESULT GetTransport( OUT FILEMGMT_TRANSPORT* pTransport );
  163. virtual void AddRefCookie();
  164. virtual void ReleaseCookie();
  165. // CHasMachineName
  166. CSfmCookieBlock* m_pCookieBlock;
  167. DECLARE_FORWARDS_MACHINE_NAME(m_pCookieBlock)
  168. };
  169. class CSfmCookieBlock : public CCookieBlock<CSfmCookie>, public CStoresMachineName
  170. {
  171. public:
  172. inline CSfmCookieBlock(
  173. CSfmCookie* aCookies, // use vector ctor, we use vector dtor
  174. INT cCookies,
  175. LPCTSTR lpcszMachineName,
  176. PVOID pvCookieData)
  177. : CCookieBlock<CSfmCookie>( aCookies, cCookies ),
  178. CStoresMachineName( lpcszMachineName ),
  179. m_pvCookieData( pvCookieData )
  180. {
  181. for (int i = 0; i < cCookies; i++)
  182. // {
  183. // aCookies[i].ReadMachineNameFrom( (CHasMachineName*)this );
  184. aCookies[i].m_pCookieBlock = this;
  185. // }
  186. }
  187. virtual ~CSfmCookieBlock();
  188. private:
  189. PVOID m_pvCookieData;
  190. };
  191. class CSfmShareCookie : public CSfmCookie
  192. {
  193. public:
  194. CSfmShareCookie() : CSfmCookie( FILEMGMT_SHARE ) {}
  195. virtual HRESULT GetShareName( OUT CString& strShareName );
  196. inline virtual DWORD GetNumOfCurrentUses() { return GetShareInfo()->afpvol_curr_uses; }
  197. virtual BSTR GetColumnText(int nCol);
  198. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  199. inline AFP_VOLUME_INFO* GetShareInfo()
  200. {
  201. ASSERT( NULL != m_pobject );
  202. return (AFP_VOLUME_INFO*)m_pobject;
  203. }
  204. virtual HRESULT GetSharePIDList( OUT LPITEMIDLIST *ppidl );
  205. };
  206. class CSfmSessionCookie : public CSfmCookie
  207. {
  208. public:
  209. inline CSfmSessionCookie() : CSfmCookie( FILEMGMT_SESSION )
  210. {
  211. }
  212. virtual HRESULT GetSessionID( DWORD* pdwSessionID );
  213. inline virtual DWORD GetNumOfOpenFiles() { return GetSessionInfo()->afpsess_num_opens; }
  214. inline virtual DWORD GetConnectedTime() { return GetSessionInfo()->afpsess_time; }
  215. inline virtual DWORD GetIdleTime() { return 0; }
  216. virtual BSTR GetColumnText(int nCol);
  217. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  218. inline AFP_SESSION_INFO* GetSessionInfo()
  219. {
  220. ASSERT( NULL != m_pobject );
  221. return (AFP_SESSION_INFO*)m_pobject;
  222. }
  223. };
  224. class CSfmResourceCookie : public CSfmCookie
  225. {
  226. public:
  227. CSfmResourceCookie() : CSfmCookie( FILEMGMT_RESOURCE ) {}
  228. virtual HRESULT GetFileID( DWORD* pdwFileID );
  229. inline virtual DWORD GetNumOfLocks() { return GetFileInfo()->afpfile_num_locks; }
  230. virtual BSTR GetColumnText(int nCol);
  231. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  232. inline AFP_FILE_INFO* GetFileInfo()
  233. {
  234. ASSERT( NULL != m_pobject );
  235. return (AFP_FILE_INFO*)m_pobject;
  236. }
  237. };
  238. #endif // ~__SFM_H_INCLUDED__