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.

1523 lines
47 KiB

  1. /****************************************************************************\
  2. *
  3. * pleasdlg.cpp
  4. *
  5. * Created: William Taylor (wtaylor) 01/22/01
  6. *
  7. * MS Ratings Access Denied Dialog
  8. *
  9. \****************************************************************************/
  10. #include "msrating.h"
  11. #include "mslubase.h"
  12. #include "debug.h"
  13. #include "parselbl.h"
  14. #include "picsrule.h"
  15. #include "pleasdlg.h" // CPleaseDialog
  16. #include "hint.h" // CHint
  17. #include <contxids.h> // Help Context ID's
  18. #include <mluisupp.h> // SHWinHelpOnDemandWrap() and MLLoadStringA()
  19. #include <wininet.h> // URL_COMPONENTS
  20. //The FN_INTERNETCRACKURL type describes the URLMON function InternetCrackUrl
  21. typedef BOOL (*FN_INTERNETCRACKURL)(LPCTSTR lpszUrl,DWORD dwUrlLength,DWORD dwFlags,LPURL_COMPONENTS lpUrlComponents);
  22. // $KLUDGE begins -- These should not be a global set outside the class!!
  23. extern BOOL g_fInvalid;
  24. extern DWORD g_dwDataSource;
  25. extern PICSRulesRatingSystem * g_pPRRS;
  26. extern array<PICSRulesRatingSystem*> g_arrpPRRS;
  27. extern PICSRulesRatingSystem * g_pApprovedPRRS;
  28. extern PICSRulesRatingSystem * g_pApprovedPRRSPreApply;
  29. extern array<PICSRulesRatingSystem*> g_arrpPICSRulesPRRSPreApply;
  30. extern BOOL g_fPICSRulesEnforced,g_fApprovedSitesEnforced;
  31. extern HMODULE g_hURLMON,g_hWININET;
  32. extern char g_szLastURL[INTERNET_MAX_URL_LENGTH];
  33. // $KLUDGE ends -- These should not be a global set outside the class!!
  34. DWORD CPleaseDialog::aIds[] = {
  35. IDC_STATIC2, IDH_IGNORE,
  36. IDC_CONTENTLABEL, IDH_IGNORE,
  37. IDC_CONTENTERROR, IDH_RATINGS_DESCRIBE_RESTRICTED,
  38. IDC_CONTENTDESCRIPTION, IDH_RATINGS_DESCRIBE_RESTRICTED,
  39. IDC_STATIC4, IDH_IGNORE,
  40. IDC_STATIC5, IDH_IGNORE,
  41. IDC_STATIC3, IDH_IGNORE,
  42. IDC_BLOCKING_SITE, IDH_RATINGS_VIEW_RESTRICTED,
  43. IDC_BLOCKING_PAGE, IDH_RATINGS_VIEW_RESTRICTED,
  44. IDC_BLOCKING_ONCE, IDH_RATINGS_VIEW_RESTRICTED,
  45. IDC_OLD_HINT_LABEL, IDH_RATINGS_DISPLAY_PW_HINT,
  46. IDC_OLD_HINT_TEXT, IDH_RATINGS_DISPLAY_PW_HINT,
  47. IDC_STATIC1, IDH_RATINGS_SUPERVISOR_PASSWORD,
  48. IDC_PASSWORD, IDH_RATINGS_SUPERVISOR_PASSWORD,
  49. 0,0
  50. };
  51. // Array of Dialog Ids which are displayed for Please dialog and not for Deny dialog.
  52. DWORD CPleaseDialog::aPleaseIds[] = {
  53. IDC_STATIC4,
  54. IDC_STATIC3,
  55. IDC_STATIC5,
  56. IDC_BLOCKING_SITE,
  57. IDC_BLOCKING_PAGE,
  58. IDC_BLOCKING_ONCE,
  59. IDC_OLD_HINT_LABEL,
  60. IDC_OLD_HINT_TEXT,
  61. IDC_STATIC1,
  62. IDC_PASSWORD
  63. };
  64. CPleaseDialog::CPleaseDialog( PleaseDlgData * p_ppdd )
  65. {
  66. ASSERT( p_ppdd );
  67. m_ppdd = p_ppdd;
  68. }
  69. LRESULT CPleaseDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  70. {
  71. ASSERT( m_ppdd );
  72. if ( m_ppdd )
  73. {
  74. ASSERT( m_ppdd->hwndDlg == NULL );
  75. if ( m_ppdd->hwndDlg == NULL )
  76. {
  77. m_ppdd->hwndDlg = m_hWnd;
  78. /* Attach our data structure to the dialog so we can find it when the
  79. * dialog is dismissed, and on the owner window passed to the API so
  80. * we can find it on subsequent API calls.
  81. */
  82. SetProp( m_ppdd->hwndOwner, szRatingsProp, (HANDLE)m_ppdd );
  83. }
  84. }
  85. // Display the Please dialog controls or hide them all.
  86. for ( int iIndex=0; iIndex<sizeof(aPleaseIds)/sizeof(DWORD); iIndex++ )
  87. {
  88. ShowHideControl( aPleaseIds[iIndex], IsPleaseDialog() );
  89. }
  90. // Reduce the height of the dialog.
  91. if ( IsDenyDialog() )
  92. {
  93. ReduceDialogHeight( IDC_CONTENTDESCRIPTION );
  94. }
  95. InitPleaseDialog( m_ppdd );
  96. if ( IsPleaseDialog() )
  97. {
  98. if ( GetDlgItem(IDC_PASSWORD) != NULL )
  99. {
  100. SendDlgItemMessage(IDC_PASSWORD,EM_SETLIMITTEXT,(WPARAM) RATINGS_MAX_PASSWORD_LENGTH,(LPARAM) 0);
  101. }
  102. // Display previously created hint (if one exists).
  103. {
  104. CHint oldHint( m_hWnd, IDC_OLD_HINT_TEXT );
  105. oldHint.DisplayHint();
  106. }
  107. // set focus to password field
  108. ::SetFocus( GetDlgItem(IDC_PASSWORD) );
  109. }
  110. bHandled = FALSE;
  111. return 0L; // The focus was set to the password field.
  112. }
  113. LRESULT CPleaseDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  114. {
  115. EndPleaseDialog(FALSE);
  116. return 0L;
  117. }
  118. LRESULT CPleaseDialog::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  119. {
  120. // For Deny dialog there is no password so the code below checks for a non-existance password?
  121. if ( IsDenyDialog() )
  122. {
  123. EndPleaseDialog(FALSE);
  124. return 0L;
  125. }
  126. char szPassword[MAXPATHLEN];
  127. HRESULT hRet;
  128. szPassword[0] = '\0';
  129. ASSERT( GetDlgItem( IDC_PASSWORD ) != NULL );
  130. GetDlgItemText(IDC_PASSWORD, szPassword, sizeof(szPassword));
  131. hRet = VerifySupervisorPassword(szPassword);
  132. if (hRet == ResultFromScode(S_OK))
  133. {
  134. if (SendDlgItemMessage(IDC_BLOCKING_PAGE,
  135. BM_GETCHECK,
  136. (WPARAM) 0,
  137. (LPARAM) 0)==BST_CHECKED)
  138. {
  139. HRESULT hRes;
  140. hRes=AddToApprovedSites(PICSRULES_ALWAYS,PICSRULES_PAGE);
  141. if (FAILED(hRes))
  142. {
  143. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  144. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  145. MLLoadString(IDS_APPROVED_CANTSAVE,(LPTSTR) szMessage,MAX_PATH);
  146. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  147. return(E_OUTOFMEMORY);
  148. }
  149. }
  150. else if (SendDlgItemMessage(IDC_BLOCKING_SITE,
  151. BM_GETCHECK,
  152. (WPARAM) 0,
  153. (LPARAM) 0)==BST_CHECKED)
  154. {
  155. HRESULT hRes;
  156. hRes=AddToApprovedSites(PICSRULES_ALWAYS,PICSRULES_SITE);
  157. if (FAILED(hRes))
  158. {
  159. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  160. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  161. MLLoadString(IDS_APPROVED_CANTSAVE,(LPTSTR) szMessage,MAX_PATH);
  162. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  163. return(E_OUTOFMEMORY);
  164. }
  165. }
  166. EndPleaseDialog(TRUE);
  167. }
  168. else
  169. {
  170. MyMessageBox(m_hWnd, IDS_BADPASSWORD, IDS_GENERIC, MB_OK|MB_ICONERROR);
  171. ::SetFocus(GetDlgItem(IDC_PASSWORD));
  172. SetDlgItemText(IDC_PASSWORD, szNULL);
  173. }
  174. return 0L;
  175. }
  176. LRESULT CPleaseDialog::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  177. {
  178. SHWinHelpOnDemandWrap((HWND)((LPHELPINFO)lParam)->hItemHandle, ::szHelpFile,
  179. HELP_WM_HELP, (DWORD_PTR)(LPSTR)aIds);
  180. return 0L;
  181. }
  182. LRESULT CPleaseDialog::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  183. {
  184. SHWinHelpOnDemandWrap((HWND)wParam, ::szHelpFile, HELP_CONTEXTMENU,
  185. (DWORD_PTR)(LPVOID)aIds);
  186. return 0L;
  187. }
  188. LRESULT CPleaseDialog::OnNewDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  189. {
  190. InitPleaseDialog( (PleaseDlgData *) lParam );
  191. return 0L;
  192. }
  193. void CPleaseDialog::AppendString(HWND hwndEC, LPCSTR pszString)
  194. {
  195. int cchEdit = ::GetWindowTextLength(hwndEC);
  196. ::SendMessage(hwndEC, EM_SETSEL, (WPARAM)cchEdit, (LPARAM)cchEdit);
  197. ::SendMessage(hwndEC, EM_REPLACESEL, 0, (LPARAM)pszString);
  198. }
  199. void CPleaseDialog::AddSeparator(HWND hwndEC, BOOL fAppendToEnd)
  200. {
  201. NLS_STR nlsTemp(MAX_RES_STR_LEN);
  202. if (nlsTemp.QueryError() != ERROR_SUCCESS)
  203. {
  204. TraceMsg( TF_WARNING, "PleaseDialog::AddSeparator() - Failed to allocate nlsTemp!" );
  205. return;
  206. }
  207. if (fAppendToEnd)
  208. {
  209. nlsTemp.LoadString(IDS_DESCRIPTION_SEPARATOR);
  210. AppendString(hwndEC, nlsTemp.QueryPch());
  211. }
  212. nlsTemp.LoadString(IDS_FRAME);
  213. if (fAppendToEnd)
  214. {
  215. AppendString(hwndEC, nlsTemp.QueryPch());
  216. }
  217. else
  218. {
  219. ::SendMessage(hwndEC, EM_SETSEL, 0, 0);
  220. ::SendMessage(hwndEC, EM_REPLACESEL, 0, (LPARAM)(LPCSTR)nlsTemp.QueryPch());
  221. }
  222. }
  223. void CPleaseDialog::InitPleaseDialog( PleaseDlgData * pdd )
  224. {
  225. CComAutoCriticalSection critSec;
  226. /****
  227. rated:
  228. for each URS with m_fInstalled = TRUE:
  229. for each UR with m_fFailed = TRUE:
  230. add line to EC
  231. not rated:
  232. no label list? --> report not rated
  233. invalid string in label list? --> report invalid rating
  234. any URS's with invalid strings? --> report invalid rating
  235. any URS's with error strings? --> report label error
  236. no URS's marked installed? --> report unknown rating system
  237. for installed URS's:
  238. for each UR:
  239. options has invalid string? --> report invalid rating
  240. options expired? --> report expired
  241. not fFound? --> report unknown rating
  242. ****/
  243. ASSERT( pdd );
  244. if ( ! pdd )
  245. {
  246. TraceMsg( TF_ERROR, "CPleaseDialog::InitPleaseDialog() - pdd is NULL!" );
  247. return;
  248. }
  249. ASSERT( pdd == m_ppdd );
  250. CParsedLabelList *pLabelList = pdd->pLabelList;
  251. for (UINT i=0; i<pdd->cLabels && i<ARRAYSIZE(pdd->apLabelStrings); i++)
  252. {
  253. if (pdd->apLabelStrings[i] == NULL)
  254. {
  255. if (pLabelList == NULL || pLabelList->m_pszOriginalLabel == NULL)
  256. {
  257. TraceMsg( TF_WARNING, "CPleaseDialog::InitPleaseDialog() - pLabelList is NULL or m_pszOriginalLabel is NULL!" );
  258. return;
  259. }
  260. }
  261. else
  262. {
  263. if (pLabelList != NULL &&
  264. pLabelList->m_pszOriginalLabel != NULL &&
  265. ! ::strcmpf( pdd->apLabelStrings[i], pLabelList->m_pszOriginalLabel ) )
  266. {
  267. TraceMsg( TF_WARNING, "CPleaseDialog::InitPleaseDialog() - apLabelStrings[%d]='%s' does not match m_pszOriginalLabel='%s'!", i, pdd->apLabelStrings[i], pLabelList->m_pszOriginalLabel );
  268. return;
  269. }
  270. }
  271. }
  272. if (pdd->cLabels < ARRAYSIZE(pdd->apLabelStrings))
  273. {
  274. if (pLabelList == NULL || pLabelList->m_pszOriginalLabel == NULL)
  275. {
  276. pdd->apLabelStrings[pdd->cLabels] = NULL;
  277. }
  278. else
  279. {
  280. pdd->apLabelStrings[pdd->cLabels] = new char[::strlenf(pLabelList->m_pszOriginalLabel)+1];
  281. if (pdd->apLabelStrings[pdd->cLabels] != NULL)
  282. {
  283. ::strcpyf(pdd->apLabelStrings[pdd->cLabels], pLabelList->m_pszOriginalLabel);
  284. }
  285. }
  286. }
  287. CString strTitle;
  288. if ( pLabelList && pLabelList->m_pszURL && pLabelList->m_pszURL[0] != '\0' )
  289. {
  290. strTitle.Format( IDS_CONTENT_ADVISOR_HTTP_TITLE, pLabelList->m_pszURL );
  291. }
  292. else
  293. {
  294. strTitle.LoadString( IDS_CONTENT_ADVISOR_TITLE );
  295. }
  296. SetWindowText( strTitle );
  297. HWND hwndDescription = GetDlgItem(IDC_CONTENTDESCRIPTION);
  298. HWND hwndError = GetDlgItem(IDC_CONTENTERROR);
  299. HWND hwndPrevEC = pdd->hwndEC;
  300. /* There are two edit controls in the dialog. One, the "description"
  301. * control, has a horizontal scrollbar, because we don't want word wrap
  302. * for the category names (cleaner presentation). The other EC has no
  303. * scrollbar so that the lengthy error strings will wordwrap.
  304. *
  305. * If we've been using the description control and we add error-type
  306. * information, we need to copy the text out of the description control
  307. * into the error control and show it.
  308. */
  309. BOOL fRatedPage = ( pLabelList != NULL && pLabelList->m_fRated );
  310. if ( ! fRatedPage && pdd->hwndEC == hwndDescription )
  311. {
  312. NLS_STR nlsTemp(::GetWindowTextLength(hwndDescription));
  313. if (nlsTemp.QueryError() == ERROR_SUCCESS)
  314. {
  315. CHAR * tempStr = nlsTemp.Party();
  316. if (tempStr)
  317. {
  318. ::GetWindowText(hwndDescription, tempStr, nlsTemp.QueryAllocSize());
  319. nlsTemp.DonePartying();
  320. ::SetWindowText(hwndError, nlsTemp.QueryPch());
  321. }
  322. else
  323. {
  324. nlsTemp.DonePartying();
  325. }
  326. }
  327. pdd->hwndEC = hwndError;
  328. }
  329. else if (pdd->hwndEC == NULL)
  330. {
  331. pdd->hwndEC = fRatedPage ? hwndDescription : hwndError;
  332. }
  333. if (pdd->hwndEC != hwndPrevEC)
  334. {
  335. BOOL fShowErrorCtl = (pdd->hwndEC == hwndError);
  336. if (::GetFocus() == hwndPrevEC)
  337. {
  338. ::SetFocus(pdd->hwndEC);
  339. }
  340. ShowHideControl( IDC_CONTENTERROR, fShowErrorCtl );
  341. ShowHideControl( IDC_CONTENTDESCRIPTION, ! fShowErrorCtl );
  342. }
  343. /* If there's already just one label in the list, prefix it with a
  344. * label "Frame:" since there will now be two.
  345. */
  346. if (pdd->cLabels == 1)
  347. {
  348. AddSeparator(pdd->hwndEC, FALSE);
  349. }
  350. /* If this is not the first label we're adding, we need a full separator
  351. * appended before we add new descriptive text.
  352. */
  353. if (pdd->cLabels > 0)
  354. {
  355. AddSeparator(pdd->hwndEC, TRUE);
  356. }
  357. if (g_fInvalid)
  358. {
  359. char szSourceMessage[MAX_PATH];
  360. MLLoadString(IDS_TAMPEREDRATING1,(char *) szSourceMessage,MAX_PATH);
  361. AppendString(pdd->hwndEC, szSourceMessage);
  362. AppendString(pdd->hwndEC, "\x0D\x0A");
  363. MLLoadString(IDS_TAMPEREDRATING2,(char *) szSourceMessage,MAX_PATH);
  364. AppendString(pdd->hwndEC, szSourceMessage);
  365. }
  366. else if (fRatedPage)
  367. {
  368. NLS_STR nlsTemplate(MAX_RES_STR_LEN);
  369. nlsTemplate.LoadString(IDS_RATINGTEMPLATE);
  370. NLS_STR nlsTmp;
  371. if (nlsTemplate.QueryError() || nlsTmp.QueryError())
  372. {
  373. TraceMsg( TF_WARNING, "CPleaseDialog::InitPleaseDialog() - fRatedPage => nlsTemplate or nlsTmp Error!" );
  374. return;
  375. }
  376. for (CParsedServiceInfo *ppsi = &pLabelList->m_ServiceInfo;
  377. ppsi != NULL;
  378. ppsi = ppsi->Next())
  379. {
  380. if (!ppsi->m_fInstalled)
  381. continue;
  382. UserRatingSystem *pURS = pdd->pPU->FindRatingSystem(ppsi->m_pszServiceName);
  383. if (pURS == NULL || pURS->m_pPRS == NULL)
  384. continue;
  385. NLS_STR nlsSystemName(STR_OWNERALLOC, pURS->m_pPRS->etstrName.Get());
  386. UINT cRatings = ppsi->aRatings.Length();
  387. for (UINT i=0; i<cRatings; i++)
  388. {
  389. CParsedRating *pRating = &ppsi->aRatings[i];
  390. if (pRating->fFailed)
  391. {
  392. nlsTmp = nlsTemplate;
  393. UserRating *pUR = pURS->FindRating(pRating->pszTransmitName);
  394. if (pUR == NULL)
  395. continue;
  396. PicsCategory *pPC = pUR->m_pPC;
  397. if (pPC == NULL)
  398. continue;
  399. LPCSTR pszCategory;
  400. if (pPC->etstrName.fIsInit())
  401. {
  402. pszCategory = pPC->etstrName.Get();
  403. }
  404. else if (pPC->etstrDesc.fIsInit())
  405. {
  406. pszCategory = pPC->etstrDesc.Get();
  407. }
  408. else
  409. {
  410. pszCategory = pRating->pszTransmitName;
  411. }
  412. NLS_STR nlsCategoryName(STR_OWNERALLOC, (LPSTR)pszCategory);
  413. UINT cValues = pPC->arrpPE.Length();
  414. PicsEnum *pPE;
  415. for (UINT iValue=0; iValue<cValues; iValue++)
  416. {
  417. pPE = pPC->arrpPE[iValue];
  418. if (pPE->etnValue.Get() == pRating->nValue)
  419. break;
  420. }
  421. LPCSTR pszValue = szNULL;
  422. char szNumBuf[20];
  423. if (iValue < cValues)
  424. {
  425. if (pPE->etstrName.fIsInit())
  426. {
  427. pszValue = pPE->etstrName.Get();
  428. }
  429. else if (pPE->etstrDesc.fIsInit())
  430. {
  431. pszValue = pPE->etstrDesc.Get();
  432. }
  433. else
  434. {
  435. wsprintf(szNumBuf, "%d", pRating->nValue);
  436. pszValue = szNumBuf;
  437. }
  438. }
  439. NLS_STR nlsValueName(STR_OWNERALLOC, (LPSTR)pszValue);
  440. const NLS_STR *apnls[] = { &nlsSystemName, &nlsCategoryName, &nlsValueName, NULL };
  441. nlsTmp.InsertParams(apnls);
  442. if (!nlsTmp.QueryError())
  443. {
  444. AppendString(pdd->hwndEC, nlsTmp.QueryPch());
  445. }
  446. }
  447. }
  448. }
  449. if ((g_fPICSRulesEnforced!=TRUE)&&(g_fApprovedSitesEnforced!=TRUE))
  450. {
  451. UINT idSourceMsg;
  452. char szSourceMessage[MAX_PATH];
  453. switch(g_dwDataSource)
  454. {
  455. case PICS_LABEL_FROM_HEADER:
  456. {
  457. idSourceMsg=IDS_SOURCE_SERVER;
  458. break;
  459. }
  460. case PICS_LABEL_FROM_PAGE:
  461. {
  462. idSourceMsg=IDS_SOURCE_EMBEDDED;
  463. break;
  464. }
  465. case PICS_LABEL_FROM_BUREAU:
  466. {
  467. idSourceMsg=IDS_SOURCE_BUREAU;
  468. break;
  469. }
  470. }
  471. MLLoadString(idSourceMsg,(char *) szSourceMessage,MAX_PATH);
  472. AppendString(pdd->hwndEC, "\x0D\x0A");
  473. AppendString(pdd->hwndEC, szSourceMessage);
  474. }
  475. }
  476. else
  477. {
  478. UINT idMsg = 0;
  479. LPCSTR psz1=szNULL, psz2=szNULL;
  480. if ( pLabelList == NULL || pLabelList->m_fNoRating )
  481. {
  482. idMsg = IDS_UNRATED;
  483. }
  484. else if (pLabelList->m_pszInvalidString)
  485. {
  486. idMsg = IDS_INVALIDRATING;
  487. psz1 = pLabelList->m_pszInvalidString;
  488. }
  489. else
  490. {
  491. BOOL fErrorFound = FALSE;
  492. BOOL fAnyInstalled = FALSE;
  493. CParsedServiceInfo *ppsi = &pLabelList->m_ServiceInfo;
  494. while (ppsi != NULL)
  495. {
  496. if (ppsi->m_pszInvalidString)
  497. {
  498. idMsg = IDS_INVALIDRATING;
  499. psz1 = ppsi->m_pszInvalidString;
  500. fErrorFound = TRUE;
  501. }
  502. else if (ppsi->m_pszErrorString)
  503. {
  504. idMsg = IDS_LABELERROR;
  505. psz1 = ppsi->m_pszErrorString;
  506. fErrorFound = TRUE;
  507. }
  508. else if (ppsi->m_fInstalled)
  509. {
  510. fAnyInstalled = TRUE;
  511. }
  512. ppsi = ppsi->Next();
  513. }
  514. if (!fErrorFound)
  515. {
  516. if (!fAnyInstalled)
  517. {
  518. idMsg = IDS_UNKNOWNSYSTEM;
  519. psz1 = pLabelList->m_ServiceInfo.m_pszServiceName;
  520. }
  521. else
  522. {
  523. for (ppsi = &pLabelList->m_ServiceInfo;
  524. ppsi != NULL;
  525. ppsi = ppsi->Next())
  526. {
  527. if ( ! ppsi->m_fInstalled )
  528. continue;
  529. UINT cRatings = ppsi->aRatings.Length();
  530. for (UINT i=0; i<cRatings; i++)
  531. {
  532. CParsedRating *ppr = &ppsi->aRatings[i];
  533. COptionsBase *pOpt = ppr->pOptions;
  534. if (pOpt->m_pszInvalidString)
  535. {
  536. idMsg = IDS_INVALIDRATING;
  537. psz1 = pOpt->m_pszInvalidString;
  538. break;
  539. }
  540. else if (pOpt->m_fdwFlags & LBLOPT_WRONGURL)
  541. {
  542. idMsg = IDS_WRONGURL;
  543. psz1 = pLabelList->m_pszURL;
  544. psz2 = pOpt->m_pszURL;
  545. }
  546. else if (pOpt->m_fdwFlags & LBLOPT_EXPIRED)
  547. {
  548. idMsg = IDS_EXPIRED;
  549. break;
  550. }
  551. else if (!ppr->fFound)
  552. {
  553. idMsg = IDS_UNKNOWNRATING;
  554. psz1 = ppr->pszTransmitName;
  555. UserRatingSystem *pURS = pdd->pPU->FindRatingSystem(ppsi->m_pszServiceName);
  556. if (pURS != NULL && pURS->m_pPRS != NULL)
  557. {
  558. if (pURS->m_pPRS->etstrName.fIsInit())
  559. {
  560. psz2 = pURS->m_pPRS->etstrName.Get();
  561. }
  562. }
  563. break;
  564. }
  565. }
  566. if (idMsg != 0)
  567. break;
  568. }
  569. }
  570. }
  571. }
  572. if (g_fPICSRulesEnforced==TRUE)
  573. {
  574. idMsg=IDS_PICSRULES_ENFORCED;
  575. }
  576. else if (g_fApprovedSitesEnforced==TRUE)
  577. {
  578. idMsg=IDS_APPROVEDSITES_ENFORCED;
  579. }
  580. /* It's theoretically possible that we got through all that and
  581. * didn't find anything explicitly wrong, yet the site was considered
  582. * unrated (perhaps it was a valid label with no actual ratings in it).
  583. * So if we didn't decide what error to display, just don't stick
  584. * anything in the edit control, and the dialog will just say "Sorry"
  585. * at the top.
  586. */
  587. if (idMsg != 0)
  588. {
  589. NLS_STR nls1(STR_OWNERALLOC, (LPSTR)psz1);
  590. NLS_STR nls2(STR_OWNERALLOC, (LPSTR)psz2);
  591. const NLS_STR *apnls[] = { &nls1, &nls2, NULL };
  592. NLS_STR nlsMessage(MAX_RES_STR_LEN);
  593. nlsMessage.LoadString((USHORT)idMsg, apnls);
  594. AppendString(pdd->hwndEC, nlsMessage.QueryPch());
  595. }
  596. if (idMsg == IDS_UNKNOWNSYSTEM)
  597. {
  598. NLS_STR nlsTemplate(MAX_RES_STR_LEN);
  599. nlsTemplate.LoadString(IDS_UNKNOWNRATINGTEMPLATE);
  600. NLS_STR nlsTmp;
  601. if (nlsTemplate.QueryError() || nlsTmp.QueryError())
  602. {
  603. TraceMsg( TF_WARNING, "CPleaseDialog::InitPleaseDialog() - IDS_UNKNOWNSYSTEM => nlsTemplate or nlsTmp Error!" );
  604. return;
  605. }
  606. UINT cRatings = pLabelList->m_ServiceInfo.aRatings.Length();
  607. for (UINT i=0; i<cRatings; i++)
  608. {
  609. CParsedRating *ppr = &pLabelList->m_ServiceInfo.aRatings[i];
  610. char szNumBuf[20];
  611. wsprintf(szNumBuf, "%d", ppr->nValue);
  612. NLS_STR nlsCategoryName(STR_OWNERALLOC, ppr->pszTransmitName);
  613. NLS_STR nlsValueName(STR_OWNERALLOC, szNumBuf);
  614. const NLS_STR *apnls[] = { &nlsCategoryName, &nlsValueName, NULL };
  615. nlsTmp = nlsTemplate;
  616. nlsTmp.InsertParams(apnls);
  617. if (!nlsTmp.QueryError())
  618. {
  619. AppendString(pdd->hwndEC, nlsTmp.QueryPch());
  620. }
  621. }
  622. }
  623. }
  624. if ( IsPleaseDialog() )
  625. {
  626. SendDlgItemMessage(IDC_BLOCKING_ONCE,
  627. BM_SETCHECK,
  628. (WPARAM) BST_CHECKED,
  629. (LPARAM) 0);
  630. SendDlgItemMessage(IDC_BLOCKING_PAGE,
  631. BM_SETCHECK,
  632. (WPARAM) BST_UNCHECKED,
  633. (LPARAM) 0);
  634. SendDlgItemMessage(IDC_BLOCKING_SITE,
  635. BM_SETCHECK,
  636. (WPARAM) BST_UNCHECKED,
  637. (LPARAM) 0);
  638. }
  639. pdd->cLabels++; /* now one more label description in the box */
  640. }
  641. void CPleaseDialog::EndPleaseDialog( BOOL fRet)
  642. {
  643. PleaseDlgData *ppdd = m_ppdd;
  644. ASSERT( m_ppdd );
  645. if (ppdd != NULL)
  646. {
  647. ppdd->dwFlags = PDD_DONE | (fRet ? PDD_ALLOW : 0);
  648. ppdd->hwndDlg = NULL;
  649. SetProp( m_ppdd->hwndOwner, szRatingsValue, UlongToPtr( ppdd->dwFlags ) );
  650. RemoveProp(ppdd->hwndOwner, szRatingsProp);
  651. }
  652. EndDialog(fRet);
  653. }
  654. HRESULT CPleaseDialog::AddToApprovedSites(BOOL fAlwaysNever,BOOL fSitePage)
  655. {
  656. PICSRulesPolicy * pPRPolicy;
  657. PICSRulesByURL * pPRByURL;
  658. PICSRulesByURLExpression * pPRByURLExpression;
  659. char * lpszSiteURL;
  660. HRESULT hRes;
  661. URL_COMPONENTS URLComponents;
  662. FN_INTERNETCRACKURL pfnInternetCrackUrl;
  663. INTERNET_SCHEME INetScheme=INTERNET_SCHEME_DEFAULT;
  664. INTERNET_PORT INetPort=INTERNET_INVALID_PORT_NUMBER;
  665. LPSTR lpszScheme,lpszHostName,lpszUserName,
  666. lpszPassword,lpszUrlPath,lpszExtraInfo;
  667. BOOL fAddedScheme=FALSE;
  668. int iCounter,iLoopCounter;
  669. lpszSiteURL=new char[INTERNET_MAX_URL_LENGTH];
  670. if (lpszSiteURL==NULL)
  671. {
  672. return(E_OUTOFMEMORY);
  673. }
  674. strcpy(lpszSiteURL,g_szLastURL);
  675. if (g_pApprovedPRRS==NULL)
  676. {
  677. g_pApprovedPRRS=new PICSRulesRatingSystem;
  678. if (g_pApprovedPRRS==NULL)
  679. {
  680. return(E_OUTOFMEMORY);
  681. }
  682. }
  683. pPRPolicy=new PICSRulesPolicy;
  684. if (pPRPolicy==NULL)
  685. {
  686. return(E_OUTOFMEMORY);
  687. }
  688. pPRByURL=new PICSRulesByURL;
  689. if (pPRByURL==NULL)
  690. {
  691. return(E_OUTOFMEMORY);
  692. }
  693. if (fAlwaysNever==PICSRULES_NEVER)
  694. {
  695. pPRPolicy->m_PRPolicyAttribute=PR_POLICY_REJECTBYURL;
  696. pPRPolicy->AddItem(PROID_REJECTBYURL,pPRByURL);
  697. }
  698. else
  699. {
  700. pPRPolicy->m_PRPolicyAttribute=PR_POLICY_ACCEPTBYURL;
  701. pPRPolicy->AddItem(PROID_ACCEPTBYURL,pPRByURL);
  702. }
  703. pPRByURLExpression=new PICSRulesByURLExpression;
  704. if (pPRByURLExpression==NULL)
  705. {
  706. return(E_OUTOFMEMORY);
  707. }
  708. pPRByURL->m_arrpPRByURL.Append(pPRByURLExpression);
  709. //if we made it through all that, then we have a
  710. //PICSRulesByURLExpression to fill out, and need
  711. //to update the list box.
  712. lpszScheme=new char[INTERNET_MAX_SCHEME_LENGTH+1];
  713. lpszHostName=new char[INTERNET_MAX_PATH_LENGTH+1];
  714. lpszUserName=new char[INTERNET_MAX_PATH_LENGTH+1];
  715. lpszPassword=new char[INTERNET_MAX_PATH_LENGTH+1];
  716. lpszUrlPath=new char[INTERNET_MAX_PATH_LENGTH+1];
  717. lpszExtraInfo=new char[INTERNET_MAX_PATH_LENGTH+1];
  718. if (lpszScheme==NULL ||
  719. lpszHostName==NULL ||
  720. lpszUserName==NULL ||
  721. lpszPassword==NULL ||
  722. lpszUrlPath==NULL ||
  723. lpszExtraInfo==NULL)
  724. {
  725. return(E_OUTOFMEMORY);
  726. }
  727. URLComponents.dwStructSize=sizeof(URL_COMPONENTS);
  728. URLComponents.lpszScheme=lpszScheme;
  729. URLComponents.dwSchemeLength=INTERNET_MAX_SCHEME_LENGTH;
  730. URLComponents.nScheme=INetScheme;
  731. URLComponents.lpszHostName=lpszHostName;
  732. URLComponents.dwHostNameLength=INTERNET_MAX_PATH_LENGTH;
  733. URLComponents.nPort=INetPort;
  734. URLComponents.lpszUserName=lpszUserName;
  735. URLComponents.dwUserNameLength=INTERNET_MAX_PATH_LENGTH;
  736. URLComponents.lpszPassword=lpszPassword;
  737. URLComponents.dwPasswordLength=INTERNET_MAX_PATH_LENGTH;
  738. URLComponents.lpszUrlPath=lpszUrlPath;
  739. URLComponents.dwUrlPathLength=INTERNET_MAX_PATH_LENGTH;
  740. URLComponents.lpszExtraInfo=lpszExtraInfo;
  741. URLComponents.dwExtraInfoLength=INTERNET_MAX_PATH_LENGTH;
  742. pfnInternetCrackUrl=(FN_INTERNETCRACKURL) GetProcAddress(g_hWININET,"InternetCrackUrlA");
  743. if (pfnInternetCrackUrl==NULL)
  744. {
  745. return(E_UNEXPECTED);
  746. }
  747. pfnInternetCrackUrl(lpszSiteURL,0,ICU_DECODE,&URLComponents);
  748. delete lpszExtraInfo; //we don't do anything with this for now
  749. lpszExtraInfo = NULL;
  750. delete lpszPassword; //not supported by PICSRules
  751. lpszPassword = NULL;
  752. if (g_fApprovedSitesEnforced==TRUE)
  753. {
  754. int iCounter;
  755. PICSRulesPolicy * pPRFindPolicy;
  756. BOOL fFound=FALSE,fDeleted=FALSE;
  757. //we've already got an Approved Sites setting enforcing this
  758. //so check for an exact match, and if it exists, change it
  759. //instead of adding another
  760. for (iCounter=0;iCounter<g_pApprovedPRRS->m_arrpPRPolicy.Length();iCounter++)
  761. {
  762. PICSRulesByURLExpression * pPRFindByURLExpression;
  763. PICSRulesByURL * pPRFindByURL;
  764. char * lpszTest;
  765. pPRFindPolicy=g_pApprovedPRRS->m_arrpPRPolicy[iCounter];
  766. switch(pPRFindPolicy->m_PRPolicyAttribute)
  767. {
  768. case PR_POLICY_REJECTBYURL:
  769. {
  770. pPRFindByURL=pPRFindPolicy->m_pPRRejectByURL;
  771. break;
  772. }
  773. case PR_POLICY_ACCEPTBYURL:
  774. {
  775. pPRFindByURL=pPRFindPolicy->m_pPRAcceptByURL;
  776. break;
  777. }
  778. }
  779. pPRFindByURLExpression=pPRFindByURL->m_arrpPRByURL[0];
  780. if ((pPRFindByURLExpression->m_bNonWild)&BYURL_SCHEME)
  781. {
  782. if (lpszScheme==NULL)
  783. {
  784. fFound=FALSE;
  785. continue;
  786. }
  787. lpszTest=pPRFindByURLExpression->m_etstrScheme.Get();
  788. if (lstrcmpi(lpszScheme,lpszTest)==0)
  789. {
  790. fFound=TRUE;
  791. }
  792. else
  793. {
  794. fFound=FALSE;
  795. continue;
  796. }
  797. }
  798. else
  799. {
  800. fFound=TRUE;
  801. }
  802. if ((pPRFindByURLExpression->m_bNonWild)&BYURL_USER)
  803. {
  804. if (lpszUserName==NULL)
  805. {
  806. fFound=FALSE;
  807. continue;
  808. }
  809. lpszTest=pPRFindByURLExpression->m_etstrUser.Get();
  810. if (lstrcmpi(lpszUserName,lpszTest)==0)
  811. {
  812. fFound=TRUE;
  813. }
  814. else
  815. {
  816. fFound=FALSE;
  817. continue;
  818. }
  819. }
  820. else
  821. {
  822. fFound=TRUE;
  823. }
  824. if ((pPRFindByURLExpression->m_bNonWild)&BYURL_HOST)
  825. {
  826. if (lpszHostName==NULL)
  827. {
  828. fFound=FALSE;
  829. continue;
  830. }
  831. lpszTest=pPRFindByURLExpression->m_etstrHost.Get();
  832. if (lstrcmp(lpszHostName,lpszTest)==0)
  833. {
  834. fFound=TRUE;
  835. }
  836. else
  837. {
  838. fFound=FALSE;
  839. continue;
  840. }
  841. }
  842. else
  843. {
  844. fFound=TRUE;
  845. }
  846. if (fSitePage!=PICSRULES_SITE)
  847. {
  848. if ((pPRFindByURLExpression->m_bNonWild)&BYURL_PATH)
  849. {
  850. int iLen;
  851. if (lpszUrlPath==NULL)
  852. {
  853. fFound=FALSE;
  854. continue;
  855. }
  856. lpszTest=pPRFindByURLExpression->m_etstrPath.Get();
  857. //kill trailing slashes
  858. iLen=lstrlen(lpszTest);
  859. if (lpszTest[iLen-1]=='/')
  860. {
  861. lpszTest[iLen-1]='\0';
  862. }
  863. iLen=lstrlen(lpszUrlPath);
  864. if (lpszUrlPath[iLen-1]=='/')
  865. {
  866. lpszUrlPath[iLen-1]='\0';
  867. }
  868. if (lstrcmp(lpszUrlPath,lpszTest)==0)
  869. {
  870. fFound=TRUE;
  871. }
  872. else
  873. {
  874. fFound=FALSE;
  875. continue;
  876. }
  877. }
  878. else
  879. {
  880. fFound=FALSE;
  881. continue;
  882. }
  883. }
  884. if (fFound==TRUE)
  885. {
  886. if (fSitePage==PICSRULES_PAGE)
  887. {
  888. break;
  889. }
  890. else
  891. {
  892. delete pPRFindPolicy;
  893. pPRFindPolicy = NULL;
  894. g_pApprovedPRRS->m_arrpPRPolicy[iCounter]=NULL;
  895. fDeleted=TRUE;
  896. }
  897. }
  898. }
  899. if (fDeleted==TRUE)
  900. {
  901. PICSRulesRatingSystem * pPRRSNew;
  902. pPRRSNew=new PICSRulesRatingSystem;
  903. if (pPRRSNew==NULL)
  904. {
  905. return(E_OUTOFMEMORY);
  906. }
  907. for (iCounter=0;iCounter<g_pApprovedPRRS->m_arrpPRPolicy.Length();iCounter++)
  908. {
  909. if ((g_pApprovedPRRS->m_arrpPRPolicy[iCounter])!=NULL)
  910. {
  911. pPRRSNew->m_arrpPRPolicy.Append((g_pApprovedPRRS->m_arrpPRPolicy[iCounter]));
  912. }
  913. }
  914. g_pApprovedPRRS->m_arrpPRPolicy.ClearAll();
  915. delete g_pApprovedPRRS;
  916. g_pApprovedPRRS=pPRRSNew;
  917. fFound=FALSE;
  918. }
  919. if (fFound==TRUE)
  920. {
  921. delete pPRFindPolicy;
  922. pPRFindPolicy= NULL;
  923. g_pApprovedPRRS->m_arrpPRPolicy[iCounter]=pPRPolicy;
  924. }
  925. else
  926. {
  927. hRes=g_pApprovedPRRS->AddItem(PROID_POLICY,pPRPolicy);
  928. if (FAILED(hRes))
  929. {
  930. return(hRes);
  931. }
  932. }
  933. }
  934. else
  935. {
  936. hRes=g_pApprovedPRRS->AddItem(PROID_POLICY,pPRPolicy);
  937. if (FAILED(hRes))
  938. {
  939. return(hRes);
  940. }
  941. }
  942. pPRByURLExpression->m_fInternetPattern=TRUE;
  943. if ((*lpszScheme!=NULL)&&(fAddedScheme==FALSE))
  944. {
  945. pPRByURLExpression->m_bNonWild|=BYURL_SCHEME;
  946. pPRByURLExpression->m_etstrScheme.SetTo(lpszScheme);
  947. }
  948. else
  949. {
  950. delete lpszScheme;
  951. lpszScheme = NULL;
  952. }
  953. pPRByURLExpression->m_bSpecified|=BYURL_SCHEME;
  954. if (*lpszUserName!=NULL)
  955. {
  956. pPRByURLExpression->m_bNonWild|=BYURL_USER;
  957. pPRByURLExpression->m_etstrUser.SetTo(lpszUserName);
  958. }
  959. else
  960. {
  961. delete lpszUserName;
  962. lpszUserName = NULL;
  963. }
  964. pPRByURLExpression->m_bSpecified|=BYURL_USER;
  965. if (*lpszHostName!=NULL)
  966. {
  967. pPRByURLExpression->m_bNonWild|=BYURL_HOST;
  968. pPRByURLExpression->m_etstrHost.SetTo(lpszHostName);
  969. }
  970. else
  971. {
  972. delete lpszHostName;
  973. lpszHostName = NULL;
  974. }
  975. pPRByURLExpression->m_bSpecified|=BYURL_HOST;
  976. if (*lpszUrlPath!=NULL)
  977. {
  978. if (lstrcmp(lpszUrlPath,"/")!=0)
  979. {
  980. if (fSitePage==PICSRULES_PAGE)
  981. {
  982. pPRByURLExpression->m_bNonWild|=BYURL_PATH;
  983. pPRByURLExpression->m_etstrPath.SetTo(lpszUrlPath);
  984. }
  985. }
  986. }
  987. else
  988. {
  989. delete lpszUrlPath;
  990. lpszUrlPath = NULL;
  991. }
  992. pPRByURLExpression->m_bSpecified|=BYURL_PATH;
  993. if (URLComponents.nPort!=INTERNET_INVALID_PORT_NUMBER)
  994. {
  995. LPSTR lpszTemp;
  996. lpszTemp=new char[MAX_PATH];
  997. if (lpszTemp==NULL)
  998. {
  999. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1000. //out of memory, so we init on the stack
  1001. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1002. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1003. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1004. return(E_OUTOFMEMORY);
  1005. }
  1006. wsprintf(lpszTemp,"%d",URLComponents.nPort);
  1007. pPRByURLExpression->m_bNonWild|=BYURL_PORT;
  1008. pPRByURLExpression->m_etstrPort.SetTo(lpszTemp);
  1009. }
  1010. pPRByURLExpression->m_bSpecified|=BYURL_PORT;
  1011. if (fSitePage==PICSRULES_PAGE)
  1012. {
  1013. pPRByURLExpression->m_etstrURL.SetTo(lpszSiteURL);
  1014. }
  1015. else
  1016. {
  1017. pPRByURLExpression->m_etstrURL.Set(pPRByURLExpression->m_etstrHost.Get());
  1018. }
  1019. //copy master list to the PreApply list so we can reorder the entries
  1020. //to obtain the appropriate logic.
  1021. if (g_pApprovedPRRSPreApply!=NULL)
  1022. {
  1023. delete g_pApprovedPRRSPreApply;
  1024. }
  1025. g_pApprovedPRRSPreApply=new PICSRulesRatingSystem;
  1026. if (g_pApprovedPRRSPreApply==NULL)
  1027. {
  1028. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1029. //out of memory, so we init on the stack
  1030. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1031. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1032. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1033. return(E_OUTOFMEMORY);
  1034. }
  1035. for (iCounter=0;iCounter<g_pApprovedPRRS->m_arrpPRPolicy.Length();iCounter++)
  1036. {
  1037. PICSRulesPolicy * pPRPolicy,* pPRPolicyToCopy;
  1038. PICSRulesByURL * pPRByURL,* pPRByURLToCopy;
  1039. PICSRulesByURLExpression * pPRByURLExpression,* pPRByURLExpressionToCopy;
  1040. pPRPolicy=new PICSRulesPolicy;
  1041. if (pPRPolicy==NULL)
  1042. {
  1043. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1044. //out of memory, so we init on the stack
  1045. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1046. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1047. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1048. return(E_OUTOFMEMORY);
  1049. }
  1050. pPRPolicyToCopy=g_pApprovedPRRS->m_arrpPRPolicy[iCounter];
  1051. pPRPolicy->m_PRPolicyAttribute=pPRPolicyToCopy->m_PRPolicyAttribute;
  1052. pPRByURL=new PICSRulesByURL;
  1053. if (pPRByURL==NULL)
  1054. {
  1055. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1056. //out of memory, so we init on the stack
  1057. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1058. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1059. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1060. return(E_OUTOFMEMORY);
  1061. }
  1062. if (pPRPolicy->m_PRPolicyAttribute==PR_POLICY_ACCEPTBYURL)
  1063. {
  1064. pPRByURLToCopy=pPRPolicyToCopy->m_pPRAcceptByURL;
  1065. pPRPolicy->m_pPRAcceptByURL=pPRByURL;
  1066. }
  1067. else
  1068. {
  1069. pPRByURLToCopy=pPRPolicyToCopy->m_pPRRejectByURL;
  1070. pPRPolicy->m_pPRRejectByURL=pPRByURL;
  1071. }
  1072. pPRByURLExpression=new PICSRulesByURLExpression;
  1073. if (pPRByURLExpression==NULL)
  1074. {
  1075. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1076. //out of memory, so we init on the stack
  1077. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1078. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1079. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1080. return(E_OUTOFMEMORY);
  1081. }
  1082. pPRByURLExpressionToCopy=pPRByURLToCopy->m_arrpPRByURL[0];
  1083. if (pPRByURLExpressionToCopy==NULL)
  1084. {
  1085. char *lpszTitle,*lpszMessage;
  1086. //we shouldn't ever get here
  1087. lpszTitle=(char *) GlobalAlloc(GPTR,MAX_PATH);
  1088. lpszMessage=(char *) GlobalAlloc(GPTR,MAX_PATH);
  1089. MLLoadString(IDS_ERROR,(LPTSTR) lpszTitle,MAX_PATH);
  1090. MLLoadString(IDS_PICSRULES_NOAPPROVEDSAVE,(LPTSTR) lpszMessage,MAX_PATH);
  1091. MessageBox((LPCTSTR) lpszMessage,(LPCTSTR) lpszTitle,MB_OK|MB_ICONERROR);
  1092. GlobalFree(lpszTitle);
  1093. lpszTitle = NULL;
  1094. GlobalFree(lpszMessage);
  1095. lpszMessage = NULL;
  1096. delete pPRPolicy;
  1097. pPRPolicy = NULL;
  1098. return(E_UNEXPECTED);
  1099. }
  1100. pPRByURLExpression->m_fInternetPattern=pPRByURLExpressionToCopy->m_fInternetPattern;
  1101. pPRByURLExpression->m_bNonWild=pPRByURLExpressionToCopy->m_bNonWild;
  1102. pPRByURLExpression->m_bSpecified=pPRByURLExpressionToCopy->m_bSpecified;
  1103. pPRByURLExpression->m_etstrScheme.Set(pPRByURLExpressionToCopy->m_etstrScheme.Get());
  1104. pPRByURLExpression->m_etstrUser.Set(pPRByURLExpressionToCopy->m_etstrUser.Get());
  1105. pPRByURLExpression->m_etstrHost.Set(pPRByURLExpressionToCopy->m_etstrHost.Get());
  1106. pPRByURLExpression->m_etstrPort.Set(pPRByURLExpressionToCopy->m_etstrPort.Get());
  1107. pPRByURLExpression->m_etstrPath.Set(pPRByURLExpressionToCopy->m_etstrPath.Get());
  1108. pPRByURLExpression->m_etstrURL.Set(pPRByURLExpressionToCopy->m_etstrURL.Get());
  1109. pPRByURL->m_arrpPRByURL.Append(pPRByURLExpression);
  1110. g_pApprovedPRRSPreApply->m_arrpPRPolicy.Append(pPRPolicy);
  1111. }
  1112. if (g_pApprovedPRRS!=NULL)
  1113. {
  1114. delete g_pApprovedPRRS;
  1115. }
  1116. g_pApprovedPRRS=new PICSRulesRatingSystem;
  1117. if (g_pApprovedPRRS==NULL)
  1118. {
  1119. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1120. //out of memory, so we init on the stack
  1121. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1122. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1123. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1124. return(E_OUTOFMEMORY);
  1125. }
  1126. for (iLoopCounter=0;iLoopCounter<2;iLoopCounter++)
  1127. {
  1128. for (iCounter=0;iCounter<g_pApprovedPRRSPreApply->m_arrpPRPolicy.Length();iCounter++)
  1129. {
  1130. PICSRulesPolicy * pPRPolicy,* pPRPolicyToCopy;
  1131. PICSRulesByURL * pPRByURL,* pPRByURLToCopy;
  1132. PICSRulesByURLExpression * pPRByURLExpression,* pPRByURLExpressionToCopy;
  1133. pPRPolicyToCopy=g_pApprovedPRRSPreApply->m_arrpPRPolicy[iCounter];
  1134. if (pPRPolicyToCopy->m_PRPolicyAttribute==PR_POLICY_ACCEPTBYURL)
  1135. {
  1136. pPRByURLToCopy=pPRPolicyToCopy->m_pPRAcceptByURL;
  1137. }
  1138. else
  1139. {
  1140. pPRByURLToCopy=pPRPolicyToCopy->m_pPRRejectByURL;
  1141. }
  1142. pPRByURLExpressionToCopy=pPRByURLToCopy->m_arrpPRByURL[0];
  1143. if (pPRByURLExpressionToCopy==NULL)
  1144. {
  1145. char *lpszTitle,*lpszMessage;
  1146. //we shouldn't ever get here
  1147. lpszTitle=(char *) GlobalAlloc(GPTR,MAX_PATH);
  1148. lpszMessage=(char *) GlobalAlloc(GPTR,MAX_PATH);
  1149. MLLoadString(IDS_ERROR,(LPTSTR) lpszTitle,MAX_PATH);
  1150. MLLoadString(IDS_PICSRULES_NOAPPROVEDSAVE,(LPTSTR) lpszMessage,MAX_PATH);
  1151. MessageBox((LPCTSTR) lpszMessage,(LPCTSTR) lpszTitle,MB_OK|MB_ICONERROR);
  1152. GlobalFree(lpszTitle);
  1153. lpszTitle = NULL;
  1154. GlobalFree(lpszMessage);
  1155. lpszMessage = NULL;
  1156. return(E_UNEXPECTED);
  1157. }
  1158. //we want to put all of the non-sitewide approved sites first
  1159. //so that a user can specify, allow all of xyz.com except for
  1160. //xyz.com/foo.htm
  1161. switch(iLoopCounter)
  1162. {
  1163. case 0:
  1164. {
  1165. if ((pPRByURLExpressionToCopy->m_bNonWild)&BYURL_PATH)
  1166. {
  1167. break;
  1168. }
  1169. else
  1170. {
  1171. continue;
  1172. }
  1173. }
  1174. case 1:
  1175. {
  1176. if (!((pPRByURLExpressionToCopy->m_bNonWild)&BYURL_PATH))
  1177. {
  1178. break;
  1179. }
  1180. else
  1181. {
  1182. continue;
  1183. }
  1184. }
  1185. }
  1186. pPRPolicy=new PICSRulesPolicy;
  1187. if (pPRPolicy==NULL)
  1188. {
  1189. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1190. //out of memory, so we init on the stack
  1191. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1192. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1193. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1194. return(E_OUTOFMEMORY);
  1195. }
  1196. pPRPolicy->m_PRPolicyAttribute=pPRPolicyToCopy->m_PRPolicyAttribute;
  1197. pPRByURL=new PICSRulesByURL;
  1198. if (pPRByURL==NULL)
  1199. {
  1200. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1201. //out of memory, so we init on the stack
  1202. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1203. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1204. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1205. return(E_OUTOFMEMORY);
  1206. }
  1207. if (pPRPolicy->m_PRPolicyAttribute==PR_POLICY_ACCEPTBYURL)
  1208. {
  1209. pPRPolicy->m_pPRAcceptByURL=pPRByURL;
  1210. }
  1211. else
  1212. {
  1213. pPRPolicy->m_pPRRejectByURL=pPRByURL;
  1214. }
  1215. pPRByURLExpression=new PICSRulesByURLExpression;
  1216. if (pPRByURLExpression==NULL)
  1217. {
  1218. char szTitle[MAX_PATH],szMessage[MAX_PATH];
  1219. //out of memory, so we init on the stack
  1220. MLLoadString(IDS_ERROR,(LPTSTR) szTitle,MAX_PATH);
  1221. MLLoadString(IDS_PICSRULES_OUTOFMEMORY,(LPTSTR) szMessage,MAX_PATH);
  1222. MessageBox((LPCTSTR) szMessage,(LPCTSTR) szTitle,MB_OK|MB_ICONERROR);
  1223. return(E_OUTOFMEMORY);
  1224. }
  1225. pPRByURLExpression->m_fInternetPattern=pPRByURLExpressionToCopy->m_fInternetPattern;
  1226. pPRByURLExpression->m_bNonWild=pPRByURLExpressionToCopy->m_bNonWild;
  1227. pPRByURLExpression->m_bSpecified=pPRByURLExpressionToCopy->m_bSpecified;
  1228. pPRByURLExpression->m_etstrScheme.Set(pPRByURLExpressionToCopy->m_etstrScheme.Get());
  1229. pPRByURLExpression->m_etstrUser.Set(pPRByURLExpressionToCopy->m_etstrUser.Get());
  1230. pPRByURLExpression->m_etstrHost.Set(pPRByURLExpressionToCopy->m_etstrHost.Get());
  1231. pPRByURLExpression->m_etstrPort.Set(pPRByURLExpressionToCopy->m_etstrPort.Get());
  1232. pPRByURLExpression->m_etstrPath.Set(pPRByURLExpressionToCopy->m_etstrPath.Get());
  1233. pPRByURLExpression->m_etstrURL.Set(pPRByURLExpressionToCopy->m_etstrURL.Get());
  1234. pPRByURL->m_arrpPRByURL.Append(pPRByURLExpression);
  1235. g_pApprovedPRRS->m_arrpPRPolicy.Append(pPRPolicy);
  1236. }
  1237. }
  1238. PICSRulesDeleteSystem(PICSRULES_APPROVEDSITES);
  1239. PICSRulesSaveToRegistry(PICSRULES_APPROVEDSITES,&g_pApprovedPRRS);
  1240. return(NOERROR);
  1241. }