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.

249 lines
6.8 KiB

  1. // smb.h: SMB shares, sessions and open resources
  2. #ifndef __SMB_H_INCLUDED__
  3. #define __SMB_H_INCLUDED__
  4. #include "FileSvc.h" // FileServiceProvider
  5. #include "shlobj.h" // LPITEMIDLIST
  6. //
  7. // helper functions
  8. //
  9. HRESULT GetDCInfo(
  10. IN LPCTSTR ptchServerName,
  11. OUT CString& strDCName
  12. );
  13. HRESULT GetADsPathOfComputerObject(
  14. IN LPCTSTR ptchServerName,
  15. OUT CString& strADsPath,
  16. OUT CString& strDCName
  17. );
  18. HRESULT CheckSchemaVersion(IN LPCTSTR ptchServerName);
  19. BOOL CheckPolicyOnSharePublish(IN LPCTSTR ptchShareName);
  20. HRESULT PutMultiValuesIntoVarArray(
  21. IN LPCTSTR pszValues,
  22. OUT VARIANT* pVar
  23. );
  24. HRESULT GetSingleOrMultiValuesFromVarArray(
  25. IN VARIANT* pVar,
  26. OUT CString& strValues
  27. );
  28. HRESULT IsValueInVarArray(
  29. IN VARIANT* pVar,
  30. IN LPCTSTR ptchValue
  31. );
  32. // forward declarations
  33. class CSmbCookieBlock;
  34. class SmbFileServiceProvider : public FileServiceProvider
  35. {
  36. public:
  37. SmbFileServiceProvider( CFileMgmtComponentData* pFileMgmtData );
  38. virtual DWORD DeleteShare(LPCTSTR ptchServerName, LPCTSTR ptchShareName);
  39. virtual DWORD CloseSession(CFileMgmtResultCookie* pcookie);
  40. virtual DWORD CloseResource(CFileMgmtResultCookie* pcookie);
  41. virtual VOID DisplayShareProperties(
  42. LPPROPERTYSHEETCALLBACK pCallBack,
  43. LPDATAOBJECT pDataObject,
  44. LONG_PTR handle);
  45. virtual DWORD ReadShareProperties(
  46. LPCTSTR ptchServerName,
  47. LPCTSTR ptchShareName,
  48. OUT PVOID* ppvPropertyBlock,
  49. OUT CString& strDescription,
  50. OUT CString& strPath,
  51. OUT BOOL* pfEditDescription,
  52. OUT BOOL* pfEditPath,
  53. OUT DWORD* pdwShareType);
  54. virtual DWORD WriteShareProperties(
  55. LPCTSTR ptchServerName,
  56. LPCTSTR ptchShareName,
  57. PVOID pvPropertyBlock,
  58. LPCTSTR ptchDescription,
  59. LPCTSTR ptchPath);
  60. virtual HRESULT ReadSharePublishInfo(
  61. LPCTSTR ptchServerName,
  62. LPCTSTR ptchShareName,
  63. OUT BOOL* pbPublish,
  64. OUT CString& strUNCPath,
  65. OUT CString& strDescription,
  66. OUT CString& strKeywords,
  67. OUT CString& strManagedBy);
  68. virtual HRESULT WriteSharePublishInfo(
  69. LPCTSTR ptchServerName,
  70. LPCTSTR ptchShareName,
  71. IN BOOL bPublish,
  72. LPCTSTR ptchDescription,
  73. LPCTSTR ptchKeywords,
  74. LPCTSTR ptchManagedBy);
  75. virtual DWORD ReadShareType(
  76. LPCTSTR ptchServerName,
  77. LPCTSTR ptchShareName,
  78. DWORD* pdwShareType );
  79. virtual DWORD ReadShareFlags(
  80. LPCTSTR ptchServerName,
  81. LPCTSTR ptchShareName,
  82. DWORD* pdwFlags );
  83. virtual DWORD WriteShareFlags(
  84. LPCTSTR ptchServerName,
  85. LPCTSTR ptchShareName,
  86. DWORD dwFlags );
  87. virtual BOOL GetCachedFlag( DWORD dwFlags, DWORD dwFlagToCheck );
  88. virtual VOID SetCachedFlag( DWORD* pdwFlags, DWORD dwNewFlag );
  89. virtual VOID FreeShareProperties(PVOID pvPropertyBlock);
  90. virtual HRESULT PopulateShares(
  91. IResultData* pResultData,
  92. CFileMgmtCookie* pcookie);
  93. // if pResultData is not NULL, add sessions/resources to the listbox
  94. // if pResultData is NULL, delete all sessions/resources
  95. // if pResultData is NULL, return SUCCEEDED(hr) to continue or
  96. // FAILED(hr) to abort
  97. virtual HRESULT EnumerateSessions(
  98. IResultData* pResultData,
  99. CFileMgmtCookie* pcookie,
  100. bool bAddToResultPane);
  101. virtual HRESULT EnumerateResources(
  102. IResultData* pResultData,
  103. CFileMgmtCookie* pcookie);
  104. virtual VOID FreeData(PVOID pv);
  105. virtual DWORD QueryMaxUsers(PVOID pvPropertyBlock);
  106. virtual VOID SetMaxUsers( PVOID pvPropertyBlock, DWORD dwMaxUsers);
  107. virtual LPCTSTR QueryTransportString();
  108. HRESULT AddSMBShareItems(
  109. IResultData* pResultData,
  110. CFileMgmtCookie* pParentCookie,
  111. PVOID pinfo,
  112. DWORD nItems);
  113. HRESULT HandleSMBSessionItems(
  114. IResultData* pResultData,
  115. CFileMgmtCookie* pParentCookie,
  116. PVOID pinfo,
  117. DWORD nItems,
  118. BOOL bAddToResultPane);
  119. HRESULT HandleSMBResourceItems(
  120. IResultData* pResultData,
  121. CFileMgmtCookie* pParentCookie,
  122. PVOID pinfo,
  123. DWORD nItems);
  124. private:
  125. CString m_strTransportSMB;
  126. };
  127. class CSmbCookie : public CFileMgmtResultCookie
  128. {
  129. public:
  130. inline CSmbCookie( FileMgmtObjectType objecttype )
  131. : CFileMgmtResultCookie( objecttype ),
  132. m_pCookieBlock (0)
  133. {}
  134. virtual HRESULT GetTransport( OUT FILEMGMT_TRANSPORT* pTransport );
  135. virtual void AddRefCookie();
  136. virtual void ReleaseCookie();
  137. // CHasMachineName
  138. CSmbCookieBlock* m_pCookieBlock;
  139. DECLARE_FORWARDS_MACHINE_NAME(m_pCookieBlock)
  140. };
  141. class CSmbCookieBlock : public CCookieBlock<CSmbCookie>, public CStoresMachineName
  142. {
  143. public:
  144. inline CSmbCookieBlock(
  145. CSmbCookie* aCookies, // use vector ctor, we use vector dtor
  146. INT cCookies,
  147. LPCTSTR lpcszMachineName,
  148. PVOID pvCookieData)
  149. : CCookieBlock<CSmbCookie>( aCookies, cCookies ),
  150. CStoresMachineName( lpcszMachineName ),
  151. m_pvCookieData( pvCookieData )
  152. {
  153. for (int i = 0; i < cCookies; i++)
  154. // {
  155. // aCookies[i].ReadMachineNameFrom( (CHasMachineName*)this );
  156. aCookies[i].m_pCookieBlock = this;
  157. // }
  158. }
  159. virtual ~CSmbCookieBlock();
  160. private:
  161. PVOID m_pvCookieData;
  162. };
  163. class CSmbShareCookie : public CSmbCookie
  164. {
  165. public:
  166. inline CSmbShareCookie() : CSmbCookie( FILEMGMT_SHARE ) {}
  167. virtual HRESULT GetShareName( OUT CString& strShareName );
  168. virtual HRESULT GetExplorerViewDescription( OUT CString& strExplorerViewDescription );
  169. inline virtual DWORD GetNumOfCurrentUses() { return GetShareInfo()->shi2_current_uses; }
  170. virtual BSTR GetColumnText(int nCol);
  171. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  172. inline SHARE_INFO_2* GetShareInfo()
  173. {
  174. ASSERT( NULL != m_pobject );
  175. return (SHARE_INFO_2*)m_pobject;
  176. }
  177. virtual HRESULT GetSharePIDList( OUT LPITEMIDLIST *ppidl );
  178. };
  179. class CSmbSessionCookie : public CSmbCookie
  180. {
  181. public:
  182. inline CSmbSessionCookie() : CSmbCookie( FILEMGMT_SESSION )
  183. {
  184. }
  185. virtual HRESULT GetSessionClientName( OUT CString& strShareName );
  186. virtual HRESULT GetSessionUserName( OUT CString& strShareName );
  187. inline virtual DWORD GetNumOfOpenFiles() { return GetSessionInfo()->sesi1_num_opens; }
  188. inline virtual DWORD GetConnectedTime() { return GetSessionInfo()->sesi1_time; }
  189. inline virtual DWORD GetIdleTime() { return GetSessionInfo()->sesi1_idle_time; }
  190. virtual BSTR GetColumnText(int nCol);
  191. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  192. inline SESSION_INFO_1* GetSessionInfo()
  193. {
  194. ASSERT( NULL != m_pobject );
  195. return (SESSION_INFO_1*)m_pobject;
  196. }
  197. };
  198. class CSmbResourceCookie : public CSmbCookie
  199. {
  200. public:
  201. inline CSmbResourceCookie() : CSmbCookie( FILEMGMT_RESOURCE ) {}
  202. virtual HRESULT GetFileID( DWORD* pdwFileID );
  203. inline virtual DWORD GetNumOfLocks() { return GetFileInfo()->fi3_num_locks; }
  204. virtual BSTR GetColumnText(int nCol);
  205. virtual BSTR QueryResultColumnText( int nCol, CFileMgmtComponentData& refcdata );
  206. inline FILE_INFO_3* GetFileInfo()
  207. {
  208. ASSERT( NULL != m_pobject );
  209. return (FILE_INFO_3*)m_pobject;
  210. }
  211. };
  212. #endif // ~__SMB_H_INCLUDED__