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.

577 lines
12 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: agent.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 11-21-1996 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef _AGENT_HXX_
  18. #define _AGENT_HXX_
  19. #include "webchk.h"
  20. class CAtomX
  21. {
  22. public:
  23. CAtomX()
  24. {
  25. }
  26. CAtomX(ATOM atom)
  27. {
  28. _atom = atom;
  29. }
  30. CAtomX(LPCWSTR pwzStr)
  31. {
  32. char szStr[SZMIMESIZE_MAX];
  33. W2A(pwzStr, szStr, SZMIMESIZE_MAX);
  34. _atom = AddAtom(szStr);
  35. }
  36. CAtomX(LPCSTR pszStr)
  37. {
  38. _atom = AddAtom(pszStr);
  39. }
  40. operator void* ()
  41. {
  42. return (void *)_atom;
  43. }
  44. ~CAtomX()
  45. {
  46. }
  47. private:
  48. DWORD _atom;
  49. };
  50. class CKey
  51. {
  52. public:
  53. CKey()
  54. {
  55. }
  56. CKey(ATOM atom)
  57. {
  58. _atom = atom;
  59. }
  60. CKey(LPCWSTR pwzStr)
  61. {
  62. W2A(pwzStr, _szStr, SZMIMESIZE_MAX);
  63. _atom = AddAtom(_szStr);
  64. //_pwzStr = pwzStr;
  65. _pszStr = _szStr;
  66. }
  67. CKey(LPCSTR pszStr)
  68. {
  69. _atom = AddAtom(pszStr);
  70. }
  71. operator void* ()
  72. {
  73. return (void *)_atom;
  74. }
  75. /*
  76. operator LPCWSTR ()
  77. {
  78. return _pwzStr;
  79. }
  80. */
  81. operator LPCSTR ()
  82. {
  83. return _pszStr;
  84. }
  85. ~CKey()
  86. {
  87. }
  88. private:
  89. DWORD _atom;
  90. //LPCWSTR _pwzStr;
  91. LPCSTR _pszStr;
  92. char _szStr[SZMIMESIZE_MAX];
  93. };
  94. class CXUnknown
  95. {
  96. public:
  97. CXUnknown(IUnknown *pUnk)
  98. {
  99. _pUnk = pUnk;
  100. _pUnk->AddRef();
  101. }
  102. ~CXUnknown()
  103. {
  104. _pUnk->Release();
  105. }
  106. private:
  107. IUnknown *_pUnk;
  108. };
  109. #ifdef foofoo
  110. //class CXNode : public CList<CXUnknown *, CXUnknown*>
  111. //class CXNode : public CList<IUnknown *, IUnknown*>
  112. clase CXNode : public CPtrArray
  113. {
  114. public:
  115. CXNode() : _cElements(0)
  116. {
  117. _pos = 0;
  118. }
  119. CXNode(IUnknown *pUnk) : _cElements(1)
  120. {
  121. Add(pUnk);
  122. pUnk->AddRef();
  123. _pos = 0;
  124. }
  125. BOOL Add(IUnknown *pUnk)
  126. {
  127. _cElements++;
  128. Add(pUnk);
  129. pUnk->AddRef();
  130. return TRUE;
  131. }
  132. BOOL Remove(IUnknown *pUnk)
  133. {
  134. IUnknown *pUnkVal = 0;
  135. if (_Map.Lookup(pUnk, (void *&)pUnkVal) )
  136. {
  137. _Map.RemoveKey(pUnk);
  138. _cElements--;
  139. pUnk->Release();
  140. }
  141. else
  142. {
  143. TransAssert((FALSE));
  144. }
  145. return (_cElements) ? TRUE : FALSE;
  146. }
  147. IUnknown * FindFirst()
  148. {
  149. IUnknown *pUnkVal = 0;
  150. _pos = _Map.GetStartPosition();
  151. if (_pos)
  152. {
  153. DWORD dwKey;
  154. _Map.GetNextAssoc(_pos, (VOID *&)dwKey, (void *&) pUnkVal);
  155. }
  156. return pUnkVal;
  157. }
  158. IUnknown * FindNext()
  159. {
  160. IUnknown *pUnkVal = 0;
  161. if (_pos)
  162. {
  163. DWORD dwKey;
  164. _Map.GetNextAssoc(_pos, (void *&)dwKey, (void *&) pUnkVal);
  165. }
  166. return pUnkVal;
  167. }
  168. ~CProtNode()
  169. {
  170. TransAssert((_cElements == 0));
  171. }
  172. private:
  173. CRefCount _cElements;
  174. int _pos;
  175. };
  176. #endif //foofoo
  177. //+---------------------------------------------------------------------------
  178. //
  179. // Class: CProtNode ()
  180. //
  181. // Purpose:
  182. //
  183. // Interface: Add --
  184. // Remove
  185. // FindFirst --
  186. // FindNext --
  187. //
  188. // History: 10-29-1996 JohannP (Johann Posch) Created
  189. //
  190. // Notes:
  191. //
  192. //----------------------------------------------------------------------------
  193. class CProtNode : public CObject
  194. {
  195. public:
  196. CProtNode(IUnknown *pUnk) : _cElements(1)
  197. {
  198. _Map.SetAt(pUnk, pUnk);
  199. pUnk->AddRef();
  200. }
  201. BOOL Add(IUnknown *pUnk)
  202. {
  203. _cElements++;
  204. _Map.SetAt(pUnk, pUnk);
  205. pUnk->AddRef();
  206. return TRUE;
  207. }
  208. BOOL Remove(IUnknown *pUnk)
  209. {
  210. IUnknown *pUnkVal = 0;
  211. if (_Map.Lookup(pUnk, (void *&)pUnkVal) )
  212. {
  213. _Map.RemoveKey(pUnk);
  214. _cElements--;
  215. pUnk->Release();
  216. }
  217. else
  218. {
  219. TransAssert((FALSE));
  220. }
  221. return (_cElements) ? TRUE : FALSE;
  222. }
  223. /*
  224. IUnknown * FindFirst()
  225. {
  226. IUnknown *pUnkVal = 0;
  227. _pos = _Map.GetStartPosition();
  228. if (_pos)
  229. {
  230. DWORD dwKey;
  231. _Map.GetNextAssoc(_pos, (VOID *&)dwKey, (void *&) pUnkVal);
  232. if (pUnkVal)
  233. {
  234. pUnkVal->AddRef();
  235. }
  236. }
  237. return pUnkVal;
  238. }
  239. IUnknown * FindNext()
  240. {
  241. IUnknown *pUnkVal = 0;
  242. if (_pos)
  243. {
  244. DWORD dwKey;
  245. _Map.GetNextAssoc(_pos, (void *&)dwKey, (void *&) pUnkVal);
  246. if (pUnkVal)
  247. {
  248. pUnkVal->AddRef();
  249. }
  250. }
  251. return pUnkVal;
  252. }
  253. */
  254. BOOL FindFirst(IUnknown *& prUnk)
  255. {
  256. BOOL fRet = FALSE;
  257. _pos = _Map.GetStartPosition();
  258. if (_pos)
  259. {
  260. DWORD dwKey;
  261. _Map.GetNextAssoc(_pos, (VOID *&)dwKey, (void *&) prUnk);
  262. if (prUnk)
  263. {
  264. prUnk->AddRef();
  265. fRet = TRUE;
  266. }
  267. }
  268. return fRet;
  269. }
  270. BOOL FindNext(IUnknown *& prUnk)
  271. {
  272. BOOL fRet = FALSE;
  273. if (_pos)
  274. {
  275. DWORD dwKey;
  276. _Map.GetNextAssoc(_pos, (VOID *&)dwKey, (void *&) prUnk);
  277. if (prUnk)
  278. {
  279. prUnk->AddRef();
  280. fRet = TRUE;
  281. }
  282. }
  283. return fRet;
  284. }
  285. ~CProtNode()
  286. {
  287. TransAssert((_cElements == 0));
  288. }
  289. private:
  290. CRefCount _cElements;
  291. CAtomX _atom;
  292. CMapPtrToPtr _Map;
  293. POSITION _pos;
  294. };
  295. //+---------------------------------------------------------------------------
  296. //
  297. // Class: CMapStrToXVal ()
  298. //
  299. // Purpose:
  300. //
  301. // Interface: QueryInterface --
  302. // AddRef --
  303. // Release --
  304. // AddVal --
  305. // UnAddVal --
  306. // FindFirst --
  307. // FindNext --
  308. // _cElements --
  309. // _CRefs --
  310. // _cElements --
  311. // _Map --
  312. //
  313. // History: 10-29-1996 JohannP (Johann Posch) Created
  314. //
  315. // Notes:
  316. //
  317. //----------------------------------------------------------------------------
  318. class CMapStrToXVal
  319. {
  320. public:
  321. STDMETHODIMP AddVal(IUnknown *pUnk,LPCWSTR pwzName);
  322. STDMETHODIMP RemoveVal(IUnknown *pUnk,LPCWSTR pwzName);
  323. STDMETHODIMP FindFirst(LPCWSTR pwzName, IUnknown **ppUnk);
  324. STDMETHODIMP FindNext(LPCWSTR pwzName, IUnknown **ppUnk);
  325. public:
  326. CMapStrToXVal() : _cElements(0), _CRefs(1)
  327. {
  328. }
  329. ~CMapStrToXVal()
  330. {
  331. TransAssert((_cElements == 0));
  332. }
  333. private:
  334. CRefCount _CRefs; // the total refcount of this object
  335. CRefCount _cElements; // the total refcount of this object
  336. CMapStringToOb _Map;
  337. CMutexSem _mxs; // single access to protocol manager
  338. };
  339. #define WEBCHECK_ITEMSINKS_MAX 256
  340. class CUnknown : public IUnknown
  341. {
  342. public:
  343. // IUnknown methods
  344. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  345. STDMETHODIMP_(ULONG) AddRef(void);
  346. STDMETHODIMP_(ULONG) Release(void);
  347. private:
  348. CRefCount _CRefs; // the total refcount of this object
  349. };
  350. class COInetItem : public IOInetItem
  351. {
  352. public:
  353. // IUnknown methods
  354. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  355. STDMETHODIMP_(ULONG) AddRef(void);
  356. STDMETHODIMP_(ULONG) Release(void);
  357. STDMETHODIMP GetURL(
  358. LPOLESTR *ppwzUrl
  359. );
  360. STDMETHODIMP GetInfo(
  361. DWORD dwOptions,
  362. LPOLESTR *ppwzItemMime,
  363. LPCLSID *pclsidItem,
  364. LPOLESTR *ppwzProtocol,
  365. LPCLSID *pclsidProtocol,
  366. DWORD *pdwOut
  367. );
  368. STDMETHODIMP GetItemData(
  369. DWORD *grfITEMF,
  370. ITEMDATA * pitemdata
  371. );
  372. private:
  373. CRefCount _CRefs; // the total refcount of this object
  374. };
  375. class COInetItemSink : public IOInetItemSink
  376. {
  377. // IUnknown methods
  378. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  379. STDMETHODIMP_(ULONG) AddRef(void);
  380. STDMETHODIMP_(ULONG) Release(void);
  381. STDMETHODIMP OnItem(
  382. ITEMTYPE itemtype,
  383. IOInetItem *pWChkItem,
  384. DWORD dwReserved
  385. );
  386. private:
  387. CRefCount _CRefs; // the total refcount of this object
  388. };
  389. class COInetAgent : public IOInetAgent
  390. {
  391. public:
  392. // IUnknown methods
  393. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  394. STDMETHODIMP_(ULONG) AddRef(void);
  395. STDMETHODIMP_(ULONG) Release(void);
  396. // will start a listening protocol (APP) and listen for items
  397. // eg. mc or alert etc.
  398. STDMETHODIMP StartListen(
  399. const LPCWSTR szProtocol,
  400. IOInetItemFilter *pWChkItemFilter,
  401. DWORD grfFilterMode,
  402. CLSID *pclsidProtocol,
  403. DWORD dwReserved
  404. );
  405. // will release the sink passed in at StartListen
  406. STDMETHODIMP StopListen(
  407. CLSID *pclsidProtocol
  408. );
  409. // add item to the spooler
  410. STDMETHODIMP ScheduleItem(
  411. IOInetItem *pWChkItem,
  412. IOInetDestination *pWChkDest,
  413. SCHEDULEDATA *pschdata,
  414. DWORD dwMode,
  415. DWORD *pdwCookie
  416. );
  417. STDMETHODIMP RevokeItem(
  418. DWORD dwCookie
  419. );
  420. private:
  421. CRefCount _CRefs; // the total refcount of this object
  422. COInetItemSink _aCWIS[WEBCHECK_ITEMSINKS_MAX]; // the connection points
  423. COInetItemSink _aCWISListen[WEBCHECK_ITEMSINKS_MAX]; // the connection points
  424. };
  425. class COInetAdvisor : public IOInetAdvisor
  426. {
  427. public:
  428. // IUnknown methods
  429. STDMETHODIMP QueryInterface(REFIID iid, void **ppvObj);
  430. STDMETHODIMP_(ULONG) AddRef(void);
  431. STDMETHODIMP_(ULONG) Release(void);
  432. // will start a listening protocol (APP) and listen for items
  433. // eg. mc or alert etc.
  434. STDMETHODIMP StartListen(
  435. const LPCWSTR wzProtocol,
  436. IOInetItemFilter *pWChkItemFilter,
  437. DWORD grfFilterMode,
  438. CLSID *pclsidProtocol,
  439. DWORD dwReserved
  440. );
  441. // will release the sink passed in at StartListen
  442. STDMETHODIMP StopListen(
  443. CLSID *pclsidProtocol
  444. );
  445. STDMETHODIMP Advise(
  446. IOInetItemSink *pWChkItemSink,
  447. DWORD grfMode,
  448. ULONG cMimes,
  449. const LPCWSTR *ppwzItemMimes,
  450. DWORD dwReserved
  451. );
  452. STDMETHODIMP Unadvise(
  453. IOInetItemSink *pWChkItemSink,
  454. ULONG cMimes,
  455. const LPCWSTR *ppwzItemMimes
  456. );
  457. STDMETHODIMP SendAdvise(
  458. ITEMTYPE itemtype,
  459. IOInetItem *pWChkItem,
  460. DWORD grfMode,
  461. LPCWSTR pwzItemMimes,
  462. DWORD dwReserved
  463. );
  464. public:
  465. COInetAdvisor() : _CRefs(1)
  466. {
  467. }
  468. ~COInetAdvisor()
  469. {
  470. }
  471. private:
  472. CRefCount _CRefs; // the total refcount of this object
  473. CMapStrToXVal _AdvSinks;
  474. };
  475. HRESULT GetOInetAdvisor(DWORD dwMode, IOInetAdvisor **ppOInetAdvisor, DWORD dwReserved);
  476. #endif // _AGENT_HXX_