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.

274 lines
7.5 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 DeleteShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  72. virtual DWORD CloseSession(CFileMgmtResultCookie* pcookie);
  73. virtual DWORD CloseResource(CFileMgmtResultCookie* pcookie);
  74. virtual VOID DisplayShareProperties(
  75. LPPROPERTYSHEETCALLBACK pCallBack,
  76. LPDATAOBJECT pDataObject,
  77. LONG_PTR handle);
  78. virtual DWORD ReadShareProperties(
  79. LPCTSTR ptchServerName,
  80. LPCTSTR ptchShareName,
  81. OUT PVOID* ppvPropertyBlock,
  82. OUT CString& strDescription,
  83. OUT CString& strPath,
  84. OUT BOOL* pfEditDescription,
  85. OUT BOOL* pfEditPath,
  86. OUT DWORD* pdwShareType);
  87. virtual DWORD WriteShareProperties(LPCTSTR ptchServerName, LPCTSTR ptchShareName,
  88. PVOID pvPropertyBlock, LPCTSTR ptchDescription, LPCTSTR ptchPath);
  89. virtual VOID FreeShareProperties(PVOID pvPropertyBlock);
  90. virtual DWORD QueryMaxUsers(PVOID pvPropertyBlock);
  91. virtual VOID SetMaxUsers( PVOID pvPropertyBlock, DWORD dwMaxUsers);
  92. virtual VOID FreeData(PVOID pv);
  93. virtual HRESULT PopulateShares(
  94. IResultData* pResultData,
  95. CFileMgmtCookie* pcookie);
  96. // if pResultData is not NULL, add sessions/resources to the listbox
  97. // if pResultData is NULL, delete all sessions/resources
  98. // if pResultData is NULL, return SUCCEEDED(hr) to continue or
  99. // FAILED(hr) to abort
  100. virtual HRESULT EnumerateSessions(
  101. IResultData* pResultData,
  102. CFileMgmtCookie* pcookie,
  103. bool bAddToResultPane);
  104. virtual HRESULT EnumerateResources(
  105. IResultData* pResultData,
  106. CFileMgmtCookie* pcookie);
  107. virtual LPCTSTR QueryTransportString();
  108. HRESULT AddSFMShareItems(
  109. IResultData* pResultData,
  110. CFileMgmtCookie* pParentCookie,
  111. PVOID pinfo,
  112. DWORD nItems);
  113. HRESULT HandleSFMSessionItems(
  114. IResultData* pResultData,
  115. CFileMgmtCookie* pParentCookie,
  116. PVOID pinfo,
  117. DWORD nItems,
  118. BOOL bAddToResultPane);
  119. HRESULT HandleSFMResourceItems(
  120. IResultData* pResultData,
  121. CFileMgmtCookie* pParentCookie,
  122. PVOID pinfo,
  123. DWORD nItems);
  124. DWORD GetDirectoryInfo(
  125. LPCTSTR ptchServerName,
  126. LPCWSTR pszPath,
  127. DWORD* pdwPerms,
  128. CString& strOwner,
  129. CString& strGroup );
  130. DWORD SetDirectoryInfo(
  131. LPCTSTR ptchServerName,
  132. LPCWSTR pszPath,
  133. DWORD dwPerms,
  134. LPCWSTR pszOwner,
  135. LPCWSTR pszGroup );
  136. // functions added for SFM configuration - EricDav
  137. BOOL DisplaySfmProperties(
  138. LPDATAOBJECT pDataObject,
  139. CFileMgmtCookie* pCookie);
  140. void CleanupSfmProperties();
  141. void SetSfmPropSheet(CSFMPropertySheet * pSfmPropSheet);
  142. DWORD UserHasAccess(LPCWSTR pwchServerName);
  143. BOOL FSFMInstalled(LPCWSTR pwchServerName);
  144. BOOL StartSFM(HWND hwndParent, SC_HANDLE hScManager, LPCWSTR pwchServerName);
  145. // This is public, but be careful to use it promptly after SFMConnect().
  146. AFP_SERVER_HANDLE m_ulSFMServerConnection;
  147. BOOL SFMConnect(LPCWSTR pwchServer, BOOL fDisplayError = FALSE);
  148. void SFMDisconnect();
  149. private:
  150. CString m_ulSFMServerConnectionMachine;
  151. CString m_strTransportSFM;
  152. CSFMPropertySheet * m_pSfmPropSheet;
  153. };
  154. class CSfmCookie : public CFileMgmtResultCookie
  155. {
  156. public:
  157. CSfmCookie( FileMgmtObjectType objecttype )
  158. : CFileMgmtResultCookie( objecttype )
  159. {}
  160. virtual HRESULT GetTransport( OUT FILEMGMT_TRANSPORT* pTransport );
  161. virtual void AddRefCookie();
  162. virtual void ReleaseCookie();
  163. // CHasMachineName
  164. CSfmCookieBlock* m_pCookieBlock;
  165. DECLARE_FORWARDS_MACHINE_NAME(m_pCookieBlock)
  166. };
  167. class CSfmCookieBlock : public CCookieBlock<CSfmCookie>, public CStoresMachineName
  168. {
  169. public:
  170. inline CSfmCookieBlock(
  171. CSfmCookie* aCookies, // use vector ctor, we use vector dtor
  172. INT cCookies,
  173. LPCTSTR lpcszMachineName,
  174. PVOID pvCookieData)
  175. : CCookieBlock<CSfmCookie>( aCookies, cCookies ),
  176. CStoresMachineName( lpcszMachineName ),
  177. m_pvCookieData( pvCookieData )
  178. {
  179. for (int i = 0; i < cCookies; i++)
  180. // {
  181. // aCookies[i].ReadMachineNameFrom( (CHasMachineName*)this );
  182. aCookies[i].m_pCookieBlock = this;
  183. // }
  184. }
  185. virtual ~CSfmCookieBlock();
  186. private:
  187. PVOID m_pvCookieData;
  188. };
  189. class CSfmShareCookie : public CSfmCookie
  190. {
  191. public:
  192. CSfmShareCookie() : CSfmCookie( FILEMGMT_SHARE ) {}
  193. virtual HRESULT GetShareName( OUT CString& strShareName );
  194. inline virtual DWORD GetNumOfCurrentUses() { return GetShareInfo()->afpvol_curr_uses; }
  195. virtual BSTR GetColumnText(int nCol);
  196. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  197. inline AFP_VOLUME_INFO* GetShareInfo()
  198. {
  199. ASSERT( NULL != m_pobject );
  200. return (AFP_VOLUME_INFO*)m_pobject;
  201. }
  202. virtual HRESULT GetSharePIDList( OUT LPITEMIDLIST *ppidl );
  203. };
  204. class CSfmSessionCookie : public CSfmCookie
  205. {
  206. public:
  207. inline CSfmSessionCookie() : CSfmCookie( FILEMGMT_SESSION )
  208. {
  209. }
  210. virtual HRESULT GetSessionID( DWORD* pdwSessionID );
  211. inline virtual DWORD GetNumOfOpenFiles() { return GetSessionInfo()->afpsess_num_opens; }
  212. inline virtual DWORD GetConnectedTime() { return GetSessionInfo()->afpsess_time; }
  213. inline virtual DWORD GetIdleTime() { return 0; }
  214. virtual BSTR GetColumnText(int nCol);
  215. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  216. inline AFP_SESSION_INFO* GetSessionInfo()
  217. {
  218. ASSERT( NULL != m_pobject );
  219. return (AFP_SESSION_INFO*)m_pobject;
  220. }
  221. };
  222. class CSfmResourceCookie : public CSfmCookie
  223. {
  224. public:
  225. CSfmResourceCookie() : CSfmCookie( FILEMGMT_RESOURCE ) {}
  226. virtual HRESULT GetFileID( DWORD* pdwFileID );
  227. inline virtual DWORD GetNumOfLocks() { return GetFileInfo()->afpfile_num_locks; }
  228. virtual BSTR GetColumnText(int nCol);
  229. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  230. inline AFP_FILE_INFO* GetFileInfo()
  231. {
  232. ASSERT( NULL != m_pobject );
  233. return (AFP_FILE_INFO*)m_pobject;
  234. }
  235. };
  236. #endif // ~__SFM_H_INCLUDED__