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.

435 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: oinet.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 11-07-1996 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef _OINET_HXX_
  18. #define _OINET_HXX_
  19. enum LOC
  20. {
  21. LOC_NONE = 1
  22. ,LOC_NAMESPACE
  23. ,LOC_INTERNAL
  24. ,LOC_EXTERNAL
  25. };
  26. //+---------------------------------------------------------------------------
  27. //
  28. // Class: CProtNode ()
  29. //
  30. // Purpose:
  31. //
  32. // Interface: Add --
  33. // Remove
  34. // FindFirst --
  35. // FindNext --
  36. //
  37. // History: 10-29-1996 JohannP (Johann Posch) Created
  38. //
  39. // Notes:
  40. //
  41. //----------------------------------------------------------------------------
  42. class CNodeData;
  43. class CNodeData
  44. {
  45. public:
  46. ATOM _atom;
  47. IClassFactory *_pCFProt;
  48. CLSID _clsidProt;
  49. CNodeData *_pNextNode;
  50. CNodeData(ATOM atom, IClassFactory *pCF, CLSID clsid) : _clsidProt(clsid)
  51. {
  52. _atom = atom;
  53. _pCFProt = pCF;
  54. if (_pCFProt)
  55. {
  56. _pCFProt->AddRef();
  57. }
  58. }
  59. ~CNodeData()
  60. {
  61. if (_pCFProt)
  62. {
  63. _pCFProt->Release();
  64. }
  65. }
  66. private:
  67. CNodeData() : _clsidProt(CLSID_NULL)
  68. {
  69. TransAssert((FALSE));
  70. }
  71. };
  72. // Simple class to hold per protocol information.
  73. // Currently we only keep the name of the protocol here.
  74. class CProtocolData {
  75. public:
  76. CProtocolData(): _pszProtocol(NULL), _pNext(NULL)
  77. {}
  78. ~CProtocolData( ) { if(_pszProtocol) delete [] _pszProtocol; }
  79. BOOL Init(LPCWSTR pszProt, CProtocolData *pNext)
  80. {
  81. int len = lstrlenW(pszProt) + 1;
  82. TransAssert(_pszProtocol == NULL && _pNext == NULL);
  83. _pszProtocol = new WCHAR[len];
  84. if (_pszProtocol)
  85. {
  86. StrCpyNW(_pszProtocol, pszProt, len);
  87. _pNext = pNext;
  88. return TRUE;
  89. }
  90. else
  91. {
  92. return FALSE;
  93. }
  94. }
  95. // Access methods.
  96. LPCWSTR GetProtocol( ) const { return _pszProtocol; }
  97. CProtocolData * GetNext( ) const { return _pNext; }
  98. public:
  99. LPWSTR _pszProtocol;
  100. CProtocolData * _pNext;
  101. };
  102. //+---------------------------------------------------------------------------
  103. //
  104. // Class: CProtMgr ()
  105. //
  106. // Purpose:
  107. //
  108. // Interface: QueryInterface --
  109. // AddRef --
  110. // Release --
  111. // Register --
  112. // UnRegister --
  113. // Add --
  114. // Remove --
  115. // FindFirst --
  116. // FindNext --
  117. // _cElements --
  118. // _CRefs --
  119. // _cElements --
  120. // _MapAtom --
  121. //
  122. // History: 10-29-1996 JohannP (Johann Posch) Created
  123. //
  124. // Notes:
  125. //
  126. //----------------------------------------------------------------------------
  127. class CProtMgr
  128. {
  129. public:
  130. STDMETHODIMP Register(IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pszProtocol,
  131. ULONG cPatterns = 0, const LPCWSTR *ppwzPatterns = 0, DWORD dwReserved = 0);
  132. STDMETHODIMP Unregister(IClassFactory *pCF, LPCWSTR pszProtocol);
  133. // called by the protocol broker
  134. virtual STDMETHODIMP FindFirstCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid );
  135. virtual STDMETHODIMP FindNextCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid);
  136. virtual STDMETHODIMP LookupClsIDFromReg(LPCWSTR pwzUrl, CLSID *ppclsid, DWORD *pcClsIds = 0, DWORD *pdwFlags = 0, DWORD dwOpt = 0);
  137. private:
  138. public:
  139. CProtMgr() : _cElements(-1), _CRefs(1)
  140. {
  141. _pPosNode = 0;
  142. _pNextNode = 0;
  143. }
  144. ~CProtMgr()
  145. {
  146. TransAssert(((_cElements == -1 ) || (_cElements == 0)));
  147. }
  148. protected:
  149. CRefCount _CRefs; // the total refcount of this object
  150. CRefCount _cElements; // elements in list
  151. CMutexSem _mxs; // single access to protocol manager
  152. CNodeData *_pNextNode; // head of list
  153. CNodeData *_pPosNode; // next position for looking when call on FindNext
  154. };
  155. class CProtMgrNameSpace : public CProtMgr
  156. {
  157. public:
  158. virtual STDMETHODIMP FindFirstCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid);
  159. virtual STDMETHODIMP FindNextCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid);
  160. virtual STDMETHODIMP LookupClsIDFromReg(LPCWSTR pwzUrl, CLSID *ppclsid, DWORD *pcClsIds = 0, DWORD *pdwFlags = 0, DWORD dwOpt = 0);
  161. public:
  162. CProtMgrNameSpace() : _pProtList(NULL)
  163. {
  164. _cElements = 0;
  165. }
  166. ~CProtMgrNameSpace()
  167. {
  168. CProtocolData *pDelProtData = _pProtList;
  169. while (pDelProtData != NULL)
  170. {
  171. CProtocolData *pNext = pDelProtData->GetNext();
  172. delete pDelProtData;
  173. pDelProtData = pNext;
  174. }
  175. }
  176. private:
  177. CProtocolData * _pProtList;
  178. // Should we look up the registry for this prot. This function assumes caller will lookup the
  179. // registry if it returns TRUE.
  180. STDMETHODIMP ShouldLookupRegistry(LPCWSTR pwszProt);
  181. };
  182. class CProtMgrMimeHandler : public CProtMgr
  183. {
  184. public:
  185. virtual STDMETHODIMP LookupClsIDFromReg(LPCWSTR pwzUrl, CLSID *ppclsid, DWORD *pcClsIds = 0, DWORD *pdwFlags = 0, DWORD dwOpt = 0);
  186. public:
  187. CProtMgrMimeHandler()
  188. {
  189. }
  190. ~CProtMgrMimeHandler()
  191. {
  192. }
  193. private:
  194. };
  195. //+---------------------------------------------------------------------------
  196. //
  197. // Class: COInetSession ()
  198. //
  199. // Purpose:
  200. //
  201. // Interface: QueryInterface --
  202. // AddRef --
  203. // Release --
  204. // RegisterNameSpace --
  205. // UnregisterNameSpace --
  206. // RegisterMimeFilter --
  207. // UnregisterMimeFilter --
  208. // CreateBinding --
  209. // SetSessionOption --
  210. // GetSessionOption --
  211. // CreateFirstProtocol --
  212. // CreateNextProtocol --
  213. // CreateHandler --
  214. // FindOInetProtocolClsID --
  215. // Create --
  216. // _dwProtMax --
  217. // FindFirstCF --
  218. // FindNextCF --
  219. // FindInternalCF --
  220. // dwId --
  221. // pCF --
  222. // ProtMap --
  223. // _CRefs --
  224. // _CProtMgr --
  225. // _CProtMgrNameSpace --
  226. // _CProtMgrMimeFilter --
  227. // _dwProtMax --
  228. // INTERNAL_PROTOCOL_MAX --
  229. //
  230. // History: 11-20-1996 JohannP (Johann Posch) Created
  231. //
  232. // Notes:
  233. //
  234. //----------------------------------------------------------------------------
  235. class COInetSession : public IOInetSession, public IOInetProtocolInfo
  236. {
  237. public:
  238. // IUnknown methods
  239. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  240. STDMETHODIMP_(ULONG) AddRef(void);
  241. STDMETHODIMP_(ULONG) Release(void);
  242. STDMETHODIMP RegisterNameSpace(
  243. IClassFactory *pCF,
  244. REFCLSID rclsid,
  245. LPCWSTR pwzProtocol,
  246. ULONG cPatterns,
  247. const LPCWSTR *ppwzPatterns,
  248. DWORD dwReserved
  249. );
  250. STDMETHODIMP UnregisterNameSpace(
  251. IClassFactory *pCF,
  252. LPCWSTR pszProtocol
  253. );
  254. STDMETHODIMP RegisterMimeFilter(
  255. IClassFactory *pCF,
  256. REFCLSID rclsid,
  257. LPCWSTR pwzType
  258. );
  259. STDMETHODIMP UnregisterMimeFilter(
  260. IClassFactory *pCF,
  261. LPCWSTR pwzType
  262. );
  263. STDMETHODIMP CreateBinding(
  264. LPBC pBC,
  265. LPCWSTR szUrl,
  266. IUnknown *pUnkOuter,
  267. IUnknown **ppUnk,
  268. IOInetProtocol **ppOInetProt,
  269. DWORD dwOption
  270. );
  271. STDMETHODIMP SetSessionOption(
  272. DWORD dwOption,
  273. LPVOID pBuffer,
  274. DWORD dwBufferLength,
  275. DWORD dwReserved
  276. );
  277. STDMETHODIMP GetSessionOption(
  278. DWORD dwOption,
  279. LPVOID pBuffer,
  280. DWORD *pdwBufferLength,
  281. DWORD dwReserved
  282. );
  283. // *** IOInetProtocolInfo
  284. STDMETHODIMP ParseUrl(
  285. LPCWSTR pwzUrl,
  286. PARSEACTION ParseAction,
  287. DWORD dwFlags,
  288. LPWSTR pwzResult,
  289. DWORD cchResult,
  290. DWORD *pcchResult,
  291. DWORD dwReserved
  292. );
  293. STDMETHODIMP CombineUrl(
  294. LPCWSTR pwzBaseUrl,
  295. LPCWSTR pwzRelativeUrl,
  296. DWORD dwFlags,
  297. LPWSTR pwzResult,
  298. DWORD cchResult,
  299. DWORD *pcchResult,
  300. DWORD dwReserved
  301. );
  302. STDMETHODIMP CompareUrl(
  303. LPCWSTR pwzUrl1,
  304. LPCWSTR pwzUrl2,
  305. DWORD dwFlags
  306. );
  307. STDMETHODIMP QueryInfo(
  308. LPCWSTR pwzUrl,
  309. QUERYOPTION OueryOption,
  310. DWORD dwQueryFlags,
  311. LPVOID pBuffer,
  312. DWORD cbBuffer,
  313. DWORD *pcbBuf,
  314. DWORD dwReserved
  315. );
  316. // COInetSession methods used by the protocol broker to get protocols
  317. STDMETHODIMP CreateFirstProtocol(LPCWSTR pwzUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IOInetProtocol **ppProt, CLSID *pclsid, DWORD* pdwLocation, DWORD dwOpt = 0);
  318. STDMETHODIMP CreateNextProtocol(LPCWSTR pwzUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IOInetProtocol **ppProt, CLSID *pclsid, DWORD* pdwLocation);
  319. STDMETHODIMP CreateHandler(LPCWSTR pwzUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IOInetProtocol **ppProt, CLSID *pclsid);
  320. STDMETHODIMP FindOInetProtocolClsID(LPCWSTR pwzUrl, CLSID *pclsid);
  321. static HRESULT Create(DWORD dwMode, COInetSession **ppCOInetSession);
  322. COInetSession() : _CProtMgrNameSpace(), _CProtMgr(), _CProtMgrMimeFilter()
  323. {
  324. _dwProtMax = INTERNAL_PROTOCOL_MAX;
  325. for(DWORD i = 0; i < _dwProtMax; i++)
  326. {
  327. _ProtMap[i].pCF = 0;
  328. }
  329. }
  330. ~COInetSession()
  331. {
  332. for(DWORD i = 0; i < _dwProtMax; i++)
  333. {
  334. if (_ProtMap[i].pCF != 0)
  335. {
  336. _ProtMap[i].pCF->Release();
  337. }
  338. }
  339. }
  340. private:
  341. // private methods
  342. STDMETHODIMP FindFirstCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid, DWORD* pdwLocation, DWORD dwOpt = 0);
  343. STDMETHODIMP FindNextCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid, DWORD* pdwLocation);
  344. STDMETHODIMP FindInternalCF(LPCWSTR pszProt, IClassFactory **ppUnk, CLSID *pclsid, DWORD* pdwLocation);
  345. STDMETHODIMP CreateProtocolInfo(LPCWSTR pwzUrl, IOInetProtocolInfo **ppProtInfo);
  346. STDMETHODIMP CreateSecurityMgr(LPCWSTR pwzUrl, IInternetSecurityManager **ppSecMgr);
  347. typedef struct _tagProtMap
  348. {
  349. DWORD dwId;
  350. IClassFactory *pCF;
  351. } ProtMap;
  352. VOID UpdateTransLevelHandlerCount(BOOL bAttach);
  353. private:
  354. CRefCount _CRefs; // the total refcount of this object
  355. CProtMgr _CProtMgr;
  356. CProtMgrNameSpace _CProtMgrNameSpace;
  357. CProtMgrMimeHandler _CProtMgrMimeFilter;
  358. DWORD _dwProtMax;
  359. ProtMap _ProtMap[INTERNAL_PROTOCOL_MAX];
  360. };
  361. HRESULT GetCOInetSession(DWORD dwMode, COInetSession **ppOInetSession, DWORD dwReserved);
  362. HRESULT OInetGetSession(DWORD dwMode, IOInetSession **ppOInetSession, DWORD dwReserved);
  363. DWORD IsKnownProtocol(LPCWSTR wzProtocol);
  364. BOOL IsOInetProtocol(LPBC pBndCtx, LPCWSTR wzProtocol);
  365. DWORD IsKnownOInetProtocolClass(CLSID *pclsid);
  366. CLSID *GetKnownOInetProtocolClsID(DWORD dwProtoId);
  367. HRESULT CreateKnownProtocolInstance(DWORD dwProtId, REFCLSID rclsid, IUnknown *pUnkOuter, REFIID riid, IUnknown **ppUnk);
  368. HRESULT GetProtMgr(CProtMgr **ppCProtMgr);
  369. HRESULT GetTransactionObjects(LPBC pBndCtx, LPCWSTR wzUrl, IUnknown *pUnkOuter, IUnknown **ppUnk, IOInetProtocol **ppProt, DWORD dwOption, CTransData **pCTransData);
  370. #endif // _OINET_HXX_