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.

234 lines
9.2 KiB

  1. // --------------------------------------------------------------------------------
  2. // propfind.h
  3. // Copyright (c)1998 Microsoft Corporation, All Rights Reserved
  4. // Greg Friedman
  5. // --------------------------------------------------------------------------------
  6. #ifndef __PROPFIND_H
  7. #define __PROPFIND_H
  8. #include "mimeole.h" // for base IHashTable interface
  9. #include "hash.h"
  10. class CByteStream;
  11. const DWORD c_dwMaxNamespaceID = DAVNAMESPACE_CONTACTS;
  12. // --------------------------------------------------------------------------------
  13. // class CStringArray
  14. // Description : CStringArray is a simple utility class that maintains
  15. // an list of strings that are retrievable by index.
  16. // --------------------------------------------------------------------------------
  17. class CStringArray
  18. {
  19. public:
  20. CStringArray(void);
  21. ~CStringArray(void);
  22. private:
  23. CStringArray(const CStringArray& other);
  24. CStringArray& operator=(const CStringArray& other);
  25. public:
  26. ULONG Length(void) { return m_ulLength; }
  27. HRESULT Add(LPCSTR psz);
  28. HRESULT Adopt(LPCSTR psz);
  29. LPCSTR GetByIndex(ULONG ulIndex);
  30. HRESULT RemoveByIndex(ULONG ulIndex);
  31. private:
  32. BOOL Expand(void);
  33. private:
  34. LPCSTR *m_rgpszValues;
  35. ULONG m_ulLength;
  36. ULONG m_ulCapacity;
  37. };
  38. // wrap a CHash to provide a destructor that deallocates
  39. // string data.
  40. class CStringHash : public CHash
  41. {
  42. public:
  43. virtual ~CStringHash();
  44. };
  45. class CDAVNamespaceArbiterImp
  46. {
  47. public:
  48. CDAVNamespaceArbiterImp(void);
  49. ~CDAVNamespaceArbiterImp(void);
  50. HRESULT AddNamespace(LPCSTR pszNamespace, DWORD *pdwNamespaceID);
  51. HRESULT GetNamespaceID(LPCSTR pszNamespace, DWORD *pdwNamespaceID);
  52. HRESULT GetNamespacePrefix(DWORD dwNamespaceID, LPSTR *ppszNamespacePrefix);
  53. LPSTR AllocExpandedName(DWORD dwNamespaceID, LPCSTR pszPropertyName);
  54. HRESULT WriteNamespaces(IStream *pStream);
  55. BOOL m_rgbNsUsed[c_dwMaxNamespaceID + 1]; // flags indicating whether the
  56. // known namespaces are used
  57. CStringArray m_saNamespaces; // string array of namespaces
  58. private:
  59. HRESULT _AppendXMLNamespace(IStream *pStream, LPCSTR pszNamespace, DWORD dwNamespaceID, BOOL fWhitespacePrefix);
  60. };
  61. class CPropPatchRequest : public IPropPatchRequest
  62. {
  63. public:
  64. // ----------------------------------------------------------------------------
  65. // Construction/Destruction
  66. // ----------------------------------------------------------------------------
  67. CPropPatchRequest(void);
  68. // ----------------------------------------------------------------------------
  69. // IUnknown methods
  70. // ----------------------------------------------------------------------------
  71. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  72. STDMETHODIMP_(ULONG) AddRef(void);
  73. STDMETHODIMP_(ULONG) Release(void);
  74. // ----------------------------------------------------------------------------
  75. // IDAVNamespaceArbiter methods
  76. // ----------------------------------------------------------------------------
  77. STDMETHODIMP AddNamespace(LPCSTR pszNamespace, DWORD *pdwNamespaceID);
  78. STDMETHODIMP GetNamespaceID(LPCSTR pszNamespace, DWORD *pdwNamespaceID);
  79. STDMETHODIMP GetNamespacePrefix(DWORD dwNamespaceID, LPSTR *ppszNamespacePrefix);
  80. // ----------------------------------------------------------------------------
  81. // IPropPatchRequest methods
  82. // ----------------------------------------------------------------------------
  83. STDMETHODIMP SetProperty(DWORD dwNamespaceID, LPCSTR pszPropertyName, LPCSTR pszNewValue);
  84. STDMETHODIMP RemoveProperty(DWORD dwNamespaceID, LPCSTR pszPropertyName);
  85. STDMETHODIMP GenerateXML(LPSTR *ppszXML);
  86. // ----------------------------------------------------------------------------
  87. // Internal Methods
  88. // ----------------------------------------------------------------------------
  89. void SpecifyWindows1252Encoding(BOOL fSpecify1252) { m_fSpecify1252 = fSpecify1252; }
  90. STDMETHODIMP GenerateXML(LPHTTPTARGETLIST pTargets, LPSTR *ppszXML);
  91. private:
  92. BOOL m_fSpecify1252;
  93. CDAVNamespaceArbiterImp m_dna;
  94. ULONG m_cRef; // Reference Count
  95. CStringArray m_saPropNames; // string array of property names
  96. CStringArray m_saPropValues; // string array of property values
  97. CStringArray m_saRemovePropNames;// string array of properties to remove
  98. };
  99. class CPropFindRequest : public IPropFindRequest
  100. {
  101. public:
  102. // ----------------------------------------------------------------------------
  103. // Construction/Destruction
  104. // ----------------------------------------------------------------------------
  105. CPropFindRequest(void);
  106. // ----------------------------------------------------------------------------
  107. // IUnknown methods
  108. // ----------------------------------------------------------------------------
  109. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  110. STDMETHODIMP_(ULONG) AddRef(void);
  111. STDMETHODIMP_(ULONG) Release(void);
  112. // ----------------------------------------------------------------------------
  113. // IDAVNamespaceArbiter methods
  114. // ----------------------------------------------------------------------------
  115. STDMETHODIMP AddNamespace(LPCSTR pszNamespace, DWORD *pdwNamespaceID);
  116. STDMETHODIMP GetNamespaceID(LPCSTR pszNamespace, DWORD *pdwNamespaceID);
  117. STDMETHODIMP GetNamespacePrefix(DWORD dwNamespaceID, LPSTR *ppszNamespacePrefix);
  118. // ----------------------------------------------------------------------------
  119. // IPropFindRequest methods
  120. // ----------------------------------------------------------------------------
  121. STDMETHODIMP AddProperty(DWORD dwNamespaceID, LPCSTR pszPropertyName);
  122. STDMETHODIMP GenerateXML(LPSTR *ppszXML);
  123. private:
  124. HRESULT AppendXMLNamespace(CByteStream& bs, LPCSTR pszNamespace, DWORD dwNamespaceID);
  125. private:
  126. CDAVNamespaceArbiterImp m_dna;
  127. ULONG m_cRef; // Reference Count
  128. CStringArray m_saProperties; // string array of properties
  129. };
  130. class CPropFindMultiResponse : public IPropFindMultiResponse
  131. {
  132. public:
  133. CPropFindMultiResponse(void);
  134. ~CPropFindMultiResponse(void);
  135. // ----------------------------------------------------------------------------
  136. // IUnknown methods
  137. // ----------------------------------------------------------------------------
  138. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  139. STDMETHODIMP_(ULONG) AddRef(void);
  140. STDMETHODIMP_(ULONG) Release(void);
  141. // ----------------------------------------------------------------------------
  142. // IPropFindMultiStatus methods
  143. // ----------------------------------------------------------------------------
  144. STDMETHODIMP_(BOOL) IsComplete(void);
  145. STDMETHODIMP GetLength(ULONG *pulLength);
  146. STDMETHODIMP GetResponse(ULONG ulIndex, IPropFindResponse **ppResponse);
  147. // ----------------------------------------------------------------------------
  148. // CPropFindMultiStatus methods
  149. // ----------------------------------------------------------------------------
  150. BOOL GetDone(void) { return m_bDone; }
  151. void SetDone(BOOL bDone) { m_bDone = bDone; }
  152. HRESULT HrAddResponse(IPropFindResponse *pResponse);
  153. private:
  154. ULONG m_cRef;
  155. BOOL m_bDone;
  156. ULONG m_ulResponseCapacity;
  157. ULONG m_ulResponseLength;
  158. IPropFindResponse **m_rgResponses;
  159. };
  160. class CPropFindResponse : public IPropFindResponse
  161. {
  162. public:
  163. CPropFindResponse(void);
  164. ~CPropFindResponse(void);
  165. // ----------------------------------------------------------------------------
  166. // IUnknown methods
  167. // ----------------------------------------------------------------------------
  168. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  169. STDMETHODIMP_(ULONG) AddRef(void);
  170. STDMETHODIMP_(ULONG) Release(void);
  171. // ----------------------------------------------------------------------------
  172. // IPropFindResponse methods
  173. // ----------------------------------------------------------------------------
  174. STDMETHODIMP_(BOOL) IsComplete(void);
  175. STDMETHODIMP GetHref(LPSTR *ppszHref);
  176. STDMETHODIMP GetProperty(DWORD dwNamespaceID, LPSTR pszPropertyName, LPSTR *ppszPropertyValue);
  177. public:
  178. // ----------------------------------------------------------------------------
  179. // CPropFindResponse methods
  180. // ----------------------------------------------------------------------------
  181. HRESULT HrInitPropFindResponse(IPropFindRequest *pRequest);
  182. HRESULT HrAdoptHref(LPCSTR pszHref);
  183. HRESULT HrAdoptProperty(LPCSTR pszKey, LPCSTR pszValue);
  184. private:
  185. ULONG m_cRef;
  186. BOOL m_bDone;
  187. LPCSTR m_pszHref;
  188. IPropFindRequest *m_pRequest;
  189. CStringHash m_shProperties;
  190. DWORD m_dwCachedNamespaceID;
  191. LPSTR m_pszCachedNamespacePrefix;
  192. };
  193. #endif // __PROPFIND_H