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.

674 lines
22 KiB

  1. /** Copyright (c) 2000 Microsoft Corporation
  2. ******************************************************************************
  3. ** Module Name:
  4. **
  5. ** Newslib.h
  6. **
  7. ** Abstract:
  8. **
  9. ** Declaration of News Headlines classes
  10. **
  11. ** Author:
  12. **
  13. ** Martha Arellano (t-alopez) 06-Dec-2000
  14. **
  15. **
  16. ** Revision History:
  17. **
  18. **
  19. ******************************************************************************
  20. **/
  21. #if !defined(AFX_NEWSLIB_H__B87C3400_E0B9_48CD_A0A9_0223F4448759__INCLUDED_)
  22. #define AFX_NEWSLIB_H__B87C3400_E0B9_48CD_A0A9_0223F4448759__INCLUDED_
  23. ////////////////////////////////////////////////////////////////////////////////
  24. // NewsSet.xml path
  25. #define HC_HCUPDATE_NEWSSETTINGS HC_ROOT_HELPSVC_CONFIG L"\\NewsSet.xml"
  26. // newsver.xml path
  27. #define HC_HCUPDATE_NEWSVER HC_ROOT_HELPSVC_CONFIG L"\\News\\newsver.xml"
  28. // UpdateHeadlines.xml path
  29. #define HC_HCUPDATE_UPDATE HC_ROOT_HELPSVC_CONFIG L"\\News\\UpdateHeadlines.xml"
  30. // NewsHeadlines.xml path
  31. #define HC_HCUPDATE_NEWSHEADLINES HC_ROOT_HELPSVC_CONFIG L"\\News\\NewsHeadlines_"
  32. // default URL for newsver.xml
  33. #define NEWSSETTINGS_DEFAULT_URL L"http://go.microsoft.com/fwlink/?LinkID=11"
  34. //default URL for the icon for Update headlines
  35. #define HC_HCUPDATE_UPDATEBLOCK_ICONURL L"http://go.microsoft.com/fwlink/?LinkId=627"
  36. // default Frequency
  37. #define NEWSSETTINGS_DEFAULT_FREQUENCY 14
  38. // Headlines RegKey Name
  39. #define HEADLINES_REGKEY L"Headlines"
  40. // Default expiration date for news items from HCUpdate
  41. #define HCUPDATE_DEFAULT_TIMEOUT 10
  42. // Current number of OEM headlines
  43. #define NUMBER_OF_OEM_HEADLINES 2
  44. ////////////////////////////////////////////////////////////////////////////////
  45. namespace News
  46. {
  47. /////////////////////////////////////////////////////////////////////////////
  48. // NEWSVER
  49. //
  50. // The NEWSVER class loads the newsver.xml file, with the information to update the news headlines
  51. //
  52. // It defines the clases:
  53. // Newsblock
  54. // SKU
  55. // Language
  56. //
  57. // and the variables:
  58. // URL
  59. // Frequency
  60. //
  61. // list of Languages
  62. //
  63. //
  64. // Has the following functions:
  65. // Download ( URL )
  66. // Load( LCID, SKU )
  67. //
  68. // get_NumbeOfNewsblocks
  69. // get_NewsblockURL
  70. // get_URL
  71. // get_Frequency
  72. //
  73. class Newsver : public MPC::Config::TypeConstructor // hungarian: nw
  74. {
  75. public:
  76. //
  77. // The Newsblock class stores the newsfile information from the newsver.xml file:
  78. // URL
  79. //
  80. class Newsblock : public MPC::Config::TypeConstructor
  81. {
  82. DECLARE_CONFIG_MAP(Newsblock);
  83. public:
  84. MPC::wstring m_strURL;
  85. bool m_fNewsblockHasHeadlines;
  86. ////////////////////
  87. Newsblock();
  88. ////////////////////////////////////////
  89. //
  90. // MPC::Config::TypeConstructor
  91. //
  92. DEFINE_CONFIG_DEFAULTTAG();
  93. DECLARE_CONFIG_METHODS();
  94. //
  95. ////////////////////////////////////////
  96. };
  97. typedef std::vector< Newsblock > NewsblockVector;
  98. typedef NewsblockVector::iterator NewsblockIter;
  99. typedef NewsblockVector::const_iterator NewsblockIterConst;
  100. ////////////////////////////////////////
  101. //
  102. // The SKU class stores the SKU information from the newsver.xml file:
  103. // SKU Version (Professional, Personal, ...)
  104. //
  105. // vector of newsblocks
  106. //
  107. class SKU : public MPC::Config::TypeConstructor
  108. {
  109. DECLARE_CONFIG_MAP(SKU);
  110. public:
  111. MPC::wstring m_strSKU;
  112. NewsblockVector m_vecNewsblocks; //vector of newsblocks
  113. ////////////////////
  114. SKU();
  115. ////////////////////////////////////////
  116. //
  117. // MPC::Config::TypeConstructor
  118. //
  119. DEFINE_CONFIG_DEFAULTTAG();
  120. DECLARE_CONFIG_METHODS();
  121. //
  122. ////////////////////////////////////////
  123. };
  124. typedef std::list< SKU > SKUList;
  125. typedef SKUList::iterator SKUIter;
  126. typedef SKUList::const_iterator SKUIterConst;
  127. ////////////////////////////////////////
  128. //
  129. // The Language class stores the Language information from the newsver.xml file:
  130. // Language LCID
  131. //
  132. // list of SKUs
  133. //
  134. class Language : public MPC::Config::TypeConstructor
  135. {
  136. DECLARE_CONFIG_MAP(Language);
  137. public:
  138. long m_lLCID;
  139. SKUList m_lstSKUs; //list of SKUs
  140. ////////////////////
  141. Language();
  142. ////////////////////////////////////////
  143. //
  144. // MPC::Config::TypeConstructor
  145. //
  146. DEFINE_CONFIG_DEFAULTTAG();
  147. DECLARE_CONFIG_METHODS();
  148. //
  149. ////////////////////////////////////////
  150. };
  151. typedef std::list< Language > LanguageList;
  152. typedef LanguageList::iterator LanguageIter;
  153. typedef LanguageList::const_iterator LanguageIterConst;
  154. ////////////////////////////////////////
  155. private:
  156. DECLARE_CONFIG_MAP(Newsver);
  157. MPC::wstring m_strURL;
  158. int m_nFrequency;
  159. bool m_fLoaded;
  160. bool m_fDirty;
  161. LanguageList m_lstLanguages; //list of Languages
  162. SKU* m_data;
  163. public:
  164. Newsver();
  165. ////////////////////////////////////////
  166. //
  167. // MPC::Config::TypeConstructor
  168. //
  169. DEFINE_CONFIG_DEFAULTTAG();
  170. DECLARE_CONFIG_METHODS();
  171. //
  172. ////////////////////////////////////////
  173. HRESULT Download( /*[in]*/ const MPC::wstring& strNewsverURL );
  174. HRESULT Load( /*[in]*/ long lLCID, /*[in]*/ const MPC::wstring& strSKU );
  175. bool OEMNewsblock( /*[in]*/ size_t nIndex );
  176. size_t get_NumberOfNewsblocks( );
  177. const MPC::wstring* get_NewsblockURL ( /*[in]*/ size_t nIndex );
  178. const MPC::wstring* get_URL ( );
  179. int get_Frequency ( );
  180. };
  181. /////////////////////////////////////////////////////////////////////////////
  182. // Headlines
  183. //
  184. // The Headlines class manipulates the news headlines file (with 1 or more providers headlines)
  185. //
  186. //
  187. // It contains the clases:
  188. // Headline
  189. // Newsblock
  190. //
  191. // the variables:
  192. // Timestamp when was the file created from newsblocks
  193. // Date when was the file modified (and for the UI)
  194. //
  195. // list of Newsblocks
  196. //
  197. //
  198. // and the methods:
  199. // Clear()
  200. // Load( Path )
  201. // Save( Path )
  202. // get_Stream ( Path )
  203. // set_Timestamp()
  204. // get_Timestamp
  205. // get_Number_of_Newsblocks
  206. // check_Number_of_Newsblocks
  207. // Time_To_Update_Newsblock( BOOL )
  208. //
  209. // Add_Provider( Name, URL, PostDate )
  210. // Delete_Provider()
  211. //
  212. // Copy_Newsblock( index, LangSKU, ProvID, Block )
  213. // Add_First_Newsblock( index, LangSKU, BOOL )
  214. //
  215. class Headlines : public MPC::Config::TypeConstructor // hungarian nh
  216. {
  217. public:
  218. //
  219. // The Headline class stores the Headline information from the news headline:
  220. // Icon (path)
  221. // Title
  222. // Link
  223. // Description
  224. // Expires
  225. //
  226. class Headline : public MPC::Config::TypeConstructor
  227. {
  228. DECLARE_CONFIG_MAP(Headline);
  229. public:
  230. MPC::wstring m_strIcon;
  231. MPC::wstring m_strTitle;
  232. MPC::wstring m_strLink;
  233. MPC::wstring m_strDescription;
  234. DATE m_dtExpires;
  235. bool m_fUpdateHeadlines;
  236. ////////////////////
  237. Headline( );
  238. Headline( /*[in]*/ const MPC::wstring& strIcon ,
  239. /*[in]*/ const MPC::wstring& strTitle ,
  240. /*[in]*/ const MPC::wstring& strLink ,
  241. /*[in]*/ const MPC::wstring& strDescription ,
  242. /*[in]*/ DATE dtExpires ,
  243. /*[in]*/ bool fUpdateHeadlines);
  244. ////////////////////////////////////////
  245. //
  246. // MPC::Config::TypeConstructor
  247. //
  248. DEFINE_CONFIG_DEFAULTTAG();
  249. DECLARE_CONFIG_METHODS();
  250. //
  251. ////////////////////////////////////////
  252. };
  253. typedef std::vector< Headline > HeadlineVector;
  254. typedef HeadlineVector::iterator HeadlineIter;
  255. typedef HeadlineVector::const_iterator HeadlineConst;
  256. ////////////////////////////////////////
  257. //
  258. // The Newsblock class stores the Provider information from the news headline:
  259. // Provider
  260. // Link
  261. // Icon
  262. // Position
  263. // Timestamp
  264. // Frequency
  265. //
  266. // vector of Headlines
  267. //
  268. class Newsblock : public MPC::Config::TypeConstructor
  269. {
  270. DECLARE_CONFIG_MAP(Newsblock);
  271. private:
  272. void GetFileName( MPC::wstring strURL, MPC::wstring& strFileName );
  273. public:
  274. MPC::wstring m_strProvider;
  275. MPC::wstring m_strLink;
  276. MPC::wstring m_strIcon;
  277. MPC::wstring m_strPosition;
  278. DATE m_dtTimestamp;
  279. int m_nFrequency;
  280. HeadlineVector m_vecHeadlines; //vector of headlines
  281. ////////////////////
  282. Newsblock();
  283. ////////////////////////////////////////
  284. //
  285. // MPC::Config::TypeConstructor
  286. //
  287. DEFINE_CONFIG_DEFAULTTAG();
  288. DECLARE_CONFIG_METHODS();
  289. //
  290. ////////////////////////////////////////
  291. bool TimeToUpdate();
  292. HRESULT Copy( /*[in]*/ const Headlines::Newsblock& block ,
  293. /*[in]*/ const MPC::wstring& strLangSKU ,
  294. /*[in]*/ int nProvID );
  295. };
  296. typedef std::vector< Newsblock > NewsblockVector;
  297. typedef NewsblockVector::iterator NewsblockIter;
  298. typedef NewsblockVector::const_iterator NewsblockIterConst;
  299. ////////////////////////////////////////
  300. private:
  301. DECLARE_CONFIG_MAP(Headlines);
  302. DATE m_dtTimestamp;
  303. DATE m_dtDate;
  304. NewsblockVector m_vecNewsblocks; // vector of newsblocks
  305. public:
  306. Headlines();
  307. ////////////////////////////////////////
  308. //
  309. // MPC::Config::TypeConstructor
  310. //
  311. DEFINE_CONFIG_DEFAULTTAG();
  312. DECLARE_CONFIG_METHODS();
  313. //
  314. ////////////////////////////////////////
  315. HRESULT Clear( );
  316. HRESULT Load ( /*[in]*/ const MPC::wstring& strPath );
  317. HRESULT Save ( /*[in]*/ const MPC::wstring& strPath );
  318. HRESULT get_Stream( /*[in]*/ long lLCID, /*[in]*/ const MPC::wstring& strSKU, /*[in]*/ const MPC::wstring& strPath, /*[out]*/ IUnknown* *pVal );
  319. void set_Timestamp ( );
  320. DATE get_Timestamp ( ) { return m_dtTimestamp; }
  321. size_t get_NumberOfNewsblocks( ) { return m_vecNewsblocks.size(); }
  322. Headlines::Newsblock* get_Newsblock ( /*[in]*/ size_t nBlockIndex );
  323. HRESULT AddNewsblock( /*[in]*/ const Headlines::Newsblock& block, /*[in]*/ const MPC::wstring& strLangSKU );
  324. HRESULT AddHomepageHeadlines( /*[in]*/ const Headlines::Newsblock& block );
  325. bool CheckIfImagesExist();
  326. };
  327. /////////////////////////////////////////////////////////////////////////////
  328. // UpdateHeadlines
  329. //
  330. // The UpdateHeadlines class loads the UpdateHeadlines.xml file
  331. // that contains update headlines to insert in the news headlines
  332. //
  333. // It defines the classes:
  334. // Headline
  335. // SKU
  336. // Language
  337. //
  338. // and the variables:
  339. //
  340. // list of Languages
  341. //
  342. // functions:
  343. // Load ( LCID, SKU )
  344. // Save ( )
  345. // Add ( LCID, SKU, Icon, Title, Link, #Days )
  346. // Get ( LCID, SKU, list of Headlines )
  347. //
  348. class UpdateHeadlines : public MPC::Config::TypeConstructor // hungarian: uh
  349. {
  350. public:
  351. //
  352. // The Headline class stores the Headline information from the news headline:
  353. // Icon
  354. // Title
  355. // Link
  356. // Expires
  357. //
  358. class Headline : public MPC::Config::TypeConstructor
  359. {
  360. DECLARE_CONFIG_MAP(Headline);
  361. public:
  362. MPC::wstring m_strIcon;
  363. MPC::wstring m_strTitle;
  364. MPC::wstring m_strLink;
  365. MPC::wstring m_strDescription;
  366. DATE m_dtTimeOut;
  367. ////////////////////
  368. Headline( );
  369. Headline( /*[in]*/ const MPC::wstring& strIcon ,
  370. /*[in]*/ const MPC::wstring& strTitle ,
  371. /*[in]*/ const MPC::wstring& strLink ,
  372. /*[in]*/ const MPC::wstring& strDescription ,
  373. /*[in]*/ int nDays );
  374. ////////////////////////////////////////
  375. //
  376. // MPC::Config::TypeConstructor
  377. //
  378. DEFINE_CONFIG_DEFAULTTAG();
  379. DECLARE_CONFIG_METHODS();
  380. //
  381. ////////////////////////////////////////
  382. };
  383. typedef std::vector< Headline > HeadlineVector;
  384. typedef HeadlineVector::iterator HeadlineIter;
  385. typedef HeadlineVector::const_iterator HeadlineConst;
  386. ////////////////////////////////////////
  387. //
  388. // The SKU class stores the SKU information:
  389. // SKU Version (Professional, Personal, ...)
  390. //
  391. // vector of Newsfiles
  392. //
  393. class SKU : public MPC::Config::TypeConstructor
  394. {
  395. DECLARE_CONFIG_MAP(SKU);
  396. public:
  397. MPC::wstring m_strSKU;
  398. HeadlineVector m_vecHeadlines; //vector of news files
  399. ////////////////////
  400. SKU( );
  401. SKU( /*[in]*/ const MPC::wstring& strSKU );
  402. ////////////////////////////////////////
  403. //
  404. // MPC::Config::TypeConstructor
  405. //
  406. DEFINE_CONFIG_DEFAULTTAG();
  407. DECLARE_CONFIG_METHODS();
  408. //
  409. ////////////////////////////////////////
  410. };
  411. typedef std::list< SKU > SKUList;
  412. typedef SKUList::iterator SKUIter;
  413. typedef SKUList::const_iterator SKUIterConst;
  414. ////////////////////////////////////////
  415. //
  416. // The Language class stores the Language information:
  417. // Language LCID
  418. //
  419. // list of SKUs
  420. //
  421. class Language : public MPC::Config::TypeConstructor
  422. {
  423. DECLARE_CONFIG_MAP(Language);
  424. public:
  425. long m_lLCID;
  426. SKUList m_lstSKUs; //list of SKUs
  427. ////////////////////
  428. Language( );
  429. Language( /*[in]*/ long lLCID );
  430. ////////////////////////////////////////
  431. //
  432. // MPC::Config::TypeConstructor
  433. //
  434. DEFINE_CONFIG_DEFAULTTAG();
  435. DECLARE_CONFIG_METHODS();
  436. //
  437. ////////////////////////////////////////
  438. };
  439. typedef std::list< Language > LanguageList;
  440. typedef LanguageList::iterator LanguageIter;
  441. typedef LanguageList::const_iterator LanguageIterConst;
  442. ////////////////////////////////////////
  443. private:
  444. DECLARE_CONFIG_MAP(UpdateHeadlines);
  445. LanguageList m_lstLanguages; //list of Languages
  446. SKU* m_data;
  447. bool m_fLoaded;
  448. bool m_fDirty;
  449. ////////////////////
  450. HRESULT Locate( /*[in]*/ long lLCID, /*[in]*/ const MPC::wstring& strSKU, /*[in]*/ bool fCreate );
  451. public:
  452. UpdateHeadlines();
  453. ////////////////////////////////////////
  454. //
  455. // MPC::Config::TypeConstructor
  456. //
  457. DEFINE_CONFIG_DEFAULTTAG();
  458. DECLARE_CONFIG_METHODS();
  459. //
  460. ////////////////////////////////////////
  461. HRESULT Load( /*[in]*/ long lLCID ,
  462. /*[in]*/ const MPC::wstring& strSKU );
  463. HRESULT Save( );
  464. HRESULT Add ( /*[in]*/ long lLCID ,
  465. /*[in]*/ const MPC::wstring& strSKU ,
  466. /*[in]*/ const MPC::wstring& strIcon ,
  467. /*[in]*/ const MPC::wstring& strTitle ,
  468. /*[in]*/ const MPC::wstring& strDescription ,
  469. /*[in]*/ const MPC::wstring& strLink ,
  470. /*[in]*/ int nTimeOutDays ,
  471. /*[in]*/ DATE dtExpiryDate);
  472. HRESULT AddHCUpdateHeadlines( /*[in]*/ long lLCID ,
  473. /*[in]*/ const MPC::wstring& strSKU ,
  474. /*[in]*/ News::Headlines& nhHeadlines);
  475. HRESULT DoesMoreThanOneHeadlineExist( /*[in]*/ long lLCID,
  476. /*[in]*/ const MPC::wstring& strSKU,
  477. /*[out]*/ bool& fMoreThanOneHeadline,
  478. /*[out]*/ bool& fExactlyOneHeadline);
  479. };
  480. ////////////////////////////////////////////////////////////////////////////////
  481. /////////////////////////////////////////////////////////////////////////////
  482. // CNewslib
  483. //
  484. // The CNewslib class stores the information in the cached newsset.xml file, that stores the user news settings:
  485. // URL, Frequency (in days) and Timestamp (the time the news headlines were last updated).
  486. //
  487. // Has the following methods:
  488. // Load()
  489. // Restore(LCID)
  490. // Save()
  491. // Time_To_Update_Newsver(BOOL)
  492. // Update_Newsver
  493. // Update_NewsHeadlines
  494. // Update_Newsblocks
  495. //
  496. // get_Headlines_Enabled (BOOL)
  497. // get_News( LCID, SKU, IStream)
  498. // get_Cached_News( LCID, SKU, IStream)
  499. // get_Download_News( LCID, SKU, IStream)
  500. // get_URL
  501. // put_URL
  502. // get_Frequency
  503. // put_Frequency
  504. //
  505. //
  506. class Main : public MPC::Config::TypeConstructor
  507. {
  508. DECLARE_CONFIG_MAP(Main);
  509. MPC::wstring m_strURL;
  510. int m_nFrequency;
  511. DATE m_dtTimestamp;
  512. bool m_fLoaded;
  513. bool m_fDirty;
  514. long m_lLCID;
  515. MPC::wstring m_strSKU;
  516. MPC::wstring m_strLangSKU;
  517. MPC::wstring m_strNewsHeadlinesPath;
  518. bool m_fOnline;
  519. bool m_fConnectionStatusChecked;
  520. ////////////////////
  521. HRESULT Init( /*[in]*/ long lLCID, /*[in]*/ BSTR bstrSKU );
  522. public:
  523. Main();
  524. ////////////////////////////////////////
  525. //
  526. // MPC::Config::TypeConstructor
  527. //
  528. DEFINE_CONFIG_DEFAULTTAG();
  529. DECLARE_CONFIG_METHODS();
  530. //
  531. ////////////////////////////////////////
  532. HRESULT Load ( );
  533. HRESULT Restore( /*[in]*/ long lLCID );
  534. HRESULT Save ( );
  535. bool IsTimeToUpdateNewsver();
  536. HRESULT Update_Newsver ( /*[in/out]*/ Newsver& nwNewsver );
  537. HRESULT Update_NewsHeadlines( /*[in/out]*/ Newsver& nwNewsver, /*[in/out]*/ Headlines& nhHeadlines );
  538. HRESULT Update_NewsBlocks ( /*[in/out]*/ Newsver& nwNewsver, /*[in/out]*/ Headlines& nhHeadlines );
  539. HRESULT get_URL ( /*[out]*/ BSTR *pVal );
  540. HRESULT put_URL ( /*[in ]*/ BSTR newVal );
  541. HRESULT get_Frequency( /*[out]*/ int *pVal );
  542. HRESULT put_Frequency( /*[in ]*/ int newVal );
  543. HRESULT get_Headlines_Enabled( /*[out]*/ VARIANT_BOOL *pVal );
  544. HRESULT get_News ( /*[in]*/ long lLCID, /*[in]*/ BSTR bstrSKU, /*[out]*/ IUnknown* *pVal );
  545. HRESULT get_News_Cached ( /*[in]*/ long lLCID, /*[in]*/ BSTR bstrSKU, /*[out]*/ IUnknown* *pVal );
  546. HRESULT get_News_Download( /*[in]*/ long lLCID, /*[in]*/ BSTR bstrSKU, /*[out]*/ IUnknown* *pVal );
  547. HRESULT AddHCUpdateNews (/*[in ]*/ const MPC::wstring& strNewsHeadlinesPath );
  548. bool CheckConnectionStatus ();
  549. };
  550. ////////////////////////////////////////////////////////////////////////////////
  551. HRESULT LoadXMLFile ( /*[in]*/ LPCWSTR szURL, /*[out]*/ CComPtr<IStream>& stream );
  552. HRESULT LoadFileFromServer ( /*[in]*/ LPCWSTR szURL, /*[out]*/ CComPtr<IStream>& stream );
  553. };
  554. #endif // !defined(AFX_NEWSLIB_H__B87C3400_E0B9_48CD_A0A9_0223F4448759__INCLUDED_)